[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24344] trunk/blender: Bugfixes + Spline IK Tweaks:

Joshua Leung aligorith at gmail.com
Thu Nov 5 11:09:45 CET 2009


Revision: 24344
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24344
Author:   aligorith
Date:     2009-11-05 11:09:45 +0100 (Thu, 05 Nov 2009)

Log Message:
-----------
Bugfixes + Spline IK Tweaks:
* #19819: 'Select' operator for Hooks was crashing when Hooks didn't have any vertices assigned yet

* Default twist resolution mode for curves is now 'Minimise'. This seems to work better for Curve Deforms and other purposes. Can be changed if other ways are better after some more testing.

* Spline IK now has more options for controlling how the x and z axis scaling is determined. There is now a choice between using the radius of the curve, the x+z scaling from the bones, or no scaling (default). This does break old files a bit, but this is to have a more stable base for later.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_object_constraint.py
    trunk/blender/source/blender/blenkernel/intern/armature.c
    trunk/blender/source/blender/blenkernel/intern/curve.c
    trunk/blender/source/blender/editors/object/object_hook.c
    trunk/blender/source/blender/makesdna/DNA_constraint_types.h
    trunk/blender/source/blender/makesrna/intern/rna_constraint.c

Modified: trunk/blender/release/scripts/ui/properties_object_constraint.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_object_constraint.py	2009-11-05 10:02:29 UTC (rev 24343)
+++ trunk/blender/release/scripts/ui/properties_object_constraint.py	2009-11-05 10:09:45 UTC (rev 24344)
@@ -607,7 +607,7 @@
         col = layout.column()
         col.itemL(text="Chain Scaling:")
         col.itemR(con, "keep_max_length")
-        col.itemR(con, "radius_to_thickness")
+        col.itemR(con, "xz_scaling_mode")
 
 
 class OBJECT_PT_constraints(ConstraintButtonsPanel):

Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c	2009-11-05 10:02:29 UTC (rev 24343)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c	2009-11-05 10:09:45 UTC (rev 24344)
@@ -1891,14 +1891,33 @@
 	}
 	
 	/* step 4: set the scaling factors for the axes */
+	// TODO: include a no-scale option?
 	{
 		/* only multiply the y-axis by the scaling factor to get nice volume-preservation */
 		VecMulf(poseMat[1], scaleFac);
-			
-		/* set the scaling factors of the x and z axes from the average radius of the curve? */
-		if (ikData->flag & CONSTRAINT_SPLINEIK_RAD2FAT) {
-			VecMulf(poseMat[0], radius);
-			VecMulf(poseMat[2], radius);
+		
+		/* set the scaling factors of the x and z axes from... */
+		switch (ikData->xzScaleMode) {
+			case CONSTRAINT_SPLINEIK_XZS_RADIUS:
+			{
+				/* radius of curve */
+				VecMulf(poseMat[0], radius);
+				VecMulf(poseMat[2], radius);
+			}
+				break;
+			case CONSTRAINT_SPLINEIK_XZS_ORIGINAL:
+			{
+				/* original scales get used */
+				float scale;
+				
+				/* x-axis scale */
+				scale= VecLength(pchan->pose_mat[0]);
+				VecMulf(poseMat[0], scale);
+				/* z-axis scale */
+				scale= VecLength(pchan->pose_mat[2]);
+				VecMulf(poseMat[2], scale);
+			}
+				break;
 		}
 	}
 	

Modified: trunk/blender/source/blender/blenkernel/intern/curve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/curve.c	2009-11-05 10:02:29 UTC (rev 24343)
+++ trunk/blender/source/blender/blenkernel/intern/curve.c	2009-11-05 10:09:45 UTC (rev 24344)
@@ -145,6 +145,7 @@
 	cu->fsize= 1.0;
 	cu->ulheight = 0.05;	
 	cu->texflag= CU_AUTOSPACE;
+	cu->twist_mode= CU_TWIST_MINIMUM;	// XXX: this one seems to be the best one in most cases, at least for curve deform...
 	
 	cu->bb= unit_boundbox();
 	

Modified: trunk/blender/source/blender/editors/object/object_hook.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_hook.c	2009-11-05 10:02:29 UTC (rev 24343)
+++ trunk/blender/source/blender/editors/object/object_hook.c	2009-11-05 10:09:45 UTC (rev 24344)
@@ -362,6 +362,9 @@
 
 void object_hook_select(Object *ob, HookModifierData *hmd) 
 {
+	if (hmd->indexar == NULL)
+		return;
+	
 	if(ob->type==OB_MESH) select_editmesh_hook(ob, hmd);
 	else if(ob->type==OB_LATTICE) select_editlattice_hook(ob, hmd);
 	else if(ob->type==OB_CURVE) select_editcurve_hook(ob, hmd);

Modified: trunk/blender/source/blender/makesdna/DNA_constraint_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_constraint_types.h	2009-11-05 10:02:29 UTC (rev 24343)
+++ trunk/blender/source/blender/makesdna/DNA_constraint_types.h	2009-11-05 10:09:45 UTC (rev 24344)
@@ -169,7 +169,7 @@
 	
 		/* settings */	
 	short flag;				/* general settings for constraint */
-	short upflag;			/* axis of bone that points up */
+	short xzScaleMode;		/* method used for determining the x & z scaling of the bones */
 } bSplineIKConstraint;
 
 
@@ -551,11 +551,17 @@
 #define CONSTRAINT_SPLINEIK_NO_ROOT			(1<<1)
 	/* bones in the chain should not scale to fit the curve */
 #define CONSTRAINT_SPLINEIK_SCALE_LIMITED	(1<<2)
-	/* bones in the chain should take their x/z scales from the curve radius */
-#define CONSTRAINT_SPLINEIK_RAD2FAT			(1<<3)
 	/* evenly distribute the bones along the path regardless of length */
-#define CONSTRAINT_SPLINEIK_EVENSPLITS		(1<<4)			
+#define CONSTRAINT_SPLINEIK_EVENSPLITS		(1<<3)	
 
+/* bSplineIKConstraint->xzScaleMode */
+	/* no x/z scaling */
+#define CONSTRAINT_SPLINEIK_XZS_NONE			0
+	/* bones in the chain should take their x/z scales from the curve radius */
+#define CONSTRAINT_SPLINEIK_XZS_RADIUS			1
+	/* bones in the chain should take their x/z scales from the original scaling */
+#define CONSTRAINT_SPLINEIK_XZS_ORIGINAL		2
+
 /* MinMax (floor) flags */
 #define MINMAX_STICKY	0x01
 #define MINMAX_STUCK	0x02

Modified: trunk/blender/source/blender/makesrna/intern/rna_constraint.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_constraint.c	2009-11-05 10:02:29 UTC (rev 24343)
+++ trunk/blender/source/blender/makesrna/intern/rna_constraint.c	2009-11-05 10:09:45 UTC (rev 24344)
@@ -1679,6 +1679,12 @@
 {
 	StructRNA *srna;
 	PropertyRNA *prop;
+	
+	static EnumPropertyItem splineik_xz_scale_mode[] = {
+		{CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "None", "Don't scale the x and z axes, giving a volume preservation effect. (Default)"},
+		{CONSTRAINT_SPLINEIK_XZS_RADIUS, "CURVE_RADIUS", 0, "Curve Radius", "Use the radius of the curve."},
+		{CONSTRAINT_SPLINEIK_XZS_ORIGINAL, "ORIGINAL", 0, "Original", "Use the original scaling of the bones."},
+		{0, NULL, 0, NULL, NULL}};
 
 	srna= RNA_def_struct(brna, "SplineIKConstraint", "Constraint");
 	RNA_def_struct_ui_text(srna, "Spline IK Constraint", "Align 'n' bones along a curve.");
@@ -1715,9 +1721,10 @@
 	RNA_def_property_ui_text(prop, "Keep Max Length", "Maintain the maximum length of the chain when spline is stretched.");
 	RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
 	
-	prop= RNA_def_property(srna, "radius_to_thickness", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_RAD2FAT);
-	RNA_def_property_ui_text(prop, "Radius to Thickness", "Radius of the spline affects the x/z scaling of the bones.");
+	prop= RNA_def_property(srna, "xz_scaling_mode", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_sdna(prop, NULL, "xzScaleMode");
+	RNA_def_property_enum_items(prop, splineik_xz_scale_mode);
+	RNA_def_property_ui_text(prop, "XZ Scale Mode", "Method used for determining the scaling of the X and Z axes of the bone.");
 	RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
 }
 





More information about the Bf-blender-cvs mailing list