From ac140c9cf25f7880e62b396739f67b21c3daa7a5 Mon Sep 17 00:00:00 2001 From: Benau Date: Sun, 1 May 2022 08:36:56 +0800 Subject: [PATCH] Fix #4770 --- src/modes/soccer_world.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modes/soccer_world.cpp b/src/modes/soccer_world.cpp index 1144ef113..51e39da2f 100644 --- a/src/modes/soccer_world.cpp +++ b/src/modes/soccer_world.cpp @@ -305,7 +305,14 @@ void SoccerWorld::init() if (!m_ball) Log::fatal("SoccerWorld","Ball is missing in soccer field, abort."); - m_bgd->init(m_ball->getPhysicalObject()->getRadius()); + float radius = m_ball->getPhysicalObject()->getRadius(); + if (radius <= 0.0f) + { + btVector3 min, max; + m_ball->getPhysicalObject()->getBody()->getAabb(min, max); + radius = (max.y() - min.y()) / 2.0f; + } + m_bgd->init(radius); } // init