Home Website Youtube GitHub

intMatrix Causing Flipping on Chains

Hey mGear team!

I’ve found that any chain with an IK control flips when the first and last IK control hit a 180º difference from each othe. This gets exacerbated when the chain is not set up perfectly straight. In my case I have a ponytail which coils from the back of the head to the front of the body, and it breaks at only 50º on the end (chain_IK_variable_FK).

It seems very similar to the issue described in Neck IK Popping/Flipping - Support - mGear Framework Forum (mgear-framework.com)

I added some transform groups and constraints in a post-script to help the ponytail slide on the shoulder, but that causes the rotation of the head to also cause the flip when rotated the same amount.

One of our programmers said it looks like it was doing a lerp instead of a slerp between the matrices, but I don’t know enough about C++ or math to dig into the mgear_interpolateMatrix class. In the meantime, are there any good solutions for preventing these flips considering there is an intMatrix going to every FK control?

Don’t things normally flip at 180 with matrixes?

I don’t know that it’s always a given. It seems the Maya API MQuaternion that is used for interpolation has a “spin” value which can be set to -1 to force it along the “long path.”

I’m not familiar with compiling but if my team can help then I’m hoping to try changing the value to see if it at least increases the range before flipping occurs.

After testing the -1 spin and a few other options, including a friend’s suggestion of dot product to check for negatives, I’m still stumped.

-1 and 1+ spin resulted in immediate flipping rather than the 180 value it defaults to. The last hope might be the dslerp option because it defines a direction for the slerp to travel, so I may give that a go.

Though at this point I’m a bit curious what purpose the intMatrix is serving. Do you mGear devs have any insight? It seems like the only important value is the axis pointing down the chain and the others are unused or cause strange side-effects.

I’ll keep experimenting in the meantime!

the int matrix is to blend between two matrixes, this is a stand in for stuff like the blendColor node, or the pairBlend node. Since it’s matrix based it’s easy to integrate. Normally I use it for things like an IKFK blend. I normally see 180 flips with any rotational interpolation unless it’s a linear thing. Even still that has limits.