-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Fix ccd enabled by default on Bullet bodies #43801
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the problem is that when CCD is disabled, Bullet's ccdMotionThreshold should be set to 0. not 10000.0:
godot/modules/bullet/rigid_body_bullet.cpp
Line 747 in c545146
btBody->setCcdMotionThreshold(10000.0); |
First, it defaults to 0.:
m_ccdMotionThreshold(btScalar(0.)), |
Second, if it's 0, CCD is not used:
if (getDispatchInfo().m_useContinuous && body->getCcdSquareMotionThreshold() && body->getCcdSquareMotionThreshold() < squareMotion) |
Crashing asserts will still happen with CCD enabled. A separate issue should be raised, because there is a problem with the way that Godot is configuring Bullet CCD. |
Good point, I'll open a ticket for the CCD issue. Edit: Opened #43868 |
Edit: |
@AndreaCatania Do you remember why you set the CCD threshold to 10000 instead of 0 when CCD is disabled in PR #28595? For now, I'm going to set it to 0 to make things more consistent, but let us know if it was solving a specific issue. Looking at Bullet code it shouldn't make a difference in behavior. |
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.
a8bafa8
to
faca8b7
Compare
Thanks! |
Cherry-picked for 3.5. |
Fix based on #42643 (comment)
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 created with disabled ccd by default.
This was causing crashing asserts in Bullet when adding bodies in some scenarios, in
btVector3::normalize()
:btAssert(!fuzzyZero());