From 285e082a772f99fc09e52bcc8e8dd95f66431a60 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 3 Aug 2016 12:38:25 +0200 Subject: [PATCH] Fix T49010: Portals don't work in recent Blender versions --- intern/cycles/render/light.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index ae6042cef34..4cd77f8c6e1 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -238,14 +238,19 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen /* count */ size_t num_lights = 0; + size_t num_portals = 0; size_t num_background_lights = 0; size_t num_triangles = 0; bool background_mis = false; foreach(Light *light, scene->lights) { - if(light->is_enabled) + if(light->is_enabled) { num_lights++; + } + if(light->is_portal) { + num_portals++; + } } foreach(Object *object, scene->objects) { @@ -435,9 +440,9 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen device->tex_alloc("__light_distribution", dscene->light_distribution); /* Portals */ - if(num_background_lights > 0 && light_index != num_lights) { + if(num_portals > 0) { kintegrator->portal_offset = light_index; - kintegrator->num_portals = num_lights - light_index; + kintegrator->num_portals = num_portals; kintegrator->portal_pdf = background_mis? 0.5f: 1.0f; } else { @@ -601,10 +606,10 @@ void LightManager::device_update_points(Device *device, Scene *scene) { int num_scene_lights = scene->lights.size(); - int num_lights = 0; + int num_lights = 0; foreach(Light *light, scene->lights) { - if(light->is_enabled) { + if(light->is_enabled || light->is_portal) { num_lights++; } }