diff options
author | Joshua Leung <aligorith@gmail.com> | 2008-01-21 14:26:24 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2008-01-21 14:26:24 +0300 |
commit | 173830a7fa45cd6b4ebff002519ce8e8932c473f (patch) | |
tree | ddc925a47f466756a7ddf8939cc09fe061512d2e /source/blender/src/editaction.c | |
parent | 1db590092fc6720d976e2b979a87436c68391207 (diff) |
== Action/Pose Groups - Keyframing Integration ==
Now, when inserting keyframes (either IKEY or AutoKeying), if an ActionChannel has been newly created, it will get assigned to an Action-Group with the same name as the Bone-Group that the bone it represents belongs to.
Diffstat (limited to 'source/blender/src/editaction.c')
-rw-r--r-- | source/blender/src/editaction.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c index cb436e8bff1..3d97cac3164 100644 --- a/source/blender/src/editaction.c +++ b/source/blender/src/editaction.c @@ -812,6 +812,17 @@ static void action_groups_addachan (bAction *act, bActionGroup *agrp, bActionCha if (ELEM3(NULL, act, agrp, achan)) return; + /* if no channels, just add to two lists at the same time */ + if (act->chanbase.first == NULL) { + achan->next = achan->prev = NULL; + + agrp->channels.first = agrp->channels.last = achan; + act->chanbase.first = act->chanbase.last = achan; + + achan->grp= agrp; + return; + } + /* try to find a channel to slot this in before/after */ for (chan= act->chanbase.first; chan; chan= chan->next) { /* if channel has no group, then we have ungrouped channels, which should always occur after groups */ @@ -1025,6 +1036,59 @@ void action_groups_ungroup (void) allqueue(REDRAWACTION, 0); } +/* This function is used when inserting keyframes for pose-channels. It assigns the + * action-channel with the nominated name to a group with the same name as that of + * the pose-channel with the nominated name. + * + * Note: this function calls validate_action_channel if action channel doesn't exist + */ +void verify_pchan2achan_grouping (bAction *act, bPose *pose, char name[]) +{ + bActionChannel *achan; + bPoseChannel *pchan; + + /* sanity checks */ + if (ELEM3(NULL, act, pose, name)) + return; + if (name[0] == 0) + return; + + /* try to get the channels */ + pchan= get_pose_channel(pose, name); + if (pchan == NULL) return; + achan= verify_action_channel(act, name); + + /* check if pchan has a group */ + if ((pchan->agrp_index) && (achan->grp == NULL)) { + bActionGroup *agrp, *grp=NULL; + + /* get group to try to be like */ + agrp= (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1)); + if (agrp == NULL) { + error("PoseChannel has invalid group!"); + return; + } + + /* try to find a group which is similar to the one we want (or add one) */ + for (grp= act->groups.first; grp; grp= grp->next) { + if (!strcmp(grp->name, agrp->name)) + break; + } + if (grp == NULL) { + grp= MEM_callocN(sizeof(bActionGroup), "bActionGroup"); + + grp->flag |= (AGRP_ACTIVE|AGRP_SELECTED|AGRP_EXPANDED); + sprintf(grp->name, agrp->name); + + BLI_addtail(&act->groups, grp); + } + + /* make sure this channel is definitely not connected to anything before adding to group */ + action_groups_removeachan(act, achan); + action_groups_addachan(act, grp, achan); + } +} + /* **************************************************** */ /* TRANSFORM TOOLS */ |