[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14586] trunk/blender/source/blender: == Action Editor - Action Groups finishing touches ==

Joshua Leung aligorith at gmail.com
Mon Apr 28 09:38:07 CEST 2008


Revision: 14586
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14586
Author:   aligorith
Date:     2008-04-28 09:38:06 +0200 (Mon, 28 Apr 2008)

Log Message:
-----------
== 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. 

Modified Paths:
--------------
    trunk/blender/source/blender/include/BIF_editaction.h
    trunk/blender/source/blender/src/drawaction.c
    trunk/blender/source/blender/src/editaction.c
    trunk/blender/source/blender/src/header_action.c

Modified: trunk/blender/source/blender/include/BIF_editaction.h
===================================================================
--- trunk/blender/source/blender/include/BIF_editaction.h	2008-04-28 05:14:26 UTC (rev 14585)
+++ trunk/blender/source/blender/include/BIF_editaction.h	2008-04-28 07:38:06 UTC (rev 14586)
@@ -141,7 +141,8 @@
 /* Group/Channel Operations */
 struct bActionGroup *get_active_actiongroup(struct bAction *act);
 void set_active_actiongroup(struct bAction *act, struct bActionGroup *agrp, short select);
-void verify_pchan2achan_grouping(struct bAction *act, struct bPose *pose, char name[]); 
+void verify_pchan2achan_grouping(struct bAction *act, struct bPose *pose, char name[]);
+void sync_pchan2achan_grouping(void); 
 void action_groups_group(short add_group);
 void action_groups_ungroup(void);
 

Modified: trunk/blender/source/blender/src/drawaction.c
===================================================================
--- trunk/blender/source/blender/src/drawaction.c	2008-04-28 05:14:26 UTC (rev 14585)
+++ trunk/blender/source/blender/src/drawaction.c	2008-04-28 07:38:06 UTC (rev 14586)
@@ -635,9 +635,11 @@
 			else {
 				/* for normal channels 
 				 *	- use 3 shades of color group/standard colour for 3 indention level
-				 *	- use standard colour if enabled
+				 *	- only use group colors if allowed to, and if actually feasible
 				 */
-				if ((G.saction->flag & SACTION_DRAWGCOLORS) && (grp)) {
+				if ( (G.saction->flag & SACTION_DRAWGCOLORS) && 
+					 (grp) && (grp->customCol) ) 
+				{
 					char cp[3];
 					
 					if (indent == 2) {

Modified: trunk/blender/source/blender/src/editaction.c
===================================================================
--- trunk/blender/source/blender/src/editaction.c	2008-04-28 05:14:26 UTC (rev 14585)
+++ trunk/blender/source/blender/src/editaction.c	2008-04-28 07:38:06 UTC (rev 14586)
@@ -1178,6 +1178,7 @@
 					}
 				}
 			}
+			grp->customCol= agrp->customCol;
 			
 			BLI_addtail(&act->groups, grp);
 		}
@@ -1188,6 +1189,50 @@
 	}
 }
 
+/* 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 */
 

Modified: trunk/blender/source/blender/src/header_action.c
===================================================================
--- trunk/blender/source/blender/src/header_action.c	2008-04-28 05:14:26 UTC (rev 14585)
+++ trunk/blender/source/blender/src/header_action.c	2008-04-28 07:38:06 UTC (rev 14586)
@@ -136,7 +136,8 @@
 enum {
 	ACTMENU_CHANNELS_GROUP_ADD_TOACTIVE	= 0,
 	ACTMENU_CHANNELS_GROUP_ADD_TONEW,
-	ACTMENU_CHANNELS_GROUP_REMOVE
+	ACTMENU_CHANNELS_GROUP_REMOVE,
+	ACTMENU_CHANNELS_GROUP_SYNCPOSE
 };
 
 enum {
@@ -762,6 +763,9 @@
 		case ACTMENU_CHANNELS_GROUP_REMOVE:
 			action_groups_ungroup();
 			break;
+		case ACTMENU_CHANNELS_GROUP_SYNCPOSE: /* Syncronise Pose-data and Action-data */
+			sync_pchan2achan_grouping();
+			break;
 	}
 }
 
@@ -782,7 +786,7 @@
 					 "Add to New Group|Ctrl Shift G", 0, yco-=20, 
 					 menuwidth, 19, NULL, 0.0, 0.0, 0, 
 					 ACTMENU_CHANNELS_GROUP_ADD_TONEW, "");
-	
+		
 	uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
 					menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 					
@@ -790,6 +794,14 @@
 					 "Remove From Group|Alt G", 0, yco-=20, 
 					 menuwidth, 19, NULL, 0.0, 0.0, 0, 
 					 ACTMENU_CHANNELS_GROUP_REMOVE, "");
+					 
+	uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
+					menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+					
+	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
+					 "Synchronise with Armature", 0, yco-=20, 
+					 menuwidth, 19, NULL, 0.0, 0.0, 0, 
+					 ACTMENU_CHANNELS_GROUP_SYNCPOSE, "");
 
 	uiBlockSetDirection(block, UI_RIGHT);
 	uiTextBoundsBlock(block, 60);





More information about the Bf-blender-cvs mailing list