Fix #30061: cycles single render layer through python operator parameter not
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 7 Feb 2012 20:51:33 +0000 (20:51 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 7 Feb 2012 20:51:33 +0000 (20:51 +0000)
working.

intern/cycles/blender/blender_session.cpp
intern/cycles/blender/blender_sync.cpp
intern/cycles/blender/blender_sync.h

index 5ea3f2ce16edc7656cd173c8d0b81ce07a20d3c0..cc6ba0731880e002203ceb51c3b115245ed567cd 100644 (file)
@@ -191,14 +191,8 @@ void BlenderSession::render()
        BL::RenderResult::layers_iterator b_iter;
        BL::RenderLayers b_rr_layers(r.ptr);
        
-       int active = 0;
-
        /* render each layer */
-       for(b_rr.layers.begin(b_iter); b_iter != b_rr.layers.end(); ++b_iter, ++active) {
-               /* single layer render */
-               if(r.use_single_layer())
-                       active = b_rr_layers.active_index();
-
+       for(b_rr.layers.begin(b_iter); b_iter != b_rr.layers.end(); ++b_iter) {
                /* set layer */
                b_rlay = *b_iter;
 
@@ -226,7 +220,7 @@ void BlenderSession::render()
                session->reset(buffer_params, session_params.samples);
 
                /* update scene */
-               sync->sync_data(b_v3d, active);
+               sync->sync_data(b_v3d, b_iter->name().c_str());
 
                /* render */
                session->start();
index 29ab0ebef1f4c6e5767482bdc04b6c9173643ac5..91996d52bea1fe93d2f2d65f888b91b87028ea90 100644 (file)
@@ -122,7 +122,7 @@ bool BlenderSync::sync_recalc()
        return recalc;
 }
 
-void BlenderSync::sync_data(BL::SpaceView3D b_v3d, int layer)
+void BlenderSync::sync_data(BL::SpaceView3D b_v3d, const char *layer)
 {
        sync_render_layers(b_v3d);
        sync_integrator(layer);
@@ -133,7 +133,7 @@ void BlenderSync::sync_data(BL::SpaceView3D b_v3d, int layer)
 
 /* Integrator */
 
-void BlenderSync::sync_integrator(int layer)
+void BlenderSync::sync_integrator(const char *layer)
 {
        PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
 
@@ -155,7 +155,20 @@ void BlenderSync::sync_integrator(int layer)
 
        integrator->no_caustics = get_boolean(cscene, "no_caustics");
        integrator->seed = get_int(cscene, "seed");
-       integrator->layer_flag = render_layers[layer].layer;
+
+       /* render layer */
+       int active_layer = 0;
+
+       if(layer) {
+               for(int i = 0; i < render_layers.size(); i++) {
+                       if(render_layers[i].name == layer) {
+                               active_layer = i;
+                               break;
+                       }
+               }
+       }
+
+       integrator->layer_flag = render_layers[active_layer].layer;
 
        if(integrator->modified(previntegrator))
                integrator->tag_update(scene);
@@ -208,6 +221,7 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d)
                        /* single layer for now */
                        RenderLayerInfo rlay;
 
+                       rlay.name = b_rlay->name();
                        rlay.scene_layer = get_layer(b_scene.layers());
                        rlay.layer = get_layer(b_rlay->layers());
                        rlay.material_override = b_rlay->material_override();
index 5e76a0a0b1e858a349530504c5b4c228e7162e79..b0bd3004492d2ef51b3e6bd03b3528bd755844e9 100644 (file)
@@ -54,7 +54,7 @@ public:
 
        /* sync */
        bool sync_recalc();
-       void sync_data(BL::SpaceView3D b_v3d, int layer = 0);
+       void sync_data(BL::SpaceView3D b_v3d, const char *layer = 0);
        void sync_camera(int width, int height);
        void sync_view(BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height);
 
@@ -70,7 +70,7 @@ private:
        void sync_materials();
        void sync_objects(BL::SpaceView3D b_v3d);
        void sync_film();
-       void sync_integrator(int layer);
+       void sync_integrator(const char *layer);
        void sync_view();
        void sync_world();
        void sync_render_layers(BL::SpaceView3D b_v3d);
@@ -110,6 +110,7 @@ private:
                  material_override(PointerRNA_NULL)
                {}
 
+               string name;
                uint scene_layer;
                uint layer;
                BL::Material material_override;