Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.2] Only remove Bullet's body constraints when removing body from space #45160

Merged
merged 1 commit into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/bullet/rigid_body_bullet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,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);
}
Expand Down
6 changes: 5 additions & 1 deletion modules/bullet/space_bullet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,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();
Expand All @@ -507,6 +507,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);
Expand Down
1 change: 1 addition & 0 deletions modules/bullet/space_bullet.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class SpaceBullet : public RIDBullet {
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);

Expand Down