Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions korman/idprops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
37 changes: 36 additions & 1 deletion korman/properties/modifiers/water.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def export(self, exporter, bo, so):
# 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,
Expand Down Expand Up @@ -471,3 +471,38 @@ class PlasmaWaveTexState(PlasmaWaveState, PlasmaModifierProperties):
def export(self, exporter, bo, so):
waveset = exporter.mgr.find_create_object(plWaveSet7, name=bo.name, so=so)
self.convert_wavestate(waveset.state.texState)


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_dynamic_objects)
Copy link
Member

@Hoikas Hoikas Jun 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is correct from an implementation standpoint, I feel like it's putting too much of a requirement on the user on knowing how buoys work under the hood. Instead, I think we should call the physics exporter in the export fxn and place the resulting physical in the dynamic group... exporter.physics.generate_physical(bo, so, member_group="kGroupDynamic") This poll fxn should probably just check for mesh objects. Further, we should alert in the UI (and maybe the log too?) if the collision mod is on with dynamic unticked. Alternatively, add instrumentation to the physics exporter to force buoys dynamic or a way to force the member_group supplied by the exporter.



class PlasmaWaterBuoyModifier(PlasmaModifierProperties):
pl_depends = {"water_basic"}
pl_id = "water_buoy"

bl_category = "Water"
bl_label = "Water Buoys"
bl_description = ""

buoys = CollectionProperty(type=PlasmaBuoyObject)
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.buoy_object.name)
waveset.addBuoy(exporter.mgr.find_create_key(plSceneObject, bl=i.buoy_object))
23 changes: 23 additions & 0 deletions korman/ui/modifiers/water.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,26 @@ def water_shore(modifier, layout, context):
col.prop(modifier, "finger")
col.prop(modifier, "edge_opacity")
col.prop(modifier, "edge_radius")


class BuoyListUI(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_property, index=0, flt_flag=0):
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):
ui_list.draw_modifier_list(layout, "BuoyListUI", modifier, "buoys",
"active_buoy_index", name_prefix="Buoy",
name_prop="display_name", rows=2, maxrows=3)

# Display the active buoy
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")