From cdb84534e5b9edd044cb015acd39cd19fb304163 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sun, 1 Nov 2009 01:11:15 +0000 Subject: [PATCH] * 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. --- source/blender/blenkernel/intern/blender.c | 3 - .../blender/editors/render/render_shading.c | 16 ++-- source/blender/freestyle/FRS_freestyle.h | 19 +--- .../blender_interface/FRS_freestyle.cpp | 86 +++++-------------- 4 files changed, 33 insertions(+), 91 deletions(-) diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 60943cbf3b1..fa6d528ea40 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -654,9 +654,6 @@ void BKE_write_undo(bContext *C, char *name) /* 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); } diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index b00cf6c13f1..11cf451b0ae 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -686,9 +686,9 @@ void SCENE_OT_render_layer_remove(wmOperatorType *ot) 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 @@ void SCENE_OT_freestyle_module_add(wmOperatorType *ot) 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 @@ void SCENE_OT_freestyle_module_remove(wmOperatorType *ot) 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 @@ void SCENE_OT_freestyle_module_move_up(wmOperatorType *ot) 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); diff --git a/source/blender/freestyle/FRS_freestyle.h b/source/blender/freestyle/FRS_freestyle.h index 96696b9cc1f..73aae416819 100644 --- a/source/blender/freestyle/FRS_freestyle.h +++ b/source/blender/freestyle/FRS_freestyle.h @@ -10,32 +10,21 @@ extern "C" { #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 } diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 48cecd1ab4f..8c5d7b0288a 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -28,11 +28,10 @@ extern "C" { #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 @@ extern "C" { 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 @@ extern "C" { 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(¤t_scene->r.layers, current_scene->r.actlay) ); - + freestyle_is_initialized = 1; } void FRS_exit() { @@ -216,7 +199,7 @@ extern "C" { 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 @@ extern "C" { 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(¤t_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