From 4846342b95cd3a8c12250f742f64c844dbe10c73 Mon Sep 17 00:00:00 2001 From: Joseph Brandenburg Date: Tue, 27 Oct 2020 12:03:44 +0100 Subject: Negate Shear in Copy Rotation This patch negates the effects of shear in the Copy Rotation constraint, which causes incorrect results and even flipping on rare occasions. Here is the bug report associated with the issue: T80970 This bug report has an example of the problem in a .blend file. This patch will change existing .blend files if a copy rotation constraint is used with a target that has shearing -- instead of pointing in the "wrong" direction (due to the shear), the constrained object will copy the final rotation of the target, with the shearing applied. Proposed Solution: Correct the matrix of the constraint target for shear. Limitations of proposed solution: - It's conceivable that someone has used the "incorrect behaviour" in a rig... although I doubt this. It may be necessary to create an "allow shear" checkbox that is disabled by default to maintain the legacy behaviour. No UI changes are needed for this patch :) Differential Revision: https://developer.blender.org/D8915 --- source/blender/blenkernel/intern/constraint.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 274546132fb..19e418aaa15 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1814,6 +1814,10 @@ static void rotlike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar if (VALID_CONS_TARGET(ct)) { float loc[3], size[3], oldrot[3][3], newrot[3][3]; float eul[3], obeul[3], defeul[3]; + float mat[4][4]; + + copy_m4_m4(mat, ct->matrix); + orthogonalize_m4_stable(mat, 1, true); mat4_to_loc_rot_size(loc, oldrot, size, cob->matrix); @@ -1828,7 +1832,7 @@ static void rotlike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar mat4_to_eulO(obeul, rot_order, cob->matrix); /* We must get compatible eulers from the beginning because * some of them can be modified below (see bug T21875). */ - mat4_to_compatible_eulO(eul, obeul, rot_order, ct->matrix); + mat4_to_compatible_eulO(eul, obeul, rot_order, mat); /* Prepare the copied euler rotation. */ bool legacy_offset = false; -- cgit v1.2.3