summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Seibert <stan@mtrr.org>2013-03-13 15:10:51 -0400
committertlatorre <tlatorre@uchicago.edu>2021-05-09 08:42:39 -0700
commitecf4fd5c775c8eb83e8c87088f94b5c2261ed87c (patch)
treef7c4450d4b9426672a1e451953e31655bc35e05a
parentdbe35efc3b26b8df6b1db05974c2b976b1c171ba (diff)
downloadchroma-ecf4fd5c775c8eb83e8c87088f94b5c2261ed87c.tar.gz
chroma-ecf4fd5c775c8eb83e8c87088f94b5c2261ed87c.tar.bz2
chroma-ecf4fd5c775c8eb83e8c87088f94b5c2261ed87c.zip
Force merging of BVH nodes to always reduce the number of parent nodes in order to ensure the process terminates.
-rw-r--r--chroma/gpu/bvh.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/chroma/gpu/bvh.py b/chroma/gpu/bvh.py
index 5e75a1e..c777c56 100644
--- a/chroma/gpu/bvh.py
+++ b/chroma/gpu/bvh.py
@@ -57,7 +57,7 @@ def create_leaf_nodes(mesh, morton_bits=16, round_to_multiple=1):
# Call GPU to compute nodes
nodes = ga.zeros(shape=round_up_to_multiple(len(triangles),
- 1),#round_to_multiple),
+ round_to_multiple),
dtype=ga.vec.uint4)
morton_codes = ga.empty(shape=len(triangles), dtype=np.uint64)
@@ -229,7 +229,10 @@ def merge_nodes(nodes, degree, max_ratio=None):
#print 'intermediate: %e' % node_areas(new_parent_nodes).max()
print 'old: %e' % node_areas(parent_nodes).max()
print 'new: %e' % node_areas(new_parent_nodes).max()
- parent_nodes = new_parent_nodes
+ if len(new_parent_nodes) < len(nodes):
+ # Only adopt new set of parent nodes if it actually reduces the
+ # total number of nodes at this level by 1.
+ parent_nodes = new_parent_nodes
return parent_nodes