From 1b0e2e715e73b854746a64d984b3c36a6c587e44 Mon Sep 17 00:00:00 2001 From: jb Date: Sun, 7 Feb 2016 11:32:36 +0100 Subject: [PATCH 1/6] Don't force clamping on stencils --- korman/exporter/material.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/korman/exporter/material.py b/korman/exporter/material.py index 2cb2eac..7a938b9 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -166,7 +166,8 @@ class MaterialConverter: if slot.use_stencil: hsgmat.compFlags |= hsGMaterial.kCompNeedsBlendChannel state.blendFlags |= hsGMatState.kBlendAlpha | hsGMatState.kBlendAlphaMult | hsGMatState.kBlendNoTexColor - state.clampFlags |= hsGMatState.kClampTexture + if slot.texture and slot.texture.type == "BLEND": + state.clampFlags |= hsGMatState.kClampTexture state.ZFlags |= hsGMatState.kZNoZWrite layer.ambient = hsColorRGBA(1.0, 1.0, 1.0, 1.0) From b73489337eaa2363992b2c64c22754d3b66a74cf Mon Sep 17 00:00:00 2001 From: jb Date: Sun, 7 Feb 2016 12:09:07 +0100 Subject: [PATCH 2/6] Physical objects can be animated --- korman/exporter/physics.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/korman/exporter/physics.py b/korman/exporter/physics.py index 69d5e89..2db134f 100644 --- a/korman/exporter/physics.py +++ b/korman/exporter/physics.py @@ -77,6 +77,14 @@ class PhysicsConverter: physical.sceneNode = self._mgr.get_scene_node(bl=bo) getattr(self, "_export_{}".format(bounds))(bo, physical) + + if self._exporter().has_coordiface(bo): + if not physical.mass: + # ...Since the object has a coordinate interface but isn't a kickable, it's likely going to be animated. In such case, + # we must warn Plasma to have the collisions follow the object's coordinates as well. + physical.mass = 1. + simIface.setProperty(plSimulationInterface.kPinned, True) + physical.setProperty(plSimulationInterface.kPinned, True) else: simIface = so.sim.object physical = simIface.physical.object From e15eccfac5c56caaa2c60a18d491ef539368fa17 Mon Sep 17 00:00:00 2001 From: jb Date: Wed, 10 Feb 2016 22:26:46 +0100 Subject: [PATCH 3/6] Move animated physical code into anim post_export + remove a useless test --- korman/exporter/material.py | 2 +- korman/exporter/physics.py | 8 -------- korman/properties/modifiers/anim.py | 9 +++++++++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/korman/exporter/material.py b/korman/exporter/material.py index 7a938b9..66c5636 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -166,7 +166,7 @@ class MaterialConverter: if slot.use_stencil: hsgmat.compFlags |= hsGMaterial.kCompNeedsBlendChannel state.blendFlags |= hsGMatState.kBlendAlpha | hsGMatState.kBlendAlphaMult | hsGMatState.kBlendNoTexColor - if slot.texture and slot.texture.type == "BLEND": + if slot.texture.type == "BLEND": state.clampFlags |= hsGMatState.kClampTexture state.ZFlags |= hsGMatState.kZNoZWrite layer.ambient = hsColorRGBA(1.0, 1.0, 1.0, 1.0) diff --git a/korman/exporter/physics.py b/korman/exporter/physics.py index 2db134f..69d5e89 100644 --- a/korman/exporter/physics.py +++ b/korman/exporter/physics.py @@ -77,14 +77,6 @@ class PhysicsConverter: physical.sceneNode = self._mgr.get_scene_node(bl=bo) getattr(self, "_export_{}".format(bounds))(bo, physical) - - if self._exporter().has_coordiface(bo): - if not physical.mass: - # ...Since the object has a coordinate interface but isn't a kickable, it's likely going to be animated. In such case, - # we must warn Plasma to have the collisions follow the object's coordinates as well. - physical.mass = 1. - simIface.setProperty(plSimulationInterface.kPinned, True) - physical.setProperty(plSimulationInterface.kPinned, True) else: simIface = so.sim.object physical = simIface.physical.object diff --git a/korman/properties/modifiers/anim.py b/korman/properties/modifiers/anim.py index aaa0156..35bc254 100644 --- a/korman/properties/modifiers/anim.py +++ b/korman/properties/modifiers/anim.py @@ -143,6 +143,15 @@ class PlasmaAnimationModifier(PlasmaModifierProperties): # If the mass is zero, then we will fail to animate. Fix that. if phys.mass == 0.0: phys.mass = 1.0 + + # On CC and Prime, set kPinned so it doesn't fall through + if bpy.context.scene.world.plasma_age.version in ["pvPots", "pvPrime"]: + sim.setProperty(plSimulationInterface.kPinned, True) + phys.setProperty(plSimulationInterface.kPinned, True) + + # Do the same for children objects + for child in so.coord.object.children: + self.post_export(exporter, None, child.object) class AnimGroupObject(bpy.types.PropertyGroup): From f895348b2152d7dc343f9b3be6127bb5e8d5d868 Mon Sep 17 00:00:00 2001 From: jb Date: Mon, 15 Feb 2016 21:40:59 +0100 Subject: [PATCH 4/6] Move physics handling code outside of post_export --- korman/properties/modifiers/anim.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/korman/properties/modifiers/anim.py b/korman/properties/modifiers/anim.py index 35bc254..dbd4690 100644 --- a/korman/properties/modifiers/anim.py +++ b/korman/properties/modifiers/anim.py @@ -133,6 +133,9 @@ class PlasmaAnimationModifier(PlasmaModifierProperties): 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 + self.make_physical_movable(so) + + def make_physical_movable(self, so): sim = so.sim if sim is not None: sim = sim.object @@ -144,14 +147,13 @@ class PlasmaAnimationModifier(PlasmaModifierProperties): if phys.mass == 0.0: phys.mass = 1.0 - # On CC and Prime, set kPinned so it doesn't fall through - if bpy.context.scene.world.plasma_age.version in ["pvPots", "pvPrime"]: - sim.setProperty(plSimulationInterface.kPinned, True) - phys.setProperty(plSimulationInterface.kPinned, True) + # set kPinned so it doesn't fall through + sim.setProperty(plSimulationInterface.kPinned, True) + phys.setProperty(plSimulationInterface.kPinned, True) # Do the same for children objects for child in so.coord.object.children: - self.post_export(exporter, None, child.object) + self.make_physical_movable(child.object) class AnimGroupObject(bpy.types.PropertyGroup): From ce2d393099c54ecdb08f9210bf37a8bf5b36d5dd Mon Sep 17 00:00:00 2001 From: jb Date: Thu, 18 Feb 2016 22:03:26 +0100 Subject: [PATCH 5/6] Move make_physical_movable and make it private --- korman/properties/modifiers/anim.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/korman/properties/modifiers/anim.py b/korman/properties/modifiers/anim.py index dbd4690..556d693 100644 --- a/korman/properties/modifiers/anim.py +++ b/korman/properties/modifiers/anim.py @@ -130,12 +130,8 @@ class PlasmaAnimationModifier(PlasmaModifierProperties): @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 - self.make_physical_movable(so) - def make_physical_movable(self, so): + def __make_physical_movable(self, so): sim = so.sim if sim is not None: sim = sim.object @@ -155,6 +151,10 @@ class PlasmaAnimationModifier(PlasmaModifierProperties): for child in so.coord.object.children: self.make_physical_movable(child.object) + 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 + self.__make_physical_movable(so) + class AnimGroupObject(bpy.types.PropertyGroup): object_name = StringProperty(name="Child", From 36a37503723d7612464fceb6236e30fb1a247113 Mon Sep 17 00:00:00 2001 From: jb Date: Fri, 19 Feb 2016 22:34:36 +0100 Subject: [PATCH 6/6] Only one underscode in make_physical_movable (ack !) --- korman/properties/modifiers/anim.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/korman/properties/modifiers/anim.py b/korman/properties/modifiers/anim.py index 556d693..77be132 100644 --- a/korman/properties/modifiers/anim.py +++ b/korman/properties/modifiers/anim.py @@ -131,7 +131,7 @@ class PlasmaAnimationModifier(PlasmaModifierProperties): def key_name(self): return "{}_(Entire Animation)".format(self.id_data.name) - def __make_physical_movable(self, so): + def _make_physical_movable(self, so): sim = so.sim if sim is not None: sim = sim.object @@ -153,7 +153,7 @@ class PlasmaAnimationModifier(PlasmaModifierProperties): 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 - self.__make_physical_movable(so) + self._make_physical_movable(so) class AnimGroupObject(bpy.types.PropertyGroup):