From c8a5bfc826b497e238df2161effad9ab34325cbe Mon Sep 17 00:00:00 2001 From: Chris Want Date: Sat, 3 Jan 2004 02:13:04 +0000 Subject: made verify_pose_channel() return the pose channel that is either found or created (just removed some silly duplicated work). --- source/blender/blenkernel/BKE_action.h | 5 +- source/blender/blenkernel/intern/action.c | 13 +++-- source/blender/blenkernel/intern/armature.c | 77 ++++++++++++----------------- source/blender/src/editarmature.c | 3 +- source/blender/src/editconstraint.c | 3 +- 5 files changed, 45 insertions(+), 56 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 6942a426d8f..7407da43543 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -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. diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 5ac1be2337a..2f0a28e662f 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -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) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index e05e222284b..e5f57e2e213 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -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); - - /* 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; - } + /* Ensure there is a channel for this bone*/ + chan = verify_pose_channel (pose, bone->name); + if (!chan) 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 (doit){ - bone_to_mat4(bone, bone->obmat); - } - else{ - Mat4CpyMat4 (bone->obmat, chan->obmat); - } - - - break; - } + 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); } } diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 6b0d0b72d55..41daaa370a2 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -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; diff --git a/source/blender/src/editconstraint.c b/source/blender/src/editconstraint.c index 702e6a82573..be74c045074 100644 --- a/source/blender/src/editconstraint.c +++ b/source/blender/src/editconstraint.c @@ -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; } -- cgit v1.2.3