[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21521] branches/soc-2009-kazanbas: Added Scene.set_frame RNA function to get immediate scene update.

Arystanbek Dyussenov arystan.d at gmail.com
Sat Jul 11 13:58:50 CEST 2009


Revision: 21521
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21521
Author:   kazanbas
Date:     2009-07-11 13:58:50 +0200 (Sat, 11 Jul 2009)

Log Message:
-----------
Added Scene.set_frame RNA function to get immediate scene update.
Changing Scene.current_frame doesn't work in this case because it adds 
a notifier.

Also added RNA_property_update call in pyrna_struct_setattro so that 
notifiers are added when a property changes.

Modified Paths:
--------------
    branches/soc-2009-kazanbas/release/io/export_fbx.py
    branches/soc-2009-kazanbas/release/scripts/export_fbx.py
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/makesrna.c
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_action.c
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_pose_api.c
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_scene_api.c
    branches/soc-2009-kazanbas/source/blender/python/intern/bpy_rna.c

Added Paths:
-----------
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_action_api.c

Modified: branches/soc-2009-kazanbas/release/io/export_fbx.py
===================================================================
--- branches/soc-2009-kazanbas/release/io/export_fbx.py	2009-07-11 11:52:20 UTC (rev 21520)
+++ branches/soc-2009-kazanbas/release/io/export_fbx.py	2009-07-11 11:58:50 UTC (rev 21521)
@@ -2500,7 +2500,8 @@
 	
 	if ANIM_ENABLE and [tmp for tmp in ob_anim_lists if tmp]:
 		
-		frame_orig = Blender.Get('curframe')
+		frame_orig = sce.current_frame
+# 		frame_orig = Blender.Get('curframe')
 		
 		if ANIM_OPTIMIZE:
 			ANIM_OPTIMIZE_PRECISSION_FLOAT = 0.1 ** ANIM_OPTIMIZE_PRECISSION
@@ -2613,7 +2614,8 @@
 			'''
 			i = act_start
 			while i <= act_end:
-				Blender.Set('curframe', i)
+				sce.set_frame(i)
+# 				Blender.Set('curframe', i)
 				for ob_generic in ob_anim_lists:
 					for my_ob in ob_generic:
 						#Blender.Window.RedrawAll()

Modified: branches/soc-2009-kazanbas/release/scripts/export_fbx.py
===================================================================
--- branches/soc-2009-kazanbas/release/scripts/export_fbx.py	2009-07-11 11:52:20 UTC (rev 21520)
+++ branches/soc-2009-kazanbas/release/scripts/export_fbx.py	2009-07-11 11:58:50 UTC (rev 21521)
@@ -2445,7 +2445,8 @@
 	
 	if ANIM_ENABLE and [tmp for tmp in ob_anim_lists if tmp]:
 		
-		frame_orig = Blender.Get('curframe')
+		frame_orig = sce.current_frame
+# 		frame_orig = Blender.Get('curframe')
 		
 		if ANIM_OPTIMIZE:
 			ANIM_OPTIMIZE_PRECISSION_FLOAT = 0.1 ** ANIM_OPTIMIZE_PRECISSION

Modified: branches/soc-2009-kazanbas/source/blender/makesrna/intern/makesrna.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/makesrna/intern/makesrna.c	2009-07-11 11:52:20 UTC (rev 21520)
+++ branches/soc-2009-kazanbas/source/blender/makesrna/intern/makesrna.c	2009-07-11 11:58:50 UTC (rev 21521)
@@ -1897,7 +1897,7 @@
 	{"rna_rna.c", NULL, RNA_def_rna},
 	{"rna_ID.c", NULL, RNA_def_ID},
 	{"rna_texture.c", NULL, RNA_def_texture},
-	{"rna_action.c", NULL, RNA_def_action},
+	{"rna_action.c", "rna_action_api.c", RNA_def_action},
 	{"rna_animation.c", NULL, RNA_def_animation},
 	{"rna_actuator.c", NULL, RNA_def_actuator},
 	{"rna_armature.c", NULL, RNA_def_armature},

Modified: branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_action.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_action.c	2009-07-11 11:52:20 UTC (rev 21520)
+++ branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_action.c	2009-07-11 11:58:50 UTC (rev 21521)
@@ -100,6 +100,8 @@
 	RNA_def_property_collection_sdna(prop, NULL, "markers", NULL);
 	RNA_def_property_struct_type(prop, "TimelineMarker");
 	RNA_def_property_ui_text(prop, "Pose Markers", "Markers specific to this Action, for labeling poses.");
+
+	RNA_api_action(srna);
 }
 
 /* --------- */

Added: branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_action_api.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_action_api.c	                        (rev 0)
+++ branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_action_api.c	2009-07-11 11:58:50 UTC (rev 21521)
@@ -0,0 +1,48 @@
+/**
+ * ***** 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): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#include "RNA_define.h"
+#include "RNA_types.h"
+
+#include "DNA_action_types.h"
+
+#ifdef RNA_RUNTIME
+
+#else
+
+void RNA_api_action(StructRNA *srna)
+{
+	FunctionRNA *func;
+	PropertyRNA *parm;
+
+}
+
+#endif

Modified: branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_pose_api.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_pose_api.c	2009-07-11 11:52:20 UTC (rev 21520)
+++ branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_pose_api.c	2009-07-11 11:58:50 UTC (rev 21521)
@@ -1,6 +1,4 @@
 /**
- * 
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or

Modified: branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_scene_api.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_scene_api.c	2009-07-11 11:52:20 UTC (rev 21520)
+++ branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_scene_api.c	2009-07-11 11:58:50 UTC (rev 21521)
@@ -33,6 +33,7 @@
 #include "RNA_types.h"
 
 #include "DNA_object_types.h"
+#include "DNA_scene_types.h"
 
 #ifdef RNA_RUNTIME
 
@@ -67,6 +68,15 @@
 	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);
+}
+
 #else
 
 void RNA_api_scene(StructRNA *srna)
@@ -85,6 +95,12 @@
 	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);
 }
 
 #endif

Modified: branches/soc-2009-kazanbas/source/blender/python/intern/bpy_rna.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/python/intern/bpy_rna.c	2009-07-11 11:52:20 UTC (rev 21520)
+++ branches/soc-2009-kazanbas/source/blender/python/intern/bpy_rna.c	2009-07-11 11:58:50 UTC (rev 21521)
@@ -1311,6 +1311,7 @@
 {
 	char *name = _PyUnicode_AsString(pyname);
 	PropertyRNA *prop = RNA_struct_find_property(&self->ptr, name);
+	int ret;
 	
 	if (prop==NULL) {
 		if (!BPy_StructRNA_CheckExact(self) && PyObject_GenericSetAttr((PyObject *)self, pyname, value) >= 0) {
@@ -1328,7 +1329,11 @@
 	}
 		
 	/* pyrna_py_to_prop sets its own exceptions */
-	return pyrna_py_to_prop(&self->ptr, prop, NULL, value);
+	ret= pyrna_py_to_prop(&self->ptr, prop, NULL, value);
+	
+	RNA_property_update(BPy_GetContext(), &self->ptr, prop);
+
+	return ret;
 }
 
 static PyObject *pyrna_prop_keys(BPy_PropertyRNA *self)





More information about the Bf-blender-cvs mailing list