Browse Source

Unify physical exporting steps

pull/8/head
Adam Johnson 10 years ago
parent
commit
ad0c8cee27
  1. 7
      korman/exporter/physics.py
  2. 3
      korman/nodes/node_conditions.py
  3. 5
      korman/properties/modifiers/physics.py
  4. 3
      korman/properties/modifiers/region.py

7
korman/exporter/physics.py

@ -65,7 +65,7 @@ class PhysicsConverter:
else:
return vertices
def generate_physical(self, bo, so, name=None):
def generate_physical(self, bo, so, bounds, name=None):
"""Generates a physical object for the given object pair"""
if so.sim is None:
if name is None:
@ -77,6 +77,8 @@ class PhysicsConverter:
simIface.physical = physical.key
physical.object = so.key
physical.sceneNode = self._mgr.get_scene_node(bl=bo)
getattr(self, "_export_{}".format(bounds))(bo, physical)
else:
simIface = so.sim.object
physical = simIface.physical.object
@ -85,9 +87,6 @@ class PhysicsConverter:
return (simIface, physical)
def export(self, bo, physical, bounds):
getattr(self, "_export_{}".format(bounds))(bo, physical)
def _export_box(self, bo, physical):
"""Exports box bounds based on the object"""
physical.boundsType = plSimDefs.kBoxBounds

3
korman/nodes/node_conditions.py

@ -101,9 +101,8 @@ class PlasmaVolumeSensorNode(PlasmaNodeBase, bpy.types.Node):
# Don't forget to export the physical object itself!
# [trollface.jpg]
simIface, physical = exporter.physics.generate_physical(bo, so, "{}_VolumeSensor".format(bo.name))
phys_bo = bpy.data.objects[self.region]
exporter.physics.export(phys_bo, physical, self.bounds)
simIface, physical = exporter.physics.generate_physical(phys_bo, so, self.bounds, "{}_VolumeSensor".format(bo.name))
physical.memberGroup = plSimDefs.kGroupDetector
if "avatar" in self.report_on:

5
korman/properties/modifiers/physics.py

@ -59,7 +59,7 @@ class PlasmaCollider(PlasmaModifierProperties):
self.display_name = "{}_Collision".format(obj.name)
def export(self, exporter, bo, so):
simIface, physical = exporter.physics.generate_physical(bo, so, self.display_name)
simIface, physical = exporter.physics.generate_physical(bo, so, self.bounds, self.display_name)
# Common props
physical.friction = self.friction
@ -84,9 +84,6 @@ class PlasmaCollider(PlasmaModifierProperties):
if self.terrain:
physical.LOSDBs |= plSimDefs.kLOSDBAvatarWalkable
# Pass this off to the PhysicsConverter to export the meat
exporter.physics.export(bo, physical, self.bounds)
@property
def requires_actor(self):
return self.dynamic

3
korman/properties/modifiers/region.py

@ -129,12 +129,11 @@ class PlasmaPanicLinkRegion(PlasmaModifierProperties):
def export(self, exporter, bo, so):
# Generate the base physical object
simIface, physical = exporter.physics.generate_physical(bo, so, self.display_name)
if self.exact_bounds:
bounds = "trimesh"
else:
bounds = "hull"
exporter.physics.export(bo, physical, bounds)
simIface, physical = exporter.physics.generate_physical(bo, so, bounds, self.display_name)
# Now setup the region detector properties
physical.memberGroup = plSimDefs.kGroupDetector

Loading…
Cancel
Save