[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25155] branches/soc-2008-mxcurioni/source /blender/freestyle: Added Freestyle.getCurrentScene() to give access to the current scene

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Sun Dec 6 23:01:06 CET 2009


Revision: 25155
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25155
Author:   kjym3
Date:     2009-12-06 23:01:04 +0100 (Sun, 06 Dec 2009)

Log Message:
-----------
Added Freestyle.getCurrentScene() to give access to the current scene
from within style modules.  Calling this function is only valid within
style modules.  Calling it from the Python Interactive Console results
in an error as follows:

>>> import Freestyle
>>> Freestyle.getCurrentScene()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: current scene not available
>>> 

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/CMakeLists.txt
    branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Freestyle.cpp

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/CMakeLists.txt
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/CMakeLists.txt	2009-12-06 17:38:39 UTC (rev 25154)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/CMakeLists.txt	2009-12-06 22:01:04 UTC (rev 25155)
@@ -27,7 +27,8 @@
 FILE(GLOB_RECURSE SRC *.cpp)
 
 SET(INC 
-  ../blenkernel ../blenloader ../blenlib ../imbuf ../makesdna ../makesrna ../python
+  ../blenkernel ../blenloader ../blenlib ../imbuf ../makesdna ../makesrna
+  ../python ../python/intern
   ../render/extern/include ../render/intern/include ../include ../src
   ../../../extern/glew/include ../../../intern/guardedalloc ../freestyle
   ${PYTHON_INC}

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h	2009-12-06 17:38:39 UTC (rev 25154)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h	2009-12-06 22:01:04 UTC (rev 25155)
@@ -10,6 +10,7 @@
 	
 	#include "BKE_context.h"
 	
+	extern Scene *freestyle_scene;
 	extern float freestyle_viewpoint[3];
 	extern float freestyle_mv[4][4];
 	extern float freestyle_proj[4][4];

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript	2009-12-06 17:38:39 UTC (rev 25154)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript	2009-12-06 22:01:04 UTC (rev 25155)
@@ -6,7 +6,8 @@
 defs = []
 incs = ''
 
-incs += '../blenkernel ../blenloader ../blenlib ../imbuf ../makesdna ../makesrna ../python '
+incs += '../blenkernel ../blenloader ../blenlib ../imbuf ../makesdna ../makesrna'
+incs += '../python ../python/intern'
 incs += '../render/extern/include ../render/intern/include ../include ../src'
 incs += ' #/extern/glew/include #/intern/guardedalloc'
 incs += ' ' + env['BF_PYTHON_INC']	

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2009-12-06 17:38:39 UTC (rev 25154)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2009-12-06 22:01:04 UTC (rev 25155)
@@ -39,6 +39,9 @@
 	float freestyle_proj[4][4];
 	int freestyle_viewport[4];
 	
+	// current scene
+	Scene *freestyle_scene;
+
 	string default_module_path;
 
 	//=======================================================
@@ -54,6 +57,7 @@
 		controller = new Controller();
 		view = new AppView;
 		controller->setView(view);
+		freestyle_scene = NULL;
 			
 		default_module_path = pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py";
 			
@@ -203,6 +207,7 @@
 		
 		init_view(re);
 		init_camera(re);
+		freestyle_scene = re->scene;
 		
 		for(srl= (SceneRenderLayer *)re->scene->r.layers.first; srl; srl= srl->next) {
 			if( !(srl->layflag & SCE_LAY_DISABLE) &&
@@ -238,6 +243,7 @@
 			}
 		}
 		
+		freestyle_scene = NULL;
 	}
 
 	//=======================================================

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Freestyle.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Freestyle.cpp	2009-12-06 17:38:39 UTC (rev 25154)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Freestyle.cpp	2009-12-06 22:01:04 UTC (rev 25155)
@@ -33,6 +33,7 @@
 
 
 //static PyObject *Freestyle_testOutput( BPy_Freestyle * self );
+static PyObject *Freestyle_getCurrentScene( PyObject *self );
 
 /*-----------------------Freestyle module doc strings--------------------------*/
 
@@ -42,6 +43,7 @@
 
 static PyMethodDef module_functions[] = {
 //	{"testOutput", ( PyCFunction ) Freestyle_testOutput, METH_NOARGS, "() - Return Curve Data name"},
+	{"getCurrentScene", ( PyCFunction ) Freestyle_getCurrentScene, METH_NOARGS, "() - Return the current scene."},
 	{NULL, NULL, 0, NULL}
 };
 
@@ -99,6 +101,20 @@
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
+#include "FRS_freestyle.h"
+#include "bpy_rna.h" /* pyrna_struct_CreatePyObject() */
+
+static PyObject *Freestyle_getCurrentScene( PyObject *self )
+{
+	if (!freestyle_scene) {
+		PyErr_SetString(PyExc_TypeError, "current scene not available");
+		return NULL;
+	}
+	PointerRNA ptr_scene;
+	RNA_pointer_create(NULL, &RNA_Scene, freestyle_scene, &ptr_scene);
+	return pyrna_struct_CreatePyObject(&ptr_scene);
+}
+
 #ifdef __cplusplus
 }
 #endif





More information about the Bf-blender-cvs mailing list