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>2018-07-15 20:39:02 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2018-11-06 10:56:08 +0300
commit798cdaeeb6927cb9ca42597fa23845eac04c02b2 (patch)
tree92e444a0a2268d891cdd90f56299ccb8f1c1bf3b /source/blender/blenlib
parenta817613be5ab1545b000e9173a8d3079aaaefa01 (diff)
Implement an Armature constraint that mimics the modifier.
The main use one can imagine for this is adding tweak controls to parts of a model that are already deformed by multiple other major bones. It is natural to expect such locations to deform as if the tweaks aren't there by default; however currently there is no easy way to make a bone follow multiple other bones. This adds a new constraint that implements the math behind the Armature modifier, with support for explicit weights, bone envelopes, and dual quaternion blending. It can also access bones from multiple armatures at the same time (mainly because it's easier to code it that way.) This also fixes dquat_to_mat4, which wasn't used anywhere before. Differential Revision: https://developer.blender.org/D3664
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/math_rotation.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 29e7cf32ddc..17b395036a3 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1872,19 +1872,24 @@ void dquat_to_mat4(float mat[4][4], const DualQuat *dq)
/* normalize */
len = sqrtf(dot_qtqt(q0, q0));
- if (len != 0.0f)
- mul_qt_fl(q0, 1.0f / len);
+ if (len != 0.0f) {
+ len = 1.0f / len;
+ }
+ mul_qt_fl(q0, len);
/* rotation */
quat_to_mat4(mat, q0);
/* translation */
t = dq->trans;
- mat[3][0] = 2.0f * (-t[0] * q0[1] + t[1] * q0[0] - t[2] * q0[3] + t[3] * q0[2]);
- mat[3][1] = 2.0f * (-t[0] * q0[2] + t[1] * q0[3] + t[2] * q0[0] - t[3] * q0[1]);
- mat[3][2] = 2.0f * (-t[0] * q0[3] - t[1] * q0[2] + t[2] * q0[1] + t[3] * q0[0]);
+ mat[3][0] = 2.0f * (-t[0] * q0[1] + t[1] * q0[0] - t[2] * q0[3] + t[3] * q0[2]) * len;
+ mat[3][1] = 2.0f * (-t[0] * q0[2] + t[1] * q0[3] + t[2] * q0[0] - t[3] * q0[1]) * len;
+ mat[3][2] = 2.0f * (-t[0] * q0[3] - t[1] * q0[2] + t[2] * q0[1] + t[3] * q0[0]) * len;
- /* note: this does not handle scaling */
+ /* scaling */
+ if (dq->scale_weight) {
+ mul_m4_m4m4(mat, mat, dq->scale);
+ }
}
void add_weighted_dq_dq(DualQuat *dqsum, const DualQuat *dq, float weight)