[Bf-blender-cvs] [6046c03] master: Cycles: Ignore zero size instances in BVH

Sergey Sharybin noreply at git.blender.org
Mon Jun 6 09:23:37 CEST 2016


Commit: 6046c03f5c2847f8eaac30fbe1c507e50340aad2
Author: Sergey Sharybin
Date:   Mon Jun 6 09:15:34 2016 +0200
Branches: master
https://developer.blender.org/rB6046c03f5c2847f8eaac30fbe1c507e50340aad2

Cycles: Ignore zero size instances in BVH

In certain types of animation it's possible to have some objects
scaling to zero. In this case we can save render times by avoid
traversing such instances.

Better to do ti ahead of a time, so traversal stays simple.

Reviewers: lukasstockner97, dingto, brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D2048

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

M	intern/cycles/bvh/bvh_build.cpp
M	intern/cycles/render/object.cpp
M	intern/cycles/render/object.h

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

diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index 87a8899..d00de00 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -205,6 +205,9 @@ void BVHBuild::add_references(BVHRange& root)
 
 	foreach(Object *ob, objects) {
 		if(params.top_level) {
+			if(!ob->is_traceable()) {
+				continue;
+			}
 			if(!ob->mesh->is_instanced()) {
 				num_alloc_references += ob->mesh->num_triangles();
 				num_alloc_references += count_curve_segments(ob->mesh);
@@ -226,6 +229,9 @@ void BVHBuild::add_references(BVHRange& root)
 
 	foreach(Object *ob, objects) {
 		if(params.top_level) {
+			if(!ob->is_traceable()) {
+				continue;
+			}
 			if(!ob->mesh->is_instanced())
 				add_reference_mesh(bounds, center, ob->mesh, i);
 			else
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index 9ee1a9e..644e581 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -225,6 +225,16 @@ vector<float> Object::motion_times()
 	return times;
 }
 
+bool Object::is_traceable()
+{
+	/* Mesh itself can be empty,can skip all such objects. */
+	if (bounds.size() == make_float3(0.0f, 0.0f, 0.0f)) {
+		return false;
+	}
+	/* TODO(sergey): Check for mesh vertices/curves. visibility flags. */
+	return true;
+}
+
 /* Object Manager */
 
 ObjectManager::ObjectManager()
diff --git a/intern/cycles/render/object.h b/intern/cycles/render/object.h
index 57614c9..7ab73f3 100644
--- a/intern/cycles/render/object.h
+++ b/intern/cycles/render/object.h
@@ -68,6 +68,11 @@ public:
 	void apply_transform(bool apply_to_motion);
 
 	vector<float> motion_times();
+
+	/* Check whether object is traceable and it worth adding it to
+	 * kernel scene.
+	 */
+	bool is_traceable();
 };
 
 /* Object Manager */




More information about the Bf-blender-cvs mailing list