Cycles: Make light behavior in local view matching BI
authorSergey Sharybin <sergey.vfx@gmail.com>
Sun, 11 Oct 2015 14:59:51 +0000 (19:59 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Sun, 11 Oct 2015 15:16:53 +0000 (20:16 +0500)
Title says it all, based on feedback of artists from gooseberry team.

This mainly affects cases when going to a local view from layers setup
when some lamps were on invisible layers. Those lights are no longer
becoming visible to the object in local view.

Reviewers: brecht, juicyfruit, dingto

Reviewed By: juicyfruit, dingto

Subscribers: maxon, eyecandy, venomgfx

Differential Revision: https://developer.blender.org/D1326

intern/cycles/blender/blender_object.cpp
intern/cycles/blender/blender_util.h

index 432c4aaa078666fbe953913dc7d12cd8f58fe3f9..7dc57c33ed315fc99942dc69d7f7fc38679af76b 100644 (file)
@@ -558,11 +558,20 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, float motion_time)
        bool cancel = false;
        bool use_portal = false;
 
+       uint layer_override = get_layer(b_engine.layer_override());
        for(; b_sce && !cancel; b_sce = b_sce.background_set()) {
+               /* Render layer's scene_layer is affected by local view already,
+                * which is not a desired behavior here.
+                */
+               uint scene_layers = layer_override ? layer_override : get_layer(b_scene.layers());
                for(b_sce.object_bases.begin(b_base); b_base != b_sce.object_bases.end() && !cancel; ++b_base) {
                        BL::Object b_ob = b_base->object();
                        bool hide = (render_layer.use_viewport_visibility)? b_ob.hide(): b_ob.hide_render();
-                       uint ob_layer = get_layer(b_base->layers(), b_base->layers_local_view(), render_layer.use_localview, object_is_light(b_ob));
+                       uint ob_layer = get_layer(b_base->layers(),
+                                                 b_base->layers_local_view(),
+                                                 render_layer.use_localview,
+                                                 object_is_light(b_ob),
+                                                 scene_layers);
                        hide = hide || !(ob_layer & scene_layer);
 
                        if(!hide) {
index 165242d0dffac8c7a70805f5de8b0e3605604826..bd1c37a756083eaa5bfd6ed658f096f727b39088 100644 (file)
@@ -196,7 +196,11 @@ static inline uint get_layer(BL::Array<int, 20> array)
        return layer;
 }
 
-static inline uint get_layer(BL::Array<int, 20> array, BL::Array<int, 8> local_array, bool use_local, bool is_light = false)
+static inline uint get_layer(BL::Array<int, 20> array,
+                             BL::Array<int, 8> local_array,
+                             bool use_local,
+                             bool is_light = false,
+                             uint scene_layers = (1 << 20) - 1)
 {
        uint layer = 0;
 
@@ -205,9 +209,13 @@ static inline uint get_layer(BL::Array<int, 20> array, BL::Array<int, 8> local_a
                        layer |= (1 << i);
 
        if(is_light) {
-               /* consider lamps on all local view layers */
-               for(uint i = 0; i < 8; i++)
-                       layer |= (1 << (20+i));
+               /* Consider light is visible if it was visible without layer
+                * override, which matches behavior of Blender Internal.
+                */
+               if(layer & scene_layers) {
+                       for(uint i = 0; i < 8; i++)
+                               layer |= (1 << (20+i));
+               }
        }
        else {
                for(uint i = 0; i < 8; i++)