[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12585] branches/harmonic-skeleton/blender /source/blender: Fixing up angle based subdivisions.

Martin Poirier theeth at yahoo.com
Wed Nov 14 02:57:17 CET 2007


Revision: 12585
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12585
Author:   theeth
Date:     2007-11-14 02:57:17 +0100 (Wed, 14 Nov 2007)

Log Message:
-----------
Fixing up angle based subdivisions.
Adding symetry detection (right now, only primary symetries and only used to determine bone orientation).
Fixing bugs (infinite loops) in length based subdivisions.
Adding number of post processing passes parameter

Modified Paths:
--------------
    branches/harmonic-skeleton/blender/source/blender/blenloader/intern/readfile.c
    branches/harmonic-skeleton/blender/source/blender/include/reeb.h
    branches/harmonic-skeleton/blender/source/blender/makesdna/DNA_scene_types.h
    branches/harmonic-skeleton/blender/source/blender/src/buttons_editing.c
    branches/harmonic-skeleton/blender/source/blender/src/editarmature.c
    branches/harmonic-skeleton/blender/source/blender/src/reeb.c

Modified: branches/harmonic-skeleton/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/harmonic-skeleton/blender/source/blender/blenloader/intern/readfile.c	2007-11-14 01:13:30 UTC (rev 12584)
+++ branches/harmonic-skeleton/blender/source/blender/blenloader/intern/readfile.c	2007-11-14 01:57:17 UTC (rev 12585)
@@ -6780,6 +6780,7 @@
 				sce->toolsettings->skgen_length_ratio			= 1.3f;
 				sce->toolsettings->skgen_length_limit			= 1.5f;
 				sce->toolsettings->skgen_postpro = SKGEN_SMOOTH;
+				sce->toolsettings->skgen_postpro_passes = 1;
 				sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_REPOSITION|SKGEN_CUT_LENGTH|SKGEN_CUT_ANGLE;
 
 			}

Modified: branches/harmonic-skeleton/blender/source/blender/include/reeb.h
===================================================================
--- branches/harmonic-skeleton/blender/source/blender/include/reeb.h	2007-11-14 01:13:30 UTC (rev 12584)
+++ branches/harmonic-skeleton/blender/source/blender/include/reeb.h	2007-11-14 01:57:17 UTC (rev 12585)
@@ -55,6 +55,7 @@
 	int degree;
 	float weight;
 	float p[3];
+	int flags;
 } ReebNode;
 
 typedef struct ReebEdge {
@@ -68,8 +69,9 @@
 	struct ReebArc *next, *prev;
 	ListBase edges;
 	struct ReebNode *v1, *v2;
+	struct EmbedBucket *buckets;
 	int	bcount;
-	struct EmbedBucket *buckets;
+	int flags;
 } ReebArc;
 
 struct EditMesh;
@@ -78,7 +80,14 @@
 void weightFromDistance(struct EditMesh *em);
 void weightFromLoc(struct EditMesh *me, int axis);
 void renormalizeWeight(struct EditMesh *em, float newmax);
-void filterReebGraph(ReebGraph *rg, float threshold);
-struct ReebGraph * generateReebGraph(struct EditMesh *me, int subdivisions);
 
+ReebGraph * generateReebGraph(struct EditMesh *me, int subdivisions);
+
+#define OTHER_NODE(arc, node) ((arc->v1 == node) ? arc->v2 : arc->v1)
+
+int subtreeDepth(ReebNode *node);
+int countConnectedArcs(ReebGraph *rg, ReebNode *node);
+int hasAdjacencyList(ReebGraph *rg); 
+int	isGraphAcyclic(ReebGraph *rg);
+
 #endif /*REEB_H_*/

Modified: branches/harmonic-skeleton/blender/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/harmonic-skeleton/blender/source/blender/makesdna/DNA_scene_types.h	2007-11-14 01:13:30 UTC (rev 12584)
+++ branches/harmonic-skeleton/blender/source/blender/makesdna/DNA_scene_types.h	2007-11-14 01:57:17 UTC (rev 12585)
@@ -372,8 +372,8 @@
 	float skgen_angle_limit;
 	short skgen_options;
 	char  skgen_postpro;
+	char  skgen_postpro_passes;
 	
-	char  pad4[1];
 } ToolSettings;
 
 /* Used by all brushes to store their properties, which can be directly set
@@ -682,12 +682,12 @@
 #define	SKGEN_SYMMETRY			8
 #define	SKGEN_CUT_LENGTH		16
 #define	SKGEN_CUT_ANGLE			32
+#define	SKGEN_LENGTH_FIRST		64
 
 /* toolsettings->skgen_postpro */
-#define SKGEN_NONE				0
-#define SKGEN_SMOOTH			1
-#define SKGEN_AVERAGE			2
-#define SKGEN_SHARPEN			3
+#define SKGEN_SMOOTH			0
+#define SKGEN_AVERAGE			1
+#define SKGEN_SHARPEN			2
 
 #ifdef __cplusplus
 }

Modified: branches/harmonic-skeleton/blender/source/blender/src/buttons_editing.c
===================================================================
--- branches/harmonic-skeleton/blender/source/blender/src/buttons_editing.c	2007-11-14 01:13:30 UTC (rev 12584)
+++ branches/harmonic-skeleton/blender/source/blender/src/buttons_editing.c	2007-11-14 01:57:17 UTC (rev 12585)
@@ -4418,9 +4418,15 @@
 	unique_vertexgroup_name((bDeformGroup*)datav, OBACT);
 }
 
+static void skgen_reorder(void *arg1, void *arg2)
+{
+	G.scene->toolsettings->skgen_options ^= SKGEN_LENGTH_FIRST;
+}
+
 static void editing_panel_mesh_skgen(Object *ob, Mesh *me)
 {
 	uiBlock *block;
+	uiBut *but;
 
 	block= uiNewBlock(&curarea->uiblocks, "editing_panel_mesh_skgen", UI_EMBOSS, UI_HELV, curarea->win);
 	if(uiNewPanel(curarea, block, "Skeleton Generation", "Editing", 960, 0, 318, 204)==0) return;
@@ -4433,13 +4439,37 @@
 	uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1111,110,164,19, &G.scene->toolsettings->skgen_threshold_internal,0.0, 1.0, 10, 0,	"Specify the threshold ratio for filtering internal arcs");
 	uiDefButBitS(block, TOG, SKGEN_FILTER_EXTERNAL, B_DIFF, "Filter Ex",	1025, 90, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Filter external small arcs from graph");
 	uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1111, 90,164,19, &G.scene->toolsettings->skgen_threshold_external,0.0, 1.0, 10, 0,	"Specify the threshold ratio for filtering external arcs");
-	uiDefButBitS(block, TOG, SKGEN_CUT_LENGTH, B_DIFF, 		"Cut Length",	1025, 70, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Subdivide arcs based on embedding");
-	uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1111, 70, 82,19, &G.scene->toolsettings->skgen_length_ratio,1.0, 4.0, 10, 0,		"Specify the ratio limit between straight arc and embeddings to trigger equal subdivisions");
-	uiDefButF(block, NUM, B_DIFF, 							"Len:",			1193, 70, 82,19, &G.scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0,		"Maximum length of the bones when subdividing");
-	uiDefButBitS(block, TOG, SKGEN_CUT_ANGLE, B_DIFF, 		"Cut Angle",	1025, 50, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Subdivide arcs based on angle");
-	uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1111, 50,164,19, &G.scene->toolsettings->skgen_angle_limit,0.0, 90.0, 10, 0,		"Specify the threshold angle in degrees for subdivision");
+
+	but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_MOVE_DOWN, 		1025, 70, 16, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Change the order the subdivisions algorithm are applied");
+	uiButSetFunc(but, skgen_reorder, NULL, NULL);
+	if (G.scene->toolsettings->skgen_options & SKGEN_LENGTH_FIRST)
+	{
+		uiDefButBitS(block, TOG, SKGEN_CUT_LENGTH, B_DIFF, 		"Length",		1041, 70, 67,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Subdivide arcs based on embedding");
+		uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1111, 70, 82,19, &G.scene->toolsettings->skgen_length_ratio,1.0, 4.0, 10, 0,		"Specify the ratio limit between straight arc and embeddings to trigger equal subdivisions");
+		uiDefButF(block, NUM, B_DIFF, 							"Len:",			1193, 70, 82,19, &G.scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0,		"Maximum length of the bones when subdividing");
+	}
+	else
+	{
+		uiDefButBitS(block, TOG, SKGEN_CUT_ANGLE, B_DIFF, 		"Angle",		1041, 70, 67,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Subdivide arcs based on angle");
+		uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1111, 70,164,19, &G.scene->toolsettings->skgen_angle_limit,0.0, 90.0, 10, 0,		"Specify the threshold angle in degrees for subdivision");
+	}
+
+	but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_MOVE_UP, 		1025, 50, 16, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Change the order the subdivisions algorithm are applied");
+	uiButSetFunc(but, skgen_reorder, NULL, NULL);
+	if (G.scene->toolsettings->skgen_options & SKGEN_LENGTH_FIRST)
+	{
+		uiDefButBitS(block, TOG, SKGEN_CUT_ANGLE, B_DIFF, 		"Angle",		1041, 50, 67,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Subdivide arcs based on angle");
+		uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1111, 50,164,19, &G.scene->toolsettings->skgen_angle_limit,0.0, 90.0, 10, 0,		"Specify the threshold angle in degrees for subdivision");
+	}
+	else
+	{
+		uiDefButBitS(block, TOG, SKGEN_CUT_LENGTH, B_DIFF, 		"Length",		1041, 50, 67,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Subdivide arcs based on embedding");
+		uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1111, 50, 82,19, &G.scene->toolsettings->skgen_length_ratio,1.0, 4.0, 10, 0,		"Specify the ratio limit between straight arc and embeddings to trigger equal subdivisions");
+		uiDefButF(block, NUM, B_DIFF, 							"Len:",			1193, 50, 82,19, &G.scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0,		"Maximum length of the bones when subdividing");
+	}
+
 	uiDefButBitS(block, TOG, SKGEN_REPOSITION, B_DIFF, 		"Reposition",	1025, 30,250,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Reposition nodes based on embedding instead of original vertice positions");
-	uiDefButC(block, ROW, B_DIFF,							"None",			1025, 10, 62,19, &G.scene->toolsettings->skgen_postpro, 5.0, (float)SKGEN_NONE, 0, 0, "No postprocessing on embeddings");
+	uiDefButC(block, NUM, B_DIFF, 							"P:",			1025, 10, 62,19, &G.scene->toolsettings->skgen_postpro_passes, 0, 10, 10, 0,		"Specify the number of processing passes on the embeddings");
 	uiDefButC(block, ROW, B_DIFF,							"Smooth",		1087, 10, 63,19, &G.scene->toolsettings->skgen_postpro, 5.0, (float)SKGEN_SMOOTH, 0, 0, "Smooth embeddings");
 	uiDefButC(block, ROW, B_DIFF,							"Average",		1150, 10, 62,19, &G.scene->toolsettings->skgen_postpro, 5.0, (float)SKGEN_AVERAGE, 0, 0, "Average embeddings");
 	uiDefButC(block, ROW, B_DIFF,							"Sharpen",		1212, 10, 63,19, &G.scene->toolsettings->skgen_postpro, 5.0, (float)SKGEN_SHARPEN, 0, 0, "Sharpen embeddings");

Modified: branches/harmonic-skeleton/blender/source/blender/src/editarmature.c
===================================================================
--- branches/harmonic-skeleton/blender/source/blender/src/editarmature.c	2007-11-14 01:13:30 UTC (rev 12584)
+++ branches/harmonic-skeleton/blender/source/blender/src/editarmature.c	2007-11-14 01:57:17 UTC (rev 12585)
@@ -3175,6 +3175,286 @@
 	return embedLength / arcLength;	
 }
 
+void symetryMarkdown(ReebGraph *rg)
+{
+	ReebNode *node;
+	ReebArc *arc;
+	
+	/* mark down all arcs as non-symetric */
+	for(arc = rg->arcs.first; arc; arc = arc->next)
+	{
+		arc->flags = 0;
+	}
+	
+	/* mark down all nodes as not on the symetry axis */
+	for(node = rg->nodes.first; node; node = node->next)
+	{
+		node->flags = 0;
+	}
+
+	/* node list is sorted, so lowest node is always the head (by design) */
+	node = rg->nodes.first;
+	
+	/* only work if only one arc is incident on the first node */
+	if (countConnectedArcs(rg, node) == 1)
+	{
+		int symetry = 1;
+		
+		arc = node->arcs[0];
+		
+		while(arc)
+		{
+			int i;
+			arc->flags = symetry;
+			
+			node = OTHER_NODE(arc, node);
+			
+			for(i = 0; node->arcs[i] != NULL; i++)
+			{
+				ReebArc *connectedArc = node->arcs[i];
+				
+				if (connectedArc != arc)
+				{
+					ReebNode *connectedNode = OTHER_NODE(connectedArc, node);
+					

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list