Browse Source

Toss modifier display names

These would be copied along with entire objects, potentially resulting in
duplicate key names. Better to just toss the whole thing...
pull/11/head
Adam Johnson 9 years ago
parent
commit
644b22ecfd
  1. 4
      korman/exporter/convert.py
  2. 6
      korman/nodes/node_messages.py
  3. 4
      korman/nodes/node_python.py
  4. 2
      korman/operators/op_modifier.py
  5. 42
      korman/properties/modifiers/anim.py
  6. 7
      korman/properties/modifiers/avatar.py
  7. 13
      korman/properties/modifiers/base.py
  8. 13
      korman/properties/modifiers/logic.py
  9. 9
      korman/properties/modifiers/physics.py
  10. 19
      korman/properties/modifiers/region.py
  11. 16
      korman/properties/modifiers/render.py
  12. 24
      korman/properties/modifiers/water.py
  13. 1
      korman/ui/ui_modifiers.py

4
korman/exporter/convert.py

@ -199,7 +199,7 @@ class Exporter:
# And now we puke out the modifiers...
for mod in bl_obj.plasma_modifiers.modifiers:
print(" Exporting '{}' modifier as '{}'".format(mod.bl_label, mod.display_name))
print(" Exporting '{}' modifier as '{}'".format(mod.bl_label, mod.key_name))
mod.export(self, bl_obj, sceneobject)
def _export_empty_blobj(self, so, bo):
@ -264,5 +264,5 @@ class Exporter:
for mod in bl_obj.plasma_modifiers.modifiers:
proc = getattr(mod, "post_export", None)
if proc is not None:
print(" '{}' modifier '{}'".format(bl_obj.name, mod.display_name))
print(" '{}' modifier '{}'".format(bl_obj.name, mod.key_name))
proc(self, bl_obj, sceneobject)

6
korman/nodes/node_messages.py

@ -176,11 +176,11 @@ class PlasmaAnimCmdMsgNode(PlasmaMessageNode, bpy.types.Node):
# we might be controlling more than one animation. isn't that cute?
# https://www.youtube.com/watch?v=hspNaoxzNbs
# (but obviously this is not wrong...)
target = exporter.mgr.find_create_key(plMsgForwarder, bl=obj, name=group.display_name)
target = exporter.mgr.find_create_key(plMsgForwarder, bl=obj, name=group.key_name)
else:
# remember, the AGModifier MUST exist first... so just in case...
exporter.mgr.find_create_key(plAGModifier, bl=obj, name=anim.display_name)
target = exporter.mgr.find_create_key(plAGMasterMod, bl=obj, name=anim.display_name)
exporter.mgr.find_create_key(plAGModifier, bl=obj, name=anim.key_name)
target = exporter.mgr.find_create_key(plAGMasterMod, bl=obj, name=anim.key_name)
else:
material = bpy.data.materials.get(self.material_name, None)
if material is None:

4
korman/nodes/node_python.py

@ -454,8 +454,8 @@ class PlasmaAttribObjectNode(PlasmaAttribNodeBase, bpy.types.Node):
return ref_so_key
elif attrib == "ptAttribAnimation":
anim = bo.plasma_modifiers.animation
agmod = exporter.mgr.find_create_key(plAGModifier, so=ref_so, name=anim.display_name)
agmaster = exporter.mgr.find_create_key(plAGMasterModifier, so=ref_so, name=anim.display_name)
agmod = exporter.mgr.find_create_key(plAGModifier, so=ref_so, name=anim.key_name)
agmaster = exporter.mgr.find_create_key(plAGMasterModifier, so=ref_so, name=anim.key_name)
return agmaster
elif attrib == "ptAttribWaveSet":
waveset = bo.plasma_modifiers.water_basic

2
korman/operators/op_modifier.py

@ -51,7 +51,7 @@ class ModifierAddOperator(ModifierOperator, bpy.types.Operator):
theMod = getattr(plmods, myType)
theMod.display_order = plmods.determine_next_id()
theMod.created(context.object)
theMod.created()
# Determine if this modifier has any dependencies and make sure they're enabled
deps = getattr(theMod, "pl_depends", set())

42
korman/properties/modifiers/anim.py

@ -51,9 +51,6 @@ class PlasmaAnimationModifier(PlasmaModifierProperties):
loop_end = StringProperty(name="Loop End",
description="Marker indicating where the default loop ends")
def created(self, obj):
self.display_name = "{}_(Entire Animation)".format(obj.name)
@property
def requires_actor(self):
return True
@ -62,7 +59,7 @@ class PlasmaAnimationModifier(PlasmaModifierProperties):
action = _get_blender_action(bo)
markers = action.pose_markers
atcanim = exporter.mgr.find_create_key(plATCAnim, so=so, name=self.display_name).object
atcanim = exporter.mgr.find_create_object(plATCAnim, so=so, name=self.key_name)
atcanim.autoStart = self.auto_start
atcanim.loop = self.loop
atcanim.name = "(Entire Animation)"
@ -123,11 +120,15 @@ class PlasmaAnimationModifier(PlasmaModifierProperties):
# We need both an AGModifier and an AGMasterMod
# NOTE: mandatory order--otherwise the animation will not work in game!
agmod = exporter.mgr.find_create_object(plAGModifier, so=so, name=self.display_name)
agmod = exporter.mgr.find_create_object(plAGModifier, so=so, name=self.key_name)
agmod.channelName = bo.name
agmaster = exporter.mgr.find_create_object(plAGMasterMod, so=so, name=self.display_name)
agmaster = exporter.mgr.find_create_object(plAGMasterMod, so=so, name=self.key_name)
agmaster.addPrivateAnim(atcanim.key)
@property
def key_name(self):
return "{}_(Entire Animation)".format(self.id_data.name)
def post_export(self, exporter, bo, so):
# If this object has a physical, we need to tell the simulation iface that it can be animated
sim = so.sim
@ -161,18 +162,15 @@ class PlasmaAnimationGroupModifier(PlasmaModifierProperties):
type=AnimGroupObject)
active_child_index = IntProperty(options={"HIDDEN"})
def created(self, obj):
self.display_name = "{}_AnimGroup".format(obj.name)
def export(self, exporter, bo, so):
action = _get_blender_action(bo)
key_name = bo.plasma_modifiers.animation.display_name
key_name = bo.plasma_modifiers.animation.key_name
# See above... AGModifier must always be inited first...
agmod = exporter.mgr.find_create_object(plAGModifier, so=so, name=key_name)
# The message forwarder is the guy that makes sure that everybody knows WTF is going on
msgfwd = exporter.mgr.find_create_object(plMsgForwarder, so=so, name=self.display_name)
msgfwd = exporter.mgr.find_create_object(plMsgForwarder, so=so, name=self.key_name)
# Now, this is da swhiz...
agmaster = exporter.mgr.find_create_object(plAGMasterMod, so=so, name=key_name)
@ -182,22 +180,26 @@ class PlasmaAnimationGroupModifier(PlasmaModifierProperties):
child_bo = bpy.data.objects.get(i.object_name, None)
if child_bo is None:
msg = "Animation Group '{}' specifies an invalid object '{}'. Ignoring..."
exporter.report.warn(msg.format(self.display_name, i.object_name), ident=2)
exporter.report.warn(msg.format(self.key_name, i.object_name), ident=2)
continue
if child_bo.animation_data is None or child_bo.animation_data.action is None:
msg = "Animation Group '{}' specifies an object '{}' with no valid animation data. Ignoring..."
exporter.report.warn(msg.format(self.display_name, i.object_name), indent=2)
exporter.report.warn(msg.format(self.key_name, i.object_name), indent=2)
continue
child_animation = child_bo.plasma_modifiers.animation
if not child_animation.enabled:
msg = "Animation Group '{}' specifies an object '{}' with no Plasma Animation modifier. Ignoring..."
exporter.report.warn(msg.format(self.display_name, i.object_name), indent=2)
exporter.report.warn(msg.format(self.key_name, i.object_name), indent=2)
continue
child_agmod = exporter.mgr.find_create_key(plAGModifier, bl=child_bo, name=child_animation.display_name)
child_agmaster = exporter.mgr.find_create_key(plAGMasterMod, bl=child_bo, name=child_animation.display_name)
child_agmod = exporter.mgr.find_create_key(plAGModifier, bl=child_bo, name=child_animation.key_name)
child_agmaster = exporter.mgr.find_create_key(plAGMasterMod, bl=child_bo, name=child_animation.key_name)
msgfwd.addForwardKey(child_agmaster)
msgfwd.addForwardKey(agmaster.key)
@property
def key_name(self):
return "{}_AnimGroup".format(self.id_data.name)
class LoopMarker(bpy.types.PropertyGroup):
loop_name = StringProperty(name="Loop Name",
@ -222,16 +224,12 @@ class PlasmaAnimationLoopModifier(PlasmaModifierProperties):
type=LoopMarker)
active_loop_index = IntProperty(options={"HIDDEN"})
def created(self, obj):
# who cares, this modifier creates no Keys...
self.display_name = "AnimLoops"
def export(self, exporter, bo, so):
action = _get_blender_action(bo)
markers = action.pose_markers
key_name = bo.plasma_modifiers.animation.display_name
atcanim = exporter.mgr.find_create_key(plATCAnim, so=so, name=key_name).object
key_name = bo.plasma_modifiers.animation.key_name
atcanim = exporter.mgr.find_create_object(plATCAnim, so=so, name=key_name)
for loop in self.loops:
start = markers.get(loop.loop_start)
end = markers.get(loop.loop_end)

7
korman/properties/modifiers/avatar.py

@ -51,9 +51,6 @@ class PlasmaSittingBehavior(PlasmaModifierProperties, PlasmaModifierLogicWiz):
description="How far away we will tolerate the avatar facing the clickable",
min=-180, max=180, default=45)
def created(self, obj):
self.display_name = "{}_SitBeh".format(obj.name)
def export(self, exporter, bo, so):
# The user absolutely MUST specify a clickable or this won't export worth crap.
clickable_obj = bpy.data.objects.get(self.clickable_obj, None)
@ -108,6 +105,10 @@ class PlasmaSittingBehavior(PlasmaModifierProperties, PlasmaModifierLogicWiz):
# facing target conditional for us. isn't that nice?
clickable.find_input_socket("facing").allow_simple = False
@property
def key_name(self):
return "{}_SitBeh".format(self.id_data.name)
@property
def requires_actor(self):
# This should be an empty, really...

13
korman/properties/modifiers/base.py

@ -18,9 +18,8 @@ import bpy
from bpy.props import *
class PlasmaModifierProperties(bpy.types.PropertyGroup):
def created(self, obj):
# This is here just to prevent us from having unnamed modifiers
self.display_name = "{}Modifier{}".format(obj.name, self.display_order)
def created(self):
pass
def destroyed(self):
pass
@ -32,6 +31,10 @@ class PlasmaModifierProperties(bpy.types.PropertyGroup):
def harvest_actors(self):
return ()
@property
def key_name(self):
return self.id_data.name
@property
def requires_actor(self):
"""Indicates if this modifier requires the object to be a movable actor"""
@ -53,8 +56,6 @@ class PlasmaModifierProperties(bpy.types.PropertyGroup):
# you see... So, we'll store our definitions in a dict and make those properties on each subclass
# at runtime. What joy. Python FTW. See register() in __init__.py
_subprops = {
"display_name": (StringProperty, {"name": "Name",
"description": "Modifier name"}),
"display_order": (IntProperty, {"name": "INTERNAL: Display Ordering",
"description": "Position in the list of buttons",
"default": -1,
@ -68,7 +69,7 @@ class PlasmaModifierProperties(bpy.types.PropertyGroup):
class PlasmaModifierLogicWiz:
@property
def node_tree(self):
name = self.display_name
name = self.key_name
try:
return bpy.data.node_groups[name]
except LookupError:

13
korman/properties/modifiers/logic.py

@ -55,9 +55,6 @@ class PlasmaAdvancedLogic(PlasmaModifierProperties):
logic_groups = CollectionProperty(type=PlasmaVersionedNodeTree)
active_group_index = IntProperty(options={"HIDDEN"})
def created(self, obj):
self.display_name = "Advanced Logic"
def export(self, exporter, bo, so):
version = exporter.mgr.getVer()
for i in self.logic_groups:
@ -92,13 +89,10 @@ class PlasmaSpawnPoint(PlasmaModifierProperties):
bl_label = "Spawn Point"
bl_description = "Point at which avatars link into the Age"
def created(self, obj):
self.display_name = obj.name
def export(self, exporter, bo, so):
# Not much to this modifier... It's basically a flag that tells the engine, "hey, this is a
# place the avatar can show up." Nice to have a simple one to get started with.
spawn = exporter.mgr.add_object(pl=plSpawnModifier, so=so, name=self.display_name)
spawn = exporter.mgr.add_object(pl=plSpawnModifier, so=so, name=self.key_name)
@property
def requires_actor(self):
@ -124,11 +118,8 @@ class PlasmaMaintainersMarker(PlasmaModifierProperties):
"A marker which reports accurate coordinates to the KI.")
])
def created(self, obj):
self.display_name = obj.name
def export(self, exporter, bo, so):
maintmark = exporter.mgr.add_object(pl=plMaintainersMarkerModifier, so=so, name=self.display_name)
maintmark = exporter.mgr.add_object(pl=plMaintainersMarkerModifier, so=so, name=self.key_name)
maintmark.calibration = getattr(plMaintainersMarkerModifier, self.calibration)
@property

9
korman/properties/modifiers/physics.py

@ -58,11 +58,8 @@ class PlasmaCollider(PlasmaModifierProperties):
mass = FloatProperty(name="Mass", description="Mass of object in pounds", min=0.0, default=1.0)
start_asleep = BoolProperty(name="Start Asleep", description="Object is not active until influenced by another object", default=False)
def created(self, obj):
self.display_name = "{}_Collision".format(obj.name)
def export(self, exporter, bo, so):
simIface, physical = exporter.physics.generate_physical(bo, so, self.bounds, self.display_name)
simIface, physical = exporter.physics.generate_physical(bo, so, self.bounds, self.key_name)
# Common props
physical.friction = self.friction
@ -87,6 +84,10 @@ class PlasmaCollider(PlasmaModifierProperties):
if self.terrain:
physical.LOSDBs |= plSimDefs.kLOSDBAvatarWalkable
@property
def key_name(self):
return "{}_Collision".format(self.id_data.name)
@property
def requires_actor(self):
return self.dynamic

19
korman/properties/modifiers/region.py

@ -70,10 +70,6 @@ class PlasmaFootstepRegion(PlasmaModifierProperties, PlasmaModifierLogicWiz):
items=bounds_types,
default="hull")
def created(self, obj):
self.display_name = "{}_FootRgn".format(obj.name)
def export(self, exporter, bo, so):
# Generate the logic nodes now
self.logicwiz(bo)
@ -109,6 +105,10 @@ class PlasmaFootstepRegion(PlasmaModifierProperties, PlasmaModifierLogicWiz):
msg.link_input(respcmd, "msg", "sender")
msg.surface = self.surface
@property
def key_name(self):
return "{}_FootRgn".format(self.id_data.name)
class PlasmaPanicLinkRegion(PlasmaModifierProperties):
pl_id = "paniclink"
@ -121,21 +121,22 @@ class PlasmaPanicLinkRegion(PlasmaModifierProperties):
description="Play the link-out animation when panic linking",
default=True)
def created(self, obj):
self.display_name = "{}_PanicLinkRgn".format(obj.name)
def export(self, exporter, bo, so):
phys_mod = bo.plasma_modifiers.collision
simIface, physical = exporter.physics.generate_physical(bo, so, phys_mod.bounds, self.display_name)
simIface, physical = exporter.physics.generate_physical(bo, so, phys_mod.bounds, self.key_name)
# Now setup the region detector properties
physical.memberGroup = plSimDefs.kGroupDetector
physical.reportGroup = 1 << plSimDefs.kGroupAvatar
# Finally, the panic link region proper
reg = exporter.mgr.add_object(plPanicLinkRegion, name=self.display_name, so=so)
reg = exporter.mgr.add_object(plPanicLinkRegion, name=self.key_name, so=so)
reg.playLinkOutAnim = self.play_anim
@property
def key_name(self):
return "{}_PanicLinkRgn".format(self.id_data.name)
@property
def requires_actor(self):
return True

16
korman/properties/modifiers/render.py

@ -44,9 +44,6 @@ class PlasmaLightMapGen(PlasmaModifierProperties):
uv_map = StringProperty(name="UV Texture",
description="UV Texture used as the basis for the lightmap")
def created(self, obj):
self.display_name = "{}_LIGHTMAPGEN".format(obj.name)
def export(self, exporter, bo, so):
mat_mgr = exporter.mesh.material
materials = mat_mgr.get_materials(bo)
@ -85,6 +82,10 @@ class PlasmaLightMapGen(PlasmaModifierProperties):
# Mmm... cheating
mat_mgr.export_prepared_layer(layer, lightmap_im)
@property
def key_name(self):
return "{}_LIGHTMAPGEN".format(self.id_data.name)
@property
def resolution(self):
return int(self.quality)
@ -123,11 +124,8 @@ class PlasmaViewFaceMod(PlasmaModifierProperties):
offset_local = BoolProperty(name="Local", description="Use local coordinates", default=False)
offset_coord = FloatVectorProperty(name="", subtype="XYZ")
def created(self, obj):
self.display_name = obj.name
def export(self, exporter, bo, so):
vfm = exporter.mgr.find_create_object(plViewFaceModifier, so=so, name=self.display_name)
vfm = exporter.mgr.find_create_object(plViewFaceModifier, so=so, name=self.key_name)
# Set a default scaling (libHSPlasma will set this to 0 otherwise).
vfm.scale = hsVector3(1,1,1)
@ -154,11 +152,11 @@ class PlasmaViewFaceMod(PlasmaModifierProperties):
if self.target_object:
target_obj = bpy.data.objects.get(self.target_object, None)
if target_obj is None:
raise ExportError("'{}': Swivel's target object is invalid".format(self.display_name))
raise ExportError("'{}': Swivel's target object is invalid".format(self.key_name))
else:
vfm.faceObj = exporter.mgr.find_create_key(plSceneObject, bl=target_obj)
else:
raise ExportError("'{}': Swivel's target object must be selected".format(self.display_name))
raise ExportError("'{}': Swivel's target object must be selected".format(self.key_name))
if self.pivot_on_y:
vfm.setFlag(plViewFaceModifier.kPivotY, True)

24
korman/properties/modifiers/water.py

@ -80,15 +80,12 @@ class PlasmaWaterModifier(PlasmaModifierProperties, bpy.types.PropertyGroup):
min=-10.0, max=10.0,
default=0.0)
def created(self, obj):
self.display_name = "{}_WaveSet7".format(obj.name)
def export(self, exporter, bo, so):
waveset = exporter.mgr.find_create_object(plWaveSet7, name=bo.name, so=so)
if self.wind_object_name:
wind_obj = bpy.data.objects.get(self.wind_object_name, None)
if wind_obj is None:
raise ExportError("{}: Wind Object '{}' not found".format(self.display_name, self.wind_object_name))
raise ExportError("{}: Wind Object '{}' not found".format(bo.name, self.wind_object_name))
if wind_obj.plasma_object.enabled and wind_obj.plasma_modifiers.animation.enabled:
waveset.refObj = exporter.mgr.find_create_key(plSceneObject, bl=wind_obj)
waveset.setFlag(plWaveSet7.kHasRefObject, True)
@ -115,9 +112,9 @@ class PlasmaWaterModifier(PlasmaModifierProperties, bpy.types.PropertyGroup):
if self.envmap_name:
texture = bpy.data.textures.get(self.envmap_name, None)
if texture is None:
raise ExportError("{}: Texture '{}' not found".format(self.display_name, self.envmap_name))
raise ExportError("{}: Texture '{}' not found".format(self.key_name, self.envmap_name))
if texture.type != "ENVIRONMENT_MAP":
raise ExportError("{}: Texture '{}' is not an ENVIRONMENT MAP".format(self.display_name, self.envmap_name))
raise ExportError("{}: Texture '{}' is not an ENVIRONMENT MAP".format(self.key_name, self.envmap_name))
# maybe, just maybe, we're absuing our privledges?
dem = exporter.mesh.material.export_dynamic_env(bo, None, None, texture, plDynamicEnvMap)
@ -146,6 +143,10 @@ class PlasmaWaterModifier(PlasmaModifierProperties, bpy.types.PropertyGroup):
if not mods.water_shore.enabled:
mods.water_shore.convert_default(state)
@property
def key_name(self):
return "{}_WaveSet7".format(self.id_data.name)
class PlasmaShoreObject(bpy.types.PropertyGroup):
display_name = StringProperty(name="Display Name")
@ -209,9 +210,6 @@ class PlasmaWaterShoreModifier(PlasmaModifierProperties):
wavestate.period = self._period_default / 100.0
wavestate.fingerLength = self._finger_default / 100.0
def created(self, obj):
self.display_name = "{}_WaterShore".format(obj.name)
def export(self, exporter, bo, so):
waveset = exporter.mgr.find_create_object(plWaveSet7, name=bo.name, so=so)
wavestate = waveset.state
@ -219,7 +217,7 @@ class PlasmaWaterShoreModifier(PlasmaModifierProperties):
for i in self.shores:
shore = bpy.data.objects.get(i.object_name, None)
if shore is None:
raise ExportError("'{}': Shore Object '{}' does not exist".format(self.display_name, i.object_name))
raise ExportError("'{}': Shore Object '{}' does not exist".format(self.key_name, i.object_name))
waveset.addShore(exporter.mgr.find_create_key(plSceneObject, bl=shore))
wavestate.wispiness = self.wispiness / 100.0
@ -287,9 +285,6 @@ class PlasmaWaveGeoState(PlasmaWaveState, PlasmaModifierProperties):
_chop_default = 50
_angle_dev_default = math.radians(20.0)
def created(self, obj):
self.display_name = "{}_WaveGeoState".format(obj.name)
def export(self, exporter, bo, so):
waveset = exporter.mgr.find_create_object(plWaveSet7, name=bo.name, so=so)
self.convert_wavestate(waveset.state.geoState)
@ -308,9 +303,6 @@ class PlasmaWaveTexState(PlasmaWaveState, PlasmaModifierProperties):
_chop_default = 50
_angle_dev_default = math.radians(20.0)
def created(self, obj):
self.display_name = "{}_WaveTexState".format(obj.name)
def export(self, exporter, bo, so):
waveset = exporter.mgr.find_create_object(plWaveSet7, name=bo.name, so=so)
self.convert_wavestate(waveset.state.texState)

1
korman/ui/ui_modifiers.py

@ -74,7 +74,6 @@ class PlasmaModifiersPanel(ModifierButtonsPanel, bpy.types.Panel):
exicon = "TRIA_DOWN" if modifier.show_expanded else "TRIA_RIGHT"
row.prop(modifier, "show_expanded", text="", icon=exicon, emboss=False)
row.label(text=modifier.bl_label, icon=getattr(modifier, "bl_icon", "NONE"))
row.prop(modifier, "display_name", text="")
row.operator("object.plasma_modifier_move_up", text="", icon="TRIA_UP").active_modifier = modifier.display_order
row.operator("object.plasma_modifier_move_down", text="", icon="TRIA_DOWN").active_modifier = modifier.display_order

Loading…
Cancel
Save