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.
@janhohenheim janhohenheim added the A-Joints Relates to joints constraining the relative positions and orientations of rigid bodies label Nov 24, 2025
@janhohenheim
Copy link
Member

Marking as Waiting-on-Author due to merge conflicts

@janhohenheim janhohenheim added D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Joints Relates to joints constraining the relative positions and orientations of rigid bodies D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged

2 participants