From 6c5dff5d563da704948c47bb567759e7277d65a2 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Thu, 8 Jun 2017 12:58:48 -0400 Subject: [PATCH] Update RT Lights to IDProps --- korman/exporter/rtlight.py | 8 +++----- korman/properties/prop_lamp.py | 15 +++++++++++---- korman/ui/ui_lamp.py | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/korman/exporter/rtlight.py b/korman/exporter/rtlight.py index c249218..daa6b76 100644 --- a/korman/exporter/rtlight.py +++ b/korman/exporter/rtlight.py @@ -171,13 +171,11 @@ class LightConverter: sv_mod, sv_key = bo.plasma_modifiers.softvolume, None if sv_mod.enabled: sv_key = sv_mod.get_key(self._exporter()) - elif rtlamp.soft_region: - sv_bo = bpy.data.objects.get(rtlamp.soft_region, None) - if sv_bo is None: - raise ExportError("'{}': Invalid object for Lamp soft volume '{}'".format(bo.name, rtlamp.soft_region)) + elif rtlamp.lamp_region: + sv_bo = rtlamp.lamp_region sv_mod = sv_bo.plasma_modifiers.softvolume if not sv_mod.enabled: - raise ExportError("'{}': '{}' is not a SoftVolume".format(bo.name, rtlamp.soft_region)) + raise ExportError("'{}': '{}' is not a SoftVolume".format(bo.name, sv_bo.name)) sv_key = sv_mod.get_key(self._exporter()) pl_light.softVolume = sv_key diff --git a/korman/properties/prop_lamp.py b/korman/properties/prop_lamp.py index 428fa10..61a5a7a 100644 --- a/korman/properties/prop_lamp.py +++ b/korman/properties/prop_lamp.py @@ -16,7 +16,9 @@ import bpy from bpy.props import * -class PlasmaLamp(bpy.types.PropertyGroup): +from .. import idprops + +class PlasmaLamp(idprops.IDPropObjectMixin, bpy.types.PropertyGroup): affect_characters = BoolProperty(name="Affect Avatars", description="This lamp affects avatars", options=set(), @@ -43,9 +45,10 @@ class PlasmaLamp(bpy.types.PropertyGroup): default=False, options=set()) - soft_region = StringProperty(name="Soft Volume", - description="Soft region this light is active inside", - options=set()) + lamp_region = PointerProperty(name="Soft Volume", + description="Soft region this light is active inside", + type=bpy.types.Object, + poll=idprops.poll_softvolume_objects) # For LimitedDirLights size_height = FloatProperty(name="Height", @@ -55,3 +58,7 @@ class PlasmaLamp(bpy.types.PropertyGroup): def has_light_group(self, bo): return bool(bo.users_group) + + @classmethod + def _idprop_mapping(cls): + return {"lamp_region": "soft_region"} diff --git a/korman/ui/ui_lamp.py b/korman/ui/ui_lamp.py index 754a4d9..bb043c7 100644 --- a/korman/ui/ui_lamp.py +++ b/korman/ui/ui_lamp.py @@ -53,7 +53,7 @@ class PlasmaLampPanel(LampButtonsPanel, bpy.types.Panel): if not context.object.plasma_modifiers.softvolume.enabled: layout.separator() - layout.prop_search(rtlamp, "soft_region", bpy.data, "objects") + layout.prop(rtlamp, "lamp_region") def _draw_area_lamp(self, context):