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
This commit is contained in:
Sergey Sharybin 2016-06-06 09:15:34 +02:00
parent b62faa54de
commit 6046c03f5c
3 changed files with 21 additions and 0 deletions

View File

@ -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

View File

@ -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()

View File

@ -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 */