From 9de999444420e068ea9b5fc9135f291c5ad1d610 Mon Sep 17 00:00:00 2001 From: BimDav <67792882+BimDav@users.noreply.github.com> Date: Mon, 27 Sep 2021 09:38:44 +0200 Subject: [PATCH] Reload kinematic shapes when changing PhysicsBody mode to Kinematic Prevents a crash when calling test_body_motion. Call reload_kinematic_shapes from init_kinematic_utilities as they are always called together. (cherry picked from commits 112985c5bc2c9a3f58c4ee5c4a674beff8b75e58 and 3540e716f9e20fe57e94d55f19a789c3b9a31b28) --- modules/bullet/rigid_body_bullet.cpp | 1 + modules/bullet/space_bullet.cpp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 36baadc11ba..30cac0a60c4 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -320,6 +320,7 @@ RigidBodyBullet::~RigidBodyBullet() { void RigidBodyBullet::init_kinematic_utilities() { kinematic_utilities = memnew(KinematicUtilities(this)); + reload_kinematic_shapes(); } void RigidBodyBullet::destroy_kinematic_utilities() { diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 60bd04cc1a2..1d566d20c9b 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -967,7 +967,6 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f if (!p_body->get_kinematic_utilities()) { p_body->init_kinematic_utilities(); - p_body->reload_kinematic_shapes(); } btVector3 initial_recover_motion(0, 0, 0); @@ -1109,7 +1108,6 @@ int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p if (!p_body->get_kinematic_utilities()) { p_body->init_kinematic_utilities(); - p_body->reload_kinematic_shapes(); } btVector3 recover_motion(0, 0, 0);