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:
Diffstat (limited to 'source/blender/makesrna/intern/rna_scene_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c78
1 files changed, 67 insertions, 11 deletions
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index 26047ab5dc3..40f2db6d4a4 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -1,5 +1,5 @@
/**
- * $Id:
+ * $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -21,7 +21,7 @@
* All rights reserved.
*
*
- * Contributor(s): Joshua Leung
+ * Contributor(s): Joshua Leung, Arystanbek Dyussenov
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -40,9 +40,49 @@
#ifdef RNA_RUNTIME
#include "BKE_animsys.h"
+#include "BKE_scene.h"
+#include "BKE_depsgraph.h"
-// Scene API stuff from kazanbas branch here...
+#include "ED_object.h"
+#include "WM_api.h"
+
+static void rna_Scene_add_object(Scene *sce, ReportList *reports, Object *ob)
+{
+ Base *base= object_in_scene(ob, sce);
+ if (base) {
+ BKE_report(reports, RPT_ERROR, "Object is already in this scene.");
+ return;
+ }
+ base= scene_add_base(sce, ob);
+ ob->id.us++;
+
+ /* this is similar to what object_add_type and add_object do */
+ ob->lay= base->lay= sce->lay;
+ ob->recalc |= OB_RECALC;
+
+ DAG_scene_sort(sce);
+}
+
+static void rna_Scene_remove_object(Scene *sce, ReportList *reports, Object *ob)
+{
+ Base *base= object_in_scene(ob, sce);
+ if (!base) {
+ BKE_report(reports, RPT_ERROR, "Object is not in this scene.");
+ return;
+ }
+ /* as long as ED_base_object_free_and_unlink calls free_libblock_us, we don't have to decrement ob->id.us */
+ ED_base_object_free_and_unlink(sce, base);
+}
+
+static void rna_Scene_set_frame(Scene *sce, bContext *C, int frame)
+{
+ sce->r.cfra= frame;
+ CLAMP(sce->r.cfra, MINAFRAME, MAXFRAME);
+ scene_update_for_newframe(sce, (1<<20) - 1);
+
+ WM_event_add_notifier(C, NC_SCENE|ND_FRAME, sce);
+}
static KeyingSet *rna_Scene_add_keying_set(Scene *sce, ReportList *reports,
char name[], int absolute, int insertkey_needed, int insertkey_visual)
@@ -77,21 +117,37 @@ void RNA_api_scene(StructRNA *srna)
{
FunctionRNA *func;
PropertyRNA *parm;
-
- // Scene API stuff from kazanbas branch here...
-
+
+ func= RNA_def_function(srna, "add_object", "rna_Scene_add_object");
+ RNA_def_function_ui_description(func, "Add object to scene.");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm= RNA_def_pointer(func, "object", "Object", "", "Object to add to scene.");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+
+ func= RNA_def_function(srna, "remove_object", "rna_Scene_remove_object");
+ RNA_def_function_ui_description(func, "Remove object from scene.");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove from scene.");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+
+ func= RNA_def_function(srna, "set_frame", "rna_Scene_set_frame");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately.");
+ parm= RNA_def_int(func, "frame", 0, MINAFRAME, MAXFRAME, "", "Frame number to set.", MINAFRAME, MAXFRAME);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+
/* 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 */
+ /* returns the new KeyingSet */
parm= RNA_def_pointer(func, "keyingset", "KeyingSet", "", "Newly created Keying Set.");
- RNA_def_function_return(func, parm);
- /* name */
+ RNA_def_function_return(func, parm);
+ /* name */
RNA_def_string(func, "name", "KeyingSet", 64, "Name", "Name of Keying Set");
- /* flags */
+ /* 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 */
+ /* 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'.");
}