Commit: 74d6113c329131f51994929ae5a43935eb6be2a6 Author: mattoverby Date: Mon Jul 27 19:06:36 2020 -0500 Branches: soc-2020-soft-body https://developer.blender.org/rB74d6113c329131f51994929ae5a43935eb6be2a6
added buttons to gui but they do nothing at the moment =================================================================== M extern/softbody/src/admmpd_types.h M release/scripts/startup/bl_ui/properties_physics_softbody.py M source/blender/makesdna/DNA_object_force_types.h M source/blender/makesrna/intern/rna_object_force.c =================================================================== diff --git a/extern/softbody/src/admmpd_types.h b/extern/softbody/src/admmpd_types.h index f96bd10c8e7..2903d0add95 100644 --- a/extern/softbody/src/admmpd_types.h +++ b/extern/softbody/src/admmpd_types.h @@ -21,7 +21,7 @@ enum EnergyTermType { }; struct Options { - double timestep_s; // TODO: Figure out delta time from blender api + double timestep_s; int max_admm_iters; int max_cg_iters; int max_gs_iters; diff --git a/release/scripts/startup/bl_ui/properties_physics_softbody.py b/release/scripts/startup/bl_ui/properties_physics_softbody.py index 3b080822b95..029a35e51e3 100644 --- a/release/scripts/startup/bl_ui/properties_physics_softbody.py +++ b/release/scripts/startup/bl_ui/properties_physics_softbody.py @@ -32,7 +32,6 @@ 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' @@ -55,6 +54,8 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel): md = context.soft_body softbody = md.settings + layout.prop(softbody, "solver_mode") + layout.prop(softbody, "collision_collection") @@ -75,15 +76,25 @@ class PHYSICS_PT_softbody_object(PhysicButtonsPanel, Panel): 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") + if softbody.solver_mode=='LEGACY': - col.separator() + col = flow.column() + col.prop(softbody, "friction") - col = flow.column() - col.prop(softbody, "mass") + col.separator() + + col = flow.column() + col.prop(softbody, "mass") - col.prop_search(softbody, "vertex_group_mass", ob, "vertex_groups", text="Control Point") + col.prop_search(softbody, "vertex_group_mass", ob, "vertex_groups", text="Control Point") + + elif softbody.solver_mode=='ADMMPD': + + col = flow.column() + col.prop(softbody, "admmpd_youngs") + col.prop(softbody, "admmpd_poisson") + col.prop(softbody, "admmpd_material") + col.prop(softbody, "admmpd_density_kgm3") class PHYSICS_PT_softbody_simulation(PhysicButtonsPanel, Panel): @@ -92,6 +103,12 @@ class PHYSICS_PT_softbody_simulation(PhysicButtonsPanel, Panel): bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + @classmethod + def poll(cls, context): + md = context.soft_body + softbody = md.settings + return (softbody.solver_mode=='LEGACY') + def draw(self, context): layout = self.layout layout.use_property_split = True @@ -139,6 +156,9 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel): layout.prop_search(softbody, "vertex_group_goal", ob, "vertex_groups", text="Vertex Group") + if softbody.solver_mode == 'ADMMPD': + layout.prop(softbody, "admmpd_goalstiff") + class PHYSICS_PT_softbody_goal_strengths(PhysicButtonsPanel, Panel): bl_label = "Strengths" @@ -146,6 +166,12 @@ class PHYSICS_PT_softbody_goal_strengths(PhysicButtonsPanel, Panel): bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + @classmethod + def poll(cls, context): + md = context.soft_body + softbody = md.settings + return (softbody.solver_mode=='LEGACY') + def draw(self, context): layout = self.layout layout.use_property_split = True @@ -172,6 +198,12 @@ class PHYSICS_PT_softbody_goal_settings(PhysicButtonsPanel, Panel): bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + @classmethod + def poll(cls, context): + md = context.soft_body + softbody = md.settings + return (softbody.solver_mode=='LEGACY') + def draw(self, context): layout = self.layout layout.use_property_split = True @@ -195,6 +227,12 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, Panel): bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + @classmethod + def poll(cls, context): + md = context.soft_body + softbody = md.settings + return (softbody.solver_mode=='LEGACY') + def draw_header(self, context): softbody = context.soft_body.settings @@ -282,6 +320,25 @@ class PHYSICS_PT_softbody_edge_stiffness(PhysicButtonsPanel, Panel): layout.prop(softbody, "shear") +class PHYSICS_PT_softbody_admmpdcollision(PhysicButtonsPanel, Panel): + bl_label = "Collision" + bl_parent_id = 'PHYSICS_PT_softbody' + bl_options = {'DEFAULT_CLOSED'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + + @classmethod + def poll(cls, context): + md = context.soft_body + softbody = md.settings + return (softbody.solver_mode=='ADMMPD') + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + md = context.soft_body + softbody = md.settings + layout.prop(softbody, "admmpd_self_collision") + layout.prop(softbody, "admmpd_floor_z") class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, Panel): bl_label = "Self Collision" @@ -289,6 +346,12 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, Panel): bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + @classmethod + def poll(cls, context): + md = context.soft_body + softbody = md.settings + return (softbody.solver_mode=='LEGACY') + def draw_header(self, context): softbody = context.soft_body.settings @@ -334,14 +397,22 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, Panel): 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") + if softbody.solver_mode == 'LEGACY': - col = flow.column() - col.prop(softbody, "use_auto_step", text="Auto-Step") - col.prop(softbody, "error_threshold") + 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") + elif softbody.solver_mode == 'ADMMPD': + + col = flow.column(align=True) + col.prop(softbody, "admmpd_substeps") + col.prop(softbody, "admmpd_max_admm_iters") + col.prop(softbody, "admmpd_converge_eps") class PHYSICS_PT_softbody_solver_diagnostics(PhysicButtonsPanel, Panel): bl_label = "Diagnostics" @@ -349,6 +420,12 @@ class PHYSICS_PT_softbody_solver_diagnostics(PhysicButtonsPanel, Panel): bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + @classmethod + def poll(cls, context): + md = context.soft_body + softbody = md.settings + return (softbody.solver_mode=='LEGACY') + def draw(self, context): layout = self.layout layout.use_property_split = True @@ -368,6 +445,12 @@ class PHYSICS_PT_softbody_solver_helpers(PhysicButtonsPanel, Panel): bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + @classmethod + def poll(cls, context): + md = context.soft_body + softbody = md.settings + return (softbody.solver_mode=='LEGACY') + def draw(self, context): layout = self.layout layout.use_property_split = True @@ -391,6 +474,12 @@ class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, Panel): bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + @classmethod + def poll(cls, context): + md = context.soft_body + softbody = md.settings + return (softbody.solver_mode=='LEGACY') + def draw(self, context): md = context.soft_body softbody = md.settings @@ -409,6 +498,7 @@ classes = ( PHYSICS_PT_softbody_edge, PHYSICS_PT_softbody_edge_aerodynamics, PHYSICS_PT_softbody_edge_stiffness, + PHYSICS_PT_softbody_admmpdcollision, PHYSICS_PT_softbody_collision, PHYSICS_PT_softbody_solver, PHYSICS_PT_softbody_solver_diagnostics, diff --git a/source/blender/makesdna/DNA_object_force_types.h b/source/blender/makesdna/DNA_object_force_types.h index d85a106cfc2..81e89f2a1f1 100644 --- a/source/blender/makesdna/DNA_object_force_types.h +++ b/source/blender/makesdna/DNA_object_force_types.h @@ -212,7 +212,21 @@ typedef struct SoftBody { /** Not saved in file. */ struct BodySpring *bspring; + /* ADMM-PD settings */ struct ADMMPDInterfaceData *admmpd; + int solver_mode; // 0=legacy, 1=admmpd + int admmpd_substeps; // break time step into smaller bits + int admmpd_max_admm_iters; // max solver iterations + int admmpd_self_collision; // 0 or 1 + int admmpd_material; // see enum + float admmpd_converge_eps; // convergence epsilon + float admmpd_youngs; // Youngs mod + float admmpd_poisson; // Poisson ratio + float admmpd_density_kgm3; // unit-density of object + float admmpd_goalstiff; // 0 to 1 + float admmpd_floor_z; // floor position + int admmpd_pad; + char _pad; char msg_lock; @@ -410,6 +424,14 @@ typedef struct SoftBody { #define SBC_MODE_MAX 3 #define SBC_MODE_AVGMINMAX 4 +/* sb->solver_mode */ +#define SOLVER_MODE_ADMMPD 0 +#define SOLVER_MODE_LEGACY 1 + +/* sb- @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs