[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24206] branches/soc-2008-mxcurioni/source /blender: * Removed a back pointer to a Scene (the "current" scene as in Blender

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Sun Nov 1 02:11:15 CET 2009


Revision: 24206
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24206
Author:   kjym3
Date:     2009-11-01 02:11:15 +0100 (Sun, 01 Nov 2009)

Log Message:
-----------
* Removed a back pointer to a Scene (the "current" scene as in Blender
2.4x) from within Freestyle.  Now Freestyle configuration parameters
are edited without relying on the notion of the current scene.  This
resolved a few related issues as described below:

- A bug in Freestyle configuration management with respect to
multiple scenes was fixed.  Now Freestyle configuration parameters
(e.g., style modules, ridges/valleys, suggestive contours) can be
specified for each render layer of each scene.  Composition of
multiple render layers from different scenes should work as expected.

- A crash after undoing was fixed as well.

* Removed unused external Freestyle functions and global variables
from FRS_freestyle.h and FRS_freestyle.cpp.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/blender.c
    branches/soc-2008-mxcurioni/source/blender/editors/render/render_shading.c
    branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp

Modified: branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/blender.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/blender.c	2009-11-01 00:06:53 UTC (rev 24205)
+++ branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/blender.c	2009-11-01 01:11:15 UTC (rev 24206)
@@ -654,9 +654,6 @@
 /* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */
 void BKE_undo_step(bContext *C, int step)
 {
-	
-	FRS_initialize(C);
-	
 	if(step==0) {
 		read_undosave(C, curundo);
 	}

Modified: branches/soc-2008-mxcurioni/source/blender/editors/render/render_shading.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/editors/render/render_shading.c	2009-11-01 00:06:53 UTC (rev 24205)
+++ branches/soc-2008-mxcurioni/source/blender/editors/render/render_shading.c	2009-11-01 01:11:15 UTC (rev 24206)
@@ -686,9 +686,9 @@
 static int freestyle_module_add_exec(bContext *C, wmOperator *op)
 {
 	Scene *scene= CTX_data_scene(C);
+	SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 
-	printf("freestyle_module_add_exec\n");
-	FRS_add_module();
+	FRS_add_module(&srl->freestyleConfig);
 
 	WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 	
@@ -712,11 +712,11 @@
 static int freestyle_module_remove_exec(bContext *C, wmOperator *op)
 {
 	Scene *scene= CTX_data_scene(C);
+	SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 	PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
 	FreestyleModuleConfig *module= ptr.data;
 
-	printf("freestyle_module_remove_exec\n");
-	FRS_delete_module(module, NULL);
+	FRS_delete_module(&srl->freestyleConfig, module);
 
 	WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 	
@@ -740,13 +740,13 @@
 static int freestyle_module_move_up_exec(bContext *C, wmOperator *op)
 {
 	Scene *scene= CTX_data_scene(C);
+	SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 	PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
 	FreestyleModuleConfig *module= ptr.data;
 	int active = RNA_boolean_get(op->ptr, "active");
 
-	printf("freestyle_module_move_up_exec\n");
 	if(active)
-		FRS_move_up_module(module, NULL);
+		FRS_move_up_module(&srl->freestyleConfig, module);
 
 	WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 	
@@ -773,13 +773,13 @@
 static int freestyle_module_move_down_exec(bContext *C, wmOperator *op)
 {
 	Scene *scene= CTX_data_scene(C);
+	SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
 	PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
 	FreestyleModuleConfig *module= ptr.data;
 	int active = RNA_boolean_get(op->ptr, "active");
 
-	printf("freestyle_module_move_down_exec\n");
 	if(active)
-		FRS_move_down_module(module, NULL);
+		FRS_move_down_module(&srl->freestyleConfig, module);
 
 	WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
 	

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h	2009-11-01 00:06:53 UTC (rev 24205)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h	2009-11-01 01:11:15 UTC (rev 24206)
@@ -10,32 +10,21 @@
 	
 	#include "BKE_context.h"
 	
-	extern short freestyle_is_initialized;
-	
 	extern float freestyle_viewpoint[3];
 	extern float freestyle_mv[4][4];
 	extern float freestyle_proj[4][4];
 	extern int freestyle_viewport[4];
 
-	extern char* freestyle_current_module_path;
-	extern SceneRenderLayer* freestyle_current_layer;
-	extern ListBase* freestyle_modules;
-	extern int* freestyle_flags;
-	extern float* freestyle_sphere_radius;
-	extern float* freestyle_dkr_epsilon;
-	
 	// Rendering
 	void FRS_initialize(bContext* C);
 	void FRS_add_Freestyle( struct Render* re);
 	void FRS_exit();
 	
 	// Panel configuration
-	void FRS_select_layer( SceneRenderLayer* srl );
-	void FRS_add_module();
-	void FRS_delete_module(void *module_index_ptr, void *unused);
-	void FRS_move_up_module(void *module_index_ptr, void *unused);
-	void FRS_move_down_module(void *module_index_ptr, void *unused);
-	void FRS_set_module_path(void *module_index_ptr, void *unused);
+	void FRS_add_module(FreestyleConfig *config);
+	void FRS_delete_module(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
+	void FRS_move_up_module(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
+	void FRS_move_down_module(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
 	
 #ifdef __cplusplus
 }

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-01 00:06:53 UTC (rev 24205)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2009-11-01 01:11:15 UTC (rev 24206)
@@ -28,11 +28,10 @@
 #include "../../FRS_freestyle_config.h"
 
 	// Freestyle configuration
-	short freestyle_is_initialized = 0;
+	static short freestyle_is_initialized = 0;
 	static Config::Path *pathconfig = NULL;
 	static Controller *controller = NULL;
 	static AppView *view = NULL;
-	static Scene *current_scene = NULL;
 
 	// camera information
 	float freestyle_viewpoint[3];
@@ -40,15 +39,6 @@
 	float freestyle_proj[4][4];
 	int freestyle_viewport[4];
 	
-	// Panel configuration
-	char* freestyle_current_module_path = NULL;
-	SceneRenderLayer* freestyle_current_layer = NULL;
-
-	ListBase* freestyle_modules;
-	int* freestyle_flags;
-	float* freestyle_sphere_radius;
-	float* freestyle_dkr_epsilon;
-	
 	string default_module_path;
 
 	//=======================================================
@@ -57,24 +47,17 @@
 
 	void FRS_initialize(bContext* C){
 		
-		if( !freestyle_is_initialized ) {
+		if( freestyle_is_initialized )
+			return;
 
-			pathconfig = new Config::Path;
-			controller = new Controller(C);
-			view = new AppView;
-			controller->setView(view);
+		pathconfig = new Config::Path;
+		controller = new Controller(C);
+		view = new AppView;
+		controller->setView(view);
 			
-			default_module_path = pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py";
+		default_module_path = pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py";
 			
-			freestyle_is_initialized = 1;
-		}
-		
-		current_scene = CTX_data_scene(C);
-		if( !current_scene )
-			current_scene = (Scene*) CTX_data_main(C)->scene.first;
-		
-		FRS_select_layer( (SceneRenderLayer*) BLI_findlink(&current_scene->r.layers, current_scene->r.actlay) );
-		
+		freestyle_is_initialized = 1;
 	}
 	
 	void FRS_exit() {
@@ -216,7 +199,7 @@
 		init_view(re);
 		init_camera(re);
 		
-		for(srl= (SceneRenderLayer *)current_scene->r.layers.first; srl; srl= srl->next) {
+		for(srl= (SceneRenderLayer *)re->scene->r.layers.first; srl; srl= srl->next) {
 			if( !(srl->layflag & SCE_LAY_DISABLE) &&
 			 	srl->layflag & SCE_LAY_FRS &&
 				displayed_layer_count(srl) > 0       )
@@ -271,59 +254,32 @@
 		BLI_freelistN( &srl->freestyleConfig.modules );
 	}
 
-	void FRS_select_layer( SceneRenderLayer* srl )
-	{	
-		FreestyleConfig* config = &srl->freestyleConfig;
-		
-		freestyle_modules = &config->modules;
-		freestyle_flags = &config->flags;
-		freestyle_sphere_radius = &config->sphere_radius;
-		freestyle_dkr_epsilon = &config->dkr_epsilon;
-		
-		freestyle_current_layer = srl;
-		current_scene->freestyle_current_layer_number = BLI_findindex(&current_scene->r.layers, freestyle_current_layer);
-	}
-	
-	void FRS_add_module()
+	void FRS_add_module(FreestyleConfig *config)
 	{
 		FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) MEM_callocN( sizeof(FreestyleModuleConfig), "style module configuration");
-		BLI_addtail(freestyle_modules, (void*) module_conf);
+		BLI_addtail(&config->modules, (void*) module_conf);
 		
 		strcpy( module_conf->module_path, default_module_path.c_str() );
 		module_conf->is_displayed = 1;	
 	}
 	
-	void FRS_delete_module(void *module_index_ptr, void *unused)
+	void FRS_delete_module(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
 	{
-		FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) module_index_ptr;
-
-		BLI_freelinkN( freestyle_modules, module_conf);
+		BLI_freelinkN(&config->modules, module_conf);
 	}
 	
-	void FRS_move_up_module(void *module_index_ptr, void *unused)
+	void FRS_move_up_module(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
 	{
-		FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) module_index_ptr;
-
-		BLI_remlink(freestyle_modules, module_conf);
-		BLI_insertlink(freestyle_modules, module_conf->prev->prev, module_conf);
+		BLI_remlink(&config->modules, module_conf);
+		BLI_insertlink(&config->modules, module_conf->prev->prev, module_conf);
 	}
 	
-	void FRS_move_down_module(void *module_index_ptr, void *unused)
+	void FRS_move_down_module(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
 	{			
-		FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) module_index_ptr;
-		
-		BLI_remlink(freestyle_modules, module_conf);
-		BLI_insertlink(freestyle_modules, module_conf->next, module_conf);
+		BLI_remlink(&config->modules, module_conf);
+		BLI_insertlink(&config->modules, module_conf->next, module_conf);
 	}
-	
-	void FRS_set_module_path(void *module_index_ptr, void *unused)
-	{
-		FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr);
-		freestyle_current_module_path = module_conf->module_path;
-	}
-	
-	
-	
+
 #ifdef __cplusplus
 }
 #endif





More information about the Bf-blender-cvs mailing list