[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12517] branches/harmonic-skeleton/blender /source/blender: Update from school work.

Martin Poirier theeth at yahoo.com
Wed Nov 7 22:45:35 CET 2007


Revision: 12517
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12517
Author:   theeth
Date:     2007-11-07 22:45:35 +0100 (Wed, 07 Nov 2007)

Log Message:
-----------
Update from school work.

Modified Paths:
--------------
    branches/harmonic-skeleton/blender/source/blender/blenlib/BLI_arithb.h
    branches/harmonic-skeleton/blender/source/blender/blenloader/intern/readfile.c
    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/blenlib/BLI_arithb.h
===================================================================
--- branches/harmonic-skeleton/blender/source/blender/blenlib/BLI_arithb.h	2007-11-07 21:39:23 UTC (rev 12516)
+++ branches/harmonic-skeleton/blender/source/blender/blenlib/BLI_arithb.h	2007-11-07 21:45:35 UTC (rev 12517)
@@ -54,6 +54,10 @@
 #define M_SQRT1_2	0.70710678118654752440
 #endif
 
+#ifdef WIN32
+    #define isnan(n) _isnan(n)
+#endif
+
 #define MAT4_UNITY {{ 1.0, 0.0, 0.0, 0.0},\
 					{ 0.0, 1.0, 0.0, 0.0},\
 					{ 0.0, 0.0, 1.0, 0.0},\

Modified: branches/harmonic-skeleton/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/harmonic-skeleton/blender/source/blender/blenloader/intern/readfile.c	2007-11-07 21:39:23 UTC (rev 12516)
+++ branches/harmonic-skeleton/blender/source/blender/blenloader/intern/readfile.c	2007-11-07 21:45:35 UTC (rev 12517)
@@ -6585,7 +6585,7 @@
 				else
 					wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY;
 				
-				wrld->ao_adapt_thresh = 0.005;
+				wrld->ao_adapt_thresh = 0.005f;
 			}
 			
 			for(la=main->lamp.first; la; la= la->id.next) {
@@ -6778,7 +6778,7 @@
 				sce->toolsettings->skgen_threshold_external 	= 0.01f;
 				sce->toolsettings->skgen_threshold_angle 		= 45.0f;
 				sce->toolsettings->skgen_threshold_length		= 1.3f;
-				sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_REPOSITION|SKGEN_CUT_LENGTH|SKGEN_CUT_ANGLE;
+				sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_REPOSITION|SKGEN_SMOOTH|SKGEN_CUT_LENGTH|SKGEN_CUT_ANGLE;
 			}
 		}
 	}

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-07 21:39:23 UTC (rev 12516)
+++ branches/harmonic-skeleton/blender/source/blender/makesdna/DNA_scene_types.h	2007-11-07 21:45:35 UTC (rev 12517)
@@ -680,6 +680,7 @@
 #define	SKGEN_SYMMETRY			8
 #define	SKGEN_CUT_LENGTH		16
 #define	SKGEN_CUT_ANGLE			32
+#define SKGEN_SMOOTH			64
 
 #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-07 21:39:23 UTC (rev 12516)
+++ branches/harmonic-skeleton/blender/source/blender/src/buttons_editing.c	2007-11-07 21:45:35 UTC (rev 12517)
@@ -4425,19 +4425,20 @@
 	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;
 	
-	uiDefBut(block, BUT, B_GEN_SKELETON, "Generate Skeleton",			1125,160,150,39, 0, 0, 0, 0, 0, "Generate Skeleton from Mesh");
+	uiDefBut(block, BUT, B_GEN_SKELETON, "Generate Skeleton",			1075,160,200,39, 0, 0, 0, 0, 0, "Generate Skeleton from Mesh");
 
 	uiBlockBeginAlign(block);
-	uiDefButS(block, NUM, B_DIFF, "Resolution:",							1125,110,150,19, &G.scene->toolsettings->skgen_resolution,10.0,1000.0, 0, 0,		"Specifies the resolution of the graph's embedding");
-	uiDefButBitS(block, TOG, SKGEN_FILTER_INTERNAL, B_DIFF, "Filter In",	1125, 90, 58,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Filter internal small arcs from graph");
-	uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1186, 90, 89,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",	1125, 70, 58,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Filter external small arcs from graph");
-	uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1186, 70, 89,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",	1125, 50, 58,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Subdivide arcs based on length");
-	uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1186, 50, 89,19, &G.scene->toolsettings->skgen_threshold_length,1.0, 2.0, 10, 0,	"Specify the threshold ratio for subdivision");
-	uiDefButBitS(block, TOG, SKGEN_CUT_ANGLE, B_DIFF, 		"Cut Angle",	1125, 30, 58,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Subdivide arcs based on angle");
-	uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1186, 30, 89,19, &G.scene->toolsettings->skgen_threshold_angle,0.0, 90.0, 10, 0,		"Specify the threshold angle in degrees for subdivision");
-	uiDefButBitS(block, TOG, SKGEN_REPOSITION, B_DIFF, 		"Reposition",	1125, 10,150,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Reposition nodes based on embedding instead of original vertice positions");
+	uiDefButS(block, NUM, B_DIFF, "Resolution:",							1075,110,200,19, &G.scene->toolsettings->skgen_resolution,10.0,1000.0, 0, 0,		"Specifies the resolution of the graph's embedding");
+	uiDefButBitS(block, TOG, SKGEN_FILTER_INTERNAL, B_DIFF, "Filter In",	1075, 90, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Filter internal small arcs from graph");
+	uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1161, 90,114,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",	1075, 70, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Filter external small arcs from graph");
+	uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1161, 70,114,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",	1075, 50, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Subdivide arcs based on length");
+	uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1161, 50,114,19, &G.scene->toolsettings->skgen_threshold_length,1.0, 2.0, 10, 0,	"Specify the threshold ratio for subdivision");
+	uiDefButBitS(block, TOG, SKGEN_CUT_ANGLE, B_DIFF, 		"Cut Angle",	1075, 30, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Subdivide arcs based on angle");
+	uiDefButF(block, NUM, B_DIFF, 							"Thresh:",		1161, 30,114,19, &G.scene->toolsettings->skgen_threshold_angle,0.0, 90.0, 10, 0,		"Specify the threshold angle in degrees for subdivision");
+	uiDefButBitS(block, TOG, SKGEN_REPOSITION, B_DIFF, 		"Reposition",	1075, 10,100,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Reposition nodes based on embedding instead of original vertice positions");
+	uiDefButBitS(block, TOG, SKGEN_SMOOTH, B_DIFF, 			"Smooth",		1175, 10,100,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,					"Smooth embeddings");
 	uiBlockEndAlign(block);
 }
 

Modified: branches/harmonic-skeleton/blender/source/blender/src/editarmature.c
===================================================================
--- branches/harmonic-skeleton/blender/source/blender/src/editarmature.c	2007-11-07 21:39:23 UTC (rev 12516)
+++ branches/harmonic-skeleton/blender/source/blender/src/editarmature.c	2007-11-07 21:45:35 UTC (rev 12517)
@@ -3228,6 +3228,7 @@
 			tail = arc->v1;
 		}
 		
+		/************************* CUT LENGTH *****************************/
 		if ((G.scene->toolsettings->skgen_options & SKGEN_CUT_LENGTH) &&
 			arcLengthRatio(arc) >= G.scene->toolsettings->skgen_threshold_length)
 		{
@@ -3331,6 +3332,59 @@
 
 			added = 1;			
 		}
+		/************************* CUT ANGLE *****************************/
+		else if (G.scene->toolsettings->skgen_options & SKGEN_CUT_ANGLE)
+		{
+			EditBone *child = NULL;
+			EditBone *parent = NULL;
+			float angleLimit = 0.80f;//cosf(M_PI / 4);//cosf(G.scene->toolsettings->skgen_threshold_angle * M_PI / 180.0f);
+			int same = 0;
+			int index = 0;
+			int stride = 1;
+
+			// If head is the highest node, invert stride and start index
+			if (head == arc->v2)
+			{
+				stride *= -1;
+				index = arc->bcount -1;
+			}
+			
+			parent = add_editbone("Bone");
+			VECCOPY(parent->head, head->p);
+			
+			firstBone = parent; /* set first bone in the chain */
+
+			for(index = 1; index < arc->bcount; index++)
+			{
+				float vec1[3], vec2[3];
+				float len1, len2;
+
+				VecSubf(vec1, arc->buckets[index - 1].p, parent->head);
+				VecSubf(vec2, arc->buckets[index].p, arc->buckets[index - 1].p);
+
+				len1 = Normalize(vec1);
+				len2 = Normalize(vec2);
+
+				//printf("%f < %f\n", Inpf(vec1, vec2), angleLimit);
+
+				if (len1 > 0.0f && len2 > 0.0f && Inpf(vec1, vec2) < angleLimit)
+				{
+					VECCOPY(parent->tail, arc->buckets[index - 1].p);
+
+					child = add_editbone("Bone");
+					VECCOPY(child->head, parent->tail);
+					child->parent = parent;
+					child->flag |= BONE_CONNECTED;
+					
+					parent = child; // new child is next parent
+				}
+			}
+			VECCOPY(parent->tail, tail->p);
+			
+			lastBone = parent; /* set last bone in the chain */
+
+			added = 1;			
+		}
 	
 		if (added == 0)
 		{

Modified: branches/harmonic-skeleton/blender/source/blender/src/reeb.c
===================================================================
--- branches/harmonic-skeleton/blender/source/blender/src/reeb.c	2007-11-07 21:39:23 UTC (rev 12516)
+++ branches/harmonic-skeleton/blender/source/blender/src/reeb.c	2007-11-07 21:45:35 UTC (rev 12517)
@@ -380,7 +380,26 @@
 		addArcToNodeAdjacencyList(arc->v2, arc);
 	}
 }
+/****************************************** SMOOTHING **************************************************/
 
+void smoothGraph(ReebGraph *rg)
+{
+	ReebArc *arc;
+	
+	for(arc = rg->arcs.first; arc; arc = arc->next)
+	{
+		EmbedBucket *buckets = arc->buckets;
+		int bcount = arc->bcount;
+		int index;
+
+		for(index = 1; index < bcount - 1; index++)
+		{
+			VecLerpf(buckets[index].p, buckets[index].p, buckets[index - 1].p, 0.5f);
+			VecLerpf(buckets[index].p, buckets[index].p, buckets[index + 1].p, 1.0f/3.0f);
+		}
+	}
+}
+
 /****************************************** FILTERING **************************************************/
 
 int compareArcs(void *varc1, void *varc2)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list