[Bf-blender-cvs] [df00529] master: Cycles: Fix missing mesh flags update when tweaking shaders

Sergey Sharybin noreply at git.blender.org
Thu Jul 28 12:51:48 CEST 2016


Commit: df0052964860ad98d1147400d256029d519a313b
Author: Sergey Sharybin
Date:   Thu Jul 28 12:37:44 2016 +0200
Branches: master
https://developer.blender.org/rBdf0052964860ad98d1147400d256029d519a313b

Cycles: Fix missing mesh flags update when tweaking shaders

This is a bit weak, but better than tagging whole mesh manager for update.

Maybe we'll solve such dual-look up in the future.

This commit finally solves T48963: Noise when changing Diffuse node to Emission node

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

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

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

diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index d97c1ae..ae6042c 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -220,10 +220,16 @@ bool LightManager::object_usable_as_light(Object *object) {
 		return false;
 	}
 	/* Skip if we have no emission shaders. */
-	if(!mesh->has_mis_emission) {
-		return false;
+	/* TODO(sergey): Ideally we want to avoid such duplicated loop, since it'll
+	 * iterate all mesh shaders twice (when counting and when calculating
+	 * triangle area.
+	 */
+	foreach(const Shader *shader, mesh->used_shaders) {
+		if(shader->use_mis && shader->has_surface_emission) {
+			return true;
+		}
 	}
-	return true;
+	return false;
 }
 
 void LightManager::device_update_distribution(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 74880f5..8b0ed9f 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -156,7 +156,6 @@ Mesh::Mesh()
 	geometry_flags = GEOMETRY_NONE;
 
 	has_volume = false;
-	has_mis_emission = false;
 	has_surface_bssrdf = false;
 }
 
@@ -1290,14 +1289,10 @@ void MeshManager::device_update_flags(Device * /*device*/,
 	/* update flags */
 	foreach(Mesh *mesh, scene->meshes) {
 		mesh->has_volume = false;
-		mesh->has_mis_emission = false;
 		foreach(const Shader *shader, mesh->used_shaders) {
 			if(shader->has_volume) {
 				mesh->has_volume = true;
 			}
-			if(shader->use_mis && shader->has_surface_emission) {
-				mesh->has_mis_emission = true;
-			}
 			if(shader->has_surface_bssrdf) {
 				mesh->has_surface_bssrdf = true;
 			}
diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h
index 8225463..0aea555 100644
--- a/intern/cycles/render/mesh.h
+++ b/intern/cycles/render/mesh.h
@@ -122,7 +122,6 @@ public:
 	array<bool> forms_quad; /* used to tell if triangle is part of a quad patch */
 
 	bool has_volume;  /* Set in the device_update_flags(). */
-	bool has_mis_emission;  /* Set in the device_update_flags(). */
 	bool has_surface_bssrdf;  /* Set in the device_update_flags(). */
 
 	array<float3> curve_keys;




More information about the Bf-blender-cvs mailing list