[Bf-blender-cvs] [4846342b95c] temp-D8915-copy-rotation-remove-sheer: Negate Shear in Copy Rotation

Joseph Brandenburg noreply at git.blender.org
Tue Oct 27 13:52:43 CET 2020


Commit: 4846342b95cd3a8c12250f742f64c844dbe10c73
Author: Joseph Brandenburg
Date:   Tue Oct 27 12:03:44 2020 +0100
Branches: temp-D8915-copy-rotation-remove-sheer
https://developer.blender.org/rB4846342b95cd3a8c12250f742f64c844dbe10c73

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

===================================================================

M	source/blender/blenkernel/intern/constraint.c

===================================================================

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;



More information about the Bf-blender-cvs mailing list