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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-17 03:39:29 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-17 03:39:29 +0300
commitf2453ecdcd179fb696494d03501c0dd149ee1ed2 (patch)
tree23fdd70d99c95b5efab3fb258db77b68501aa059 /source/blender/collada/collada_utils.cpp
parent09eb790f4bbc89ceac0dda949f2f42a3c94883a4 (diff)
parent5bc2c17161cfc23ca2d8c58e7e24458c277100ae (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/collada/collada_utils.cpp')
-rw-r--r--source/blender/collada/collada_utils.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index f351ebf7952..117e2ef7f76 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -384,6 +384,35 @@ void bc_decompose(float mat[4][4], float *loc, float eul[3], float quat[4], floa
}
}
+/*
+* Create rotation_quaternion from a delta rotation and a reference quat
+*
+* Input:
+* mat_from: The rotation matrix before rotation
+* mat_to : The rotation matrix after rotation
+* qref : the quat corresponding to mat_from
+*
+* Output:
+* rot : the calculated result (quaternion)
+*
+*/
+void bc_rotate_from_reference_quat(float quat_to[4], float quat_from[4], float mat_to[4][4])
+{
+ float qd[4];
+ float matd[4][4];
+ float mati[4][4];
+ float mat_from[4][4];
+ quat_to_mat4(mat_from, quat_from);
+
+ // Calculate the difference matrix matd between mat_from and mat_to
+ invert_m4_m4(mati, mat_from);
+ mul_m4_m4m4(matd, mati, mat_to);
+
+ mat4_to_quat(qd, matd);
+
+ mul_qt_qtqt(quat_to, qd, quat_from); // rot is the final rotation corresponding to mat_to
+}
+
void bc_triangulate_mesh(Mesh *me)
{
bool use_beauty = false;
@@ -841,3 +870,11 @@ void bc_sanitize_mat(float mat[4][4], int precision)
for (int j = 0; j < 4; j++)
mat[i][j] = double_round(mat[i][j], precision);
}
+
+void bc_sanitize_mat(double mat[4][4], int precision)
+{
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 4; j++)
+ mat[i][j] = double_round(mat[i][j], precision);
+}
+