svn merge ^/trunk/blender -r43443:43461
[blender.git] / source / blender / editors / space_view3d / view3d_snap.c
index 1ee0c03d5e5893cd0f315024ef0a067d6b1f737e..2e8ddbbede41b19c4caf9d177e4400e9287b8c5b 100644 (file)
@@ -564,7 +564,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]);
@@ -576,9 +575,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)
@@ -701,12 +699,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];