[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13330] trunk/blender/source/blender: == Action/Pose Groups - Keyframing Integration ==
Joshua Leung
aligorith at gmail.com
Mon Jan 21 12:26:24 CET 2008
Revision: 13330
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13330
Author: aligorith
Date: 2008-01-21 12:26:24 +0100 (Mon, 21 Jan 2008)
Log Message:
-----------
== 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.
Modified Paths:
--------------
trunk/blender/source/blender/include/BIF_editaction.h
trunk/blender/source/blender/src/buttons_editing.c
trunk/blender/source/blender/src/editaction.c
trunk/blender/source/blender/src/editipo.c
trunk/blender/source/blender/src/poseobject.c
Modified: trunk/blender/source/blender/include/BIF_editaction.h
===================================================================
--- trunk/blender/source/blender/include/BIF_editaction.h 2008-01-21 10:55:46 UTC (rev 13329)
+++ trunk/blender/source/blender/include/BIF_editaction.h 2008-01-21 11:26:24 UTC (rev 13330)
@@ -108,6 +108,7 @@
struct bAction;
struct bActionChannel;
struct bActionGroup;
+struct bPose;
struct bPoseChannel;
struct Object;
struct Ipo;
@@ -142,8 +143,7 @@
/* Group/Channel Operations */
struct bActionGroup *get_active_actiongroup(struct bAction *act);
void set_active_actiongroup(struct bAction *act, struct bActionGroup *agrp, short select);
-void unique_name_actiongroup(struct ListBase *lb, struct bActionGroup *agrp);
-// <--- add some func to add group for action-channel based on corresponding pchan's grouping
+void verify_pchan2achan_grouping(struct bAction *act, struct bPose *pose, char name[]);
void action_groups_group(short add_group);
void action_groups_ungroup(void);
Modified: trunk/blender/source/blender/src/buttons_editing.c
===================================================================
--- trunk/blender/source/blender/src/buttons_editing.c 2008-01-21 10:55:46 UTC (rev 13329)
+++ trunk/blender/source/blender/src/buttons_editing.c 2008-01-21 11:26:24 UTC (rev 13330)
@@ -3853,6 +3853,8 @@
}
}
break;
+
+ // TODO: make these pose-group options proper tools in poseobject.c
case B_POSEGRP_RECALC:
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWBUTSEDIT, 0);
@@ -3879,6 +3881,7 @@
bPose *pose= ob->pose;
bActionGroup *grp= NULL;
+ // FIXME: make sure all that referenced it get reset
grp= BLI_findlink(&pose->agroups, pose->active_group-1);
if (grp) {
BLI_freelinkN(&pose->agroups, grp);
@@ -4330,7 +4333,7 @@
/* add title first (and the "none" entry) */
BLI_dynstr_append(pupds, "Pose Group%t|");
- BLI_dynstr_append(pupds, "BG: [None]%x0");
+ BLI_dynstr_append(pupds, "BG: [None]%x0|");
/* loop through markers, adding them */
for (agrp= pose->agroups.first, i=1; agrp; agrp=agrp->next, i++) {
@@ -4386,7 +4389,7 @@
/* Bone custom drawing */
menustr= build_posegroups_menustr(ob->pose);
- uiDefButS(block, MENU,REDRAWVIEW3D, menustr, 107,by,105,19, &pchan->agrp_index, 0.0, 0.0, 0.0, 0.0, "Change the Pose Group this Bone belongs to");
+ uiDefButS(block, MENU,REDRAWVIEW3D, menustr, 107,by,105,19, &pchan->agrp_index, 0, 0.0, 0.0, 0.0, "Change the Pose Group this Bone belongs to");
MEM_freeN(menustr);
ob_arm_bone_pchan_lock(ob, arm, curBone, pchan);
Modified: trunk/blender/source/blender/src/editaction.c
===================================================================
--- trunk/blender/source/blender/src/editaction.c 2008-01-21 10:55:46 UTC (rev 13329)
+++ trunk/blender/source/blender/src/editaction.c 2008-01-21 11:26:24 UTC (rev 13330)
@@ -812,6 +812,17 @@
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 @@
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 */
Modified: trunk/blender/source/blender/src/editipo.c
===================================================================
--- trunk/blender/source/blender/src/editipo.c 2008-01-21 10:55:46 UTC (rev 13329)
+++ trunk/blender/source/blender/src/editipo.c 2008-01-21 11:26:24 UTC (rev 13330)
@@ -1802,6 +1802,10 @@
achan= verify_action_channel(ob->action, actname);
if(achan) {
+ /* automatically assign achan to act-group based on pchan's grouping */
+ if (blocktype == ID_PO)
+ verify_pchan2achan_grouping(ob->action, ob->pose, actname);
+
/* constraint exception */
if(blocktype==ID_CO) {
bConstraintChannel *conchan= verify_constraint_channel(&achan->constraintChannels, constname);
Modified: trunk/blender/source/blender/src/poseobject.c
===================================================================
--- trunk/blender/source/blender/src/poseobject.c 2008-01-21 10:55:46 UTC (rev 13329)
+++ trunk/blender/source/blender/src/poseobject.c 2008-01-21 11:26:24 UTC (rev 13330)
@@ -909,6 +909,15 @@
/* ********************************************** */
+/* adds a new pose-group */
+// TODO...
+void pose_add_posegroup ()
+{
+
+}
+
+/* ********************************************** */
+
/* context active object */
void pose_flip_names(void)
{
More information about the Bf-blender-cvs
mailing list