From ed5b6d702252ff68b351b3d44c5ecc792bf09ff9 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 23 Dec 2017 21:46:33 -0500 Subject: [PATCH] Implement the Filter Transform modifier This causes an object to be given a plFilterCoordInterface instead of a plCoordinateInterface. The difference is that plFilterCoordInterface will reject changes to certain components of an object's transform. This is useful in certain parenting situations, namely subworlds. --- korman/exporter/convert.py | 3 +- korman/properties/modifiers/anim.py | 43 +++++++++++++++++++++++++++++ korman/properties/prop_object.py | 7 +++++ korman/ui/modifiers/anim.py | 12 ++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/korman/exporter/convert.py b/korman/exporter/convert.py index edf378e..801a6ba 100644 --- a/korman/exporter/convert.py +++ b/korman/exporter/convert.py @@ -191,7 +191,8 @@ class Exporter: if so is None: so = self.mgr.find_create_object(plSceneObject, bl=bl) if so.coord is None: - ci = self.mgr.add_object(plCoordinateInterface, bl=bl, so=so) + ci_cls = bl.plasma_object.ci_type + ci = self.mgr.add_object(ci_cls, bl=bl, so=so) # Now we have the "fun" work of filling in the CI ci.localToWorld = utils.matrix44(bl.matrix_basis) diff --git a/korman/properties/modifiers/anim.py b/korman/properties/modifiers/anim.py index 341e9cd..9821636 100644 --- a/korman/properties/modifiers/anim.py +++ b/korman/properties/modifiers/anim.py @@ -104,6 +104,49 @@ class AnimGroupObject(idprops.IDPropObjectMixin, bpy.types.PropertyGroup): return {"child_anim": "object_name"} +class PlasmaAnimationFilterModifier(PlasmaModifierProperties): + pl_id = "animation_filter" + + bl_category = "Animation" + bl_label = "Filter Transform" + bl_description = "Filter animation components" + bl_icon = "UNLINKED" + + no_rotation = BoolProperty(name="Filter Rotation", + description="Filter rotations", + options=set()) + + no_transX = BoolProperty(name="Filter X Translation", + description="Filter the X component of translations", + options=set()) + no_transY = BoolProperty(name="Filter Y Translation", + description="Filter the Y component of translations", + options=set()) + no_transZ = BoolProperty(name="Filter Z Translation", + description="Filter the Z component of translations", + options=set()) + + def export(self, exporter, bo, so): + # By this point, the object should already have a plFilterCoordInterface + # created by the converter. Let's test that assumption. + coord = so.coord.object + assert isinstance(coord, plFilterCoordInterface) + + # Apply filtercoordinterface properties + if self.no_rotation: + coord.filterMask |= plFilterCoordInterface.kNoRotation + if self.no_transX: + coord.filterMask |= plFilterCoordInterface.kNoTransX + if self.no_transY: + coord.filterMask |= plFilterCoordInterface.kNoTransY + if self.no_transZ: + coord.filterMask |= plFilterCoordInterface.kNoTransZ + + @property + def requires_actor(self): + return True + + class PlasmaAnimationGroupModifier(ActionModifier, PlasmaModifierProperties): pl_id = "animation_group" pl_depends = {"animation"} diff --git a/korman/properties/prop_object.py b/korman/properties/prop_object.py index 2ea9e55..4cd02d0 100644 --- a/korman/properties/prop_object.py +++ b/korman/properties/prop_object.py @@ -52,6 +52,13 @@ class PlasmaObject(bpy.types.PropertyGroup): default=False, options={"HIDDEN"}) + @property + def ci_type(self): + if self.id_data.plasma_modifiers.animation_filter.enabled: + return plFilterCoordInterface + else: + return plCoordinateInterface + @property def has_animation_data(self): bo = self.id_data diff --git a/korman/ui/modifiers/anim.py b/korman/ui/modifiers/anim.py index a17f0c4..681e43a 100644 --- a/korman/ui/modifiers/anim.py +++ b/korman/ui/modifiers/anim.py @@ -42,6 +42,18 @@ def animation(modifier, layout, context): col.prop_search(modifier, "loop_start", action, "pose_markers", icon="PMARKER") col.prop_search(modifier, "loop_end", action, "pose_markers", icon="PMARKER") +def animation_filter(modifier, layout, context): + split = layout.split() + + col = split.column() + col.label("Translation:") + col.prop(modifier, "no_transX", text="Filter X") + col.prop(modifier, "no_transY", text="Filter Y") + col.prop(modifier, "no_transZ", text="Filter Z") + + col = split.column() + col.label("Rotation:") + col.prop(modifier, "no_rotation", text="Filter Rotation") class GroupListUI(bpy.types.UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_property, index=0, flt_flag=0):