From 72a4cf179eed11deffd7de98b3912b672221a5ef Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 3 Sep 2018 20:15:19 -0400 Subject: [PATCH] Add export-time texcache controls Now you can turn off the texture cache entirely or force a recache of the entire age... :) --- korman/exporter/convert.py | 4 ++++ korman/exporter/image.py | 9 +++++++-- korman/operators/op_export.py | 11 ++++++++++- korman/ui/ui_world.py | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/korman/exporter/convert.py b/korman/exporter/convert.py index f0647fb..98f1cea 100644 --- a/korman/exporter/convert.py +++ b/korman/exporter/convert.py @@ -360,3 +360,7 @@ class Exporter: filepath = str(Path(filepath).with_suffix(".ktc")) age.texcache_path = filepath return filepath + + @property + def texcache_method(self): + return bpy.context.scene.world.plasma_age.texcache_method diff --git a/korman/exporter/image.py b/korman/exporter/image.py index fff107e..908b4d0 100644 --- a/korman/exporter/image.py +++ b/korman/exporter/image.py @@ -68,7 +68,7 @@ class ImageCache: self._stream_handles = 0 def add_texture(self, key, num_levels, export_size, compression, data): - if key.ephemeral: + if key.ephemeral or self._exporter().texcache_method == "skip": return image = _CachedImage() image.name = str(key) @@ -98,7 +98,7 @@ class ImageCache: self._read_stream.close() def get_from_texture(self, texture, compression): - if texture.ephemeral: + if self._exporter().texcache_method != "use" or texture.ephemeral: return None key = (str(texture), compression) @@ -123,6 +123,8 @@ class ImageCache: return cached_image def load(self): + if self._exporter().texcache_method == "skip": + return try: with self: self._read(self._read_stream) @@ -223,6 +225,9 @@ class ImageCache: return self._exporter().report def save(self): + if self._exporter().texcache_method == "skip": + return + # TODO: add a way to preserve unused images for a brief period so we don't toss # already cached images that are only removed from the age temporarily... self._compact() diff --git a/korman/operators/op_export.py b/korman/operators/op_export.py index d06def1..97f2e44 100644 --- a/korman/operators/op_export.py +++ b/korman/operators/op_export.py @@ -49,7 +49,15 @@ class ExportOperator(bpy.types.Operator): "description": "Forces the Blender System Console open during the export", "default": True}), - "texcache_path": (StringProperty, {"name": "Texture Cache"}), + "texcache_path": (StringProperty, {"name": "Texture Cache Path", + "description": "Texture Cache Filepath"}), + + "texcache_method": (EnumProperty, {"name": "Texture Cache", + "description": "Texture Cache Settings", + "items": [("skip", "Don't Use Texture Cache", "The texture cache is neither used nor updated."), + ("use", "Use Texture Cache", "Use (and update, if needed) cached textures."), + ("rebuild", "Rebuild Texture Cache", "Rebuilds the texture cache from scratch.")], + "default": "use"}), } # This wigs out and very bad things happen if it's not directly on the operator... @@ -68,6 +76,7 @@ class ExportOperator(bpy.types.Operator): # The crazy mess we're doing with props on the fly means we have to explicitly draw them :( layout.prop(self, "version") + layout.prop(age, "texcache_method", text="") layout.prop(age, "bake_lighting") row = layout.row() row.enabled = ConsoleToggler.is_platform_supported() diff --git a/korman/ui/ui_world.py b/korman/ui/ui_world.py index 333dbbc..6cac4e4 100644 --- a/korman/ui/ui_world.py +++ b/korman/ui/ui_world.py @@ -133,6 +133,7 @@ class PlasmaAgePanel(AgeButtonsPanel, bpy.types.Panel): col = split.column() col.label("Export Settings:") + col.prop(age, "texcache_method", text="") col.prop(age, "bake_lighting") cons_ui = col.column() cons_ui.enabled = ConsoleToggler.is_platform_supported()