Merge pull request #2135 from N8n5h/physics-2

Expose the exported rigid body type to the UI to make rb less confusing
This commit is contained in:
Lubos Lenco 2021-03-21 13:03:34 +01:00 committed by GitHub
commit d88d2320ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View file

@ -2308,6 +2308,10 @@ class ArmoryExporter:
return instanced_type, instanced_data
@staticmethod
def rigid_body_static(rb):
return (not rb.enabled and not rb.kinematic) or (rb.type == 'PASSIVE' and not rb.kinematic)
def post_export_object(self, bobject: bpy.types.Object, o, type):
# Export traits
self.export_traits(bobject, o)
@ -2334,7 +2338,7 @@ class ArmoryExporter:
elif rb.collision_shape == 'CAPSULE':
shape = 6
body_mass = rb.mass
is_static = (not rb.enabled and not rb.kinematic) or (rb.type == 'PASSIVE' and not rb.kinematic)
is_static = self.rigid_body_static(rb)
if is_static:
body_mass = 0
x = {}

View file

@ -22,6 +22,8 @@ from arm.lightmapper.utility import icon
from arm.lightmapper.properties.denoiser import oidn, optix
import importlib
from arm.exporter import ArmoryExporter
# Menu in object region
class ARM_PT_ObjectPropsPanel(bpy.types.Panel):
bl_label = "Armory Props"
@ -180,7 +182,19 @@ class ARM_PT_PhysicsPropsPanel(bpy.types.Panel):
if obj == None:
return
if obj.rigid_body != None:
rb = obj.rigid_body
if rb is not None:
col = layout.column()
row = col.row()
row.alignment = 'RIGHT'
rb_type = 'Dynamic'
if ArmoryExporter.rigid_body_static(rb):
rb_type = 'Static'
if rb.kinematic:
rb_type = 'Kinematic'
row.label(text=(f'Rigid Body Export Type: {rb_type}'), icon='AUTO')
layout.prop(obj, 'arm_rb_linear_factor')
layout.prop(obj, 'arm_rb_angular_factor')
layout.prop(obj, 'arm_rb_trigger')