From 17c26ac3f4a3c67ec5ac4c848fa3aad73188a2e3 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 14 Feb 2016 20:56:29 -0500 Subject: [PATCH] Lightmap/Autocolor garbage collection --- korman/exporter/etlight.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/korman/exporter/etlight.py b/korman/exporter/etlight.py index d6fff0e..127e6f1 100644 --- a/korman/exporter/etlight.py +++ b/korman/exporter/etlight.py @@ -14,6 +14,7 @@ # along with Korman. If not, see . import bpy +from bpy.app.handlers import persistent from .mesh import _VERTEX_COLOR_LAYERS from ..helpers import * @@ -313,3 +314,21 @@ class LightBaker: else: for i in bpy.data.objects: i.select = i in objs + +@persistent +def _toss_garbage(scene): + """Removes all LIGHTMAPGEN and autocolor garbage before saving""" + for i in bpy.data.images: + if i.name.endswith("_LIGHTMAPGEN.png"): + i.user_clear() + bpy.data.images.remove(i) + for i in bpy.data.meshes: + for uv_tex in i.uv_textures: + if uv_tex.name == "LIGHTMAPGEN": + i.uv_textures.remove(uv_tex) + for vcol in i.vertex_colors: + if vcol.name == "autocolor": + i.vertex_colors.remove(vcol) + +# collects light baking garbage +bpy.app.handlers.save_pre.append(_toss_garbage)