From 6ac378e685f357e969abcdd327f2ade95340e814 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 23 Jul 2021 16:09:57 +0200 Subject: 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 --- source/blender/blenlib/BLI_float4x4.hh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source') 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; -- cgit v1.2.3