[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34386] trunk/blender/source/blender: rename fcurve.keyframe_points.add() --> insert()

Campbell Barton ideasman42 at gmail.com
Tue Jan 18 12:27:53 CET 2011


Revision: 34386
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34386
Author:   campbellbarton
Date:     2011-01-18 11:27:52 +0000 (Tue, 18 Jan 2011)
Log Message:
-----------
rename fcurve.keyframe_points.add() --> insert()
add new add function which allocates a number of points instead.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_curve.c
    trunk/blender/source/blender/makesrna/intern/rna_fcurve.c
    trunk/blender/source/blender/python/intern/bpy_rna.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_curve.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_curve.c	2011-01-18 09:25:37 UTC (rev 34385)
+++ trunk/blender/source/blender/makesrna/intern/rna_curve.c	2011-01-18 11:27:52 UTC (rev 34386)
@@ -1118,7 +1118,7 @@
 	func= RNA_def_function(srna, "add", "rna_Curve_spline_points_add");
 	RNA_def_function_ui_description(func, "Add a number of points to this spline.");
 	RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_USE_REPORTS);
-	RNA_def_int(func, "number", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
+	RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX);
 
 	/*
 	func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove");
@@ -1145,7 +1145,7 @@
 	func= RNA_def_function(srna, "add", "rna_Curve_spline_bezpoints_add");
 	RNA_def_function_ui_description(func, "Add a number of points to this spline.");
 	RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_USE_REPORTS);
-	RNA_def_int(func, "number", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
+	RNA_def_int(func, "count", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
 
 	/*
 	func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove");

Modified: trunk/blender/source/blender/makesrna/intern/rna_fcurve.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_fcurve.c	2011-01-18 09:25:37 UTC (rev 34385)
+++ trunk/blender/source/blender/makesrna/intern/rna_fcurve.c	2011-01-18 11:27:52 UTC (rev 34386)
@@ -546,12 +546,29 @@
 	*max= MAXFRAMEF;
 }
 
-static BezTriple *rna_FKeyframe_points_add(FCurve *fcu, float frame, float value, int flag)
+static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, int flag)
 {
 	int index= insert_vert_fcurve(fcu, frame, value, flag);
 	return ((fcu->bezt) && (index >= 0))? (fcu->bezt + index) : NULL;
 }
 
+static void rna_FKeyframe_points_add(FCurve *fcu, int tot)
+{
+	if(tot > 0) {
+		if(fcu->totvert) {
+			BezTriple *nbezt= MEM_callocN(sizeof(BezTriple) * (fcu->totvert + tot), "rna_FKeyframe_points_add");
+			memcpy(nbezt, fcu->bezt, sizeof(BezTriple) * fcu->totvert);
+			MEM_freeN(fcu->bezt);
+			fcu->bezt= nbezt;
+		}
+		else {
+			fcu->bezt= MEM_callocN(sizeof(BezTriple) * tot, "rna_FKeyframe_points_add");
+		}
+
+		fcu->totvert += tot;
+	}
+}
+
 static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, BezTriple *bezt, int do_fast)
 {
 	int index= (int)(bezt - fcu->bezt);
@@ -1326,7 +1343,7 @@
 	RNA_def_struct_sdna(srna, "FCurve");
 	RNA_def_struct_ui_text(srna, "Keyframe Points", "Collection of keyframe points");
 
-	func= RNA_def_function(srna, "add", "rna_FKeyframe_points_add");
+	func= RNA_def_function(srna, "insert", "rna_FKeyframe_points_insert");
 	RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve.");
 	parm= RNA_def_float(func, "frame", 0.0f, -FLT_MAX, FLT_MAX, "", "X Value of this keyframe point", -FLT_MAX, FLT_MAX);
 	RNA_def_property_flag(parm, PROP_REQUIRED);
@@ -1338,6 +1355,9 @@
 	parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe");
 	RNA_def_function_return(func, parm);
 
+	func= RNA_def_function(srna, "add", "rna_FKeyframe_points_add");
+	RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve.");
+	RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX);
 
 	func= RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove");
 	RNA_def_function_ui_description(func, "Remove keyframe from an fcurve.");

Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c	2011-01-18 09:25:37 UTC (rev 34385)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c	2011-01-18 11:27:52 UTC (rev 34386)
@@ -3480,11 +3480,37 @@
 	Py_RETURN_NONE;
 }
 
+static char pyrna_prop_collection_foreach_get_doc[] =
+".. method:: foreach_get(attr, seq)\n"
+"\n"
+"   This is a function to give fast access to attribites within a collection.\n"
+"\n"
+"   .. code-block:: python\n"
+"\n"
+"      collection.foreach_get(someseq, attr)\n"
+"\n"
+"      # Python equivelent\n"
+"      for i in range(len(seq)): someseq[i] = getattr(collection, attr)\n"
+"\n"
+;
 static PyObject *pyrna_prop_collection_foreach_get(BPy_PropertyRNA *self, PyObject *args)
 {
 	return foreach_getset(self, args, 0);
 }
 
+static char pyrna_prop_collection_foreach_set_doc[] =
+".. method:: foreach_set(attr, seq)\n"
+"\n"
+"   This is a function to give fast access to attribites within a collection.\n"
+"\n"
+"   .. code-block:: python\n"
+"\n"
+"      collection.foreach_set(seq, attr)\n"
+"\n"
+"      # Python equivelent\n"
+"      for i in range(len(seq)): setattr(collection[i], attr, seq[i])\n"
+"\n"
+;
 static  PyObject *pyrna_prop_collection_foreach_set(BPy_PropertyRNA *self, PyObject *args)
 {
 	return foreach_getset(self, args, 1);
@@ -3566,8 +3592,8 @@
 };
 
 static struct PyMethodDef pyrna_prop_collection_methods[] = {
-	{"foreach_get", (PyCFunction)pyrna_prop_collection_foreach_get, METH_VARARGS, NULL},
-	{"foreach_set", (PyCFunction)pyrna_prop_collection_foreach_set, METH_VARARGS, NULL},
+	{"foreach_get", (PyCFunction)pyrna_prop_collection_foreach_get, METH_VARARGS, pyrna_prop_collection_foreach_get_doc},
+	{"foreach_set", (PyCFunction)pyrna_prop_collection_foreach_set, METH_VARARGS, pyrna_prop_collection_foreach_set_doc},
 
 	{"keys", (PyCFunction)pyrna_prop_collection_keys, METH_NOARGS, NULL},
 	{"items", (PyCFunction)pyrna_prop_collection_items, METH_NOARGS,NULL},




More information about the Bf-blender-cvs mailing list