Browse Source

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.
pull/11/head
Adam Johnson 9 years ago
parent
commit
d27630f501
  1. 2
      korman/exporter/mesh.py
  2. 13
      korman/helpers.py

2
korman/exporter/mesh.py

@ -331,7 +331,7 @@ class MeshConverter:
return geospans return geospans
def _export_static_lighting(self, bo): def _export_static_lighting(self, bo):
helpers.make_active_selection(bo) bpy.context.scene.objects.active = bo
mods = bo.plasma_modifiers mods = bo.plasma_modifiers
lm = mods.lightmap lm = mods.lightmap
if lm.enabled: if lm.enabled:

13
korman/helpers.py

@ -59,6 +59,10 @@ def ensure_object_can_bake(bo, toggle):
toggle.track(bo, "hide_render", False) toggle.track(bo, "hide_render", False)
toggle.track(bo, "hide_select", 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): def ensure_power_of_two(value):
return pow(2, math.floor(math.log(value, 2))) 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 # if they give us the wrong modid, it is a bug and an AttributeError
return getattr(bo.plasma_modifiers, modid) return getattr(bo.plasma_modifiers, modid)
return None 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

Loading…
Cancel
Save