diff options
-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) |