Todo #8511: Lock Transform Channels does not work with Clear Transforms

When transform channels (i.e. LocX, RotY, ScaleZ) are 'locked' in the Transform Properties panel, the Clear Transform Tools (Alt-G/R/S) didn't respect these.

Also fixed typo in 3D-View Menu item.
This commit is contained in:
Joshua Leung 2008-03-16 03:11:57 +00:00
parent a4283a139a
commit f50eb9c0c9
3 changed files with 82 additions and 23 deletions

@ -2843,23 +2843,56 @@ void clear_armature(Object *ob, char mode)
bPoseChannel *pchan;
bArmature *arm;
arm=get_armature(ob);
if (!arm)
arm= get_armature(ob);
if (arm == NULL)
return;
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if(pchan->bone && (pchan->bone->flag & BONE_SELECTED)) {
if(arm->layer & pchan->bone->layer) {
/* only clear those channels that are not locked */
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if (pchan->bone && (pchan->bone->flag & BONE_SELECTED)) {
if (arm->layer & pchan->bone->layer) {
switch (mode) {
case 'r':
pchan->quat[1]=pchan->quat[2]=pchan->quat[3]=0.0F; pchan->quat[0]=1.0F;
if (pchan->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ)) {
float eul[3], oldeul[3], quat1[4];
QUATCOPY(quat1, pchan->quat);
QuatToEul(pchan->quat, oldeul);
eul[0]= eul[1]= eul[2]= 0.0f;
if (pchan->protectflag & OB_LOCK_ROTX)
eul[0]= oldeul[0];
if (pchan->protectflag & OB_LOCK_ROTY)
eul[1]= oldeul[1];
if (pchan->protectflag & OB_LOCK_ROTZ)
eul[2]= oldeul[2];
EulToQuat(eul, pchan->quat);
/* quaternions flip w sign to accumulate rotations correctly */
if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) {
QuatMulf(pchan->quat, -1.0f);
}
}
else {
pchan->quat[1]=pchan->quat[2]=pchan->quat[3]=0.0F;
pchan->quat[0]=1.0F;
}
break;
case 'g':
pchan->loc[0]=pchan->loc[1]=pchan->loc[2]=0.0F;
if ((pchan->protectflag & OB_LOCK_LOCX)==0)
pchan->loc[0]= 0.0f;
if ((pchan->protectflag & OB_LOCK_LOCY)==0)
pchan->loc[1]= 0.0f;
if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
pchan->loc[2]= 0.0f;
break;
case 's':
pchan->size[0]=pchan->size[1]=pchan->size[2]=1.0F;
if ((pchan->protectflag & OB_LOCK_SCALEX)==0)
pchan->size[0]= 1.0f;
if ((pchan->protectflag & OB_LOCK_SCALEY)==0)
pchan->size[1]= 1.0f;
if ((pchan->protectflag & OB_LOCK_SCALEZ)==0)
pchan->size[2]= 1.0f;
break;
}

@ -1030,18 +1030,31 @@ void clear_object(char mode)
* - with a mesh in weightpaint mode, it's related armature needs to be cleared
* - with clearing transform of object being edited at the time
*/
if ((G.f & G_WEIGHTPAINT) || ob==OBACT) {
if ((G.f & G_WEIGHTPAINT) || (ob==OBACT)) {
clear_armature(ob, mode);
armature_clear= 1; /* silly system to prevent another dag update, so no action applied */
}
}
else if((G.f & G_WEIGHTPAINT)==0) {
if(mode=='r') {
memset(ob->rot, 0, 3*sizeof(float));
memset(ob->drot, 0, 3*sizeof(float));
/* only clear transforms of 'normal' (not armature) object if:
* - not in weightpaint mode or editmode
* - if that object's transform locks are not enabled (this is done on a per-channel basis)
*/
if (mode=='r') {
/* eulers can only get cleared if they are not protected */
if ((ob->protectflag & OB_LOCK_ROTX)==0)
ob->rot[0]= ob->drot[0]= 0.0f;
if ((ob->protectflag & OB_LOCK_ROTY)==0)
ob->rot[1]= ob->drot[1]= 0.0f;
if ((ob->protectflag & OB_LOCK_ROTZ)==0)
ob->rot[2]= ob->drot[2]= 0.0f;
/* quats here are not really used anymore anywhere, so it probably doesn't
* matter to not clear them whether the euler-based rotation is used
*/
QuatOne(ob->quat);
QuatOne(ob->dquat);
#ifdef WITH_VERSE
if(ob->vnode) {
struct VNode *vnode = (VNode*)ob->vnode;
@ -1051,9 +1064,14 @@ void clear_object(char mode)
#endif
}
else if(mode=='g') {
memset(ob->loc, 0, 3*sizeof(float));
memset(ob->dloc, 0, 3*sizeof(float));
else if (mode=='g') {
if ((ob->protectflag & OB_LOCK_LOCX)==0)
ob->loc[0]= ob->dloc[0]= 0.0f;
if ((ob->protectflag & OB_LOCK_LOCY)==0)
ob->loc[1]= ob->dloc[1]= 0.0f;
if ((ob->protectflag & OB_LOCK_LOCZ)==0)
ob->loc[2]= ob->dloc[2]= 0.0f;
#ifdef WITH_VERSE
if(ob->vnode) {
struct VNode *vnode = (VNode*)ob->vnode;
@ -1063,11 +1081,19 @@ void clear_object(char mode)
#endif
}
else if(mode=='s') {
memset(ob->dsize, 0, 3*sizeof(float));
ob->size[0]= 1.0;
ob->size[1]= 1.0;
ob->size[2]= 1.0;
else if (mode=='s') {
if ((ob->protectflag & OB_LOCK_SCALEX)==0) {
ob->dsize[0]= 0.0f;
ob->size[0]= 1.0f;
}
if ((ob->protectflag & OB_LOCK_SCALEY)==0) {
ob->dsize[1]= 0.0f;
ob->size[1]= 1.0f;
}
if ((ob->protectflag & OB_LOCK_SCALEZ)==0) {
ob->dsize[2]= 0.0f;
ob->size[2]= 1.0f;
}
#ifdef WITH_VERSE
if(ob->vnode) {
struct VNode *vnode = (VNode*)ob->vnode;

@ -1977,7 +1977,7 @@ static uiBlock *view3d_edit_object_transformmenu(void *arg_unused)
block= uiNewBlock(&curarea->uiblocks, "view3d_edit_object_transformmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetButmFunc(block, do_view3d_edit_object_transformmenu, NULL);
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Apply Scale/Rotationr to ObData|Ctrl A, 1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Apply Scale/Rotation to ObData|Ctrl A, 1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Apply Visual Transform|Ctrl A, 2", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Apply Deformation|Ctrl Shift A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make Duplicates Real|Ctrl Shift A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");