Files
test2/scripts/startup/bl_ui/properties_physics_softbody.py
Campbell Barton e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00

487 lines
14 KiB
Python

# SPDX-FileCopyrightText: 2009-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
from bpy.types import (
Panel,
)
from bl_ui.properties_physics_common import (
point_cache_ui,
effector_weights_ui,
)
COMPAT_OB_TYPES = {'MESH', 'LATTICE', 'CURVE', 'SURFACE', 'FONT'}
def softbody_panel_enabled(md):
return (md.point_cache.is_baked is False)
class PhysicButtonsPanel:
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "physics"
@classmethod
def poll(cls, context):
ob = context.object
return ob and ob.type in COMPAT_OB_TYPES and context.engine in cls.COMPAT_ENGINES and context.soft_body
class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
bl_label = "Soft Body"
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw(self, context):
layout = self.layout
layout.use_property_split = True
md = context.soft_body
softbody = md.settings
layout.prop(softbody, "collision_collection")
class PHYSICS_PT_softbody_object(PhysicButtonsPanel, Panel):
bl_label = "Object"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw(self, context):
layout = self.layout
layout.use_property_split = True
md = context.soft_body
softbody = md.settings
ob = context.object
layout.enabled = softbody_panel_enabled(md)
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
col = flow.column()
col.prop(softbody, "friction")
col.separator()
col = flow.column()
col.prop(softbody, "mass")
col.prop_search(softbody, "vertex_group_mass", ob, "vertex_groups", text="Control Point")
class PHYSICS_PT_softbody_simulation(PhysicButtonsPanel, Panel):
bl_label = "Simulation"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw(self, context):
layout = self.layout
layout.use_property_split = True
md = context.soft_body
softbody = md.settings
layout.enabled = softbody_panel_enabled(md)
layout.prop(softbody, "speed")
class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, Panel):
bl_label = "Cache"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw(self, context):
md = context.soft_body
point_cache_ui(self, md.point_cache, softbody_panel_enabled(md), 'SOFTBODY')
class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel):
bl_label = "Goal"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw_header(self, context):
softbody = context.soft_body.settings
self.layout.active = softbody_panel_enabled(context.soft_body)
self.layout.prop(softbody, "use_goal", text="")
def draw(self, context):
layout = self.layout
layout.use_property_split = True
md = context.soft_body
softbody = md.settings
ob = context.object
layout.active = softbody.use_goal and softbody_panel_enabled(md)
layout.prop_search(softbody, "vertex_group_goal", ob, "vertex_groups", text="Vertex Group")
class PHYSICS_PT_softbody_goal_strengths(PhysicButtonsPanel, Panel):
bl_label = "Strengths"
bl_parent_id = 'PHYSICS_PT_softbody_goal'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw(self, context):
layout = self.layout
layout.use_property_split = True
md = context.soft_body
softbody = md.settings
layout.active = softbody.use_goal and softbody_panel_enabled(md)
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
col = flow.column()
col.prop(softbody, "goal_default", text="Default")
col.separator()
col = flow.column(align=True)
col.prop(softbody, "goal_min", text="Min")
col.prop(softbody, "goal_max", text="Max")
class PHYSICS_PT_softbody_goal_settings(PhysicButtonsPanel, Panel):
bl_label = "Settings"
bl_parent_id = 'PHYSICS_PT_softbody_goal'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw(self, context):
layout = self.layout
layout.use_property_split = True
md = context.soft_body
softbody = md.settings
layout.active = softbody.use_goal and softbody_panel_enabled(md)
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
col = flow.column()
col.prop(softbody, "goal_spring", text="Stiffness")
col = flow.column()
col.prop(softbody, "goal_friction", text="Damping")
class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, Panel):
bl_label = "Edges"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw_header(self, context):
softbody = context.soft_body.settings
self.layout.active = softbody_panel_enabled(context.soft_body)
self.layout.prop(softbody, "use_edges", text="")
def draw(self, context):
layout = self.layout
layout.use_property_split = True
md = context.soft_body
softbody = md.settings
ob = context.object
layout.active = softbody.use_edges and softbody_panel_enabled(md)
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
col = flow.column()
col.prop_search(softbody, "vertex_group_spring", ob, "vertex_groups", text="Springs")
col.separator()
col.prop(softbody, "pull")
col.prop(softbody, "push")
col.separator()
col = flow.column()
col.prop(softbody, "damping")
col.prop(softbody, "plastic")
col.prop(softbody, "bend")
col.separator()
col = flow.column()
col.prop(softbody, "spring_length", text="Length")
col.separator()
col = flow.column(align=True, heading="Collision")
col.prop(softbody, "use_edge_collision", text="Edge", toggle=False)
col.prop(softbody, "use_face_collision", text="Face", toggle=False)
class PHYSICS_PT_softbody_edge_aerodynamics(PhysicButtonsPanel, Panel):
bl_label = "Aerodynamics"
bl_parent_id = 'PHYSICS_PT_softbody_edge'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw(self, context):
layout = self.layout
layout.use_property_split = True
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
md = context.soft_body
softbody = md.settings
flow.active = softbody.use_edges and softbody_panel_enabled(md)
col = flow.column()
col.prop(softbody, "aerodynamics_type", text="Type")
col = flow.column()
col.prop(softbody, "aero", text="Factor")
class PHYSICS_PT_softbody_edge_stiffness(PhysicButtonsPanel, Panel):
bl_label = "Stiffness"
bl_parent_id = 'PHYSICS_PT_softbody_edge'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw_header(self, context):
softbody = context.soft_body.settings
self.layout.active = softbody_panel_enabled(context.soft_body)
self.layout.prop(softbody, "use_stiff_quads", text="")
def draw(self, context):
layout = self.layout
layout.use_property_split = True
md = context.soft_body
softbody = md.settings
layout.active = softbody.use_edges and softbody.use_stiff_quads and softbody_panel_enabled(md)
layout.prop(softbody, "shear")
class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, Panel):
bl_label = "Self Collision"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw_header(self, context):
softbody = context.soft_body.settings
self.layout.active = softbody_panel_enabled(context.soft_body)
self.layout.prop(softbody, "use_self_collision", text="")
def draw(self, context):
layout = self.layout
layout.use_property_split = True
md = context.soft_body
softbody = md.settings
layout.active = softbody.use_self_collision and softbody_panel_enabled(md)
layout.prop(softbody, "collision_type", text="Calculation Type")
layout.separator()
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
col = flow.column()
col.prop(softbody, "ball_size", text="Ball Size")
col = flow.column()
col.prop(softbody, "ball_stiff", text="Stiffness")
col.prop(softbody, "ball_damp", text="Dampening")
class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, Panel):
bl_label = "Solver"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw(self, context):
layout = self.layout
layout.use_property_split = True
md = context.soft_body
softbody = md.settings
layout.active = softbody_panel_enabled(md)
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
col = flow.column(align=True)
col.prop(softbody, "step_min", text="Step Size Min")
col.prop(softbody, "step_max", text="Max")
col = flow.column()
col.prop(softbody, "use_auto_step", text="Auto-Step")
col.prop(softbody, "error_threshold")
class PHYSICS_PT_softbody_solver_diagnostics(PhysicButtonsPanel, Panel):
bl_label = "Diagnostics"
bl_parent_id = 'PHYSICS_PT_softbody_solver'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw(self, context):
layout = self.layout
layout.use_property_split = True
md = context.soft_body
softbody = md.settings
layout.active = softbody_panel_enabled(md)
layout.prop(softbody, "use_diagnose")
layout.prop(softbody, "use_estimate_matrix")
class PHYSICS_PT_softbody_solver_helpers(PhysicButtonsPanel, Panel):
bl_label = "Helpers"
bl_parent_id = 'PHYSICS_PT_softbody_solver'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw(self, context):
layout = self.layout
layout.use_property_split = True
md = context.soft_body
softbody = md.settings
layout.active = softbody_panel_enabled(md)
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
col = flow.column()
col.prop(softbody, "choke")
col = flow.column()
col.prop(softbody, "fuzzy")
class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, Panel):
bl_label = "Field Weights"
bl_parent_id = 'PHYSICS_PT_softbody'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw(self, context):
md = context.soft_body
softbody = md.settings
effector_weights_ui(self, softbody.effector_weights, 'SOFTBODY')
classes = (
PHYSICS_PT_softbody,
PHYSICS_PT_softbody_object,
PHYSICS_PT_softbody_simulation,
PHYSICS_PT_softbody_cache,
PHYSICS_PT_softbody_goal,
PHYSICS_PT_softbody_goal_settings,
PHYSICS_PT_softbody_goal_strengths,
PHYSICS_PT_softbody_edge,
PHYSICS_PT_softbody_edge_aerodynamics,
PHYSICS_PT_softbody_edge_stiffness,
PHYSICS_PT_softbody_collision,
PHYSICS_PT_softbody_solver,
PHYSICS_PT_softbody_solver_diagnostics,
PHYSICS_PT_softbody_solver_helpers,
PHYSICS_PT_softbody_field_weights,
)
if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)