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:
authorBastien Montagne <montagne29@wanadoo.fr>2012-01-17 17:30:20 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2012-01-17 17:30:20 +0400
commit25e3b647b198d3eeb14345ccbeb6ce96e23c2cf9 (patch)
tree1fac56629855ca2e27b461c4f2a3782358922f64 /source/blender/editors/transform
parentf3e39fc8c9d83fff1e4d591b27073586d855bdc6 (diff)
New pchan to pose matrices computes. Fixes [#27898] Bone snap to cursor fails and [#29461] Selection-to-Cursor works strange with bones with TrackTo constraint. Also fixes some inconsistant behavior of no Inherit Rotation/Scale options.
WARNING: This commits modifies how translated unconnected child bones with *no Inherit Rotation option* are positionned. This means that if you open a posed/animated armature using such (corner-case) setup, you'll have to adjust manually the locations of such bones: now, disabling Inherit Rotation/Scale will no more move the bone, only affecting its rotation/scale. Many thanks to Bassam Kurdali (slikdigit) for his advices and tests of the patch! ----- Dev notesĀ : the pchan_to_pose_mat() func was added to BKE_armature.h, which computes two matrices to get the pose transformations (pchan) of the bone directly in pose (i.e. armature object) space. The first matrix is the rotation/scaling parts, the second one is for location. That new function is used by (hence deduplicating and simplifying their code): * The pose evaluation code (where_is_pose_bone()). * The interactive transformation code (add_pose_transdata(), in transform_conversion.c). * The snap to cursor/grid code (through armature_loc_pose_to_bone()/armature_mat_pose_to_bone()).
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r--source/blender/editors/transform/transform_conversions.c48
1 files changed, 40 insertions, 8 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 44dc909314a..b060c04de4e 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -515,7 +515,7 @@ static short apply_targetless_ik(Object *ob)
static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, TransData *td)
{
Bone *bone= pchan->bone;
- float pmat[3][3], omat[3][3], bmat[3][3];
+ float pmat[3][3], omat[3][3];
float cmat[3][3], tmat[3][3];
float vec[3];
@@ -569,39 +569,71 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
copy_qt_qt(td->ext->iquat, pchan->quat);
}
td->ext->rotOrder= pchan->rotmode;
-
+
/* proper way to get parent transform + own transform + constraints transform */
copy_m3_m4(omat, ob->obmat);
+ /* New code, using "generic" pchan_to_pose_mat(). */
+ {
+ float rotscale_mat[4][4], loc_mat[4][4];
+
+ pchan_to_pose_mat(pchan, rotscale_mat, loc_mat);
+ if (t->mode == TFM_TRANSLATION)
+ copy_m3_m4(pmat, loc_mat);
+ else
+ copy_m3_m4(pmat, rotscale_mat);
+
+ if (constraints_list_needinv(t, &pchan->constraints)) {
+ copy_m3_m4(tmat, pchan->constinv);
+ invert_m3_m3(cmat, tmat);
+ mul_serie_m3(td->mtx, pmat, omat, cmat, NULL,NULL,NULL,NULL,NULL);
+ }
+ else
+ mul_serie_m3(td->mtx, pmat, omat, NULL, NULL,NULL,NULL,NULL,NULL);
+ }
+
+ /* XXX Old code. Will remove it later. */
+#if 0
if (ELEM(t->mode, TFM_TRANSLATION, TFM_RESIZE) && (pchan->bone->flag & BONE_NO_LOCAL_LOCATION))
unit_m3(bmat);
else
copy_m3_m3(bmat, pchan->bone->bone_mat);
if (pchan->parent) {
- if(pchan->bone->flag & BONE_HINGE)
+ if(pchan->bone->flag & BONE_HINGE) {
copy_m3_m4(pmat, pchan->parent->bone->arm_mat);
- else
+ if(!(pchan->bone->flag & BONE_NO_SCALE)) {
+ float tsize[3], tsmat[3][3];
+ mat4_to_size(tsize, pchan->parent->pose_mat);
+ size_to_mat3(tsmat, tsize);
+ mul_m3_m3m3(pmat, tsmat, pmat);
+ }
+ }
+ else {
copy_m3_m4(pmat, pchan->parent->pose_mat);
+ if(pchan->bone->flag & BONE_NO_SCALE)
+ normalize_m3(pmat);
+ }
if (constraints_list_needinv(t, &pchan->constraints)) {
copy_m3_m4(tmat, pchan->constinv);
invert_m3_m3(cmat, tmat);
- mul_serie_m3(td->mtx, bmat, pmat, omat, cmat, NULL,NULL,NULL,NULL); // dang mulserie swaps args
+ mul_serie_m3(td->mtx, bmat, pmat, omat, cmat, NULL,NULL,NULL,NULL);
}
else
- mul_serie_m3(td->mtx, bmat, pmat, omat, NULL,NULL,NULL,NULL,NULL); // dang mulserie swaps args
+ mul_serie_m3(td->mtx, bmat, pmat, omat, NULL,NULL,NULL,NULL,NULL);
}
else {
if (constraints_list_needinv(t, &pchan->constraints)) {
copy_m3_m4(tmat, pchan->constinv);
invert_m3_m3(cmat, tmat);
- mul_serie_m3(td->mtx, bmat, omat, cmat, NULL,NULL,NULL,NULL,NULL); // dang mulserie swaps args
+ mul_serie_m3(td->mtx, bmat, omat, cmat, NULL,NULL,NULL,NULL,NULL);
}
else
- mul_m3_m3m3(td->mtx, omat, bmat); // Mat3MulMat3 has swapped args!
+ mul_m3_m3m3(td->mtx, omat, bmat);
}
+# endif
invert_m3_m3(td->smtx, td->mtx);