Cycles: add rendered draw mode option in 3d view header to show the active
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 28 Mar 2012 09:07:35 +0000 (09:07 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 28 Mar 2012 09:07:35 +0000 (09:07 +0000)
render layer rather than the viewport layers.

intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_sync.cpp
source/blender/makesrna/intern/rna_scene.c

index 86f726f7828312cf3e0965ebccc2d52ebd4ce72a..da4de1aeafd5053219657a6fe5bbbc83556e49b0 100644 (file)
@@ -74,6 +74,11 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
                 description="Pause all viewport preview renders",
                 default=False,
                 )
+        cls.preview_active_layer = BoolProperty(
+                name="Preview Active Layer",
+                description="Preview active render layer in viewport",
+                default=False,
+                )
 
         cls.no_caustics = BoolProperty(
                 name="No Caustics",
index 39f55aafa395196a155b6cf6e4ab8a1226bc3562..3b78be6c6c9fd5f80db8a22dffd99cf87cceed5b 100644 (file)
@@ -804,7 +804,9 @@ def draw_pause(self, context):
 
         if view.viewport_shade == 'RENDERED':
             cscene = scene.cycles
+            layername = scene.render.layers.active.name
             layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
+            layout.prop(cscene, "preview_active_layer", icon="RENDERLAYERS", text=layername)
 
 
 def get_panels():
index 9fb2c6e132888cb0cb0d39f8e76207fd82299a6e..e88f74eea68615e2fa32274a5189368da9998f09 100644 (file)
@@ -189,29 +189,42 @@ void BlenderSync::sync_film()
 
 void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer)
 {
+       string layername;
+
+       /* 3d view */
        if(b_v3d) {
-               render_layer.scene_layer = get_layer(b_v3d.layers());
-               render_layer.layer = render_layer.scene_layer;
-               render_layer.holdout_layer = 0;
-               render_layer.material_override = PointerRNA_NULL;
+               PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
+
+               if(RNA_boolean_get(&cscene, "preview_active_layer")) {
+                       BL::RenderLayers layers(b_scene.render().ptr);
+                       layername = layers.active().name();
+                       layer = layername.c_str();
+               }
+               else {
+                       render_layer.scene_layer = get_layer(b_v3d.layers());
+                       render_layer.layer = render_layer.scene_layer;
+                       render_layer.holdout_layer = 0;
+                       render_layer.material_override = PointerRNA_NULL;
+                       return;
+               }
        }
-       else {
-               BL::RenderSettings r = b_scene.render();
-               BL::RenderSettings::layers_iterator b_rlay;
-               bool first_layer = true;
-
-               for(r.layers.begin(b_rlay); b_rlay != r.layers.end(); ++b_rlay) {
-                       if((!layer && first_layer) || (layer && b_rlay->name() == layer)) {
-                               render_layer.name = b_rlay->name();
-                               render_layer.scene_layer = get_layer(b_scene.layers());
-                               render_layer.layer = get_layer(b_rlay->layers());
-                               render_layer.holdout_layer = get_layer(b_rlay->layers_zmask());
-                               render_layer.layer |= render_layer.holdout_layer;
-                               render_layer.material_override = b_rlay->material_override();
-                       }
 
-                       first_layer = false;
+       /* render layer */
+       BL::RenderSettings r = b_scene.render();
+       BL::RenderSettings::layers_iterator b_rlay;
+       bool first_layer = true;
+
+       for(r.layers.begin(b_rlay); b_rlay != r.layers.end(); ++b_rlay) {
+               if((!layer && first_layer) || (layer && b_rlay->name() == layer)) {
+                       render_layer.name = b_rlay->name();
+                       render_layer.scene_layer = get_layer(b_scene.layers());
+                       render_layer.layer = get_layer(b_rlay->layers());
+                       render_layer.holdout_layer = get_layer(b_rlay->layers_zmask());
+                       render_layer.layer |= render_layer.holdout_layer;
+                       render_layer.material_override = b_rlay->material_override();
                }
+
+               first_layer = false;
        }
 }
 
index a8c0bb97137d444e904b6f75655a85f75d369170..67710817de30e8e44d67cf7c261c42c480f95222 100644 (file)
@@ -1140,12 +1140,14 @@ static void rna_SceneRenderLayer_layer_set(PointerRNA *ptr, const int *values)
        rl->lay = ED_view3d_scene_layer_set(rl->lay, values, NULL);
 }
 
-static void rna_SceneRenderLayer_pass_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_SceneRenderLayer_pass_update(Main *bmain, Scene *activescene, PointerRNA *ptr)
 {
        Scene *scene = (Scene*)ptr->id.data;
 
        if (scene->nodetree)
                ntreeCompositForceHidden(scene->nodetree, scene);
+       
+       rna_Scene_glsl_update(bmain, activescene, ptr);
 }
 
 static void rna_Scene_use_nodes_set(PointerRNA *ptr, int value)
@@ -1884,14 +1886,14 @@ void rna_def_render_layer_common(StructRNA *srna, int scene)
        RNA_def_property_ui_text(prop, "Visible Layers", "Scene layers included in this render layer");
        if (scene) RNA_def_property_boolean_funcs(prop, NULL, "rna_SceneRenderLayer_layer_set");
        else RNA_def_property_boolean_funcs(prop, NULL, "rna_RenderLayer_layer_set");
-       if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
+       if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
        else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
        prop = RNA_def_property(srna, "layers_zmask", PROP_BOOLEAN, PROP_LAYER);
        RNA_def_property_boolean_sdna(prop, NULL, "lay_zmask", 1);
        RNA_def_property_array(prop, 20);
        RNA_def_property_ui_text(prop, "Zmask Layers", "Zmask scene layers for solid faces");
-       if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
+       if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
        else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
        /* layer options */
@@ -1904,14 +1906,14 @@ void rna_def_render_layer_common(StructRNA *srna, int scene)
        prop = RNA_def_property(srna, "use_zmask", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_ZMASK);
        RNA_def_property_ui_text(prop, "Zmask", "Only render what's in front of the solid z values");
-       if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
+       if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
        else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
        prop = RNA_def_property(srna, "invert_zmask", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_NEG_ZMASK);
        RNA_def_property_ui_text(prop, "Zmask Negate",
                                 "For Zmask, only render what is behind solid z values instead of in front");
-       if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
+       if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
        else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
        prop = RNA_def_property(srna, "use_all_z", PROP_BOOLEAN, PROP_NONE);
@@ -2685,7 +2687,7 @@ static void rna_def_render_layers(BlenderRNA *brna, PropertyRNA *cprop)
                                   "rna_RenderSettings_active_layer_index_set",
                                   "rna_RenderSettings_active_layer_index_range");
        RNA_def_property_ui_text(prop, "Active Layer Index", "Active index in render layer array");
-       RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
+       RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
        
        prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED);
        RNA_def_property_struct_type(prop, "SceneRenderLayer");
@@ -2693,7 +2695,7 @@ static void rna_def_render_layers(BlenderRNA *brna, PropertyRNA *cprop)
                                       "rna_RenderSettings_active_layer_set", NULL, NULL);
        RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_NULL);
        RNA_def_property_ui_text(prop, "Active Render Layer", "Active Render Layer");
-       RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
+       RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
 
        func = RNA_def_function(srna, "new", "rna_RenderLayer_new");
        RNA_def_function_ui_description(func, "Add a render layer to scene");