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/space_view3d/view3d_snap.c
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/space_view3d/view3d_snap.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 6bc1b3acce6..3665b0b13c3 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -505,7 +505,6 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op))
if(pchan->bone->layer & arm->layer) {
if((pchan->bone->flag & BONE_CONNECTED)==0) {
float nLoc[3];
- float inv_restmat[4][4];
/* get nearest grid point to snap to */
copy_v3_v3(nLoc, pchan->pose_mat[3]);
@@ -517,9 +516,8 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op))
/* Back in object space... */
mul_m4_v3(ob->imat, vec);
- /* get location of grid point in *rest* bone-space */
- invert_m4_m4(inv_restmat, pchan->bone->arm_mat);
- mul_m4_v3(inv_restmat, vec);
+ /* Get location of grid point in pose space. */
+ armature_loc_pose_to_bone(pchan, vec, vec);
/* adjust location */
if ((pchan->protectflag & OB_LOCK_LOCX)==0)
@@ -642,12 +640,9 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op))
if(pchan->bone->flag & BONE_SELECTED) {
if(pchan->bone->layer & arm->layer) {
if((pchan->bone->flag & BONE_CONNECTED)==0) {
- float inv_restmat[4][4];
-
- /* get location of cursor in *rest* bone-space */
- invert_m4_m4(inv_restmat, pchan->bone->arm_mat);
- mul_m4_v3(inv_restmat, vec);
-
+ /* Get position in pchan (pose) space. */
+ armature_loc_pose_to_bone(pchan, vec, vec);
+
/* copy new position */
if ((pchan->protectflag & OB_LOCK_LOCX)==0)
pchan->loc[0]= vec[0];