Browse Source

Add export-time texcache controls

Now you can turn off the texture cache entirely or force a recache of
the entire age... :)
pull/117/head
Adam Johnson 6 years ago
parent
commit
72a4cf179e
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 4
      korman/exporter/convert.py
  2. 9
      korman/exporter/image.py
  3. 11
      korman/operators/op_export.py
  4. 1
      korman/ui/ui_world.py

4
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

9
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()

11
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()

1
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()

Loading…
Cancel
Save