From db47b670f6544f89ef6c63bf26e7439c9f7be89a Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Wed, 18 Aug 2021 13:07:21 -0700 Subject: [PATCH] Fix crash in body_test_motion when used with RigidBody3D in Bullet Kinematic utilities are now initialized for a rigid body if needed for a call to body_test_motion. --- modules/bullet/space_bullet.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 9a6a11eb4d..e3874e74b3 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -965,6 +965,11 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f G_TO_B(p_from, body_transform); UNSCALE_BT_BASIS(body_transform); + if (!p_body->get_kinematic_utilities()) { + p_body->init_kinematic_utilities(); + p_body->reload_kinematic_shapes(); + } + btVector3 initial_recover_motion(0, 0, 0); { /// Phase one - multi shapes depenetration using margin for (int t(RECOVERING_MOVEMENT_CYCLES); 0 < t; --t) { @@ -1087,6 +1092,11 @@ int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p G_TO_B(p_transform, body_transform); UNSCALE_BT_BASIS(body_transform); + if (!p_body->get_kinematic_utilities()) { + p_body->init_kinematic_utilities(); + p_body->reload_kinematic_shapes(); + } + btVector3 recover_motion(0, 0, 0); int rays_found = 0;