UI: Single column layout and sub-panels for Rigid Body Physics panels
This commit is contained in:

committed by
Pablo Vazquez

parent
1f809f34c1
commit
2499ee64a1
@@ -39,20 +39,23 @@ class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
|
||||
ob = context.object
|
||||
rbo = ob.rigid_body
|
||||
|
||||
if rbo is not None:
|
||||
layout.prop(rbo, "type", text="Type")
|
||||
row = layout.row()
|
||||
if rbo.type == 'ACTIVE':
|
||||
row.prop(rbo, "enabled", text="Dynamic")
|
||||
row.prop(rbo, "kinematic", text="Animated")
|
||||
|
||||
if rbo.type == 'ACTIVE':
|
||||
layout.prop(rbo, "mass")
|
||||
|
||||
col = layout.column()
|
||||
if rbo.type == 'ACTIVE':
|
||||
col.prop(rbo, "enabled", text="Dynamic")
|
||||
col.prop(rbo, "kinematic", text="Animated")
|
||||
|
||||
|
||||
|
||||
class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
|
||||
bl_label = "Collisions"
|
||||
@@ -70,6 +73,7 @@ class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
|
||||
|
||||
ob = context.object
|
||||
rbo = ob.rigid_body
|
||||
layout.use_property_split = True
|
||||
|
||||
layout.prop(rbo, "collision_shape", text="Shape")
|
||||
|
||||
@@ -79,15 +83,51 @@ class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
|
||||
if rbo.collision_shape == 'MESH' and rbo.mesh_source == 'DEFORM':
|
||||
layout.prop(rbo, "use_deform", text="Deforming")
|
||||
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
col.label(text="Surface Response:")
|
||||
class PHYSICS_PT_rigid_body_collisions_surface(PHYSICS_PT_rigidbody_panel, Panel):
|
||||
bl_label = "Surface Response"
|
||||
bl_parent_id = 'PHYSICS_PT_rigid_body_collisions'
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
obj = context.object
|
||||
return (obj and obj.rigid_body and
|
||||
(context.engine in cls.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
ob = context.object
|
||||
rbo = ob.rigid_body
|
||||
layout.use_property_split = True
|
||||
|
||||
col = layout.column()
|
||||
col.prop(rbo, "friction")
|
||||
col.prop(rbo, "restitution", text="Bounciness")
|
||||
|
||||
col = split.column()
|
||||
col.label(text="Sensitivity:")
|
||||
class PHYSICS_PT_rigid_body_collisions_sensitivity(PHYSICS_PT_rigidbody_panel, Panel):
|
||||
bl_label = "Sensitivity"
|
||||
bl_parent_id = 'PHYSICS_PT_rigid_body_collisions'
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
obj = context.object
|
||||
return (obj and obj.rigid_body and
|
||||
(context.engine in cls.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
ob = context.object
|
||||
rbo = ob.rigid_body
|
||||
layout.use_property_split = True
|
||||
|
||||
col = layout.column()
|
||||
|
||||
if rbo.collision_shape in {'MESH', 'CONE'}:
|
||||
col.prop(rbo, "collision_margin", text="Margin")
|
||||
else:
|
||||
@@ -96,7 +136,25 @@ class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
|
||||
sub.active = rbo.use_margin
|
||||
sub.prop(rbo, "collision_margin", text="Margin")
|
||||
|
||||
layout.prop(rbo, "collision_groups")
|
||||
class PHYSICS_PT_rigid_body_collisions_collections(PHYSICS_PT_rigidbody_panel, Panel):
|
||||
bl_label = "Collision Collections"
|
||||
bl_parent_id = 'PHYSICS_PT_rigid_body_collisions'
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
obj = context.object
|
||||
return (obj and obj.rigid_body and
|
||||
(context.engine in cls.COMPAT_ENGINES))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
ob = context.object
|
||||
rbo = ob.rigid_body
|
||||
|
||||
layout.prop(rbo, "collision_groups", text="")
|
||||
|
||||
|
||||
class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel):
|
||||
@@ -114,6 +172,7 @@ class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
|
||||
ob = context.object
|
||||
rbo = ob.rigid_body
|
||||
@@ -122,28 +181,53 @@ class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel):
|
||||
# col.label(text="Activation:")
|
||||
# XXX: settings such as activate on collison/etc.
|
||||
|
||||
split = layout.split()
|
||||
col = layout.column()
|
||||
col.prop(rbo, "linear_damping", text="Translation Damping")
|
||||
col.prop(rbo, "angular_damping", text="Rotation Damping")
|
||||
|
||||
col = split.column()
|
||||
col.label(text="Deactivation:")
|
||||
col.prop(rbo, "use_deactivation")
|
||||
sub = col.column()
|
||||
sub.active = rbo.use_deactivation
|
||||
sub.prop(rbo, "use_start_deactivated")
|
||||
sub.prop(rbo, "deactivate_linear_velocity", text="Linear Vel")
|
||||
sub.prop(rbo, "deactivate_angular_velocity", text="Angular Vel")
|
||||
# TODO: other params such as time?
|
||||
|
||||
col = split.column()
|
||||
col.label(text="Damping:")
|
||||
col.prop(rbo, "linear_damping", text="Translation")
|
||||
col.prop(rbo, "angular_damping", text="Rotation")
|
||||
class PHYSICS_PT_rigid_body_dynamics_deactivation(PHYSICS_PT_rigidbody_panel, Panel):
|
||||
bl_label = "Deactivation"
|
||||
bl_parent_id = 'PHYSICS_PT_rigid_body_dynamics'
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
obj = context.object
|
||||
return (obj and obj.rigid_body and
|
||||
obj.rigid_body.type == 'ACTIVE' and
|
||||
(context.engine in cls.COMPAT_ENGINES))
|
||||
|
||||
def draw_header(self, context):
|
||||
ob = context.object
|
||||
rbo = ob.rigid_body
|
||||
self.layout.prop(rbo, "use_deactivation", text="")
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
|
||||
ob = context.object
|
||||
rbo = ob.rigid_body
|
||||
|
||||
layout.active = rbo.use_deactivation
|
||||
|
||||
col = layout.column()
|
||||
col.prop(rbo, "use_start_deactivated")
|
||||
col.prop(rbo, "deactivate_linear_velocity", text="Linear Velocity")
|
||||
col.prop(rbo, "deactivate_angular_velocity", text="Angular Velocity")
|
||||
# TODO: other params such as time?
|
||||
|
||||
|
||||
classes = (
|
||||
PHYSICS_PT_rigid_body,
|
||||
PHYSICS_PT_rigid_body_collisions,
|
||||
PHYSICS_PT_rigid_body_collisions_surface,
|
||||
PHYSICS_PT_rigid_body_collisions_sensitivity,
|
||||
PHYSICS_PT_rigid_body_collisions_collections,
|
||||
PHYSICS_PT_rigid_body_dynamics,
|
||||
PHYSICS_PT_rigid_body_dynamics_deactivation,
|
||||
)
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
|
Reference in New Issue
Block a user