From ad0c8cee275db2b552eceb9aa8a0cb7286a5ba57 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 27 Jun 2015 20:37:57 -0400 Subject: [PATCH] Unify physical exporting steps --- korman/exporter/physics.py | 7 +++---- korman/nodes/node_conditions.py | 3 +-- korman/properties/modifiers/physics.py | 5 +---- korman/properties/modifiers/region.py | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/korman/exporter/physics.py b/korman/exporter/physics.py index 352bf2b..e0e52c6 100644 --- a/korman/exporter/physics.py +++ b/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 diff --git a/korman/nodes/node_conditions.py b/korman/nodes/node_conditions.py index 6aad214..759164b 100644 --- a/korman/nodes/node_conditions.py +++ b/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: diff --git a/korman/properties/modifiers/physics.py b/korman/properties/modifiers/physics.py index cb004f9..8a80096 100644 --- a/korman/properties/modifiers/physics.py +++ b/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 diff --git a/korman/properties/modifiers/region.py b/korman/properties/modifiers/region.py index 89c96f3..c0f0bd3 100644 --- a/korman/properties/modifiers/region.py +++ b/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