Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-07-28 13:27:24 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-07-28 13:28:31 +0300
commitd3d1313ca4fff7566d84ba4f3495977791d8c895 (patch)
tree6bdb2374dc6fa662aae4ca32b63eba9e0a5afc7f /intern/cycles
parent87717c64490f3fe3a00e5df844f3d03923ceca34 (diff)
Cycles: De-duplicate more checks around light emisive meshes
Once again, should be no functional changes.
Diffstat (limited to 'intern/cycles')
-rw-r--r--intern/cycles/render/light.cpp54
-rw-r--r--intern/cycles/render/light.h4
2 files changed, 27 insertions, 31 deletions
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index 41af209226d..d97c1aefc89 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 2f1df1c9417..745caa96159 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