Also clamp angular and linear velocities to max speeds while solving constraints #651
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Allow
MaxLinearSpeedandMaxAngularSpeedcomponents to be used to prevent the issue described on this Discord message that can cause objects to “disappear”. (Actually get corrupted withNaNs)Some details on the issue:
RigidBodyQueryItem::velocity_at_point()is involved, producing a “lever“-like effect (that somehow doesn't properly conserve momentum, possibly due to the interaction with joint constraints)MaxLinearSpeedandMaxAngularSpeedcan't really be used to prevent this, as duringContactConstraintsolving it is possible for a dynamic rigid body's linear and angular velocity to (temporarily) exceed the limits specified by them, as they are presently only applied during velocity integration.Solution
MaxLinearSpeedandMaxAngularSpeedtoRigidBodyQueryRigidBodyQueryItem::clamp_velocities()methodContactConstraint::warm_start(),ContactConstraint::solve()andContactConstraint::apply_restitution()Changelog
MaxLinearSpeedandMaxAngularSpeednow apply continuously duringContactConstraintsolving, preventing dynamic rigid bodies from (temporarily) exceeding the speed limits during this computation.Migration Guide
MaxLinearSpeedandMaxAngularSpeed(e.g. same order of magnitude asSolverConfig::max_overlap_solve_speedor smaller) and encounter collision “tunneling” issues (i.e. objects clipping through each other) consider bumping them to higher amounts, as these components now also apply duringContactConstraintsolving and can prevent overlap solving from working properly if set too low.