From d27630f501679cb4f963c23057e48c13a5626622 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 17 Jul 2015 15:29:22 -0400 Subject: [PATCH] Delay manipulating the selection We may not be baking anything, so this can be a collosal waste of time. Observed speedups of several seconds in some ages. --- korman/exporter/mesh.py | 2 +- korman/helpers.py | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/korman/exporter/mesh.py b/korman/exporter/mesh.py index 9ae48e0..0662b8b 100644 --- a/korman/exporter/mesh.py +++ b/korman/exporter/mesh.py @@ -331,7 +331,7 @@ class MeshConverter: return geospans def _export_static_lighting(self, bo): - helpers.make_active_selection(bo) + bpy.context.scene.objects.active = bo mods = bo.plasma_modifiers lm = mods.lightmap if lm.enabled: diff --git a/korman/helpers.py b/korman/helpers.py index faaffea..4c6029c 100644 --- a/korman/helpers.py +++ b/korman/helpers.py @@ -59,6 +59,10 @@ def ensure_object_can_bake(bo, toggle): toggle.track(bo, "hide_render", False) toggle.track(bo, "hide_select", False) + # Ensure only this object is selected + for i in bpy.data.objects: + i.select = i == bo + def ensure_power_of_two(value): return pow(2, math.floor(math.log(value, 2))) @@ -69,12 +73,3 @@ def find_modifier(boname, modid): # if they give us the wrong modid, it is a bug and an AttributeError return getattr(bo.plasma_modifiers, modid) return None - -def make_active_selection(bo): - """Selects a single Blender Object and makes it active""" - for i in bpy.data.objects: - if i == bo: - bpy.context.scene.objects.active = i - i.select = True - else: - i.select = False