summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Seibert <stan@mtrr.org>2012-01-20 14:31:13 -0500
committertlatorre <tlatorre@uchicago.edu>2021-05-09 08:42:38 -0700
commitc1b6aad3f3e6ba7299cd352999ba1c8f82cf9367 (patch)
tree220436571ba910bc9bc0a54dc54d5a47ea6cc81a
parent93d1f42c5c803c3da27312823ec19dedc8f16aa2 (diff)
downloadchroma-c1b6aad3f3e6ba7299cd352999ba1c8f82cf9367.tar.gz
chroma-c1b6aad3f3e6ba7299cd352999ba1c8f82cf9367.tar.bz2
chroma-c1b6aad3f3e6ba7299cd352999ba1c8f82cf9367.zip
Do not save the BVH when caching the geometry.
-rw-r--r--chroma/cache.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/chroma/cache.py b/chroma/cache.py
index 392e434..5a00df2 100644
--- a/chroma/cache.py
+++ b/chroma/cache.py
@@ -99,11 +99,17 @@ class Cache(object):
def save_geometry(self, name, geometry):
'''Save ``geometry`` in the cache with the name ``name``.'''
geo_file = self.get_geometry_filename(name)
- with open(geo_file, 'wb') as output_file:
- pickle.dump(geometry.mesh.md5(), output_file,
- pickle.HIGHEST_PROTOCOL)
- pickle.dump(geometry, output_file,
- pickle.HIGHEST_PROTOCOL)
+ # exclude saving the BVH
+ bvh = geometry.bvh
+ try:
+ geometry.bvh = None
+ with open(geo_file, 'wb') as output_file:
+ pickle.dump(geometry.mesh.md5(), output_file,
+ pickle.HIGHEST_PROTOCOL)
+ pickle.dump(geometry, output_file,
+ pickle.HIGHEST_PROTOCOL)
+ finally:
+ geometry.bvh = bvh
def load_geometry(self, name):
'''Returns the chroma.geometry.Geometry object associated with