Limit Rotation: explicitly orthogonalize the matrix before processing.

Add a call to orthogonalize the matrix before processing for the
same reasons as D8915, and an early exit in case no limits are
enabled for a bit of extra efficiency.

Since the constraint goes through Euler decomposition, it would
in fact remove shear even before this change, but the resulting
rotation won't make much sense.

This change allows using the constraint without any enabled limits
purely for the purpose of efficiently removing shear.

Differential Revision: https://developer.blender.org/D9626
This commit is contained in:
Alexander Gavrilov 2021-06-05 15:47:11 +03:00
parent d2dc452333
commit edaaa2afdd
Notes: blender-bot 2023-02-14 00:20:19 +01:00
Referenced by issue #83908, Streamlining advanced rigging of B-Bone chains.
1 changed files with 10 additions and 0 deletions

View File

@ -1635,6 +1635,16 @@ static void rotlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UN
float eul[3];
float size[3];
/* This constraint is based on euler rotation math, which doesn't work well with shear.
* The Y axis is chosen as the main one because constraints are most commonly used on bones.
* This also allows using the constraint to simply remove shear. */
orthogonalize_m4_stable(cob->matrix, 1, false);
/* Only do the complex processing if some limits are actually enabled. */
if (!(data->flag & (LIMIT_XROT | LIMIT_YROT | LIMIT_ZROT))) {
return;
}
/* Select the Euler rotation order, defaulting to the owner value. */
short rot_order = cob->rotOrder;