diff options
author | Stan Seibert <stan@mtrr.org> | 2012-02-06 11:25:39 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2021-05-09 08:42:38 -0700 |
commit | 630aecaaf9df6afb43ccd5f509ec3b8a118f40f2 (patch) | |
tree | a24c0172e933ba5d0b520324ca012b2f18b8e67d | |
parent | f1f102beae06f098e74073492b824da237f89fab (diff) | |
download | chroma-630aecaaf9df6afb43ccd5f509ec3b8a118f40f2.tar.gz chroma-630aecaaf9df6afb43ccd5f509ec3b8a118f40f2.tar.bz2 chroma-630aecaaf9df6afb43ccd5f509ec3b8a118f40f2.zip |
Rename node_area() to node_areas() and make it return the array of node areas
-rw-r--r-- | chroma/bvh/bvh.py | 14 | ||||
-rw-r--r-- | chroma/bvh/grid.py | 4 | ||||
-rw-r--r-- | chroma/bvh/simple.py | 2 |
3 files changed, 12 insertions, 8 deletions
diff --git a/chroma/bvh/bvh.py b/chroma/bvh/bvh.py index e8c128b..1c26088 100644 --- a/chroma/bvh/bvh.py +++ b/chroma/bvh/bvh.py @@ -196,8 +196,12 @@ class BVH(object): '''Returns the number of nodes in this BVH''' return len(self.nodes) -def node_area(nodes): - '''Returns the area of a list of nodes in fixed point units.''' +def node_areas(nodes): + '''Returns the areas of each node in an array of nodes in fixed point units. + + ``nodes``: ndarray(dtype=uint4) + array of packed BVH nodes + ''' unpacked = unpack_nodes(nodes) delta = np.empty(shape=len(nodes), dtype=[('x', float), ('y', float), ('z', float)]) @@ -207,7 +211,7 @@ def node_area(nodes): half_area = delta['x']*delta['y'] + delta['y']*delta['z'] \ + delta['z']*delta['x'] - return 2.0 * half_area.sum() + return 2.0 * half_area class BVHLayerSlice(object): '''A single layer in a bounding volume hierarchy represented as a slice @@ -232,9 +236,9 @@ class BVHLayerSlice(object): def area_fixed(self): '''Return the surface area of all the nodes in this layer in fixed point units.''' - return node_area(self.nodes) + return node_areas(self.nodes).sum() def area(self): '''Return the surface area of all the nodes in this layer in world units.''' - return self.area_fixed() * self.world_coords.world_scale**2 + return self.area_fixed().sum() * self.world_coords.world_scale**2 diff --git a/chroma/bvh/grid.py b/chroma/bvh/grid.py index 0b36a2f..5392976 100644 --- a/chroma/bvh/grid.py +++ b/chroma/bvh/grid.py @@ -1,4 +1,4 @@ -from chroma.bvh.bvh import BVH, node_area +from chroma.bvh.bvh import BVH, node_areas from chroma.gpu.bvh import create_leaf_nodes def make_recursive_grid_bvh(mesh, bits=11): @@ -23,6 +23,6 @@ def make_recursive_grid_bvh(mesh, bits=11): morton_codes[argsort] - print node_area(leaf_nodes) * world_coords.world_scale**2 + print node_areas(leaf_nodes).sum() * world_coords.world_scale**2 diff --git a/chroma/bvh/simple.py b/chroma/bvh/simple.py index 6ce45e7..f87f6d8 100644 --- a/chroma/bvh/simple.py +++ b/chroma/bvh/simple.py @@ -1,4 +1,4 @@ -from chroma.bvh.bvh import BVH, node_area +from chroma.bvh.bvh import BVH from chroma.gpu.bvh import create_leaf_nodes, merge_nodes, concatenate_layers def make_simple_bvh(mesh, degree): |