Merge pull request #45159 from madmiraal/fix-45145
Only remove Bullet's body constraints when removing body from space
This commit is contained in:
commit
8d4698db36
3 changed files with 8 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue