Skip to content

Commit

Permalink
Fixed ccd enabled by default on Bullet bodies
Browse files Browse the repository at this point in the history
It was due to main_shape_changed being called two times for each
added body. The first time it disables ccd, which sets the internal ccd
threshold to be 10000. The second time, it enables ccd again because
the internal threshold is > 0.

Bodies are now consistently set with a ccd threshold of 0 when ccd is
disabled.

This was causing crashing asserts in Bullet when adding bodies in some
scenarios, in btVector3::normalize():
btAssert(!fuzzyZero());

These crashes will still happen with ccd enabled.
  • Loading branch information
pouleyKetchoupp committed Nov 25, 2020
1 parent 50db0e6 commit faca8b7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/bullet/rigid_body_bullet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ void RigidBodyBullet::set_continuous_collision_detection(bool p_enable) {
}
btBody->setCcdSweptSphereRadius(radius * 0.2);
} else {
btBody->setCcdMotionThreshold(10000.0);
btBody->setCcdMotionThreshold(0.);
btBody->setCcdSweptSphereRadius(0.);
}
}
Expand Down Expand Up @@ -824,7 +824,7 @@ void RigidBodyBullet::reload_shapes() {
btBody->updateInertiaTensor();

reload_kinematic_shapes();
set_continuous_collision_detection(btBody->getCcdMotionThreshold() < 9998.0);
set_continuous_collision_detection(is_continuous_collision_detection_enabled());
reload_body();
}

Expand Down

0 comments on commit faca8b7

Please sign in to comment.