made verify_pose_channel() return the pose channel that is either

found or created (just removed some silly duplicated work).
This commit is contained in:
Chris Want
2004-01-03 02:13:04 +00:00
parent 33916a2402
commit c8a5bfc826
5 changed files with 43 additions and 54 deletions

View File

@@ -100,8 +100,9 @@ struct bPoseChannel *get_pose_channel(const struct bPose *pose,
* already exists in this pose - if not a new one is
* allocated and initialized.
*/
void verify_pose_channel(struct bPose* pose, const char* name);
struct bPoseChannel *verify_pose_channel(struct bPose* pose,
const char* name);
/**
* Allocate a new bAction on the heap and copy
* the contents of src into it. If src is NULL NULL is returned.

View File

@@ -278,18 +278,18 @@ float calc_action_end(const bAction *act)
return size;
}
void verify_pose_channel(bPose* pose, const char* name)
bPoseChannel *verify_pose_channel(bPose* pose, const char* name)
{
bPoseChannel *chan;
if (!pose){
return;
return NULL;
}
/* See if this channel exists */
/* See if this channel exists */
for (chan=pose->chanbase.first; chan; chan=chan->next){
if (!strcmp (name, chan->name))
return;
return chan;
}
/* If not, create it and add it */
@@ -297,12 +297,15 @@ void verify_pose_channel(bPose* pose, const char* name)
strcpy (chan->name, name);
chan->loc[0] = chan->loc[1] = chan->loc[2] = 0.0F;
chan->quat[1] = chan->quat[2] = chan->quat[3] = 0.0F; chan->quat[0] = 1.0F;
chan->quat[1] = chan->quat[2] = chan->quat[3] = 0.0F;
chan->quat[0] = 1.0F;
chan->size[0] = chan->size[1] = chan->size[2] = 1.0F;
chan->flag |= POSE_ROT|POSE_SIZE|POSE_LOC;
BLI_addtail (&pose->chanbase, chan);
return chan;
}
void get_pose_from_pose(bPose **pose, const bPose *src)

View File

@@ -267,32 +267,26 @@ void where_is_bone1_time (Object *ob, Bone *bone, float ctime)
arm = get_armature(ob);
/* Ensure there is achannel for this bone*/
verify_pose_channel (pose, bone->name);
/* Ensure there is a channel for this bone*/
chan = verify_pose_channel (pose, bone->name);
if (!chan) return;
/* Search the pose for a channel with the same name, and copy the
transformations from the channel into the bone */
for (chan=pose->chanbase.first; chan; chan=chan->next){
if (!strcmp (chan->name, bone->name)){
#if 1 /* If 1 attempt to use pose caching features */
/* Bail out if we've been recalced recently */
if (chan->flag & PCHAN_DONE){
Mat4CpyMat4 (bone->obmat, chan->obmat);
if (bone->parent){
if ((bone->flag & BONE_IK_TOPARENT))
where_is_bone1_time (ob, bone->parent, ctime);
else
where_is_bone_time (ob, bone->parent, ctime);
}
return;
}
#if 1
/* If 1 attempt to use pose caching features */
/* Bail out if we've been recalced recently */
if (chan->flag & PCHAN_DONE){
Mat4CpyMat4 (bone->obmat, chan->obmat);
if (bone->parent){
if ((bone->flag & BONE_IK_TOPARENT))
where_is_bone1_time (ob, bone->parent, ctime);
else
chan->flag |= PCHAN_DONE;
#endif
break;
where_is_bone_time (ob, bone->parent, ctime);
}
return;
}
else
chan->flag |= PCHAN_DONE;
#endif
#if 1
/* Ensure parents have been evaluated */
@@ -842,30 +836,23 @@ static void apply_pose_bonechildren (Bone* bone, bPose* pose, int doit)
bone->loc[0]=bone->loc[1]=bone->loc[2]=0.0F;
}
// Ensure there is achannel for this bone
verify_pose_channel (pose, bone->name);
// Ensure there is a channel for this bone
chan = verify_pose_channel (pose, bone->name);
if (chan) {
// Search the pose for a channel with the same name
if (pose){
for (chan=pose->chanbase.first; chan; chan=chan->next){
if (!strcmp (chan->name, bone->name)){
if (chan->flag & POSE_LOC)
memcpy (bone->loc, chan->loc, sizeof (bone->loc));
if (chan->flag & POSE_SIZE)
memcpy (bone->size, chan->size, sizeof (bone->size));
if (chan->flag & POSE_ROT)
memcpy (bone->quat, chan->quat, sizeof (bone->quat));
if (chan->flag & POSE_LOC)
memcpy (bone->loc, chan->loc, sizeof (bone->loc));
if (chan->flag & POSE_SIZE)
memcpy (bone->size, chan->size, sizeof (bone->size));
if (chan->flag & POSE_ROT)
memcpy (bone->quat, chan->quat, sizeof (bone->quat));
if (doit){
bone_to_mat4(bone, bone->obmat);
}
else{
Mat4CpyMat4 (bone->obmat, chan->obmat);
}
break;
}
if (doit){
bone_to_mat4(bone, bone->obmat);
}
else{
Mat4CpyMat4 (bone->obmat, chan->obmat);
}
}

View File

@@ -2058,8 +2058,7 @@ static void clear_armature_children (Bone *bone, bPose *pose, char mode){
if (!bone)
return;
verify_pose_channel (pose, bone->name);
chan=get_pose_channel (pose, bone->name);
chan = verify_pose_channel (pose, bone->name);
if (!chan)
return;

View File

@@ -709,8 +709,7 @@ ListBase *get_constraint_client(char *name, short *clientType, void **clientdata
*clientdata = bone;
if (name)
sprintf (name, "%s>>%s", name, bone->name);
verify_pose_channel(G.obpose->pose, bone->name);
chan = get_pose_channel (G.obpose->pose, bone->name);
chan = verify_pose_channel(G.obpose->pose, bone->name);
list = &chan->constraints;
}