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
This commit is contained in:
Jacques Lucke
2021-07-23 16:09:57 +02:00
parent 25fc77f46c
commit 6ac378e685

View File

@@ -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;