diff --git a/korman/exporter/material.py b/korman/exporter/material.py index f66f52d..eb817b1 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -476,11 +476,11 @@ class MaterialConverter: # Whoever wrote this PyHSPlasma binding didn't follow the convention. Sigh. visregions = [] for region in texture.plasma_layer.vis_regions: - rgn = bpy.data.objects.get(region.region_name, None) + rgn = region.control_region if rgn is None: - raise ExportError("'{}': VisControl '{}' not found".format(texture.name, region.region_name)) + raise ExportError("'{}': Has an invalid Visibility Control".format(texture.name)) if not rgn.plasma_modifiers.visregion.enabled: - raise ExportError("'{}': '{}' is not a VisControl".format(texture.name, region.region_name)) + raise ExportError("'{}': '{}' is not a VisControl".format(texture.name, rgn.name)) visregions.append(self._mgr.find_create_key(plVisRegion, bl=rgn)) pl_env.visRegions = visregions diff --git a/korman/properties/prop_texture.py b/korman/properties/prop_texture.py index bfd93a7..8cf3c26 100644 --- a/korman/properties/prop_texture.py +++ b/korman/properties/prop_texture.py @@ -16,10 +16,18 @@ import bpy from bpy.props import * -class EnvMapVisRegion(bpy.types.PropertyGroup): +from .. import idprops + +class EnvMapVisRegion(idprops.IDPropObjectMixin, bpy.types.PropertyGroup): enabled = BoolProperty(default=True) - region_name = StringProperty(name="Control", - description="Object defining a Plasma Visibility Control") + control_region = PointerProperty(name="Control", + description="Object defining a Plasma Visibility Control", + type=bpy.types.Object, + poll=idprops.poll_visregion_objects) + + @classmethod + def _idprop_mapping(cls): + return {"control_region": "region_name"} class PlasmaLayer(bpy.types.PropertyGroup): diff --git a/korman/ui/ui_texture.py b/korman/ui/ui_texture.py index 98fbf8a..ba706de 100644 --- a/korman/ui/ui_texture.py +++ b/korman/ui/ui_texture.py @@ -52,7 +52,7 @@ class PlasmaEnvMapPanel(TextureButtonsPanel, bpy.types.Panel): op.index = layer_props.active_region_index rgns = layer_props.vis_regions if layer_props.vis_regions: - layout.prop_search(rgns[layer_props.active_region_index], "region_name", bpy.data, "objects") + layout.prop(rgns[layer_props.active_region_index], "control_region") layout.separator() layout.prop(layer_props, "envmap_color")