diff options
author | Joshua Leung <aligorith@gmail.com> | 2008-04-28 11:38:06 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2008-04-28 11:38:06 +0400 |
commit | 945527549024f7ba6a1cc185b30a103e293376ce (patch) | |
tree | fb09e12e4e612282a01eb65d84fe84329cba701a /source/blender/src/editaction.c | |
parent | cf84cf5f211475dc72cffe0ebba85e2ad91fee6b (diff) |
== Action Editor - Action Groups finishing touches ==
* Added a new tool "Synchronise with Armature" (found under Channels->Grouping), which synchronises the grouping of action-channels and the grouping of their relevant bones.
This only works when the active object is an armature, and the action isn't pinned. All of the action's action-channels are removed from their groups, and are added back into groups according to the current grouping of their corresponding bones.
A bit of testing for weird cases is needed.
* Group colours are now not drawn if the group originally was using the 'default' colour-set.
Diffstat (limited to 'source/blender/src/editaction.c')
-rw-r--r-- | source/blender/src/editaction.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c index d5bec0431e5..d0ef051b713 100644 --- a/source/blender/src/editaction.c +++ b/source/blender/src/editaction.c @@ -1178,6 +1178,7 @@ void verify_pchan2achan_grouping (bAction *act, bPose *pose, char name[]) } } } + grp->customCol= agrp->customCol; BLI_addtail(&act->groups, grp); } @@ -1188,6 +1189,50 @@ void verify_pchan2achan_grouping (bAction *act, bPose *pose, char name[]) } } +/* This function is used when the user specifically requests to sync changes of pchans + bone groups + * to achans + action groups. All achans are detached from their groups, and all groups are destroyed. + * They are then recreated when the achans are reassigned to groups. + * + * Note: This doesn't preserve hand-created groups, and will operate on ALL action-channels regardless of + * whether they were selected or active. More specific filtering can be added later. + */ +void sync_pchan2achan_grouping () +{ + void *data; + short datatype; + bAction *act; + bActionChannel *achan, *next, *last; + bPose *pose; + + /* determine what type of data we are operating on */ + data = get_action_context(&datatype); + if ((datatype != ACTCONT_ACTION) || (data==NULL)) return; + if ((G.saction->pin) || (OBACT==NULL) || (OBACT->type != OB_ARMATURE)) { + error("Action doesn't belong to active armature"); + return; + } + + /* get data */ + act= (bAction *)data; + pose= OBACT->pose; + + /* remove achan->group links, then delete all groups */ + for (achan= act->chanbase.first; achan; achan= achan->next) + achan->grp = NULL; + BLI_freelistN(&act->groups); + + /* loop through all achans, reassigning them to groups (colours are resyncronised) */ + last= act->chanbase.last; + for (achan= act->chanbase.first; achan && achan!=last; achan= next) { + next= achan->next; + verify_pchan2achan_grouping(act, pose, achan->name); + } + + /* undo and redraw */ + BIF_undo_push("Sync Armature-Data and Action"); + allqueue(REDRAWACTION, 0); +} + /* **************************************************** */ /* TRANSFORM TOOLS */ |