Fix #35681: cycles excluded layers still got evaluated before and after
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 10 Jun 2013 13:53:38 +0000 (13:53 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 10 Jun 2013 13:53:38 +0000 (13:53 +0000)
rendering even if they were not used on any render layers.

intern/cycles/blender/addon/__init__.py
source/blender/editors/render/render_internal.c
source/blender/makesrna/intern/rna_render.c
source/blender/render/extern/include/RE_engine.h
source/blender/render/intern/source/external_engine.c

index 526c5658b93b7fa6cd7da4678012bcb2087571ad..e1015fa3ceecec0b9545ff500b688162057dd916 100644 (file)
@@ -40,6 +40,7 @@ class CyclesRender(bpy.types.RenderEngine):
     bl_label = "Cycles Render"
     bl_use_shading_nodes = True
     bl_use_preview = True
+    bl_use_exclude_layers = True
 
     def __init__(self):
         self.session = None
index 4b62eb7c645328ef1c16dc90f3e14a03fc20b6c1..da2f8bd2f9d5452e4fb5fffa396234109fee4b06 100644 (file)
@@ -422,7 +422,7 @@ static void render_endjob(void *rjv)
                free_main(rj->main);
 
        /* else the frame will not update for the original value */
-       if (!(rj->scene->r.scemode & R_NO_FRAME_UPDATE)) {
+       if (rj->anim && !(rj->scene->r.scemode & R_NO_FRAME_UPDATE)) {
                /* possible this fails of loading new file while rendering */
                if (G.main->wm.first) {
                        ED_update_for_newframe(G.main, rj->scene, 1);
index 8cf352311f7c77816270c1b8f9c6bcc67d0c547f..90c0282545ccb8c4f3094c8e4b1b7374b6b85b08 100644 (file)
@@ -452,6 +452,10 @@ static void rna_def_render_engine(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_SHADING_NODES);
        RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
 
+       prop = RNA_def_property(srna, "bl_use_exclude_layers", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_EXCLUDE_LAYERS);
+       RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+
        RNA_define_verify_sdna(1);
 }
 
index 7c1bc4d12d695275dc4742dcaabe0be21b1cd21a..b6c3668512b613aaab9a1946e79e7eacac342056 100644 (file)
@@ -56,6 +56,7 @@ struct Scene;
 #define RE_USE_PREVIEW                 4
 #define RE_USE_POSTPROCESS             8
 #define RE_USE_SHADING_NODES   16
+#define RE_USE_EXCLUDE_LAYERS  32
 
 /* RenderEngine.flag */
 #define RE_ENGINE_ANIMATION            1
index b76e67dd63421bc7932805df6401f59bb88216da..551f36863702bbafdee52e04e55df7d98f66bb2b 100644 (file)
@@ -410,8 +410,30 @@ int RE_engine_render(Render *re, int do_all)
 
        /* update animation here so any render layer animation is applied before
         * creating the render result */
-       if ((re->r.scemode & (R_NO_FRAME_UPDATE | R_BUTS_PREVIEW)) == 0)
-               BKE_scene_update_for_newframe(re->main, re->scene, re->lay);
+       if ((re->r.scemode & (R_NO_FRAME_UPDATE | R_BUTS_PREVIEW)) == 0) {
+               unsigned int lay = re->lay;
+
+               /* don't update layers excluded on all render layers */
+               if (type->flag & RE_USE_EXCLUDE_LAYERS) {
+                       SceneRenderLayer *srl;
+                       unsigned int non_excluded_lay = 0;
+
+                       if (re->r.scemode & R_SINGLE_LAYER) {
+                               srl = BLI_findlink(&re->r.layers, re->r.actlay);
+                               if (srl)
+                                       non_excluded_lay |= ~srl->lay_exclude;
+                       }
+                       else {
+                               for (srl = re->r.layers.first; srl; srl = srl->next)
+                                       if (!(srl->layflag & SCE_LAY_DISABLE))
+                                               non_excluded_lay |= ~srl->lay_exclude;
+                       }
+
+                       lay &= non_excluded_lay;
+               }
+
+               BKE_scene_update_for_newframe(re->main, re->scene, lay);
+       }
 
        /* create render result */
        BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);