diff options
author | Jacques Lucke <jacques@blender.org> | 2021-07-23 17:09:57 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-07-23 17:10:03 +0300 |
commit | 6ac378e685f357e969abcdd327f2ade95340e814 (patch) | |
tree | a359c0347fef860c14e9c1decf79d9f8922347e9 /source/blender/blenlib/BLI_float4x4.hh | |
parent | 25fc77f46c67599f97851ee7eb32ed65bdfd492b (diff) |
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
Diffstat (limited to 'source/blender/blenlib/BLI_float4x4.hh')
-rw-r--r-- | source/blender/blenlib/BLI_float4x4.hh | 8 |
1 files changed, 7 insertions, 1 deletions
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; |