Hinge Bone Transform

====================

This changes the way hinge bones are transformed when their parent bones
are also selected. Before it just disabled transform for these, now they
are rotated and scaled as well, but without influencing the transform
center, which gives behaviour as if they were regular bones.
This commit is contained in:
Brecht Van Lommel
2007-11-01 12:55:47 +00:00
parent c5d2be76d7
commit 0ca5c98f23
4 changed files with 20 additions and 5 deletions

View File

@@ -269,6 +269,7 @@ typedef struct TransInfo {
#define TD_VERSE_VERT 64
#endif
#define TD_TIMEONLY 128
#define TD_NOCENTER 256
/* transsnap->status */
#define SNAP_ON 1

View File

@@ -148,5 +148,7 @@ typedef struct bArmature {
#define BONE_NO_DEFORM 4096
/* set to prevent destruction of its unkeyframed pose (after transform) */
#define BONE_UNKEYED 8192
/* set to prevent hinge child bones from influencing the transform center */
#define BONE_HINGE_CHILD_TRANSFORM 16384
#endif

View File

@@ -529,6 +529,8 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
td->ob = ob;
td->flag= TD_SELECTED|TD_USEQUAT;
if(bone->flag & BONE_HINGE_CHILD_TRANSFORM)
td->flag |= TD_NOCENTER;
td->protectflag= pchan->protectflag;
td->loc = pchan->loc;
@@ -617,7 +619,11 @@ static void bone_children_clear_transflag(ListBase *lb)
Bone *bone= lb->first;
for(;bone;bone= bone->next) {
bone->flag &= ~BONE_TRANSFORM;
if(bone->flag & BONE_HINGE)
bone->flag |= BONE_HINGE_CHILD_TRANSFORM;
else
bone->flag &= ~BONE_TRANSFORM;
bone_children_clear_transflag(&bone->childbase);
}
}
@@ -638,6 +644,8 @@ static void set_pose_transflags(TransInfo *t, Object *ob)
bone->flag |= BONE_TRANSFORM;
else
bone->flag &= ~BONE_TRANSFORM;
bone->flag &= ~BONE_HINGE_CHILD_TRANSFORM;
}
}
@@ -658,8 +666,10 @@ static void set_pose_transflags(TransInfo *t, Object *ob)
if(t->mode==TFM_TRANSLATION) {
if( has_targetless_ik(pchan)==NULL ) {
if(pchan->parent && (pchan->bone->flag & BONE_CONNECTED))
t->mode= TFM_ROTATION;
if(pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) {
if(!(pchan->bone->flag & BONE_HINGE_CHILD_TRANSFORM))
t->mode= TFM_ROTATION;
}
else if((pchan->protectflag & OB_LOCK_LOC)==OB_LOCK_LOC)
t->mode= TFM_ROTATION;
}

View File

@@ -782,7 +782,8 @@ void calculateCenterMedian(TransInfo *t)
for(i = 0; i < t->total; i++) {
if (t->data[i].flag & TD_SELECTED) {
VecAddf(partial, partial, t->data[i].center);
if (!(t->data[i].flag & TD_NOCENTER))
VecAddf(partial, partial, t->data[i].center);
}
else {
/*
@@ -807,7 +808,8 @@ void calculateCenterBound(TransInfo *t)
for(i = 0; i < t->total; i++) {
if (i) {
if (t->data[i].flag & TD_SELECTED) {
MinMax3(min, max, t->data[i].center);
if (!(t->data[i].flag & TD_NOCENTER))
MinMax3(min, max, t->data[i].center);
}
else {
/*