Skip to content

Conversation

coreh
Copy link

@coreh coreh commented Feb 7, 2025

Objective

Allow MaxLinearSpeed and MaxAngularSpeed components to be used to prevent the issue described on this Discord message that can cause objects to “disappear”. (Actually get corrupted with NaNs)

Some details on the issue:

  • When many objects interact, particularly when constrained by joints (that update position and rotation instantaneously via impulse) and seemingly depending on the arbitrary solving order, it's possible for angular velocity/linear velocity to be exchanged and transferred between objects in a cascade that can produce really high velocity values (beyond reasonable floating point precision range) that then quickly diverge into non-finite values.
  • I haven't been able to fully understand the exact mechanism, but believe 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 and MaxAngularSpeed can't really be used to prevent this, as during ContactConstraint 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

  • Added MaxLinearSpeed and MaxAngularSpeed to RigidBodyQuery
  • Added RigidBodyQueryItem::clamp_velocities() method
  • Clamp velocities during ContactConstraint::warm_start(), ContactConstraint::solve() and ContactConstraint::apply_restitution()

Changelog

  • Fixed: MaxLinearSpeed and MaxAngularSpeed now apply continuously during ContactConstraint solving, preventing dynamic rigid bodies from (temporarily) exceeding the speed limits during this computation.

Migration Guide

  • If you're using really low values of MaxLinearSpeed and MaxAngularSpeed (e.g. same order of magnitude as SolverConfig::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 during ContactConstraint solving and can prevent overlap solving from working properly if set too low.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant