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
MaxLinearSpeed
andMaxAngularSpeed
components to be used to prevent the issue described on this Discord message that can cause objects to “disappear”. (Actually get corrupted withNaN
s)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)MaxLinearSpeed
andMaxAngularSpeed
can't really be used to prevent this, as duringContactConstraint
solving 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
MaxLinearSpeed
andMaxAngularSpeed
toRigidBodyQuery
RigidBodyQueryItem::clamp_velocities()
methodContactConstraint::warm_start()
,ContactConstraint::solve()
andContactConstraint::apply_restitution()
Changelog
MaxLinearSpeed
andMaxAngularSpeed
now apply continuously duringContactConstraint
solving, preventing dynamic rigid bodies from (temporarily) exceeding the speed limits during this computation.Migration Guide
MaxLinearSpeed
andMaxAngularSpeed
(e.g. same order of magnitude asSolverConfig::max_overlap_solve_speed
or 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 duringContactConstraint
solving and can prevent overlap solving from working properly if set too low.