Browse Source

CI and other modifier improvements

These were picked over from the larger basic physics commit. I don't want
to hold up better modifier stuff while waiting on more physics code.
pull/6/head
Adam Johnson 11 years ago
parent
commit
52752b9dda
  1. 11
      korman/exporter/convert.py
  2. 22
      korman/exporter/manager.py
  3. 4
      korman/exporter/mesh.py
  4. 2
      korman/operators/op_modifier.py
  5. 5
      korman/properties/modifiers/base.py
  6. 4
      korman/properties/modifiers/logic.py
  7. 5
      korman/ui/ui_modifiers.py

11
korman/exporter/convert.py

@ -95,16 +95,13 @@ class Exporter:
def _export_actor(self, so, bo):
"""Exports a Coordinate Interface if we need one"""
empty = bo.type in {"CAMERA", "EMPTY", "LAMP"}
childobj = bo.parent is not None
if empty or childobj:
if self.mgr.has_coordiface(bo):
self._export_coordinate_interface(so, bo)
# If this object has a parent, then we will need to go upstream and add ourselves to the
# parent's CoordinateInterface... Because life just has to be backwards.
if childobj:
parent = bo.parent
parent = bo.parent
if parent is not None:
if parent.plasma_object.enabled:
print(" Attaching to parent SceneObject '{}'".format(parent.name))
@ -120,6 +117,8 @@ class Exporter:
def _export_coordinate_interface(self, so, bo):
"""Ensures that the SceneObject has a CoordinateInterface"""
if not so.coord:
print(" Exporting CoordinateInterface")
ci = self.mgr.find_create_key(bo, plCoordinateInterface)
so.coord = ci
ci = ci.object

22
korman/exporter/manager.py

@ -151,12 +151,16 @@ class ExportManager:
return key
return None
def get_location(self, bl_obj):
def get_location(self, bl):
"""Returns the Page Location of a given Blender Object"""
return self._pages[bl_obj.plasma_object.page]
return self._pages[bl.plasma_object.page]
def get_scene_node(self, location):
def get_scene_node(self, location=None, bl=None):
"""Gets a Plasma Page's plSceneNode key"""
assert (location is not None) ^ (bl is not None)
if location is None:
location = self._pages[bl.plasma_object.page]
return self._nodes[location].key
def get_textures_page(self, layer):
@ -167,6 +171,18 @@ class ExportManager:
else:
return layer.key.location
def has_coordiface(self, bo):
if bo.type in {"CAMERA", "EMPTY", "LAMP"}:
return True
if bo.parent is not None:
return True
for mod in bo.plasma_modifiers.modifiers:
if mod.enabled:
if mod.requires_actor:
return True
return False
def sanity_check_object_pages(self, age, objects):
"""Ensure all objects are in valid pages and create the Default page if used"""

4
korman/exporter/mesh.py

@ -111,7 +111,7 @@ class MeshConverter:
# TODO: RunTime lights (requires libHSPlasma feature)
# If this object has a CI, we don't need xforms here...
if self._mgr.find_key(bo, plCoordinateInterface) is not None:
if self._mgr.has_coordiface(bo):
geospan.localToWorld = hsMatrix44()
geospan.worldToLocal = hsMatrix44()
else:
@ -270,7 +270,7 @@ class MeshConverter:
if crit not in self._dspans[location]:
# AgeName_[District_]_Page_RenderLevel_Crit[Blend]Spans
# Just because it's nice to be consistent
node = self._mgr.get_scene_node(location)
node = self._mgr.get_scene_node(location=location)
name = "{}_{:08X}_{:X}{}".format(node.name, crit.render_level.level, crit.criteria, crit.span_type)
dspan = self._mgr.add_object(pl=plDrawableSpans, name=name, loc=location)

2
korman/operators/op_modifier.py

@ -22,7 +22,7 @@ def _fetch_modifiers():
items = []
mapping = modifiers.modifier_mapping()
for i in mapping.keys():
for i in sorted(mapping.keys()):
items.append(("", i, ""))
items.extend(mapping[i])
#yield ("", i, "")

5
korman/properties/modifiers/base.py

@ -28,6 +28,11 @@ class PlasmaModifierProperties(bpy.types.PropertyGroup):
def enabled(self):
return self.display_order >= 0
@property
def requires_actor(self):
"""Indicates if this modifier requires the object to be a movable actor"""
return False
# Guess what?
# You can't register properties on a base class--Blender isn't smart enough to do inheritance,
# you see... So, we'll store our definitions in a dict and make those properties on each subclass

4
korman/properties/modifiers/logic.py

@ -33,3 +33,7 @@ class PlasmaSpawnPoint(PlasmaModifierProperties):
# place the avatar can show up." Nice to have a simple one to get started with.
spawn = exporter.mgr.add_object(pl=plSpawnModifier, bl=bo, name=self.display_name)
so.addModifier(spawn.key)
@property
def requires_actor(self):
return True

5
korman/ui/ui_modifiers.py

@ -73,10 +73,7 @@ class PlasmaModifiersPanel(ModifierButtonsPanel, bpy.types.Panel):
row = layout.row(align=True)
exicon = "TRIA_DOWN" if modifier.show_expanded else "TRIA_RIGHT"
row.prop(modifier, "show_expanded", text="", icon=exicon, emboss=False)
if hasattr(modifier, "bl_icon"):
row.label(icon=modifier.bl_icon)
else:
row.label(text=modifier.bl_label)
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

Loading…
Cancel
Save