Browse Source

Add support for triangle mesh proxy collision.

pull/197/head
Adam Johnson 4 years ago
parent
commit
2f925221ff
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 11
      korman/exporter/physics.py
  2. 6
      korman/properties/modifiers/physics.py
  3. 5
      korman/ui/modifiers/physics.py

11
korman/exporter/physics.py

@ -282,9 +282,16 @@ class PhysicsConverter:
def _export_trimesh(self, bo, physical, local_space):
"""Exports an object's mesh as exact physical bounds"""
physical.boundsType = plSimDefs.kExplicitBounds
vertices, indices = self._convert_mesh_data(bo, physical, local_space)
# Triangle meshes MAY optionally specify a proxy object to fetch the triangles from...
mod = bo.plasma_modifiers.collision
if mod.enabled and mod.proxy_object is not None:
physical.boundsType = plSimDefs.kProxyBounds
vertices, indices = self._convert_mesh_data(mod.proxy_object, physical, local_space)
else:
physical.boundsType = plSimDefs.kExplicitBounds
vertices, indices = self._convert_mesh_data(bo, physical, local_space)
physical.verts = vertices
physical.indices = indices

6
korman/properties/modifiers/physics.py

@ -19,6 +19,7 @@ from PyHSPlasma import *
from .base import PlasmaModifierProperties
from ...exporter import ExportError
from ... import idprops
# These are the kinds of physical bounds Plasma can work with.
# This sequence is acceptable in any EnumProperty
@ -62,6 +63,11 @@ class PlasmaCollider(PlasmaModifierProperties):
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",
type=bpy.types.Object,
poll=idprops.poll_mesh_objects)
def export(self, exporter, bo, so):
# All modifier properties are examined by this little stinker...
exporter.physics.generate_physical(bo, so)

5
korman/ui/modifiers/physics.py

@ -39,6 +39,11 @@ def collision(modifier, layout, context):
col.active = modifier.dynamic
col.prop(modifier, "mass")
layout.separator()
row = layout.row()
row.active = modifier.bounds == "trimesh"
row.prop(modifier, "proxy_object")
def subworld_def(modifier, layout, context):
layout.prop(modifier, "sub_type")
if modifier.sub_type != "dynamicav":

Loading…
Cancel
Save