[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21755] branches/blender2.5/blender: 2. 5 - Restoring Bone Groups

Joshua Leung aligorith at gmail.com
Tue Jul 21 12:18:09 CEST 2009


Revision: 21755
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21755
Author:   aligorith
Date:     2009-07-21 12:18:08 +0200 (Tue, 21 Jul 2009)

Log Message:
-----------
2.5 - Restoring Bone Groups 

* Added Bone Groups UI to 'Armature' context buttons for now. Later, it may be more convenient to have these with bones instead?

* Added operators for the operations that can be performed on these groups. Moved the core adding/removing functions to blenkernel so that they can be used elsewhere in future if need be.

* Properly wrapped bone groups in RNA. Copied the way that Vertex Groups are wrapped, since they share some similarities. Setting colours for bone groups still needs more work though.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_data_armature.py
    branches/blender2.5/blender/source/blender/blenkernel/BKE_action.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/action.c
    branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
    branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
    branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
    branches/blender2.5/blender/source/blender/editors/armature/poseobject.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
    branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_pose.c

Modified: branches/blender2.5/blender/release/ui/buttons_data_armature.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_armature.py	2009-07-21 10:13:20 UTC (rev 21754)
+++ branches/blender2.5/blender/release/ui/buttons_data_armature.py	2009-07-21 10:18:08 UTC (rev 21755)
@@ -79,6 +79,38 @@
 		sub.itemR(arm, "draw_group_colors", text="Colors")
 		sub.itemR(arm, "delay_deform", text="Delay Refresh")
 
+class DATA_PT_bone_groups(DataButtonsPanel):
+	__idname__ = "DATA_PT_bone_groups"
+	__label__ = "Bone Groups"
+	
+	def poll(self, context):
+		return (context.object and context.object.type=='ARMATURE' and context.object.pose)
+
+	def draw(self, context):
+		layout = self.layout
+		ob = context.object
+		pose= ob.pose
+		
+		row = layout.row()
+		
+		row.template_list(pose, "bone_groups", pose, "active_bone_group_index")
+		
+		col = row.column(align=True)
+		col.itemO("pose.group_add", icon="ICON_ZOOMIN", text="")
+		col.itemO("pose.group_remove", icon="ICON_ZOOMOUT", text="")
+		
+		group = pose.active_bone_group
+		if group:
+			row = layout.row()
+			row.itemR(group, "name")
+		
+		row = layout.row(align=True)
+		
+		row.itemO("pose.group_assign", text="Assign")
+		row.itemO("pose.group_remove", text="Remove") #row.itemO("pose.bone_group_remove_from", text="Remove")
+		#row.itemO("object.bone_group_select", text="Select")
+		#row.itemO("object.bone_group_deselect", text="Deselect")
+
 class DATA_PT_paths(DataButtonsPanel):
 	__idname__ = "DATA_PT_paths"
 	__label__ = "Paths"
@@ -136,5 +168,6 @@
 bpy.types.register(DATA_PT_context_arm)
 bpy.types.register(DATA_PT_skeleton)
 bpy.types.register(DATA_PT_display)
+bpy.types.register(DATA_PT_bone_groups)
 bpy.types.register(DATA_PT_paths)
 bpy.types.register(DATA_PT_ghost)

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_action.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_action.h	2009-07-21 10:13:20 UTC (rev 21754)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_action.h	2009-07-21 10:18:08 UTC (rev 21755)
@@ -1,6 +1,6 @@
 /*  BKE_action.h   May 2001
  *  
- *  Blender kernel action functionality
+ *  Blender kernel action and pose functionality
  *
  *	Reevan McKay
  *
@@ -26,7 +26,7 @@
  * All rights reserved.
  *
  * Contributor(s): Full recode, Ton Roosendaal, Crete 2005
- *				Full recode, Joshua Leung, 2009
+ *				 Full recode, Joshua Leung, 2009
  *
  * ***** END GPL LICENSE BLOCK *****
  */
@@ -103,8 +103,7 @@
  * Allocate a new pose on the heap, and copy the src pose and it's channels
  * into the new pose. *dst is set to the newly allocated structure, and assumed to be NULL.
  */ 
-void copy_pose(struct bPose **dst, struct bPose *src,
-			   int copyconstraints);
+void copy_pose(struct bPose **dst, struct bPose *src, int copyconstraints);
 
 
 
@@ -112,9 +111,8 @@
  * Return a pointer to the pose channel of the given name
  * from this pose.
  */
-struct  bPoseChannel *get_pose_channel(const struct bPose *pose,
-									   const char *name);
-									   
+struct bPoseChannel *get_pose_channel(const struct bPose *pose, const char *name);
+
 /**
  * Return a pointer to the active pose channel from this Object.
  * (Note: Object, not bPose is used here, as we need layer info from Armature)
@@ -126,9 +124,10 @@
  * already exists in this pose - if not a new one is
  * allocated and initialized.
  */
-struct bPoseChannel *verify_pose_channel(struct bPose* pose, 
-										 const char* name);
+struct bPoseChannel *verify_pose_channel(struct bPose* pose, const char* name);
 
+
+
 /* sets constraint flags */
 void update_pose_constraint_flags(struct bPose *pose);
 
@@ -136,18 +135,30 @@
 // XXX to be depreceated for a more general solution in animsys...
 void framechange_poses_clear_unkeyed(void);
 
+/* Bone Groups API --------------------- */	
+
+/* Adds a new bone-group */
+void pose_add_group(struct Object *ob);
+
+/* Remove the active bone-group */
+void pose_remove_group(struct Object *ob);
+
+/* Assorted Evaluation ----------------- */	
+
 /* Used for the Action Constraint */
 void what_does_obaction(struct Scene *scene, struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe);
 
-/* exported for game engine */
-void game_blend_poses(struct bPose *dst, struct bPose *src, float srcweight/*, short mode*/); /* was blend_poses */
-void extract_pose_from_pose(struct bPose *pose, const struct bPose *src);
-
 /* for proxy */
 void copy_pose_result(struct bPose *to, struct bPose *from);
 /* clear all transforms */
 void rest_pose(struct bPose *pose);
 
+/* Game Engine ------------------------- */
+
+/* exported for game engine */
+void game_blend_poses(struct bPose *dst, struct bPose *src, float srcweight/*, short mode*/); /* was blend_poses */
+void extract_pose_from_pose(struct bPose *pose, const struct bPose *src);
+
 /* functions used by the game engine */
 void game_copy_pose(struct bPose **dst, struct bPose *src);
 void game_free_pose(struct bPose *pose);

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/action.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/action.c	2009-07-21 10:13:20 UTC (rev 21754)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/action.c	2009-07-21 10:18:08 UTC (rev 21755)
@@ -21,6 +21,7 @@
  * All rights reserved.
  *
  * Contributor(s): Full recode, Ton Roosendaal, Crete 2005
+ *				 Full recode, Joshua Leung, 2009
  *
  * ***** END GPL LICENSE BLOCK *****
  */
@@ -31,7 +32,8 @@
 
 #include <string.h>
 #include <math.h>
-#include <stdlib.h>	/* for NULL */
+#include <stdlib.h>
+#include <stddef.h>	
 
 #include "MEM_guardedalloc.h"
 
@@ -68,8 +70,6 @@
 #include "RNA_access.h"
 #include "RNA_types.h"
 
-//XXX #include "nla.h"
-
 /* *********************** NOTE ON POSE AND ACTION **********************
 
   - Pose is the local (object level) component of armature. The current
@@ -765,8 +765,58 @@
 	}
 }
 
-/* ************************ END Pose channels *************** */
+/* ************************** Bone Groups ************************** */
 
+/* Adds a new bone-group */
+void pose_add_group (Object *ob)
+{
+	bPose *pose= (ob) ? ob->pose : NULL;
+	bActionGroup *grp;
+	
+	if (ELEM(NULL, ob, ob->pose))
+		return;
+	
+	grp= MEM_callocN(sizeof(bActionGroup), "PoseGroup");
+	strcpy(grp->name, "Group");
+	BLI_addtail(&pose->agroups, grp);
+	BLI_uniquename(&pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), 32);
+	
+	pose->active_group= BLI_countlist(&pose->agroups);
+}
+
+/* Remove the active bone-group */
+void pose_remove_group (Object *ob)
+{
+	bPose *pose= (ob) ? ob->pose : NULL;
+	bActionGroup *grp = NULL;
+	bPoseChannel *pchan;
+	
+	/* sanity checks */
+	if (ELEM(NULL, ob, pose))
+		return;
+	if (pose->active_group <= 0)
+		return;
+	
+	/* get group to remove */
+	grp= BLI_findlink(&pose->agroups, pose->active_group-1);
+	if (grp) {
+		/* adjust group references (the trouble of using indices!):
+		 *	- firstly, make sure nothing references it 
+		 *	- also, make sure that those after this item get corrected
+		 */
+		for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
+			if (pchan->agrp_index == pose->active_group)
+				pchan->agrp_index= 0;
+			else if (pchan->agrp_index > pose->active_group)
+				pchan->agrp_index--;
+		}
+		
+		/* now, remove it from the pose */
+		BLI_freelinkN(&pose->agroups, grp);
+		pose->active_group= 0;
+	}
+}
+
 /* ************** time ****************** */
 
 /* Check if the given action has any keyframes */

Modified: branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h	2009-07-21 10:13:20 UTC (rev 21754)
+++ branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h	2009-07-21 10:18:08 UTC (rev 21755)
@@ -33,28 +33,37 @@
 
 /* editarmature.c operators */
 void ARMATURE_OT_bone_primitive_add(struct wmOperatorType *ot);
+
 void ARMATURE_OT_bones_align(struct wmOperatorType *ot);
 void ARMATURE_OT_calculate_roll(struct wmOperatorType *ot);
 void ARMATURE_OT_switch_direction(struct wmOperatorType *ot);
+
 void ARMATURE_OT_subdivs(struct wmOperatorType *ot);
 void ARMATURE_OT_subdivide_simple(struct wmOperatorType *ot);
 void ARMATURE_OT_subdivide_multi(struct wmOperatorType *ot);
+
 void ARMATURE_OT_parent_set(struct wmOperatorType *ot);
 void ARMATURE_OT_parent_clear(struct wmOperatorType *ot);
+
 void ARMATURE_OT_select_all_toggle(struct wmOperatorType *ot);
 void ARMATURE_OT_select_inverse(struct wmOperatorType *ot);
 void ARMATURE_OT_select_hierarchy(struct wmOperatorType *ot);
 void ARMATURE_OT_select_linked(struct wmOperatorType *ot);
+
 void ARMATURE_OT_delete(struct wmOperatorType *ot);
 void ARMATURE_OT_duplicate_selected(struct wmOperatorType *ot);
 void ARMATURE_OT_extrude(struct wmOperatorType *ot);
 void ARMATURE_OT_click_extrude(struct wmOperatorType *ot);
 
+/* ******************************************************* */
+/* Pose-Mode Operators */
 void POSE_OT_hide(struct wmOperatorType *ot);
 void POSE_OT_reveal(struct wmOperatorType *ot);
+
 void POSE_OT_rot_clear(struct wmOperatorType *ot);
 void POSE_OT_loc_clear(struct wmOperatorType *ot);
 void POSE_OT_scale_clear(struct wmOperatorType *ot);
+
 void POSE_OT_select_all_toggle(struct wmOperatorType *ot);
 void POSE_OT_select_inverse(struct wmOperatorType *ot);
 void POSE_OT_select_parent(struct wmOperatorType *ot);
@@ -62,6 +71,16 @@
 void POSE_OT_select_linked(struct wmOperatorType *ot);
 void POSE_OT_select_constraint_target(struct wmOperatorType *ot);
 
+void POSE_OT_groups_menu(struct wmOperatorType *ot);
+void POSE_OT_group_add(struct wmOperatorType *ot);
+void POSE_OT_group_remove(struct wmOperatorType *ot);
+void POSE_OT_group_remove(struct wmOperatorType *ot);
+void POSE_OT_group_assign(struct wmOperatorType *ot);
+void POSE_OT_group_unassign(struct wmOperatorType *ot);
+
+/* ******************************************************* */
+/* Etch-A-Ton */
+
 void SKETCH_OT_gesture(struct wmOperatorType *ot);
 void SKETCH_OT_delete(struct wmOperatorType *ot);
 void SKETCH_OT_draw_stroke(struct wmOperatorType *ot);
@@ -70,12 +89,14 @@

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list