From 094c784dd2cd266e2e7ad024d4e90de1200b1851 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 6 Jul 2015 19:37:12 -0400 Subject: [PATCH] Add last-chance export pass This allows us to inspect our objects just before we blast them out, preventing race conditions. Implement physical animations as an example. --- korman/exporter/convert.py | 20 +++++++++++++++++--- korman/properties/modifiers/anim.py | 9 +++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/korman/exporter/convert.py b/korman/exporter/convert.py index a657cec..d68bc0a 100644 --- a/korman/exporter/convert.py +++ b/korman/exporter/convert.py @@ -61,6 +61,10 @@ class Exporter: # Step 3: Export all the things! self._export_scene_objects() + # Step 3.1: Now that all Plasma Objects (save Mipmaps) are exported, we do any post + # processing that needs to inspect those objects + self._post_process_scene_objects() + # Step 4: Finalize... self.mesh.material.finalize() self.mesh.finalize() @@ -188,9 +192,6 @@ class Exporter: print(" Exporting '{}' modifier as '{}'".format(mod.bl_label, mod.display_name)) mod.export(self, bl_obj, sceneobject) - # Last, but not least, apply synch settings - bl_obj.plasma_net.export(bl_obj, sceneobject) - def _export_empty_blobj(self, so, bo): # We don't need to do anything here. This function just makes sure we don't error out # or add a silly special case :( @@ -205,3 +206,16 @@ class Exporter: self.mesh.export_object(bo) else: print(" No material(s) on the ObData, so no drawables") + + def _post_process_scene_objects(self): + print("\nPostprocessing SceneObjects...") + for bl_obj in self._objects: + sceneobject = self.mgr.find_key(plSceneObject, bl=bl_obj).object + bl_obj.plasma_net.export(bl_obj, sceneobject) + + # Modifiers don't have to expose post-processing, but if they do, run it + 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)) + proc(self, bl_obj, sceneobject) diff --git a/korman/properties/modifiers/anim.py b/korman/properties/modifiers/anim.py index 328ec0c..0a757bb 100644 --- a/korman/properties/modifiers/anim.py +++ b/korman/properties/modifiers/anim.py @@ -128,6 +128,15 @@ class PlasmaAnimationModifier(PlasmaModifierProperties): agmaster = exporter.mgr.add_object(plAGMasterMod, so=so, name=self.display_name) agmaster.addPrivateAnim(atcanim.key) + 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 + if sim is not None: + sim = sim.object + sim.setProperty(plSimulationInterface.kPhysAnim, True) + phys = sim.physical.object + phys.setProperty(plSimulationInterface.kPhysAnim, True) + class LoopMarker(bpy.types.PropertyGroup): loop_name = StringProperty(name="Loop Name",