12-08-2025, 08:57 AM
(This post was last modified: 12-08-2025, 09:59 AM by josemendez.)
Hi Qriva0 and Matt,
The behavior of Qriva's repro scene was not what I was picturing in my head, thanks to it I was able to spot a bug in the pin constraints orientation code in 7.1. This causes relative orientations to flip to the exact opposite orientation when exactly at 180º degrees from it, instead of doing so when approaching 90º - which is what should happen: flip to the closest orientation (either q or -q), but not flip to -q when exactly at q.
The fix is very simple: just check the imaginary part of the quaternion instead of all of it when determining which rest orientation is closest to the current one, q or -q. This affects both pin and bend/twist constraints, so for your convenience I'm attaching the files where this was changed: replace your version ofBurstBendTwistConstraintsBatch.cs and BurstPinConstraintsBatch.cs with the ones I'm attaching.
Note this will still allow the attachment to jump to the opposite rest orientation when the current relative orientation is closer to the opposite than the initial orientation (which may happen during violent movement, more than 90º degrees in a single frame) but this is easy to prevent with a second attachment as originally suggested.
While working on this, I think I figured out a way to prevent the ambiguity completely by enforcing the orientation constraint in a different manner. That will have to wait until 7.2 though.
let me know how it goes,
kind regards
The behavior of Qriva's repro scene was not what I was picturing in my head, thanks to it I was able to spot a bug in the pin constraints orientation code in 7.1. This causes relative orientations to flip to the exact opposite orientation when exactly at 180º degrees from it, instead of doing so when approaching 90º - which is what should happen: flip to the closest orientation (either q or -q), but not flip to -q when exactly at q.
The fix is very simple: just check the imaginary part of the quaternion instead of all of it when determining which rest orientation is closest to the current one, q or -q. This affects both pin and bend/twist constraints, so for your convenience I'm attaching the files where this was changed: replace your version ofBurstBendTwistConstraintsBatch.cs and BurstPinConstraintsBatch.cs with the ones I'm attaching.
Note this will still allow the attachment to jump to the opposite rest orientation when the current relative orientation is closer to the opposite than the initial orientation (which may happen during violent movement, more than 90º degrees in a single frame) but this is easy to prevent with a second attachment as originally suggested.
While working on this, I think I figured out a way to prevent the ambiguity completely by enforcing the orientation constraint in a different manner. That will have to wait until 7.2 though.
let me know how it goes,
kind regards