fix for cycles bug in localview: see r48269, bits used for localview gave collisions...
authorCampbell Barton <ideasman42@gmail.com>
Mon, 23 Jul 2012 14:48:19 +0000 (14:48 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 23 Jul 2012 14:48:19 +0000 (14:48 +0000)
intern/cycles/blender/blender_object.cpp
intern/cycles/blender/blender_sync.cpp
intern/cycles/blender/blender_sync.h
intern/cycles/kernel/kernel_types.h

index a928bd9a6ea98a7df3dcfdf7707e0b3061d90016..242f7c8ecefb3ecd0838d28a4fb830a0b62551aa 100644 (file)
@@ -306,6 +306,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
                for(b_sce.objects.begin(b_ob); b_ob != b_sce.objects.end(); ++b_ob) {
                        bool hide = (render_layer.use_viewport_visibility)? b_ob->hide(): b_ob->hide_render();
                        uint ob_layer = get_layer(b_ob->layers(), b_ob->layers_local_view(), object_is_light(*b_ob));
+                       CYCLES_LOCAL_LAYER_HACK(render_layer.use_localview, ob_layer);
                        hide = hide || !(ob_layer & scene_layer);
 
                        if(!hide) {
index c9d2d68da0ab604d2c2bed8a82345641676a112d..ae28453a69684858ac2db3d63718c2f338f54a70 100644 (file)
@@ -219,7 +219,9 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer)
                        layer = layername.c_str();
                }
                else {
+                       render_layer.use_localview = (b_v3d.local_view() ? true : false);
                        render_layer.scene_layer = get_layer(b_v3d.layers(), b_v3d.layers_local_view());
+                       CYCLES_LOCAL_LAYER_HACK(render_layer.use_localview, render_layer.scene_layer);
                        render_layer.layer = render_layer.scene_layer;
                        render_layer.holdout_layer = 0;
                        render_layer.material_override = PointerRNA_NULL;
@@ -245,6 +247,7 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer)
                        render_layer.material_override = b_rlay->material_override();
                        render_layer.use_background = b_rlay->use_sky();
                        render_layer.use_viewport_visibility = false;
+                       render_layer.use_localview = false;
                        render_layer.samples = b_rlay->samples();
                }
 
index 8c31c4b86baa62419e51137e10cfe316fb7963b6..1a6c04db10c184f9c09c8658ce006cca1a67d012 100644 (file)
@@ -127,10 +127,25 @@ private:
                BL::Material material_override;
                bool use_background;
                bool use_viewport_visibility;
+               bool use_localview;
                int samples;
        } render_layer;
 };
 
+/* we don't have spare bits for localview (normally 20-28)
+ * because PATH_RAY_LAYER_SHIFT uses 20-32.
+ * So - check if we have localview and if so, shift local
+ * view bits down to 1-8, since this is done for the view
+ * port only - it should be OK and not conflict with
+ * render layers. - Campbell.
+ *
+ * ... as an alternative we could use uint64_t
+ */
+#define CYCLES_LOCAL_LAYER_HACK(use_localview, layer)   \
+       if (use_localview) {                                \
+               layer >>= 20;                                   \
+       } (void)0
+
 CCL_NAMESPACE_END
 
 #endif /* __BLENDER_SYNC_H__ */
index d204b114b8e5a5e51370f9a4804956e5ebc32f48..30d45ad111895ffa0c295635e3031e80381ca3c7 100644 (file)
@@ -172,6 +172,8 @@ enum PathRayFlag {
 
        PATH_RAY_ALL = (1|2|4|8|16|32|64|128|256|512),
 
+       /* this gives collisions with localview bits
+        * see: CYCLES_LOCAL_LAYER_HACK(), grr - Campbell */
        PATH_RAY_LAYER_SHIFT = (32-20)
 };