From 622ef48dae1d95d7bea070fb39eecfb6550a04a2 Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Mon, 23 Nov 2020 10:32:00 -0700 Subject: [PATCH] Fixed ccd enabled by default on Bullet bodies It was due to main_shape_changed being called two times for each added body. The first time it disables ccd, which sets the internal ccd threshold to be 10000. The second time, it enables ccd again because the internal threshold is > 0. Bodies are now consistently set with a ccd threshold of 0 when ccd is disabled. This was causing crashing asserts in Bullet when adding bodies in some scenarios, in btVector3::normalize(): btAssert(!fuzzyZero()); These crashes will still happen with ccd enabled. (cherry picked from commit faca8b77aa045a276f4ecdab1c0049755a1351ca) --- modules/bullet/rigid_body_bullet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index e52489a96c2..170072814cb 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -766,7 +766,7 @@ void RigidBodyBullet::set_continuous_collision_detection(bool p_enable) { } btBody->setCcdSweptSphereRadius(radius * 0.2); } else { - btBody->setCcdMotionThreshold(10000.0); + btBody->setCcdMotionThreshold(0.); btBody->setCcdSweptSphereRadius(0.); } } @@ -846,7 +846,7 @@ void RigidBodyBullet::reload_shapes() { btBody->updateInertiaTensor(); reload_kinematic_shapes(); - set_continuous_collision_detection(btBody->getCcdMotionThreshold() < 9998.0); + set_continuous_collision_detection(is_continuous_collision_detection_enabled()); reload_body(); }