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:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-11-23 13:11:39 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-12-24 19:58:09 +0300
commit33eabb82207e165de45fb6a0ea74dec962de7265 (patch)
tree714a714819fe27d1f998b0a3c3c7824e786be9ac /source/blender/blenlib/intern/math_matrix.c
parent9378debd26f7b20babcc251bdef64563a56c6ae0 (diff)
Action Constraint: introduce a mix mode setting.
Currently the action channels are applied after the existing transformation, as if the action controlled a child of the bone. This is not very natural, but more importantly, the transform tools are not designed to work conveniently with an additional 'pseudo-child' transformation, resulting in effects like an unexpected pivot location. Implementing a Before mode that integrates the action channels as if applied to a parent allows using the special transform tool code intended for dealing with such constraints. Note that in either mode, Action constraints should be added in reverse order, putting a new constraint before the existing ones that the Action was keyframed to work together. In order to implement the option, extract a utility from the Copy Transform constraint code for combining transforms with special anti-shear scale handling that matches the Aligned Inherit Scale mode. The Before mode also requires switching the constraint to the Local owner space, while the After mode can still use the World space for efficiency as before. Since the constraint doesn't have an Owner space option in the UI, this has to be handled in an RNA setter. For full backward compatibility, the original simple matrix multiplication mode is preserved as the third option, but it is not recommended due to creating shear. Differential Revision: https://developer.blender.org/D6297
Diffstat (limited to 'source/blender/blenlib/intern/math_matrix.c')
-rw-r--r--source/blender/blenlib/intern/math_matrix.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 5118d8a698e..4d8a2f72eca 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -1235,6 +1235,27 @@ bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
#endif
}
+/**
+ * Combines transformations, handling scale separately in a manner equivalent
+ * to the Aligned Inherit Scale mode, in order to avoid creating shear.
+ * If A scale is uniform, the result is equivalent to ordinary multiplication.
+ */
+void mul_m4_m4m4_aligned_scale(float R[4][4], const float A[4][4], const float B[4][4])
+{
+ float loc_a[3], rot_a[3][3], size_a[3];
+ float loc_b[3], rot_b[3][3], size_b[3];
+ float loc_r[3], rot_r[3][3], size_r[3];
+
+ mat4_to_loc_rot_size(loc_a, rot_a, size_a, A);
+ mat4_to_loc_rot_size(loc_b, rot_b, size_b, B);
+
+ mul_v3_m4v3(loc_r, A, loc_b);
+ mul_m3_m3m3_uniq(rot_r, rot_a, rot_b);
+ mul_v3_v3v3(size_r, size_a, size_b);
+
+ loc_rot_size_to_mat4(R, loc_r, rot_r, size_r);
+}
+
/****************************** Linear Algebra *******************************/
void transpose_m3(float mat[3][3])