Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-08-25 08:05:37 +0400
committerJoshua Leung <aligorith@gmail.com>2009-08-25 08:05:37 +0400
commite80ac54a22214a8ecc499aa70f59bb61fcba4fa3 (patch)
tree5ac843114016951bdd8c44b404be35f67279c804
parente2eaf269350d972daec1f19ae5aa5ee7fbad4685 (diff)
2.5 - Keying Sets API (now usable from Py-Scripts)
Wrapped the Keying Sets API with RNA Functions so that they can now be called from Py-Scripts. This will ultimately be useful for riggers to create Keying Sets which can get loaded up/created for animators to use after importing their rig. I've created a demo for this, which can be found at: http://www.pasteall.org/blend/552 Notes: - Kazanbas, I've had to create a rna_scene_api.c here to hold some of the relevant functions. Hopefully this won't cause you too much pain when you do your next merge from 2.5 to your branch ;) - I've noticed that there seem to be a few cases mentioned in the demo which don't totally work yet. I'll commit some fixes for those later.
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c20
-rw-r--r--source/blender/editors/animation/anim_ops.c3
-rw-r--r--source/blender/editors/animation/keyingsets.c131
-rw-r--r--source/blender/editors/include/ED_keyframing.h9
-rw-r--r--source/blender/makesrna/RNA_enum_types.h2
-rw-r--r--source/blender/makesrna/intern/makesrna.c4
-rw-r--r--source/blender/makesrna/intern/rna_animation.c20
-rw-r--r--source/blender/makesrna/intern/rna_animation_api.c89
-rw-r--r--source/blender/makesrna/intern/rna_internal.h2
-rw-r--r--source/blender/makesrna/intern/rna_scene.c3
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c100
11 files changed, 220 insertions, 163 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 8daaaab62d4..44d73a7f5b4 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -207,12 +207,6 @@ AnimData *BKE_copy_animdata (AnimData *adt)
/* *********************************** */
/* KeyingSet API */
-/* NOTES:
- * It is very likely that there will be two copies of the api - one for internal use,
- * and one 'operator' based wrapper of the internal API, which should allow for access
- * from Python/scripts so that riggers can automate the creation of KeyingSets for their rigs.
- */
-
/* Finding Tools --------------------------- */
/* Find the first path that matches the given criteria */
@@ -299,18 +293,25 @@ void BKE_keyingset_add_destination (KeyingSet *ks, ID *id, const char group_name
KS_Path *ksp;
/* sanity checks */
- if ELEM(NULL, ks, rna_path)
+ if ELEM(NULL, ks, rna_path) {
+ printf("ERROR: no Keying Set and/or RNA Path to add destination with \n");
return;
+ }
/* ID is optional for relative KeyingSets, but is necessary for absolute KeyingSets */
if (id == NULL) {
- if (ks->flag & KEYINGSET_ABSOLUTE)
+ if (ks->flag & KEYINGSET_ABSOLUTE) {
+ printf("ERROR: No ID provided for absolute destination. \n");
return;
+ }
}
/* don't add if there is already a matching KS_Path in the KeyingSet */
- if (BKE_keyingset_find_destination(ks, id, group_name, rna_path, array_index, groupmode))
+ if (BKE_keyingset_find_destination(ks, id, group_name, rna_path, array_index, groupmode)) {
+ if (G.f & G_DEBUG)
+ printf("ERROR: destination already exists in Keying Set \n");
return;
+ }
/* allocate a new KeyingSet Path */
ksp= MEM_callocN(sizeof(KS_Path), "KeyingSet Path");
@@ -1263,6 +1264,7 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime)
dummy_strip.act= adt->action;
dummy_strip.remap= adt->remap;
+ /* action range is calculated taking F-Modifiers into account (which making new strips doesn't do due to the troublesome nature of that) */
calc_action_range(dummy_strip.act, &dummy_strip.actstart, &dummy_strip.actend, 1);
dummy_strip.start = dummy_strip.actstart;
dummy_strip.end = (IS_EQ(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f): (dummy_strip.actend);
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index ffa44e60d00..72fee937e25 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -398,9 +398,6 @@ void ED_operatortypes_anim(void)
WM_operatortype_append(ANIM_OT_add_driver_button);
WM_operatortype_append(ANIM_OT_remove_driver_button);
-
- WM_operatortype_append(ANIM_OT_keyingset_add_new);
- WM_operatortype_append(ANIM_OT_keyingset_add_destination);
}
void ED_keymap_anim(wmWindowManager *wm)
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 5bd37ba7831..f19372069c3 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -80,137 +80,6 @@
/* ************************************************** */
/* KEYING SETS - EDITING API */
-/* Operators ------------------------------------------- */
-
-/* These operators are only provided for scripting/macro usage, not for direct
- * calling from the UI since they wrap some of the data-access API code for these
- * (defined in blenkernel) which have quite a few properties.
- */
-
-/* ----- */
-
-static int keyingset_add_destination_exec (bContext *C, wmOperator *op)
-{
- PointerRNA ptr;
- KeyingSet *ks= NULL;
- ID *id= NULL;
- char rna_path[256], group_name[64]; // xxx
- short groupmode=0, flag=0;
- int array_index=0;
-
- /* get settings from operator properties */
- ptr = RNA_pointer_get(op->ptr, "keyingset");
- if (ptr.data)
- ks= (KeyingSet *)ptr.data;
-
- ptr = RNA_pointer_get(op->ptr, "id");
- if (ptr.data)
- id= (ID *)ptr.data;
-
- groupmode= RNA_enum_get(op->ptr, "grouping_method");
- RNA_string_get(op->ptr, "group_name", group_name);
-
- RNA_string_get(op->ptr, "rna_path", rna_path);
- array_index= RNA_int_get(op->ptr, "array_index");
-
- if (RNA_boolean_get(op->ptr, "entire_array"))
- flag |= KSP_FLAG_WHOLE_ARRAY;
-
- /* if enough args are provided, call API method */
- if (ks) {
- BKE_keyingset_add_destination(ks, id, group_name, rna_path, array_index, flag, groupmode);
- return OPERATOR_FINISHED;
- }
- else {
- BKE_report(op->reports, RPT_ERROR, "Keying Set could not be added.");
- return OPERATOR_CANCELLED;
- }
-}
-
-void ANIM_OT_keyingset_add_destination (wmOperatorType *ot)
-{
- // XXX: this is also defined in rna_animation.c
- static EnumPropertyItem prop_mode_grouping_items[] = {
- {KSP_GROUP_NAMED, "NAMED", 0, "Named Group", ""},
- {KSP_GROUP_NONE, "NONE", 0, "None", ""},
- {KSP_GROUP_KSNAME, "KEYINGSET", 0, "Keying Set Name", ""},
- {0, NULL, 0, NULL, NULL}};
-
- /* identifiers */
- ot->name= "Add Keying Set Destination";
- ot->idname= "ANIM_OT_keyingset_add_destination";
-
- /* callbacks */
- ot->exec= keyingset_add_destination_exec;
- ot->poll= ED_operator_scene_editable;
-
- /* props */
- /* pointers */ // xxx - do we want to directly expose these?
- RNA_def_pointer_runtime(ot->srna, "keyingset", &RNA_KeyingSet, "Keying Set", "Keying Set to add destination to.");
- RNA_def_pointer_runtime(ot->srna, "id", &RNA_ID, "ID", "ID-block for the destination.");
- /* grouping */
- RNA_def_enum(ot->srna, "grouping_method", prop_mode_grouping_items, KSP_GROUP_NAMED, "Grouping Method", "Method used to define which Group-name to use.");
- RNA_def_string(ot->srna, "group_name", "", 64, "Group Name", "Name of Action Group to assign destination to (only if grouping mode is to use this name).");
- /* rna-path */
- RNA_def_string(ot->srna, "rna_path", "", 256, "RNA-Path", "RNA-Path to destination property."); // xxx hopefully this is long enough
- RNA_def_int(ot->srna, "array_index", 0, 0, INT_MAX, "Array Index", "If applicable, the index ", 0, INT_MAX);
- /* flags */
- RNA_def_boolean(ot->srna, "entire_array", 1, "Entire Array", "hen an 'array/vector' type is chosen (Location, Rotation, Color, etc.), entire array is to be used.");
-
-}
-
-/* ----- */
-
-static int keyingset_add_new_exec (bContext *C, wmOperator *op)
-{
- Scene *sce= CTX_data_scene(C);
- KeyingSet *ks= NULL;
- short flag=0, keyingflag=0;
- char name[64];
-
- /* get settings from operator properties */
- RNA_string_get(op->ptr, "name", name);
-
- if (RNA_boolean_get(op->ptr, "absolute"))
- flag |= KEYINGSET_ABSOLUTE;
- if (RNA_boolean_get(op->ptr, "insertkey_needed"))
- keyingflag |= INSERTKEY_NEEDED;
- if (RNA_boolean_get(op->ptr, "insertkey_visual"))
- keyingflag |= INSERTKEY_MATRIX;
-
- /* call the API func, and set the active keyingset index */
- ks= BKE_keyingset_add(&sce->keyingsets, name, flag, keyingflag);
-
- if (ks) {
- sce->active_keyingset= BLI_countlist(&sce->keyingsets);
- return OPERATOR_FINISHED;
- }
- else {
- BKE_report(op->reports, RPT_ERROR, "Keying Set could not be added.");
- return OPERATOR_CANCELLED;
- }
-}
-
-void ANIM_OT_keyingset_add_new (wmOperatorType *ot)
-{
- /* identifiers */
- ot->name= "Add Keying Set";
- ot->idname= "ANIM_OT_keyingset_add_new";
-
- /* callbacks */
- ot->exec= keyingset_add_new_exec;
- ot->poll= ED_operator_scene_editable;
-
- /* props */
- /* name */
- RNA_def_string(ot->srna, "name", "KeyingSet", 64, "Name", "Name of Keying Set");
- /* flags */
- RNA_def_boolean(ot->srna, "absolute", 1, "Absolute", "Keying Set defines specific paths/settings to be keyframed (i.e. is not reliant on context info)");
- /* keying flags */
- RNA_def_boolean(ot->srna, "insertkey_needed", 0, "Insert Keyframes - Only Needed", "Only insert keyframes where they're needed in the relevant F-Curves.");
- RNA_def_boolean(ot->srna, "insertkey_visual", 0, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'.");
-}
-
/* UI API --------------------------------------------- */
/* Build menu-string of available keying-sets (allocates memory for string)
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 64672e3502b..4bc24a0adeb 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -154,15 +154,6 @@ struct KeyingSet *ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, cha
/* Initialise builtin KeyingSets on startup */
void init_builtin_keyingsets(void);
-/* -------- */
-
-/* KeyingSet Editing Operators:
- * These can add a new KeyingSet and/or add 'destinations' to the KeyingSets,
- * acting as a means by which they can be added outside the Outliner.
- */
-void ANIM_OT_keyingset_add_new(struct wmOperatorType *ot);
-void ANIM_OT_keyingset_add_destination(struct wmOperatorType *ot);
-
/* ************ Drivers ********************** */
/* Main Driver Management API calls:
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index 46d8c50caa6..06be0e69be5 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -41,6 +41,8 @@ extern EnumPropertyItem boidrule_type_items[];
extern EnumPropertyItem beztriple_handle_type_items[];
extern EnumPropertyItem beztriple_interpolation_mode_items[];
+extern EnumPropertyItem keyingset_path_grouping_items[];
+
extern EnumPropertyItem fmodifier_type_items[];
extern EnumPropertyItem nla_mode_extend_items[];
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 83178f32d5f..fa3a5a40686 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -1942,7 +1942,7 @@ RNAProcessItem PROCESS_ITEMS[]= {
{"rna_ID.c", NULL, RNA_def_ID},
{"rna_texture.c", NULL, RNA_def_texture},
{"rna_action.c", NULL, RNA_def_action},
- {"rna_animation.c", NULL, RNA_def_animation},
+ {"rna_animation.c", "rna_animation_api.c", RNA_def_animation},
{"rna_actuator.c", NULL, RNA_def_actuator},
{"rna_armature.c", NULL, RNA_def_armature},
{"rna_boid.c", NULL, RNA_def_boid},
@@ -1975,7 +1975,7 @@ RNAProcessItem PROCESS_ITEMS[]= {
{"rna_pose.c", NULL, RNA_def_pose},
{"rna_property.c", NULL, RNA_def_gameproperty},
{"rna_render.c", NULL, RNA_def_render},
- {"rna_scene.c", NULL, RNA_def_scene},
+ {"rna_scene.c", "rna_scene_api.c", RNA_def_scene},
{"rna_screen.c", NULL, RNA_def_screen},
{"rna_sculpt_paint.c", NULL, RNA_def_sculpt_paint},
{"rna_sensor.c", NULL, RNA_def_sensor},
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index e334e2b5e90..7652987ac86 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -36,6 +36,14 @@
#include "MEM_guardedalloc.h"
+/* exported for use in API */
+EnumPropertyItem keyingset_path_grouping_items[] = {
+ {KSP_GROUP_NAMED, "NAMED", 0, "Named Group", ""},
+ {KSP_GROUP_NONE, "NONE", 0, "None", ""},
+ {KSP_GROUP_KSNAME, "KEYINGSET", 0, "Keying Set Name", ""},
+ {KSP_GROUP_TEMPLATE_ITEM, "TEMPLATE", 0, "Innermost Context-Item Name", ""},
+ {0, NULL, 0, NULL, NULL}};
+
#ifdef RNA_RUNTIME
static int rna_AnimData_action_editable(PointerRNA *ptr)
@@ -90,13 +98,6 @@ void rna_def_keyingset_path(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static EnumPropertyItem prop_mode_grouping_items[] = {
- {KSP_GROUP_NAMED, "NAMED", 0, "Named Group", ""},
- {KSP_GROUP_NONE, "NONE", 0, "None", ""},
- {KSP_GROUP_KSNAME, "KEYINGSET", 0, "Keying Set Name", ""},
- {KSP_GROUP_TEMPLATE_ITEM, "TEMPLATE", 0, "Innermost Context-Item Name", ""},
- {0, NULL, 0, NULL, NULL}};
-
srna= RNA_def_struct(brna, "KeyingSetPath", NULL);
RNA_def_struct_sdna(srna, "KS_Path");
RNA_def_struct_ui_text(srna, "Keying Set Path", "Path to a setting for use in a Keying Set.");
@@ -112,7 +113,7 @@ void rna_def_keyingset_path(BlenderRNA *brna)
/* Grouping */
prop= RNA_def_property(srna, "grouping", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "groupmode");
- RNA_def_property_enum_items(prop, prop_mode_grouping_items);
+ RNA_def_property_enum_items(prop, keyingset_path_grouping_items);
RNA_def_property_ui_text(prop, "Grouping Method", "Method used to define which Group-name to use.");
/* Path + Array Index */
@@ -170,7 +171,8 @@ void rna_def_keyingset(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "keyingflag", INSERTKEY_MATRIX);
RNA_def_property_ui_text(prop, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'.");
-
+ /* Keying Set API */
+ RNA_api_keyingset(srna);
}
/* --- */
diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c
new file mode 100644
index 00000000000..6af87335e02
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_animation_api.c
@@ -0,0 +1,89 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Joshua Leung
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+#include "RNA_types.h"
+
+#include "DNA_anim_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#ifdef RNA_RUNTIME
+
+#include "BKE_animsys.h"
+
+static void rna_KeyingSet_add_destination(KeyingSet *keyingset, ReportList *reports,
+ ID *id, char rna_path[], int array_index, int entire_array,
+ int grouping_method, char group_name[])
+{
+ short flag = 0;
+
+ /* validate flags */
+ if (entire_array)
+ flag |= KSP_FLAG_WHOLE_ARRAY;
+
+ /* if data is valid, call the API function for this */
+ if (keyingset) {
+ BKE_keyingset_add_destination(keyingset, id, group_name, rna_path, array_index, flag, grouping_method);
+ }
+ else {
+ BKE_report(reports, RPT_ERROR, "Keying Set Destination could not be added.");
+ }
+}
+
+#else
+
+void RNA_api_keyingset(StructRNA *srna)
+{
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ /* Add Destination */
+ func= RNA_def_function(srna, "add_destination", "rna_KeyingSet_add_destination");
+ RNA_def_function_ui_description(func, "Add a new destination for the Keying Set.");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ /* ID-block for target */
+ parm= RNA_def_pointer(func, "target_id", "ID", "Target ID", "ID-Datablock for the destination.");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ /* rna-path */
+ parm= RNA_def_string(func, "rna_path", "", 256, "RNA-Path", "RNA-Path to destination property."); // xxx hopefully this is long enough
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm=RNA_def_int(func, "array_index", 0, 0, INT_MAX, "Array Index", "If applicable, the index ", 0, INT_MAX);
+ /* flags */
+ parm=RNA_def_boolean(func, "entire_array", 1, "Entire Array", "When an 'array/vector' type is chosen (Location, Rotation, Color, etc.), entire array is to be used.");
+ /* grouping */
+ parm=RNA_def_enum(func, "grouping_method", keyingset_path_grouping_items, KSP_GROUP_KSNAME, "Grouping Method", "Method used to define which Group-name to use.");
+ parm=RNA_def_string(func, "group_name", "", 64, "Group Name", "Name of Action Group to assign destination to (only if grouping mode is to use this name).");
+}
+
+#endif
+
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 579441691ff..bd28085692f 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -197,9 +197,11 @@ void rna_Object_update_data(struct bContext *C, struct PointerRNA *ptr);
/* API functions */
+void RNA_api_keyingset(struct StructRNA *srna);
void RNA_api_main(struct StructRNA *srna);
void RNA_api_mesh(struct StructRNA *srna);
void RNA_api_object(struct StructRNA *srna);
+void RNA_api_scene(struct StructRNA *srna);
void RNA_api_ui_layout(struct StructRNA *srna);
void RNA_api_wm(struct StructRNA *srna);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 40e3efc9e46..592836c8278 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -1995,6 +1995,9 @@ void RNA_def_scene(BlenderRNA *brna)
rna_def_scene_render_data(brna);
rna_def_scene_game_data(brna);
rna_def_scene_render_layer(brna);
+
+ /* Scene API */
+ RNA_api_scene(srna);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
new file mode 100644
index 00000000000..26047ab5dc3
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -0,0 +1,100 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Joshua Leung
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+#include "RNA_types.h"
+
+#include "DNA_anim_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#ifdef RNA_RUNTIME
+
+#include "BKE_animsys.h"
+
+// Scene API stuff from kazanbas branch here...
+
+
+static KeyingSet *rna_Scene_add_keying_set(Scene *sce, ReportList *reports,
+ char name[], int absolute, int insertkey_needed, int insertkey_visual)
+{
+ KeyingSet *ks= NULL;
+ short flag=0, keyingflag=0;
+
+ /* validate flags */
+ if (absolute)
+ flag |= KEYINGSET_ABSOLUTE;
+ if (insertkey_needed)
+ keyingflag |= INSERTKEY_NEEDED;
+ if (insertkey_visual)
+ keyingflag |= INSERTKEY_MATRIX;
+
+ /* call the API func, and set the active keyingset index */
+ ks= BKE_keyingset_add(&sce->keyingsets, name, flag, keyingflag);
+
+ if (ks) {
+ sce->active_keyingset= BLI_countlist(&sce->keyingsets);
+ return ks;
+ }
+ else {
+ BKE_report(reports, RPT_ERROR, "Keying Set could not be added.");
+ return NULL;
+ }
+}
+
+#else
+
+void RNA_api_scene(StructRNA *srna)
+{
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ // Scene API stuff from kazanbas branch here...
+
+ /* Add Keying Set */
+ func= RNA_def_function(srna, "add_keying_set", "rna_Scene_add_keying_set");
+ RNA_def_function_ui_description(func, "Add a new Keying Set to Scene.");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ /* returns the new KeyingSet */
+ parm= RNA_def_pointer(func, "keyingset", "KeyingSet", "", "Newly created Keying Set.");
+ RNA_def_function_return(func, parm);
+ /* name */
+ RNA_def_string(func, "name", "KeyingSet", 64, "Name", "Name of Keying Set");
+ /* flags */
+ RNA_def_boolean(func, "absolute", 1, "Absolute", "Keying Set defines specific paths/settings to be keyframed (i.e. is not reliant on context info)");
+ /* keying flags */
+ RNA_def_boolean(func, "insertkey_needed", 0, "Insert Keyframes - Only Needed", "Only insert keyframes where they're needed in the relevant F-Curves.");
+ RNA_def_boolean(func, "insertkey_visual", 0, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'.");
+}
+
+#endif
+