Reload kinematic shapes when changing PhysicsBody mode to Kinematic to prevent a crash when calling test_body_motion. Call reload_kinematic_shapes from init_kinematic_utilities as they are always called together.

This commit is contained in:
BimDav 2021-09-27 09:38:44 +02:00
parent 8138280d20
commit 112985c5bc
2 changed files with 1 additions and 3 deletions

View file

@ -303,6 +303,7 @@ RigidBodyBullet::~RigidBodyBullet() {
void RigidBodyBullet::init_kinematic_utilities() {
kinematic_utilities = memnew(KinematicUtilities(this));
reload_kinematic_shapes();
}
void RigidBodyBullet::destroy_kinematic_utilities() {
@ -534,7 +535,6 @@ void RigidBodyBullet::set_mode(PhysicsServer3D::BodyMode p_mode) {
mode = PhysicsServer3D::BODY_MODE_KINEMATIC;
reload_axis_lock();
_internal_set_mass(0);
init_kinematic_utilities();
break;
case PhysicsServer3D::BODY_MODE_STATIC:
mode = PhysicsServer3D::BODY_MODE_STATIC;

View file

@ -947,7 +947,6 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform3D &p
if (!p_body->get_kinematic_utilities()) {
p_body->init_kinematic_utilities();
p_body->reload_kinematic_shapes();
}
btVector3 initial_recover_motion(0, 0, 0);
@ -1089,7 +1088,6 @@ int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform3D
if (!p_body->get_kinematic_utilities()) {
p_body->init_kinematic_utilities();
p_body->reload_kinematic_shapes();
}
btVector3 recover_motion(0, 0, 0);