[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24437] branches/soc-2008-mxcurioni/source : Improved context handling.
Tamito Kajiyama
rd6t-kjym at asahi-net.or.jp
Tue Nov 10 01:03:31 CET 2009
Revision: 24437
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24437
Author: kjym3
Date: 2009-11-10 01:03:31 +0100 (Tue, 10 Nov 2009)
Log Message:
-----------
Improved context handling. Previously FRS_initialize() was used for both
initializing Freestyle and specifying contexts, making the API a bit messy.
Now FRS_initialize() is only for initialization, and contexts are specified
by new FRS_set_context() function just before starting rendering.
Modified Paths:
--------------
branches/soc-2008-mxcurioni/source/blender/editors/screen/screen_ops.c
branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/PythonInterpreter.h
branches/soc-2008-mxcurioni/source/blender/windowmanager/intern/wm_files.c
branches/soc-2008-mxcurioni/source/creator/creator.c
Modified: branches/soc-2008-mxcurioni/source/blender/editors/screen/screen_ops.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/editors/screen/screen_ops.c 2009-11-09 23:41:48 UTC (rev 24436)
+++ branches/soc-2008-mxcurioni/source/blender/editors/screen/screen_ops.c 2009-11-10 00:03:31 UTC (rev 24437)
@@ -2671,6 +2671,9 @@
}
RE_test_break_cb(re, NULL, (int (*)(void *)) blender_test_break);
+ /* inform Freestyle of the context */
+ FRS_set_context(C);
+
if(RNA_boolean_get(op->ptr, "animation"))
RE_BlenderAnim(re, scene, scene->r.sfra, scene->r.efra, scene->frame_step);
else
@@ -2945,6 +2948,9 @@
/* handle UI stuff */
WM_cursor_wait(1);
+ /* inform Freestyle of the context */
+ FRS_set_context(C);
+
/* flush multires changes (for sculpt) */
multires_force_update(CTX_data_active_object(C));
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h 2009-11-09 23:41:48 UTC (rev 24436)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h 2009-11-10 00:03:31 UTC (rev 24437)
@@ -16,7 +16,8 @@
extern int freestyle_viewport[4];
// Rendering
- void FRS_initialize(bContext* C);
+ void FRS_initialize();
+ void FRS_set_context(bContext* C);
void FRS_add_Freestyle( struct Render* re);
void FRS_exit();
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.cpp 2009-11-09 23:41:48 UTC (rev 24436)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.cpp 2009-11-10 00:03:31 UTC (rev 24437)
@@ -71,7 +71,7 @@
-Controller::Controller(bContext* C)
+Controller::Controller()
{
const string sep(Config::DIR_SEP.c_str());
@@ -108,7 +108,7 @@
_Canvas = new AppCanvas;
- _inter = new PythonInterpreter(C);
+ _inter = new PythonInterpreter();
_EnableQI = true;
_ComputeRidges = true;
_ComputeSteerableViewMap = false;
@@ -175,6 +175,13 @@
_Canvas->setViewer(_pView);
}
+void Controller::setContext(bContext *C)
+{
+ PythonInterpreter* py_inter = dynamic_cast<PythonInterpreter*>(_inter);
+ assert(py_inter != 0);
+ py_inter->setContext(C);
+}
+
int Controller::LoadMesh(Render *re, SceneRenderLayer* srl)
{
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.h 2009-11-09 23:41:48 UTC (rev 24436)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.h 2009-11-10 00:03:31 UTC (rev 24437)
@@ -66,10 +66,11 @@
class Controller
{
public:
- Controller(bContext* C) ;
+ Controller() ;
~Controller() ;
void setView(AppView *iView);
+ void setContext(bContext *C);
//soc
void init_options();
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-11-09 23:41:48 UTC (rev 24436)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp 2009-11-10 00:03:31 UTC (rev 24437)
@@ -45,13 +45,13 @@
// Initialization
//=======================================================
- void FRS_initialize(bContext* C){
+ void FRS_initialize() {
if( freestyle_is_initialized )
return;
pathconfig = new Config::Path;
- controller = new Controller(C);
+ controller = new Controller();
view = new AppView;
controller->setView(view);
@@ -60,6 +60,11 @@
freestyle_is_initialized = 1;
}
+ void FRS_set_context(bContext* C) {
+ cout << "FRS_set_context: context 0x" << C << " scene 0x" << CTX_data_scene(C) << endl;
+ controller->setContext(C);
+ }
+
void FRS_exit() {
delete pathconfig;
delete controller;
@@ -205,7 +210,7 @@
displayed_layer_count(srl) > 0 )
{
cout << "\n----------------------------------------------------------" << endl;
- cout << "| "<< srl->name << endl;
+ cout << "| " << (re->scene->id.name+2) << "|" << srl->name << endl;
cout << "----------------------------------------------------------" << endl;
// prepare Freestyle:
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/PythonInterpreter.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/PythonInterpreter.h 2009-11-09 23:41:48 UTC (rev 24436)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/PythonInterpreter.h 2009-11-10 00:03:31 UTC (rev 24437)
@@ -51,9 +51,9 @@
{
public:
- PythonInterpreter(bContext* C) {
+ PythonInterpreter() {
_language = "Python";
- _context = C;
+ _context = 0;
//Py_Initialize();
}
@@ -61,6 +61,10 @@
//Py_Finalize();
}
+ void setContext(bContext *C) {
+ _context = C;
+ }
+
int interpretFile(const string& filename) {
initPath();
Modified: branches/soc-2008-mxcurioni/source/blender/windowmanager/intern/wm_files.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/windowmanager/intern/wm_files.c 2009-11-09 23:41:48 UTC (rev 24436)
+++ branches/soc-2008-mxcurioni/source/blender/windowmanager/intern/wm_files.c 2009-11-10 00:03:31 UTC (rev 24437)
@@ -89,8 +89,6 @@
#include "GPU_draw.h"
-#include "FRS_freestyle.h"
-
// XXX #include "BPY_extern.h"
#include "WM_api.h"
@@ -270,8 +268,6 @@
writeBlog();
}
- FRS_initialize(C);
-
// XXX undo_editmode_clear();
BKE_reset_undo();
BKE_write_undo(C, "original"); /* save current state */
@@ -331,9 +327,7 @@
strcpy(G.sce, scestr); /* restore */
wm_init_userdef();
- FRS_initialize(C);
-
/* When loading factory settings, the reset solid OpenGL lights need to be applied. */
GPU_default_lights();
Modified: branches/soc-2008-mxcurioni/source/creator/creator.c
===================================================================
--- branches/soc-2008-mxcurioni/source/creator/creator.c 2009-11-09 23:41:48 UTC (rev 24436)
+++ branches/soc-2008-mxcurioni/source/creator/creator.c 2009-11-10 00:03:31 UTC (rev 24437)
@@ -548,6 +548,10 @@
printf("Example: setenv BF_TIFF_LIB /usr/lib/libtiff.so\n");
}
+ /* initialize Freestyle */
+ FRS_initialize();
+ FRS_set_context(C);
+
/* OK we are ready for it */
for(a=1; a<argc; a++) {
@@ -842,7 +846,6 @@
if (G.background) {
int retval = BKE_read_file(C, argv[a], NULL, NULL);
- FRS_initialize(C);
/*we successfully loaded a blend file, get sure that
pointcache works */
More information about the Bf-blender-cvs
mailing list