Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2021-06-21 20:24:23 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-06-21 20:31:45 +0300
commitb665ad8621a0db265fd666542d26aed463025db1 (patch)
tree163a137c4e79735ca84a0cf3cfb8fe522ddc27e9 /source/blender/blenlib
parent41af27c582ec21e65ff3f835754c7b0bcf6d3be7 (diff)
Fix T89291: Objects with rotation deltas don't rotate in correct axes
Quaternion correction was not implemented and Euler values were being incorrectly combined.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_rotation.h3
-rw-r--r--source/blender/blenlib/intern/math_rotation.c25
2 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h
index fe995b2e46e..ef10d02f10f 100644
--- a/source/blender/blenlib/BLI_math_rotation.h
+++ b/source/blender/blenlib/BLI_math_rotation.h
@@ -164,6 +164,9 @@ void compatible_eul(float eul[3], const float old[3]);
void rotate_eul(float eul[3], const char axis, const float angle);
+void add_eul_euleul(float r_eul[3], float a[3], float b[3], const short order);
+void sub_eul_euleul(float r_eul[3], float a[3], float b[3], const short order);
+
/************************** Arbitrary Order Eulers ***************************/
/* warning: must match the eRotationModes in DNA_action_types.h
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 57fe99ce019..469cd573372 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1924,6 +1924,31 @@ void eulO_to_gimbal_axis(float gmat[3][3], const float eul[3], const short order
gmat[R->axis[2]][R->axis[2]] = 1;
}
+void add_eul_euleul(float r_eul[3], float a[3], float b[3], const short order)
+{
+ float quat[4], quat_b[4];
+
+ eulO_to_quat(quat, a, order);
+ eulO_to_quat(quat_b, b, order);
+
+ mul_qt_qtqt(quat, quat_b, quat);
+
+ quat_to_eulO(r_eul, order, quat);
+}
+
+void sub_eul_euleul(float r_eul[3], float a[3], float b[3], const short order)
+{
+ float quat[4], quat_b[4];
+
+ eulO_to_quat(quat, a, order);
+ eulO_to_quat(quat_b, b, order);
+
+ invert_qt_normalized(quat_b);
+ mul_qt_qtqt(quat, quat_b, quat);
+
+ quat_to_eulO(r_eul, order, quat);
+}
+
/******************************* Dual Quaternions ****************************/
/**