Commit: d3d1313ca4fff7566d84ba4f3495977791d8c895
Author: Sergey Sharybin
Date:   Thu Jul 28 12:27:24 2016 +0200
Branches: master
https://developer.blender.org/rBd3d1313ca4fff7566d84ba4f3495977791d8c895

Cycles: De-duplicate more checks around light emisive meshes

Once again, should be no functional changes.

===================================================================

M       intern/cycles/render/light.cpp
M       intern/cycles/render/light.h

===================================================================

diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index 41af209..d97c1ae 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -209,6 +209,23 @@ void LightManager::disable_ineffective_light(Device 
*device, Scene *scene)
        }
 }
 
+bool LightManager::object_usable_as_light(Object *object) {
+       Mesh *mesh = object->mesh;
+       /* Skip if we are not visible for BSDFs. */
+       if(!(object->visibility & 
(PATH_RAY_DIFFUSE|PATH_RAY_GLOSSY|PATH_RAY_TRANSMIT))) {
+               return false;
+       }
+       /* Skip motion blurred deforming meshes, not supported yet. */
+       if(mesh->has_motion_blur()) {
+               return false;
+       }
+       /* Skip if we have no emission shaders. */
+       if(!mesh->has_mis_emission) {
+               return false;
+       }
+       return true;
+}
+
 void LightManager::device_update_distribution(Device *device, DeviceScene 
*dscene, Scene *scene, Progress& progress)
 {
        progress.set_status("Updating Lights", "Computing distribution");
@@ -226,23 +243,13 @@ void LightManager::device_update_distribution(Device 
*device, DeviceScene *dscen
        }
 
        foreach(Object *object, scene->objects) {
-               Mesh *mesh = object->mesh;
-
-               /* Skip if we are not visible for BSDFs. */
-               if(!(object->visibility & 
(PATH_RAY_DIFFUSE|PATH_RAY_GLOSSY|PATH_RAY_TRANSMIT)))
-                       continue;
-
-               /* Skip motion blurred deforming meshes, not supported yet. */
-               if(mesh->has_motion_blur()) {
-                       continue;
-               }
+               if(progress.get_cancel()) return;
 
-               /* Skip if we have no emission shaders. */
-               if(!mesh->has_mis_emission) {
+               if(!object_usable_as_light(object)) {
                        continue;
                }
-
                /* Count triangles. */
+               Mesh *mesh = object->mesh;
                size_t mesh_num_triangles = mesh->num_triangles();
                for(size_t i = 0; i < mesh_num_triangles; i++) {
                        int shader_index = mesh->shader[i];
@@ -270,27 +277,12 @@ void LightManager::device_update_distribution(Device 
*device, DeviceScene *dscen
        foreach(Object *object, scene->objects) {
                if(progress.get_cancel()) return;
 
-               Mesh *mesh = object->mesh;
-
-               /* Skip if we are not visible for BSDFs. */
-               if(!(object->visibility & 
(PATH_RAY_DIFFUSE|PATH_RAY_GLOSSY|PATH_RAY_TRANSMIT))) {
-                       j++;
-                       continue;
-               }
-
-               /* Skip motion blurred deforming meshes, not supported yet. */
-               if(mesh->has_motion_blur()) {
+               if(!object_usable_as_light(object)) {
                        j++;
                        continue;
                }
-
-               /* Skip if we have no emission shaders. */
-               if(!mesh->has_mis_emission) {
-                       j++;
-                       continue;
-               }
-
-               /* sum area */
+               /* Sum area. */
+               Mesh *mesh = object->mesh;
                bool transform_applied = mesh->transform_applied;
                Transform tfm = object->tfm;
                int object_id = j;
diff --git a/intern/cycles/render/light.h b/intern/cycles/render/light.h
index 2f1df1c..745caa9 100644
--- a/intern/cycles/render/light.h
+++ b/intern/cycles/render/light.h
@@ -28,6 +28,7 @@ CCL_NAMESPACE_BEGIN
 
 class Device;
 class DeviceScene;
+class Object;
 class Progress;
 class Scene;
 class Shader;
@@ -108,6 +109,9 @@ protected:
                                      DeviceScene *dscene,
                                      Scene *scene,
                                      Progress& progress);
+
+       /* Check whether light manager can use the object as a light-emissive. 
*/
+       bool object_usable_as_light(Object *object);
 };
 
 CCL_NAMESPACE_END

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to