From 7bc9e9833ba77545921b2db6d43921c57d2a110e Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Sat, 19 Mar 2022 20:33:31 -0400 Subject: [PATCH] Add kDynamicBlocker collider toggle. Exports a collider that should hopefully block only dynamic objects (kickables). Also, some formatting adjustments to the properties script to match others (this can be undone if wanted) --- korman/exporter/physics.py | 53 +++++++++++++----------- korman/properties/modifiers/physics.py | 57 +++++++++++++++++++------- korman/ui/modifiers/physics.py | 2 + 3 files changed, 72 insertions(+), 40 deletions(-) diff --git a/korman/exporter/physics.py b/korman/exporter/physics.py index 0a6a0e9..aee83bb 100644 --- a/korman/exporter/physics.py +++ b/korman/exporter/physics.py @@ -165,33 +165,36 @@ class PhysicsConverter: physical.friction = mod.friction physical.restitution = mod.restitution - if mod.dynamic: - if ver <= pvPots: - physical.collideGroup = (1 << plSimDefs.kGroupDynamic) | \ - (1 << plSimDefs.kGroupStatic) - physical.memberGroup = plSimDefs.kGroupDynamic - physical.mass = mod.mass - _set_phys_prop(plSimulationInterface.kStartInactive, simIface, physical, - value=mod.start_asleep) - elif not mod.avatar_blocker: - physical.memberGroup = plSimDefs.kGroupLOSOnly + if not mod.dynamic_blocker: + if mod.dynamic: + if ver <= pvPots: + physical.collideGroup = (1 << plSimDefs.kGroupDynamic) | \ + (1 << plSimDefs.kGroupStatic) + physical.memberGroup = plSimDefs.kGroupDynamic + physical.mass = mod.mass + _set_phys_prop(plSimulationInterface.kStartInactive, simIface, physical, + value=mod.start_asleep) + elif not mod.avatar_blocker: + physical.memberGroup = plSimDefs.kGroupLOSOnly + else: + physical.memberGroup = plSimDefs.kGroupStatic + + # Line of Sight DB + if mod.camera_blocker: + physical.LOSDBs |= plSimDefs.kLOSDBCameraBlockers + _set_phys_prop(plSimulationInterface.kCameraAvoidObject, simIface, physical) + if mod.terrain: + physical.LOSDBs |= plSimDefs.kLOSDBAvatarWalkable else: - physical.memberGroup = plSimDefs.kGroupStatic - - # Line of Sight DB - if mod.camera_blocker: - physical.LOSDBs |= plSimDefs.kLOSDBCameraBlockers - _set_phys_prop(plSimulationInterface.kCameraAvoidObject, simIface, physical) - if mod.terrain: - physical.LOSDBs |= plSimDefs.kLOSDBAvatarWalkable - - # Hacky? We'd like to share the simple surface descriptors(TM) as much as possible... - # This could result in a few orphaned PhysicalSndGroups, but I think that's preferable - # to having a bunch of empty objects...? + physical.memberGroup = plSimDefs.kDynamicBlocker + + # Hacky? We'd like to share the simple surface descriptors(TM) as much as possible... + # This could result in a few orphaned PhysicalSndGroups, but I think that's preferable + # to having a bunch of empty objects...? if mod.surface != "kNone": - sndgroup = self._mgr.find_create_object(plPhysicalSndGroup, so=so, name="SURFACEGEN_{}".format(mod.surface)) - sndgroup.group = getattr(plPhysicalSndGroup, mod.surface) - physical.soundGroup = sndgroup.key + sndgroup = self._mgr.find_create_object(plPhysicalSndGroup, so=so, name="SURFACEGEN_{}".format(mod.surface)) + sndgroup.group = getattr(plPhysicalSndGroup, mod.surface) + physical.soundGroup = sndgroup.key else: group_name = kwargs.get("member_group") if group_name: diff --git a/korman/properties/modifiers/physics.py b/korman/properties/modifiers/physics.py index bf4c7ff..8ca529f 100644 --- a/korman/properties/modifiers/physics.py +++ b/korman/properties/modifiers/physics.py @@ -69,18 +69,42 @@ class PlasmaCollider(PlasmaModifierProperties): bl_icon = "MOD_PHYSICS" bl_description = "Simple physical collider" - bounds = EnumProperty(name="Bounds Type", description="", items=bounds_types, default="hull") - - avatar_blocker = BoolProperty(name="Blocks Avatars", description="Object blocks avatars", default=True) - camera_blocker = BoolProperty(name="Blocks Camera LOS", description="Object blocks camera line-of-sight", default=True) - - friction = FloatProperty(name="Friction", min=0.0, default=0.5) - restitution = FloatProperty(name="Restitution", description="Coefficient of collision elasticity", min=0.0, max=1.0) - terrain = BoolProperty(name="Terrain", description="Object represents the ground", default=False) - - dynamic = BoolProperty(name="Dynamic", description="Object can be influenced by other objects (ie is kickable)", default=False) - mass = FloatProperty(name="Mass", description="Mass of object in pounds", min=0.0, default=1.0) - start_asleep = BoolProperty(name="Start Asleep", description="Object is not active until influenced by another object", default=False) + bounds = EnumProperty(name="Bounds Type", + description="", + items=bounds_types, + default="hull") + + avatar_blocker = BoolProperty(name="Blocks Avatars", + description="Object blocks avatars", + default=True) + camera_blocker = BoolProperty(name="Blocks Camera LOS", + description="Object blocks camera line-of-sight", + default=True) + dynamic_blocker = BoolProperty(name="Blocks Dynamics", + description="Object blocks dynamic objects (kickables)", + default=False) + + friction = FloatProperty(name="Friction", + min=0.0, + default=0.5) + restitution = FloatProperty(name="Restitution", + description="Coefficient of collision elasticity", + min=0.0, + max=1.0) + terrain = BoolProperty(name="Terrain", + description="Object represents the ground", + default=False) + + dynamic = BoolProperty(name="Dynamic", + description="Object can be influenced by other objects (ie is kickable)", + default=False) + mass = FloatProperty(name="Mass", + description="Mass of object in pounds", + min=0.0, + default=1.0) + start_asleep = BoolProperty(name="Start Asleep", + description="Object is not active until influenced by another object", + default=False) proxy_object = PointerProperty(name="Proxy", description="Object used as the collision geometry", @@ -118,9 +142,12 @@ class PlasmaSubworld(PlasmaModifierProperties): default="auto", options=set()) gravity = FloatVectorProperty(name="Gravity", - description="Subworld's gravity defined in feet per second squared", - size=3, default=(0.0, 0.0, -32.174), precision=3, - subtype="ACCELERATION", unit="ACCELERATION") + description="Subworld's gravity defined in feet per second squared", + size=3, + default=(0.0, 0.0, -32.174), + precision=3, + subtype="ACCELERATION", + unit="ACCELERATION") def export(self, exporter, bo, so): if self.is_dedicated_subworld(exporter): diff --git a/korman/ui/modifiers/physics.py b/korman/ui/modifiers/physics.py index c8d83a2..733e809 100644 --- a/korman/ui/modifiers/physics.py +++ b/korman/ui/modifiers/physics.py @@ -20,6 +20,8 @@ def collision(modifier, layout, context): split = layout.split() col = split.column() + col.prop(modifier, "dynamic_blocker") + col.active != modifier.dynamic_blocker) col.prop(modifier, "avatar_blocker") col.prop(modifier, "camera_blocker") col.prop(modifier, "terrain")