diff options
Diffstat (limited to 'intern/cycles/bvh/bvh.cpp')
-rw-r--r-- | intern/cycles/bvh/bvh.cpp | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index ac0614e3659..af012bbf3ac 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -127,10 +127,26 @@ void BVH::build(Progress& progress, Stats*) pack.prim_time, params, progress); - BVHNode *root = bvh_build.run(); + BVHNode *bvh2_root = bvh_build.run(); if(progress.get_cancel()) { - if(root) root->deleteSubtree(); + if(bvh2_root != NULL) { + bvh2_root->deleteSubtree(); + } + return; + } + + /* BVH builder returns tree in a binary mode (with two children per inner + * node. Need to adopt that for a wider BVH implementations. */ + BVHNode *root = widen_children_nodes(bvh2_root); + if(root != bvh2_root) { + bvh2_root->deleteSubtree(); + } + + if(progress.get_cancel()) { + if(root != NULL) { + root->deleteSubtree(); + } return; } @@ -232,37 +248,6 @@ void BVH::refit_primitives(int start, int end, BoundBox& bbox, uint& visibility) } } -bool BVH::leaf_check(const BVHNode *node, BVH_TYPE bvh) -{ - if(node->is_leaf()) { - return node->is_unaligned; - } - else { - return node_is_unaligned(node, bvh); - } -} - -bool BVH::node_is_unaligned(const BVHNode *node, BVH_TYPE bvh) -{ - const BVHNode *node0 = node->get_child(0); - const BVHNode *node1 = node->get_child(1); - - switch(bvh) { - case bvh2: - return node0->is_unaligned || node1->is_unaligned; - break; - case bvh4: - return leaf_check(node0, bvh2) || leaf_check(node1, bvh2); - break; - case bvh8: - return leaf_check(node0, bvh4) || leaf_check(node1, bvh4); - break; - default: - assert(0); - return false; - } -} - /* Triangles */ void BVH::pack_triangle(int idx, float4 tri_verts[3]) |