[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28616] trunk/blender/source/blender/ makesrna/intern/rna_action.c: rna functions...

Campbell Barton ideasman42 at gmail.com
Thu May 6 16:43:21 CEST 2010


Revision: 28616
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28616
Author:   campbellbarton
Date:     2010-05-06 16:43:21 +0200 (Thu, 06 May 2010)

Log Message:
-----------
rna functions...
 fcu = action.fcurves.new(data_path, array_index, group)
 action.fcurves.remove(fcu)

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_action.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_action.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_action.c	2010-05-06 12:01:44 UTC (rev 28615)
+++ trunk/blender/source/blender/makesrna/intern/rna_action.c	2010-05-06 14:43:21 UTC (rev 28616)
@@ -41,6 +41,9 @@
 
 #ifdef RNA_RUNTIME
 
+#include "ED_keyframing.h"
+#include "BKE_fcurve.h"
+
 static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter)
 {
 	ListBaseIterator *internal= iter->internal;
@@ -86,7 +89,33 @@
 	MEM_freeN(agrp); 
 }
 
+static FCurve *rna_Action_fcurve_new(bAction *act, char *data_path, int index, char *group)
+{
+	if(group && group[0]=='\0') group= NULL;
+	return verify_fcurve(act, group, data_path, index, 1);
+}
 
+static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, FCurve *fcu)
+{
+	if(fcu->grp) {
+		if (BLI_findindex(&act->groups, fcu->grp) == -1) {
+			BKE_reportf(reports, RPT_ERROR, "FCurve's ActionGroup '%s' not found in action '%s'", fcu->grp->name, act->id.name+2);
+			return;
+		}
+
+		action_groups_remove_channel(act, fcu);
+	}
+	else {
+		if(BLI_findindex(&act->curves, fcu) == -1) {
+			BKE_reportf(reports, RPT_ERROR, "FCurve not found in action '%s'", act->id.name+2);
+			return;
+		}
+
+		BLI_remlink(&act->curves, fcu);
+		free_fcurve(fcu);
+	}
+}
+
 #else
 
 static void rna_def_dopesheet(BlenderRNA *brna)
@@ -291,7 +320,7 @@
 	RNA_def_property_srna(cprop, "ActionGroups");
 	srna= RNA_def_struct(brna, "ActionGroups", NULL);
 	RNA_def_struct_sdna(srna, "bAction");
-	RNA_def_struct_ui_text(srna, "Action Points", "Collection of action groups");
+	RNA_def_struct_ui_text(srna, "Action Groups", "Collection of action groups");
 
 	func= RNA_def_function(srna, "add", "rna_Action_groups_add");
 	RNA_def_function_ui_description(func, "Add a keyframe to the curve.");
@@ -309,6 +338,35 @@
 	RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
 }
 
+static void rna_def_action_fcurves(BlenderRNA *brna, PropertyRNA *cprop)
+{
+	StructRNA *srna;
+
+	FunctionRNA *func;
+	PropertyRNA *parm;
+
+	RNA_def_property_srna(cprop, "ActionFCurves");
+	srna= RNA_def_struct(brna, "ActionFCurves", NULL);
+	RNA_def_struct_sdna(srna, "bAction");
+	RNA_def_struct_ui_text(srna, "Action FCurves", "Collection of action fcurves");
+
+	func= RNA_def_function(srna, "new", "rna_Action_fcurve_new");
+	RNA_def_function_ui_description(func, "Add a keyframe to the curve.");
+	parm= RNA_def_string(func, "data_path", "Data Path", 0, "", "FCurve data path to use.");
+	parm= RNA_def_int(func, "array_index", 0, 0, INT_MAX, "Index", "Array index.", 0, INT_MAX);
+	parm= RNA_def_string(func, "action_group", "Action Group", 0, "", "Acton group to add this fcurve into.");
+
+	parm= RNA_def_pointer(func, "fcurve", "FCurve", "", "Newly created fcurve");
+	RNA_def_function_return(func, parm);
+
+
+	func= RNA_def_function(srna, "remove", "rna_Action_fcurve_remove");
+	RNA_def_function_ui_description(func, "Remove action group.");
+	RNA_def_function_flag(func, FUNC_USE_REPORTS);
+	parm= RNA_def_pointer(func, "fcurve", "FCurve", "", "FCurve to remove.");
+	RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
+}
+
 static void rna_def_action(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -323,6 +381,7 @@
 	RNA_def_property_collection_sdna(prop, NULL, "curves", NULL);
 	RNA_def_property_struct_type(prop, "FCurve");
 	RNA_def_property_ui_text(prop, "F-Curves", "The individual F-Curves that make up the Action");
+	rna_def_action_fcurves(brna, prop);
 
 	prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_sdna(prop, NULL, "groups", NULL);





More information about the Bf-blender-cvs mailing list