[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17429] branches/etch-a-ton/source/blender : Sensible defaults with do_version

Martin Poirier theeth at yahoo.com
Wed Nov 12 20:16:47 CET 2008


Revision: 17429
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17429
Author:   theeth
Date:     2008-11-12 20:16:46 +0100 (Wed, 12 Nov 2008)

Log Message:
-----------
Sensible defaults with do_version

Auto names for name templating. When turned on, N will be incremented everytime (after a stroke has been converted) and S will be set to "l" or "r" (or "L or "R" if it already contains a capital L or R) depending on which side of the X axis the stroke started on. Experimental, there might be some bugs left.

Modified Paths:
--------------
    branches/etch-a-ton/source/blender/blenkernel/BKE_blender.h
    branches/etch-a-ton/source/blender/blenloader/intern/readfile.c
    branches/etch-a-ton/source/blender/makesdna/DNA_scene_types.h
    branches/etch-a-ton/source/blender/src/drawview.c
    branches/etch-a-ton/source/blender/src/editarmature_sketch.c

Modified: branches/etch-a-ton/source/blender/blenkernel/BKE_blender.h
===================================================================
--- branches/etch-a-ton/source/blender/blenkernel/BKE_blender.h	2008-11-12 19:16:13 UTC (rev 17428)
+++ branches/etch-a-ton/source/blender/blenkernel/BKE_blender.h	2008-11-12 19:16:46 UTC (rev 17429)
@@ -41,7 +41,7 @@
 struct MemFile;
 
 #define BLENDER_VERSION			248
-#define BLENDER_SUBVERSION		1
+#define BLENDER_SUBVERSION		2
 
 #define BLENDER_MINVERSION		245
 #define BLENDER_MINSUBVERSION	15

Modified: branches/etch-a-ton/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/etch-a-ton/source/blender/blenloader/intern/readfile.c	2008-11-12 19:16:13 UTC (rev 17428)
+++ branches/etch-a-ton/source/blender/blenloader/intern/readfile.c	2008-11-12 19:16:46 UTC (rev 17429)
@@ -7372,47 +7372,7 @@
 				ima->flag |= IMA_DO_PREMUL;
 			}
 		}
-
-		if (main->versionfile < 245 || main->subversionfile < 12)
-		{
-			/* initialize skeleton generation toolsettings */
-			for(sce=main->scene.first; sce; sce = sce->id.next)
-			{
-				sce->toolsettings->skgen_resolution = 50;
-				sce->toolsettings->skgen_threshold_internal 	= 0.01f;
-				sce->toolsettings->skgen_threshold_external 	= 0.01f;
-				sce->toolsettings->skgen_angle_limit	 		= 45.0f;
-				sce->toolsettings->skgen_length_ratio			= 1.3f;
-				sce->toolsettings->skgen_length_limit			= 1.5f;
-				sce->toolsettings->skgen_correlation_limit		= 0.98f;
-				sce->toolsettings->skgen_symmetry_limit			= 0.1f;
-				sce->toolsettings->skgen_postpro = SKGEN_SMOOTH;
-				sce->toolsettings->skgen_postpro_passes = 1;
-				sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_SUB_CORRELATION;
-				sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
-				sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
-				sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
-			}
-		}
 	}
-	
-	/* sanity check for skgen
-	 * */
-	{
-		Scene *sce;
-		for(sce=main->scene.first; sce; sce = sce->id.next)
-		{
-			if (sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[1] ||
-				sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[2] ||
-				sce->toolsettings->skgen_subdivisions[1] == sce->toolsettings->skgen_subdivisions[2])
-			{
-					sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
-					sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
-					sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
-			}
-		}
-	}
-	
 
 	if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 2)) {
 		Image *ima;
@@ -7993,6 +7953,40 @@
 		}
 	}
 	
+	if (main->versionfile < 248 || main->subversionfile < 2)
+	{
+		Scene *sce;
+		
+		/* initialize skeleton generation toolsettings */
+		for(sce=main->scene.first; sce; sce = sce->id.next)
+		{
+			sce->toolsettings->skgen_resolution = 250;
+			sce->toolsettings->skgen_threshold_internal 	= 0.1f;
+			sce->toolsettings->skgen_threshold_external 	= 0.1f;
+			sce->toolsettings->skgen_angle_limit	 		= 30.0f;
+			sce->toolsettings->skgen_length_ratio			= 1.3f;
+			sce->toolsettings->skgen_length_limit			= 1.5f;
+			sce->toolsettings->skgen_correlation_limit		= 0.98f;
+			sce->toolsettings->skgen_symmetry_limit			= 0.1f;
+			sce->toolsettings->skgen_postpro = SKGEN_SMOOTH;
+			sce->toolsettings->skgen_postpro_passes = 3;
+			sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_FILTER_SMART|SKGEN_SUB_CORRELATION|SKGEN_HARMONIC;
+			sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
+			sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
+			sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
+
+			
+			sce->toolsettings->skgen_retarget_angle_weight = 1.0f;
+			sce->toolsettings->skgen_retarget_length_weight = 1.0f;
+			sce->toolsettings->skgen_retarget_distance_weight = 1.0f;
+	
+			/* Skeleton Sketching */
+			sce->toolsettings->bone_sketching = 0;
+			sce->toolsettings->skgen_retarget_options |= SK_RETARGET_ROLL;
+		}
+	}
+
+	
 	/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
 	/* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
 

Modified: branches/etch-a-ton/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/etch-a-ton/source/blender/makesdna/DNA_scene_types.h	2008-11-12 19:16:13 UTC (rev 17428)
+++ branches/etch-a-ton/source/blender/makesdna/DNA_scene_types.h	2008-11-12 19:16:46 UTC (rev 17429)
@@ -865,7 +865,6 @@
 #define SKGEN_DISP_ORIG			(1 << 12)
 #define SKGEN_DISP_EMBED		(1 << 13)
 #define SKGEN_DISP_INDEX		(1 << 14)
-#define	SKGEN_CUT_FIXED			64
 
 #define	SKGEN_SUB_LENGTH		0
 #define	SKGEN_SUB_ANGLE			1
@@ -889,6 +888,7 @@
 
 /* toolsettings->skgen_retarget_options */
 #define	SK_RETARGET_ROLL				1
+#define	SK_RETARGET_AUTONAME			2
 
 
 #ifdef __cplusplus

Modified: branches/etch-a-ton/source/blender/src/drawview.c
===================================================================
--- branches/etch-a-ton/source/blender/src/drawview.c	2008-11-12 19:16:13 UTC (rev 17428)
+++ branches/etch-a-ton/source/blender/src/drawview.c	2008-11-12 19:16:46 UTC (rev 17429)
@@ -2354,7 +2354,6 @@
 		but = uiDefButI(block, MENU, B_REDR, BIF_listTemplates(), 10,yco,150,19, &template_index, 0, 0, 0, 0, "Template");
 		uiButSetFunc(but, assign_template_sketch_armature, &template_index, NULL);
 		
-		//uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_DIFF, "OB:", 10, yco, 150, 19, &G.scene->toolsettings->skgen_template, "Template Object"); 
 		yco -= 20;
 		
 		uiDefButF(block, NUM, B_DIFF, 							"Ang:",			10, yco, 50,19, &G.scene->toolsettings->skgen_retarget_angle_weight, 0, 10, 1, 0,		"Angle Weight");
@@ -2362,9 +2361,12 @@
 		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;
 		
-		uiDefBut(block, TEX,0,"S:",							10, yco, 75, 20, G.scene->toolsettings->skgen_side_string, 0.0, 8.0, 0, 0, "Text to replace %S with");
-		uiDefBut(block, TEX,0,"N:",							85, yco, 75, 20, G.scene->toolsettings->skgen_num_string, 0.0, 8.0, 0, 0, "Text to replace %N with");
+		uiDefBut(block, TEX,0,"S:",							10, yco, 65, 20, G.scene->toolsettings->skgen_side_string, 0.0, 8.0, 0, 0, "Text to replace %S with");
+		uiDefBut(block, TEX,0,"N:",							75, yco, 65, 20, G.scene->toolsettings->skgen_num_string, 0.0, 8.0, 0, 0, "Text to replace %N with");
+		uiDefIconButBitC(block, TOG, SK_RETARGET_AUTONAME, B_DIFF, ICON_AUTO,140,yco,20,20, &G.scene->toolsettings->skgen_retarget_options, 0, 0, 0, 0, "Use Auto Naming");	
 
+		/* auto renaming magic */
+
 		uiBlockEndAlign(block);
 
 		if(yco < 0) uiNewPanelHeight(block, height-yco);

Modified: branches/etch-a-ton/source/blender/src/editarmature_sketch.c
===================================================================
--- branches/etch-a-ton/source/blender/src/editarmature_sketch.c	2008-11-12 19:16:13 UTC (rev 17428)
+++ branches/etch-a-ton/source/blender/src/editarmature_sketch.c	2008-11-12 19:16:46 UTC (rev 17429)
@@ -178,6 +178,11 @@
 	char menu_header[] = "Template%t|None%x0|";
 	char *p;
 	
+	if (TEMPLATES_MENU != NULL)
+	{
+		MEM_freeN(TEMPLATES_MENU);
+	}
+	
 	TEMPLATES_MENU = MEM_callocN(sizeof(char) * (BLI_ghash_size(TEMPLATES_HASH) * 32 + 30), "skeleton template menu");
 	
 	p = TEMPLATES_MENU;
@@ -472,6 +477,53 @@
 }
 /*********************** CONVERSION ***************************/
 
+void sk_autoname(ReebArc *arc)
+{
+	if (G.scene->toolsettings->skgen_retarget_options & SK_RETARGET_AUTONAME)
+	{
+		if (arc == NULL)
+		{
+			char *num = G.scene->toolsettings->skgen_num_string;
+			int i = atoi(num);
+			i++;
+			BLI_snprintf(num, 8, "%i", i);
+		}
+		else
+		{
+			char *side = G.scene->toolsettings->skgen_side_string;
+			int valid = 0;
+			int caps = 0;
+			
+			if (BLI_streq(side, ""))
+			{
+				valid = 1;
+			}
+			else if (BLI_streq(side, "R") || BLI_streq(side, "L"))
+			{
+				valid = 1;
+				caps = 1;
+			}
+			else if (BLI_streq(side, "r") || BLI_streq(side, "l"))
+			{
+				valid = 1;
+				caps = 0;
+			}
+			
+			if (valid)
+			{
+				if (arc->head->p[0] < 0)
+				{
+					BLI_snprintf(side, 8, caps?"R":"r");
+				}
+				else
+				{
+					BLI_snprintf(side, 8, caps?"L":"l");
+				}
+			}
+		}
+	}
+}
+
 ReebNode *sk_pointToNode(SK_Point *pt, float imat[][4], float tmat[][3])
 {
 	ReebNode *node;
@@ -529,8 +581,12 @@
 
 	arc = sk_strokeToArc(stk, imat, tmat);
 	
+	sk_autoname(arc);
+
 	BIF_retargetArc(arc);
 	
+	sk_autoname(NULL);
+	
 	MEM_freeN(arc->head);
 	MEM_freeN(arc->tail);
 	REEB_freeArc((BArc*)arc);





More information about the Bf-blender-cvs mailing list