[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24905] trunk/blender/source/blender: * Spline IK 'Joint Bindings' array now available from RNA.

Joshua Leung aligorith at gmail.com
Thu Nov 26 03:13:57 CET 2009


Revision: 24905
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24905
Author:   aligorith
Date:     2009-11-26 03:13:56 +0100 (Thu, 26 Nov 2009)

Log Message:
-----------
* Spline IK 'Joint Bindings' array now available from RNA. This can be used to manually slide bone joints along the curves for extra tweaking. It's only recommended to be used by advanced users for extra control over the points.

* Added some missing file-reading code to try and get things working better

Modified Paths:
--------------
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/makesrna/intern/rna_constraint.c
    trunk/blender/source/blender/makesrna/intern/rna_fcurve.c

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2009-11-26 02:11:07 UTC (rev 24904)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2009-11-26 02:13:56 UTC (rev 24905)
@@ -1708,6 +1708,9 @@
 {
 	FCurve *fcu;
 	
+	if (list == NULL)
+		return;
+	
 	/* relink ID-block references... */
 	for (fcu= list->first; fcu; fcu= fcu->next) {
 		/* driver data */
@@ -1854,6 +1857,9 @@
 		/* check strip's children */
 		lib_link_nladata_strips(fd, id, &strip->strips);
 		
+		/* check strip's F-Curves */
+		lib_link_fcurves(fd, id, &strip->fcurves);
+		
 		/* reassign the counted-reference to action */
 		strip->act = newlibadr_us(fd, id->lib, strip->act);
 	}
@@ -10512,6 +10518,9 @@
 		/* check child strips */
 		expand_animdata_nlastrips(fd, mainvar, &strip->strips);
 		
+		/* check F-Curves */
+		expand_fcurves(fd, mainvar, &strip->fcurves);
+		
 		/* check F-Modifiers */
 		expand_fmodifiers(fd, mainvar, &strip->modifiers);
 		

Modified: trunk/blender/source/blender/makesrna/intern/rna_constraint.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_constraint.c	2009-11-26 02:11:07 UTC (rev 24904)
+++ trunk/blender/source/blender/makesrna/intern/rna_constraint.c	2009-11-26 02:13:56 UTC (rev 24905)
@@ -286,6 +286,35 @@
 	}
 }
 
+static int rna_SplineIKConstraint_joint_bindings_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
+{
+	bConstraint *con= (bConstraint*)ptr->data;
+	bSplineIKConstraint *ikData= (bSplineIKConstraint *)con->data;
+
+	if (ikData)
+		length[0]= ikData->numpoints;
+	else
+		length[0]= 256; /* for raw_access, untested */
+
+	return length[0];
+}
+
+static void rna_SplineIKConstraint_joint_bindings_get(PointerRNA *ptr, float *values)
+{
+	bConstraint *con= (bConstraint*)ptr->data;
+	bSplineIKConstraint *ikData= (bSplineIKConstraint *)con->data;
+	
+	memcpy(values, ikData->points, ikData->numpoints * sizeof(float));
+}
+
+static void rna_SplineIKConstraint_joint_bindings_set(PointerRNA *ptr, const float *values)
+{
+	bConstraint *con= (bConstraint*)ptr->data;
+	bSplineIKConstraint *ikData= (bSplineIKConstraint *)con->data;
+	
+	memcpy(ikData->points, values, ikData->numpoints * sizeof(float));
+}
+
 #else
 
 EnumPropertyItem constraint_distance_items[] = {
@@ -1703,9 +1732,13 @@
 	
 	/* direct access to bindings */
 	// NOTE: only to be used by experienced users
-	//prop= RNA_def_property(srna, "joint_bindings", PROP_FLOAT, PROP_FACTOR);
-	//RNA_def_property_collection_sdna(prop, NULL, "points", "numpoints");
-	//RNA_def_property_ui_text(prop, "Joint Bindings", "(EXPERIENCED USERS ONLY) The relative positions of the joints along the chain as percentages.");
+	prop= RNA_def_property(srna, "joint_bindings", PROP_FLOAT, PROP_FACTOR);
+	RNA_def_property_array(prop, 32); // XXX this is the maximum value allowed
+	RNA_def_property_flag(prop, PROP_DYNAMIC);
+	RNA_def_property_dynamic_array_funcs(prop, "rna_SplineIKConstraint_joint_bindings_get_length");
+	RNA_def_property_float_funcs(prop, "rna_SplineIKConstraint_joint_bindings_get", "rna_SplineIKConstraint_joint_bindings_set", NULL);
+	RNA_def_property_ui_text(prop, "Joint Bindings", "(EXPERIENCED USERS ONLY) The relative positions of the joints along the chain as percentages.");
+	RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
 	
 	/* settings */
 	prop= RNA_def_property(srna, "chain_offset", PROP_BOOLEAN, PROP_NONE);

Modified: trunk/blender/source/blender/makesrna/intern/rna_fcurve.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_fcurve.c	2009-11-26 02:11:07 UTC (rev 24904)
+++ trunk/blender/source/blender/makesrna/intern/rna_fcurve.c	2009-11-26 02:13:56 UTC (rev 24905)
@@ -252,7 +252,7 @@
 	return remove_fmodifier_index(&fcu->modifiers, index);
 }
 
-static void rna_Fmodifier_active_set(PointerRNA *ptr, int value)
+static void rna_FModifier_active_set(PointerRNA *ptr, int value)
 {
 	FModifier *fm= (FModifier*)ptr->data;
 
@@ -260,7 +260,7 @@
 	fm->flag |= FMODIFIER_FLAG_ACTIVE;
 }
 
-static void rna_Fmodifier_active_update(bContext *C, PointerRNA *ptr)
+static void rna_FModifier_active_update(bContext *C, PointerRNA *ptr)
 {
 	FModifier *fm, *fmo= (FModifier*)ptr->data;
 
@@ -278,8 +278,8 @@
 
 static int rna_FModifierGenerator_coefficients_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
 {
-	FModifier *fm= (FModifier*)ptr->data;
-	FMod_Generator *gen= fm->data;
+	FModifier *fcm= (FModifier*)ptr->data;
+	FMod_Generator *gen= fcm->data;
 
 	if(gen)
 		length[0]= gen->arraysize;
@@ -291,15 +291,15 @@
 
 static void rna_FModifierGenerator_coefficients_get(PointerRNA *ptr, float *values)
 {
-	FModifier *fm= (FModifier*)ptr->data;
-	FMod_Generator *gen= fm->data;
+	FModifier *fcm= (FModifier*)ptr->data;
+	FMod_Generator *gen= fcm->data;
 	memcpy(values, gen->coefficients, gen->arraysize * sizeof(float));
 }
 
 static void rna_FModifierGenerator_coefficients_set(PointerRNA *ptr, const float *values)
 {
-	FModifier *fm= (FModifier*)ptr->data;
-	FMod_Generator *gen= fm->data;
+	FModifier *fcm= (FModifier*)ptr->data;
+	FMod_Generator *gen= fcm->data;
 	memcpy(gen->coefficients, values, gen->arraysize * sizeof(float));
 }
 
@@ -338,19 +338,13 @@
 	RNA_def_property_ui_text(prop, "Polynomial Order", "The highest power of 'x' for this polynomial. (number of coefficients - 1)");
 	RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
 	
-
+	/* coefficients array */
 	prop= RNA_def_property(srna, "coefficients", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_array(prop, 32);
 	RNA_def_property_flag(prop, PROP_DYNAMIC);
 	RNA_def_property_dynamic_array_funcs(prop, "rna_FModifierGenerator_coefficients_get_length");
 	RNA_def_property_float_funcs(prop, "rna_FModifierGenerator_coefficients_get", "rna_FModifierGenerator_coefficients_set", NULL);
 	RNA_def_property_ui_text(prop, "Coefficients", "Coefficients for 'x' (starting from lowest power of x^0).");
-
-	/* coefficients array */
-		// FIXME: this is quite difficult to try to wrap
-	//prop= RNA_def_property(srna, "coefficients", PROP_COLLECTION, PROP_NONE);
-	//RNA_def_property_collection_funcs(prop, "rna_FModifierGenerator_coefficients_begin", "rna_FModifierGenerator_coefficients_next", "rna_FModifierGenerator_coefficients_end", "rna_iterator_array_get", "rna_FModifierGenerator_coefficients_length", 0, 0, 0, 0);
-	//RNA_def_property_ui_text(prop, "Coefficients", "Coefficients for 'x' (starting from lowest power of x^0).");
 }
 
 /* --------- */
@@ -707,8 +701,8 @@
 	prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_ACTIVE);
 	RNA_def_property_ui_text(prop, "Active", "F-Curve Modifier is the one being edited ");
-	RNA_def_property_boolean_funcs(prop, NULL, "rna_Fmodifier_active_set");
-	RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, "rna_Fmodifier_active_update");
+	RNA_def_property_boolean_funcs(prop, NULL, "rna_FModifier_active_set");
+	RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, "rna_FModifier_active_update");
 	RNA_def_property_ui_icon(prop, ICON_RADIOBUT_OFF, 1);
 }	
 
@@ -848,10 +842,9 @@
 	RNA_def_property_ui_text(prop, "Point", "Point coordinates");
 }
 
-/* channeldriver.targets.* */
 static void rna_def_fcurve_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
 {
-	/* add target */
+	/* add modifiers */
 	StructRNA *srna;
 	PropertyRNA *prop;
 
@@ -861,7 +854,7 @@
 	RNA_def_property_srna(cprop, "FCurveModifiers");
 	srna= RNA_def_struct(brna, "FCurveModifiers", NULL);
 	RNA_def_struct_sdna(srna, "FCurve");
-	RNA_def_struct_ui_text(srna, "FCurve Modifiers", "Collection of fcurve modifiers.");
+	RNA_def_struct_ui_text(srna, "F-Curve Modifiers", "Collection of F-Curve Modifiers.");
 
 
 	/* Collection active property */





More information about the Bf-blender-cvs mailing list