diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_scene.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 44 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 2 | ||||
-rw-r--r-- | source/blender/editors/render/render_shading.c | 29 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 36 |
5 files changed, 82 insertions, 33 deletions
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index ad394f9fb1a..7cb31505430 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -44,6 +44,7 @@ struct Main; struct Object; struct QuicktimeCodecData; struct RenderData; +struct SceneRenderLayer; struct Scene; struct Text; struct Text; @@ -93,7 +94,8 @@ void scene_clear_tagged(struct Main *bmain, struct Scene *sce); void scene_update_for_newframe(struct Main *bmain, struct Scene *sce, unsigned int lay); -void scene_add_render_layer(struct Scene *sce); +struct SceneRenderLayer *scene_add_render_layer(struct Scene *sce, const char *name); +int scene_remove_render_layer(struct Main *main, struct Scene *scene, struct SceneRenderLayer *srl); /* render profile */ int get_render_subsurf_level(struct RenderData *r, int level); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 8b8c974cdc8..eefc5e09dbb 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -44,6 +44,7 @@ #include "DNA_anim_types.h" #include "DNA_group_types.h" +#include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" @@ -483,7 +484,7 @@ Scene *add_scene(const char *name) sce->r.osa= 8; /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */ - scene_add_render_layer(sce); + scene_add_render_layer(sce, NULL); /* game data */ sce->gm.stereoflag = STEREO_NOSTEREO; @@ -1086,13 +1087,16 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) } /* return default layer, also used to patch old files */ -void scene_add_render_layer(Scene *sce) +SceneRenderLayer *scene_add_render_layer(Scene *sce, const char *name) { SceneRenderLayer *srl; // int tot= 1 + BLI_countlist(&sce->r.layers); - + + if(!name) + name= "RenderLayer"; + srl= MEM_callocN(sizeof(SceneRenderLayer), "new render layer"); - strcpy(srl->name, "RenderLayer"); + strcpy(srl->name, name); BLI_uniquename(&sce->r.layers, srl, "RenderLayer", '.', offsetof(SceneRenderLayer, name), sizeof(srl->name)); BLI_addtail(&sce->r.layers, srl); @@ -1100,6 +1104,38 @@ void scene_add_render_layer(Scene *sce) srl->lay= (1<<20) -1; srl->layflag= 0x7FFF; /* solid ztra halo edge strand */ srl->passflag= SCE_PASS_COMBINED|SCE_PASS_Z; + + return srl; +} + +int scene_remove_render_layer(Main *main, Scene *scene, SceneRenderLayer *srl) +{ + Scene *sce; + int act= BLI_findindex(&scene->r.layers, srl); + + if(BLI_countlist(&scene->r.layers) <= 1) + return 0; + + BLI_remlink(&scene->r.layers, srl); + MEM_freeN(srl); + + scene->r.actlay= 0; + + for(sce = main->scene.first; sce; sce = sce->id.next) { + if(sce->nodetree) { + bNode *node; + for(node = sce->nodetree->nodes.first; node; node = node->next) { + if(node->type==CMP_NODE_R_LAYERS && (Scene*)node->id==scene) { + if(node->custom1==act) + node->custom1= 0; + else if(node->custom1>act) + node->custom1--; + } + } + } + } + + return 1; } /* render simplification */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 79ab90d06fb..4a530be58db 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8947,7 +8947,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if(sce->r.yparts<2) sce->r.yparts= 4; /* adds default layer */ if(sce->r.layers.first==NULL) - scene_add_render_layer(sce); + scene_add_render_layer(sce, NULL); else { SceneRenderLayer *srl; /* new layer flag for sky, was default for solid */ diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 80c54d970b4..e2e48a489b6 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -519,7 +519,7 @@ static int render_layer_add_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); - scene_add_render_layer(scene); + scene_add_render_layer(scene, NULL); scene->r.actlay= BLI_countlist(&scene->r.layers) - 1; WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); @@ -543,32 +543,11 @@ void SCENE_OT_render_layer_add(wmOperatorType *ot) static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene = CTX_data_scene(C), *sce; - SceneRenderLayer *rl; - int act= scene->r.actlay; + Scene *scene = CTX_data_scene(C); + SceneRenderLayer *rl = BLI_findlink(&scene->r.layers, scene->r.actlay); - if(BLI_countlist(&scene->r.layers) <= 1) + if(!scene_remove_render_layer(CTX_data_main(C), scene, rl)) return OPERATOR_CANCELLED; - - rl= BLI_findlink(&scene->r.layers, scene->r.actlay); - BLI_remlink(&scene->r.layers, rl); - MEM_freeN(rl); - - scene->r.actlay= 0; - - for(sce = CTX_data_main(C)->scene.first; sce; sce = sce->id.next) { - if(sce->nodetree) { - bNode *node; - for(node = sce->nodetree->nodes.first; node; node = node->next) { - if(node->type==CMP_NODE_R_LAYERS && (Scene*)node->id==scene) { - if(node->custom1==act) - node->custom1= 0; - else if(node->custom1>act) - node->custom1--; - } - } - } - } WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 2d3944a5b07..1bb184c9433 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -734,6 +734,25 @@ static void rna_RenderSettings_active_layer_set(PointerRNA *ptr, PointerRNA valu if (index != -1) rd->actlay= index; } +static SceneRenderLayer *rna_RenderLayer_add(ID *id, RenderData *UNUSED(rd), const char *name) +{ + Scene *scene= (Scene *)id; + SceneRenderLayer *srl= scene_add_render_layer(scene, name); + + WM_main_add_notifier(NC_SCENE|ND_RENDER_OPTIONS, NULL); + + return srl; +} + +static void rna_RenderLayer_remove(ID *id, RenderData *UNUSED(rd), Main *bmain, SceneRenderLayer *srl) +{ + Scene *scene= (Scene *)id; + + scene_remove_render_layer(bmain, scene, srl); + + WM_main_add_notifier(NC_SCENE|ND_RENDER_OPTIONS, NULL); +} + static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value) { RenderData *rd= (RenderData*)ptr->data; @@ -2186,8 +2205,8 @@ static void rna_def_render_layers(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; PropertyRNA *prop; - // FunctionRNA *func; - // PropertyRNA *parm; + FunctionRNA *func; + PropertyRNA *parm; RNA_def_property_srna(cprop, "RenderLayers"); srna= RNA_def_struct(brna, "RenderLayers", NULL); @@ -2209,6 +2228,19 @@ static void rna_def_render_layers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_ui_text(prop, "Active Render Layer", "Active Render Layer"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + func= RNA_def_function(srna, "new", "rna_RenderLayer_add"); + RNA_def_function_ui_description(func, "Add a render layer to scene"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); + parm= RNA_def_string(func, "name", "RenderLayer", 0, "", "New name for the marker (not unique)"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "render_layer", "SceneRenderLayer", "", "Newly created render layer"); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove", "rna_RenderLayer_remove"); + RNA_def_function_ui_description(func, "Remove a render layer"); + RNA_def_function_flag(func, FUNC_USE_MAIN|FUNC_USE_SELF_ID); + parm= RNA_def_pointer(func, "layer", "SceneRenderLayer", "", "Timeline marker to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } static void rna_def_scene_render_data(BlenderRNA *brna) |