Browse Source

Improve buoy UI & export checks

pull/256/head
Darryl Pogue 4 years ago
parent
commit
532b712ca6
No known key found for this signature in database
GPG Key ID: CB824715C3E6FD41
  1. 3
      korman/idprops.py
  2. 16
      korman/properties/modifiers/water.py
  3. 15
      korman/ui/modifiers/water.py

3
korman/idprops.py

@ -127,6 +127,9 @@ def poll_camera_objects(self, value):
def poll_drawable_objects(self, value):
return value.type == "MESH" and any(value.data.materials)
def poll_dynamic_objects(self, value):
return value.plasma_modifiers.collision.enabled and value.plasma_modifiers.collision.dynamic
def poll_empty_objects(self, value):
return value.type == "EMPTY"

16
korman/properties/modifiers/water.py

@ -125,7 +125,7 @@ class PlasmaSwimRegion(idprops.IDPropObjectMixin, PlasmaModifierProperties, bpy.
# Detector region bounds
if self.region is not None:
region_so = exporter.mgr.find_create_object(plSceneObject, bl=self.region)
# Good news: if this phys has already been exported, this is basically a noop
member_group = "kGroupDetector" if exporter.mgr.getVer() == "pvMoul" else "kGroupLOSOnly"
exporter.physics.generate_physical(self.region, region_so,
@ -473,12 +473,12 @@ class PlasmaWaveTexState(PlasmaWaveState, PlasmaModifierProperties):
self.convert_wavestate(waveset.state.texState)
class PlasmaBuoyObject(idprops.IDPropObjectMixin, bpy.types.PropertyGroup):
display_name = StringProperty(name="Display Name")
class PlasmaBuoyObject(bpy.types.PropertyGroup):
buoy_object = PointerProperty(name="Buoy Object",
description="Object that float on water",
options=set(),
type=bpy.types.Object,
poll=idprops.poll_mesh_objects)
poll=idprops.poll_dynamic_objects)
class PlasmaWaterBuoyModifier(PlasmaModifierProperties):
@ -493,10 +493,16 @@ class PlasmaWaterBuoyModifier(PlasmaModifierProperties):
active_buoy_index = IntProperty(options={"HIDDEN"})
def export(self, exporter, bo, so):
if exporter.mgr.getVer() != pvMoul:
exporter.report.warning("Not supported on this version of Plasma", indent=3)
return
else:
exporter.report.port("This will only function on MOUL", indent=3)
waveset = exporter.mgr.find_create_object(plWaveSet7, name=bo.name, so=so)
waveset.setFlag(plWaveSet7.kHasBuoys, True)
for i in self.buoys:
if i.buoy_object is None:
raise ExportError("'{}': Buoy Object for '{}' is invalid", self.key_name, i.display_name)
raise ExportError("'{}': Buoy Object for '{}' is invalid", self.key_name, i.buoy_object.name)
waveset.addBuoy(exporter.mgr.find_create_key(plSceneObject, bl=i.buoy_object))

15
korman/ui/modifiers/water.py

@ -139,7 +139,10 @@ def water_shore(modifier, layout, context):
class BuoyListUI(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_property, index=0, flt_flag=0):
layout.prop(item, "display_name", emboss=False, text="", icon="MOD_CAST")
if item.buoy_object is None:
layout.label("[No Object Specified]", icon="ERROR")
else:
layout.label(item.buoy_object.name, icon="MOD_CAST")
def water_buoy(modifier, layout, context):
@ -148,6 +151,10 @@ def water_buoy(modifier, layout, context):
name_prop="display_name", rows=2, maxrows=3)
# Display the active buoy
if modifier.buoys:
buoy = modifier.buoys[modifier.active_buoy_index]
layout.prop(buoy, "buoy_object", icon="MESH_DATA")
try:
buoy_ref = modifier.buoys[modifier.active_buoy_index]
except:
pass
else:
layout.alert = buoy_ref.buoy_object is None
layout.prop(buoy_ref, "buoy_object")

Loading…
Cancel
Save