diff options
author | Ton Roosendaal <ton@blender.org> | 2010-12-21 21:55:49 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2010-12-21 21:55:49 +0300 |
commit | aeba7032e6fe3f70ede89b24cd9e6d098adb993b (patch) | |
tree | 4dcc22d408993c0e2933deeae8b50ac27f5d16da /source/blender/editors/space_view3d | |
parent | fae8dc5a735d6e47d96d5757fbc51a33b45a4cea (diff) |
Bugfix #25330
3D Window: Snap to cursor or grid, didn't respect the 'restrict location'
options for objects or bones.
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_snap.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index beb6170e0dc..64aa21d6ad8 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -510,7 +510,12 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) armature_loc_pose_to_bone(pchan, vec, vecN); /* adjust location */ - VECCOPY(pchan->loc, vecN); + if ((pchan->protectflag & OB_LOCK_LOCX)==0) + pchan->loc[0]= vecN[0]; + if ((pchan->protectflag & OB_LOCK_LOCY)==0) + pchan->loc[0]= vecN[1]; + if ((pchan->protectflag & OB_LOCK_LOCZ)==0) + pchan->loc[0]= vecN[2]; } /* if the bone has a parent and is connected to the parent, * don't do anything - will break chain unless we do auto-ik. @@ -536,16 +541,14 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); - ob->loc[0]+= vec[0]; - ob->loc[1]+= vec[1]; - ob->loc[2]+= vec[2]; } - else { + if ((ob->protectflag & OB_LOCK_LOCX)==0) ob->loc[0]+= vec[0]; + if ((ob->protectflag & OB_LOCK_LOCY)==0) ob->loc[1]+= vec[1]; + if ((ob->protectflag & OB_LOCK_LOCZ)==0) ob->loc[2]+= vec[2]; - } - + /* auto-keyframing */ // XXX autokeyframe_ob_cb_func(ob, TFM_TRANSLATION); } @@ -633,8 +636,13 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) /* get location of cursor in bone-space */ armature_loc_pose_to_bone(pchan, cursp, curspn); - /* calculate new position */ - VECCOPY(pchan->loc, curspn); + /* copy new position */ + if ((pchan->protectflag & OB_LOCK_LOCX)==0) + pchan->loc[0]= curspn[0]; + if ((pchan->protectflag & OB_LOCK_LOCY)==0) + pchan->loc[1]= curspn[1]; + if ((pchan->protectflag & OB_LOCK_LOCZ)==0) + pchan->loc[2]= curspn[2]; } /* if the bone has a parent and is connected to the parent, * don't do anything - will break chain unless we do auto-ik. @@ -660,15 +668,14 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); - ob->loc[0]+= vec[0]; - ob->loc[1]+= vec[1]; - ob->loc[2]+= vec[2]; } - else { + if ((ob->protectflag & OB_LOCK_LOCX)==0) ob->loc[0]+= vec[0]; + if ((ob->protectflag & OB_LOCK_LOCY)==0) ob->loc[1]+= vec[1]; + if ((ob->protectflag & OB_LOCK_LOCZ)==0) ob->loc[2]+= vec[2]; - } + /* auto-keyframing */ // XXX autokeyframe_ob_cb_func(ob, TFM_TRANSLATION); } |