diff options
author | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2021-01-13 13:30:42 +0000 |
---|---|---|
committer | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2021-01-13 13:32:46 +0000 |
commit | 797a7fc6cc9c9583546447771fbf2b9c3b8cb576 (patch) | |
tree | 7ed2689bdb6713f125c805c3bc9656d423efc81f /modules/bullet | |
parent | 7f8ab378e9840ce5ea80b4bad9dcd3094cd0e0bc (diff) |
Only remove Bullet's body constraints when removing body from space
Diffstat (limited to 'modules/bullet')
-rw-r--r-- | modules/bullet/rigid_body_bullet.cpp | 3 | ||||
-rw-r--r-- | modules/bullet/space_bullet.cpp | 6 | ||||
-rw-r--r-- | modules/bullet/space_bullet.h | 1 |
3 files changed, 8 insertions, 2 deletions
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 7a53f91b33..4763098584 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -322,7 +322,8 @@ void RigidBodyBullet::set_space(SpaceBullet *p_space) { if (space) { can_integrate_forces = false; isScratchedSpaceOverrideModificator = false; - + // Remove any constraints + space->remove_rigid_body_constraints(this); // Remove this object form the physics world space->remove_rigid_body(this); } diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index a8d55b59b3..5cbaeb32d7 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -477,7 +477,7 @@ void SpaceBullet::add_rigid_body(RigidBodyBullet *p_body) { } } -void SpaceBullet::remove_rigid_body(RigidBodyBullet *p_body) { +void SpaceBullet::remove_rigid_body_constraints(RigidBodyBullet *p_body) { btRigidBody *btBody = p_body->get_bt_rigid_body(); int constraints = btBody->getNumConstraintRefs(); @@ -487,6 +487,10 @@ void SpaceBullet::remove_rigid_body(RigidBodyBullet *p_body) { dynamicsWorld->removeConstraint(btBody->getConstraintRef(i)); } } +} + +void SpaceBullet::remove_rigid_body(RigidBodyBullet *p_body) { + btRigidBody *btBody = p_body->get_bt_rigid_body(); if (p_body->is_static()) { dynamicsWorld->removeCollisionObject(btBody); diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h index 42f982d5f0..0f2482e551 100644 --- a/modules/bullet/space_bullet.h +++ b/modules/bullet/space_bullet.h @@ -151,6 +151,7 @@ public: void reload_collision_filters(AreaBullet *p_area); void add_rigid_body(RigidBodyBullet *p_body); + void remove_rigid_body_constraints(RigidBodyBullet *p_body); void remove_rigid_body(RigidBodyBullet *p_body); void reload_collision_filters(RigidBodyBullet *p_body); |