[Bf-blender-cvs] [6ac378e685f] master: Fix: avoid creating improper rotation matrix

Jacques Lucke noreply at git.blender.org
Fri Jul 23 16:12:32 CEST 2021


Commit: 6ac378e685f357e969abcdd327f2ade95340e814
Author: Jacques Lucke
Date:   Fri Jul 23 16:09:57 2021 +0200
Branches: master
https://developer.blender.org/rB6ac378e685f357e969abcdd327f2ade95340e814

Fix: avoid creating improper rotation matrix

This might change the rotation of some instances after a Curve to Points.
Unfortunately, there is not much we can do about that, the math before
was just wrong. The forward and up axis stayed the same though.

Differential Revision: https://developer.blender.org/D12006

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

M	source/blender/blenlib/BLI_float4x4.hh

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

diff --git a/source/blender/blenlib/BLI_float4x4.hh b/source/blender/blenlib/BLI_float4x4.hh
index 396b0b1bd21..8ff4f94f95c 100644
--- a/source/blender/blenlib/BLI_float4x4.hh
+++ b/source/blender/blenlib/BLI_float4x4.hh
@@ -51,8 +51,14 @@ struct float4x4 {
   {
     BLI_ASSERT_UNIT_V3(forward);
     BLI_ASSERT_UNIT_V3(up);
+
+    /* Negate the cross product so that the resulting matrix has determinant 1 (instead of -1).
+     * Without the negation, the result would be a so called improper rotation. That means it
+     * contains a reflection. Such an improper rotation matrix could not be converted to another
+     * representation of a rotation such as euler angles. */
+    const float3 cross = -float3::cross(forward, up);
+
     float4x4 matrix;
-    const float3 cross = float3::cross(forward, up);
     matrix.values[0][0] = forward.x;
     matrix.values[1][0] = cross.x;
     matrix.values[2][0] = up.x;



More information about the Bf-blender-cvs mailing list