[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17233] branches/etch-a-ton/source/blender : Lots of code cleanup and some new features.

Martin Poirier theeth at yahoo.com
Thu Oct 30 20:58:12 CET 2008


Revision: 17233
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17233
Author:   theeth
Date:     2008-10-30 20:58:11 +0100 (Thu, 30 Oct 2008)

Log Message:
-----------
Lots of code cleanup and some new features.

Clean and split editbone duplication methods for easy reuse.

Copy and retarget selected bones to stroke conversion method.

This is the start of the infamous templating system.

A simple demo video is available: http://blenderartists.org/~theeth/bf/etch-a-ton/retarget.ogv and http://vimeo.com/2111535 (for those who dislike ogg/theora)

Modified Paths:
--------------
    branches/etch-a-ton/source/blender/include/BIF_editarmature.h
    branches/etch-a-ton/source/blender/include/BIF_retarget.h
    branches/etch-a-ton/source/blender/include/reeb.h
    branches/etch-a-ton/source/blender/makesdna/DNA_scene_types.h
    branches/etch-a-ton/source/blender/src/buttons_editing.c
    branches/etch-a-ton/source/blender/src/drawview.c
    branches/etch-a-ton/source/blender/src/editarmature.c
    branches/etch-a-ton/source/blender/src/editarmature_retarget.c
    branches/etch-a-ton/source/blender/src/editarmature_sketch.c
    branches/etch-a-ton/source/blender/src/reeb.c

Modified: branches/etch-a-ton/source/blender/include/BIF_editarmature.h
===================================================================
--- branches/etch-a-ton/source/blender/include/BIF_editarmature.h	2008-10-30 18:56:20 UTC (rev 17232)
+++ branches/etch-a-ton/source/blender/include/BIF_editarmature.h	2008-10-30 19:58:11 UTC (rev 17233)
@@ -70,6 +70,13 @@
 
 EditBone *addEditBone(char *name, struct ListBase *ebones, struct bArmature *arm);
 
+/* duplicate method */
+void preEditBoneDuplicate(struct ListBase *editbones);
+EditBone *duplicateEditBone(EditBone *curBone, struct ListBase *editbones, struct Object *ob);
+void updateDuplicateSubtarget(EditBone *dupBone, struct Object *ob);
+
+/* -- */
+
 float rollBoneToVector(EditBone *bone, float new_up_axis[3]);
 void	make_boneList(struct ListBase *list, struct ListBase *bones, EditBone *parent);
 void	editbones_to_armature (struct ListBase *list, struct Object *ob);

Modified: branches/etch-a-ton/source/blender/include/BIF_retarget.h
===================================================================
--- branches/etch-a-ton/source/blender/include/BIF_retarget.h	2008-10-30 18:56:20 UTC (rev 17232)
+++ branches/etch-a-ton/source/blender/include/BIF_retarget.h	2008-10-30 19:58:11 UTC (rev 17233)
@@ -44,10 +44,7 @@
 typedef struct RigGraph {
 	ListBase	arcs;
 	ListBase	nodes;
-	ListBase	controls;
 
-	ListBase*	editbones;
-	
 	float length;
 	
 	FreeArc			free_arc;
@@ -56,6 +53,9 @@
 	AxialSymmetry	axial_symmetry;
 	/*********************************/
 
+	ListBase	controls;
+	ListBase*	editbones;
+	
 	struct RigNode *head;
 	ReebGraph *link_mesh;
 	

Modified: branches/etch-a-ton/source/blender/include/reeb.h
===================================================================
--- branches/etch-a-ton/source/blender/include/reeb.h	2008-10-30 18:56:20 UTC (rev 17232)
+++ branches/etch-a-ton/source/blender/include/reeb.h	2008-10-30 19:58:11 UTC (rev 17233)
@@ -185,6 +185,7 @@
 ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node);
 
 void REEB_freeGraph(ReebGraph *rg);
+void REEB_freeArc(BArc *barc);
 void REEB_exportGraph(ReebGraph *rg, int count);
 void REEB_draw();
 

Modified: branches/etch-a-ton/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/etch-a-ton/source/blender/makesdna/DNA_scene_types.h	2008-10-30 18:56:20 UTC (rev 17232)
+++ branches/etch-a-ton/source/blender/makesdna/DNA_scene_types.h	2008-10-30 19:58:11 UTC (rev 17233)
@@ -441,17 +441,15 @@
 	char  skgen_postpro_passes;
 	char  skgen_subdivisions[3];
 	char  skgen_multi_level;
-	char  skgen_optimisation_method;
 	
-	char tpad[6];
-	
 	/* Skeleton Sketching */
 	char bone_sketching;
+	char bone_sketching_convert;
 	char skgen_subdivision_number;
 	
 	/* Alt+RMB option */
 	char edge_mode;
-	char pad3[6];
+	char pad3[4];
 } ToolSettings;
 
 /* Used by all brushes to store their properties, which can be directly set
@@ -879,6 +877,12 @@
 #define BONE_SKETCHING			1
 #define BONE_SKETCHING_QUICK	2
 
+/* toolsettings->bone_sketching_convert */
+#define	SK_CONVERT_CUT_FIXED			1
+#define	SK_CONVERT_CUT_LENGTH			2
+#define	SK_CONVERT_CUT_CORRELATION		3
+#define	SK_CONVERT_RETARGET				4
+
 #ifdef __cplusplus
 }
 #endif

Modified: branches/etch-a-ton/source/blender/src/buttons_editing.c
===================================================================
--- branches/etch-a-ton/source/blender/src/buttons_editing.c	2008-10-30 18:56:20 UTC (rev 17232)
+++ branches/etch-a-ton/source/blender/src/buttons_editing.c	2008-10-30 19:58:11 UTC (rev 17233)
@@ -5246,7 +5246,6 @@
 	uiDefButF(block, NUM, B_DIFF, 							"Ang:",			1025, 40, 83,19, &G.scene->toolsettings->skgen_retarget_angle_weight, 0, 10, 1, 0,		"Angle Weight");
 	uiDefButF(block, NUM, B_DIFF, 							"Len:",			1108, 40, 83,19, &G.scene->toolsettings->skgen_retarget_length_weight, 0, 10, 1, 0,		"Length Weight");
 	uiDefButF(block, NUM, B_DIFF, 							"Dist:",		1191, 40, 84,19, &G.scene->toolsettings->skgen_retarget_distance_weight, 0, 10, 1, 0,		"Distance Weight");
-	uiDefButC(block, NUM, B_DIFF, 							"Method:",		1025, 20, 125,19, &G.scene->toolsettings->skgen_optimisation_method, 0, 2, 1, 0,"Optimisation Method (0: brute, 1: memoize, 2: annealing max fixed");
 }
 
 static void editing_panel_mesh_skgen(Object *ob, Mesh *me)

Modified: branches/etch-a-ton/source/blender/src/drawview.c
===================================================================
--- branches/etch-a-ton/source/blender/src/drawview.c	2008-10-30 18:56:20 UTC (rev 17232)
+++ branches/etch-a-ton/source/blender/src/drawview.c	2008-10-30 19:58:11 UTC (rev 17233)
@@ -2297,35 +2297,52 @@
 		uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE  | cntrl);
 		uiSetPanelHandler(VIEW3D_HANDLER_BONESKETCH);  // for close and esc
 	
-		if(uiNewPanel(curarea, block, "Bone Sketching", "View3d", 10, 230, 318, height)==0) return;
+		if(uiNewPanel(curarea, block, "Bone Sketching", "View3d", 10, 230, 250, height)==0) return;
 	
 		uiNewPanelHeight(block, height);
 	
 		uiBlockBeginAlign(block);
 		
 		/* use real flag instead of 1 */
-		uiDefButBitC(block, TOG, BONE_SKETCHING, B_REDR, "Use Bone Sketching", 10, 225, 130, 20, &G.scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Use sketching to create and edit bones");
-		uiDefButBitC(block, TOG, BONE_SKETCHING_QUICK, B_REDR, "Q", 140, 225, 20, 20, &G.scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Automatically convert and delete on stroke end");
-		but = uiDefBut(block, BUT, B_REDR, "Convert", 10,205,150,20, 0, 0, 0, 0, 0, "Convert sketch to armature");
+		uiDefButBitC(block, TOG, BONE_SKETCHING, B_REDR, "Use Bone Sketching", 10, yco, 130, 20, &G.scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Use sketching to create and edit bones");
+		uiDefButBitC(block, TOG, BONE_SKETCHING_QUICK, B_REDR, "Q", 140, yco, 20, 20, &G.scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Automatically convert and delete on stroke end");
+		yco -= 20;
+		
+		but = uiDefBut(block, BUT, B_REDR, "Convert", 10,yco,150,20, 0, 0, 0, 0, 0, "Convert sketch to armature");
 		uiButSetFunc(but, convert_sketch_armature, NULL, NULL);
-		but = uiDefBut(block, BUT, B_REDR, "Delete", 10,185,150,20, 0, 0, 0, 0, 0, "Delete sketch");
+		yco -= 20;
+
+		but = uiDefBut(block, BUT, B_REDR, "Delete", 10,yco,150,20, 0, 0, 0, 0, 0, "Delete sketch");
 		uiButSetFunc(but, delete_sketch_armature, NULL, NULL);
+		yco -= 20;
 		
 		uiBlockEndAlign(block);
 
 		uiBlockBeginAlign(block);
 
-		uiDefButBitS(block, TOG, SKGEN_CUT_LENGTH, B_REDR, 		"Length",		10, 155, 60, 19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,				"Subdivide arcs in bones of equal length");
-		uiDefButF(block, NUM, B_REDR, 							"L:",			70, 155, 90, 19, &G.scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0,		"Maximum length of the bones when subdividing");
+		uiDefButC(block, ROW, B_REDR, "Length",	10, yco, 60, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_CUT_LENGTH, 0, 0,				"Subdivide arcs in bones of equal length");
+		uiDefButF(block, NUM, B_REDR, 					"L:",		70, yco, 90, 19, &G.scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0,		"Maximum length of the bones when subdividing");
+		yco -= 20;
 
-		uiDefButBitS(block, TOG, SKGEN_CUT_CORRELATION, B_REDR, "Correlation",	10, 135, 60, 19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Subdivide arcs based on correlation");
-		uiDefButF(block, NUM, B_REDR, 							"T:",			70, 135, 90, 19, &G.scene->toolsettings->skgen_correlation_limit,0.0, 1.0, 0.01, 0,	"Specify the threshold correlation for subdivision");
+		uiDefButC(block, ROW, B_REDR, "Correlation",	10, yco, 60, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_CUT_CORRELATION, 0, 0,					"Subdivide arcs based on correlation");
+		uiDefButF(block, NUM, B_REDR, 						 "T:",			70, yco, 90, 19, &G.scene->toolsettings->skgen_correlation_limit,0.0, 1.0, 0.01, 0,	"Specify the threshold correlation for subdivision");
+		yco -= 20;
 	
-		uiDefButBitS(block, TOG, SKGEN_CUT_FIXED, B_REDR, 		"Fixed",		10, 115, 60, 19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Subdivide arcs based on a fixed number of bones");
-		uiDefButC(block, NUM, B_REDR, 							"N:",			70, 115, 90, 19, &G.scene->toolsettings->skgen_subdivision_number,1, 100, 1, 5,	"Specify the bones to subdivide into");
+		uiDefButC(block, ROW, B_REDR, "Fixed",		10, yco, 60, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_CUT_FIXED, 0, 0,					"Subdivide arcs based on a fixed number of bones");
+		uiDefButC(block, NUM, B_REDR, 					"N:",		70, yco, 90, 19, &G.scene->toolsettings->skgen_subdivision_number,1, 100, 1, 5,	"Specify the bones to subdivide into");
+		yco -= 20;
 
+		uiDefButC(block, ROW, B_REDR, "Retarget",		10, yco,150, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_RETARGET, 0, 0,					"Subdivide arcs based on a fixed number of bones");
+		/* button here to select what to do (copy or not), template, ...*/
+		yco -= 20;
+
 		uiBlockEndAlign(block);
 		
+		uiDefButF(block, NUM, B_DIFF, 							"Ang:",			10, yco, 50,19, &G.scene->toolsettings->skgen_retarget_angle_weight, 0, 10, 1, 0,		"Angle Weight");
+		uiDefButF(block, NUM, B_DIFF, 							"Len:",			60, yco, 50,19, &G.scene->toolsettings->skgen_retarget_length_weight, 0, 10, 1, 0,		"Length Weight");
+		uiDefButF(block, NUM, B_DIFF, 							"Dist:",		110,yco, 50,19, &G.scene->toolsettings->skgen_retarget_distance_weight, 0, 10, 1, 0,		"Distance Weight");
+		yco -= 20;
+
 		if(yco < 0) uiNewPanelHeight(block, height-yco);
 	}
 }

Modified: branches/etch-a-ton/source/blender/src/editarmature.c
===================================================================
--- branches/etch-a-ton/source/blender/src/editarmature.c	2008-10-30 18:56:20 UTC (rev 17232)
+++ branches/etch-a-ton/source/blender/src/editarmature.c	2008-10-30 19:58:11 UTC (rev 17233)
@@ -2212,8 +2212,21 @@
 	return NULL;
 }
 
-static void update_dup_subtarget(EditBone *dupBone)
+/* Call this before doing any duplications
+ * */
+void preEditBoneDuplicate(ListBase *editbones)
 {
+	EditBone *eBone;
+	
+	/* clear temp */
+	for (eBone = editbones->first; eBone; eBone = eBone->next)
+	{
+		eBone->temp = NULL;
+	}
+}
+
+void updateDuplicateSubtarget(EditBone *dupBone, Object *ob)
+{
 	/* If an edit bone has been duplicated, lets
 	 * update it's constraints if the subtarget
 	 * they point to has also been duplicated

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list