diff options
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/kernel/kernel_shader.h | 2 | ||||
-rw-r--r-- | intern/cycles/render/light.cpp | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index 570e0721268..9c59e1566a9 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -151,7 +151,7 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd, instanced = true; else #endif - sd->object = -sd->object-1; + sd->object = ~sd->object; #ifdef __INSTANCING__ } #endif diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 74943fd0ff7..c8206365373 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -109,7 +109,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen /* triangles */ size_t offset = 0; - size_t j = 0; + int j = 0; foreach(Object *object, scene->objects) { Mesh *mesh = object->mesh; @@ -128,7 +128,10 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen /* sum area */ if(have_emission) { Transform tfm = object->tfm; - int object_id = (mesh->transform_applied)? -j-1: j; + int object_id = j; + + if(mesh->transform_applied) + object_id = ~object_id; for(size_t i = 0; i < mesh->triangles.size(); i++) { Shader *shader = scene->shaders[mesh->shader[i]]; @@ -161,9 +164,9 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen if(!multi_light) { float lightarea = (totarea > 0.0f)? totarea/scene->lights.size(): 1.0f; - for(size_t i = 0; i < scene->lights.size(); i++, offset++) { + for(int i = 0; i < scene->lights.size(); i++, offset++) { distribution[offset].x = totarea; - distribution[offset].y = __int_as_float(-i-1); + distribution[offset].y = __int_as_float(~(int)i); distribution[offset].z = 1.0f; distribution[offset].w = scene->lights[i]->size; totarea += lightarea; |