diff options
author | Anthony LaTorre <devnull@localhost> | 2012-11-13 16:18:39 -0600 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2021-05-09 08:42:39 -0700 |
commit | b2d6faa0ecd2f995f332f439228124ee74436915 (patch) | |
tree | 4806fc98747ff310c1e61b6095e40145d6fde0b3 | |
parent | 6409152c14938324acb64cdb6ccb601385c80ea8 (diff) | |
download | chroma-b2d6faa0ecd2f995f332f439228124ee74436915.tar.gz chroma-b2d6faa0ecd2f995f332f439228124ee74436915.tar.bz2 chroma-b2d6faa0ecd2f995f332f439228124ee74436915.zip |
add get_bounds() method to BVHLayerSlice so that you can now view your bvh's by pressing page up/page down again
-rw-r--r-- | chroma/bvh/bvh.py | 13 | ||||
-rw-r--r-- | chroma/camera.py | 3 |
2 files changed, 14 insertions, 2 deletions
diff --git a/chroma/bvh/bvh.py b/chroma/bvh/bvh.py index 6575fd6..053b347 100644 --- a/chroma/bvh/bvh.py +++ b/chroma/bvh/bvh.py @@ -244,3 +244,16 @@ class BVHLayerSlice(object): '''Return the surface area of all the nodes in this layer in world units.''' return self.area_fixed().sum() * self.world_coords.world_scale**2 + + def get_bounds(self): + """Returns the lower and upper bounds of this layer in the BVH.""" + node_info = unpack_nodes(self.nodes) + fixed_lower = \ + np.dstack([node_info[s] for s in ['xlo','ylo','zlo']]).squeeze() + fixed_upper = \ + np.dstack([node_info[s] for s in ['xhi','yhi','zhi']]).squeeze() + + lower_bounds = self.world_coords.fixed_to_world(fixed_lower) + upper_bounds = self.world_coords.fixed_to_world(fixed_upper) + + return np.atleast_2d(lower_bounds), np.atleast_2d(upper_bounds) diff --git a/chroma/camera.py b/chroma/camera.py index 92e2e82..6f47df0 100644 --- a/chroma/camera.py +++ b/chroma/camera.py @@ -24,8 +24,7 @@ import pygame from pygame.locals import * def bvh_mesh(geometry, layer): - lower_bounds = geometry.lower_bounds[geometry.layers == layer] - upper_bounds = geometry.upper_bounds[geometry.layers == layer] + lower_bounds, upper_bounds = geometry.bvh.get_layer(layer).get_bounds() if len(lower_bounds) == 0 or len(upper_bounds) == 0: raise Exception('no nodes at layer %i' % layer) |