How to simulate "breaking" a joint (constraint)?

I’d like to have a joint that can be broken when enough force is acting on it. It seems like I ought to be able to modify FixedConstraint a little bit and get the job done, but the implementation is very intimidating :sweat_smile:

Yeah, breakable joints are not supported yet by nphysics.
Here is how I think this could be done:

  1. Add a broken flag (initially set to false) to the FixedConstraint.
  2. In the cache_impulses method, check if any impulse is greater than some user-defined value. If it is, set the self.broken flag to true.
  3. Change that and that to be zero if self.broken == true.
  4. Change that and that so they do nothing if self.broken == true.

This is currently no mechanism in place to make the MechanicalWorld automatically delete a joint. So I guess that would be the user’s responsibility. Otherwise, we could add a is_broken method to the JointConstraint trait which the MechanicalWorld will call at the beggin of each step to detect if the joint broke, and removed it if necessary.

1 Like