summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chroma/geometry.py5
-rw-r--r--chroma/loader.py12
2 files changed, 12 insertions, 5 deletions
diff --git a/chroma/geometry.py b/chroma/geometry.py
index a7e85ee..41b24a9 100644
--- a/chroma/geometry.py
+++ b/chroma/geometry.py
@@ -238,6 +238,11 @@ class Geometry(object):
This does not build the BVH! If you want to use the geometry
for rendering or simulation, you should call build() instead.
"""
+
+ # Don't run this function twice!
+ if hasattr(self, 'mesh'):
+ return
+
nv = np.cumsum([0] + [len(solid.mesh.vertices) for solid in self.solids])
nt = np.cumsum([0] + [len(solid.mesh.triangles) for solid in self.solids])
diff --git a/chroma/loader.py b/chroma/loader.py
index 6a0bf87..e5ff6ed 100644
--- a/chroma/loader.py
+++ b/chroma/loader.py
@@ -141,6 +141,7 @@ def load_bvh(geometry, bvh_name="default",
bvh = None
if read_bvh_cache and cache.exist_bvh(mesh_hash, bvh_name):
logger.info('Loading BVH "%s" for geometry from cache.' % bvh_name)
+ import pdb; pdb.set_trace()
bvh = cache.load_bvh(mesh_hash, bvh_name)
elif auto_build_bvh:
logger.info('Building new BVH using simple algorithm.')
@@ -181,10 +182,11 @@ def create_geometry_from_obj(obj, bvh_name="default",
geometry.flatten()
- geometry.bvh = load_bvh(geometry, auto_build_bvh=auto_build_bvh,
- read_bvh_cache=read_bvh_cache,
- update_bvh_cache=update_bvh_cache,
- cache_dir=cache_dir,
- cuda_device=cuda_device)
+ if geometry.bvh is None:
+ geometry.bvh = load_bvh(geometry, auto_build_bvh=auto_build_bvh,
+ read_bvh_cache=read_bvh_cache,
+ update_bvh_cache=update_bvh_cache,
+ cache_dir=cache_dir,
+ cuda_device=cuda_device)
return geometry