Skip to content

Commit

Permalink
UPBGE: Expose all soft body solver iterations and improve UI.
Browse files Browse the repository at this point in the history
This commit expose all solver iterations for position, velocity, cluster
and drift solvers.
In the same time the RNA definition of new parameters is a bit cleaned and
the UI defined in python is simplified to fit in two columns insteasd of
three.
  • Loading branch information
panzergame committed Dec 17, 2017
1 parent 2bb2675 commit 45f9385
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 74 deletions.
50 changes: 28 additions & 22 deletions release/scripts/startup/bl_ui/properties_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,55 +152,61 @@ def draw(self, context):
col.prop(game, "mass")
# disabled in the code
# col.prop(soft, "weld_threshold")
col.prop(soft, "location_iterations")
col.prop(soft, "linear_stiffness", slider=True)
col.prop(soft, "dynamic_friction", slider=True)
col.prop(soft, "kdp", text="Damping", slider=True)
col.prop(soft, "collision_margin", slider=True)
col.prop(soft, "kvcf", text="Velocity Correction")
col.prop(soft, "kvcf", text="Velocity Correction", slider=True)
col.prop(soft, "use_bending_constraints", text="Bending Constraints")

sub = col.column()
sub.active = soft.use_bending_constraints
sub.prop(soft, "bending_distance")

col.prop(soft, "use_shape_match")

sub = col.column()
sub.active = soft.use_shape_match
sub.prop(soft, "shape_threshold", slider=True)

col.label(text="Solver Iterations:")
col.prop(soft, "position_solver_iterations", text="Position Solver")
col.prop(soft, "velocity_solver_iterations", text="Velocity Solver")
col.prop(soft, "cluster_solver_iterations", text="Cluster Solver")
col.prop(soft, "drift_solver_iterations", text="Drift Solver")

col = split.column()
col.label(text="Hardness:")
col.prop(soft, "kchr", text="Rigid Contacts Hardness")
col.prop(soft, "kkhr", text="Kinetic Contacts Hardness")
col.prop(soft, "kshr", text="Soft Contacts Hardness")
col.prop(soft, "kahr", text="Anchors Hardness")


col = col.column()
col.label(text="Aerodynamics:")
col.prop(soft, "kdg", text="Drag Coefficient")
col.prop(soft, "klf", text="Lift Coefficient")

col = col.column()
col.label(text="Volume:")
col.prop(soft, "kpr", text="Pressure Coefficient")
col.prop(soft, "kvc", text="Volume Conservation")

col.prop(soft, "kchr", text="Rigid Contacts", slider=True)
col.prop(soft, "kkhr", text="Kinetic Contacts", slider=True)
col.prop(soft, "kshr", text="Soft Contacts", slider=True)
col.prop(soft, "kahr", text="Anchors", slider=True)

col = split.column()
col.label(text="Cluster Collision:")
col.prop(soft, "use_cluster_rigid_to_softbody")
col.prop(soft, "use_cluster_soft_to_softbody")
sub = col.column()
sub.active = (soft.use_cluster_rigid_to_softbody or soft.use_cluster_soft_to_softbody)
sub.prop(soft, "cluster_iterations", text="Iterations")
sub.prop(soft, "ksrhr_cl", text="Rigid Hardness")
sub.prop(soft, "kskhr_cl", text="Kinetic Hardness")
sub.prop(soft, "ksshr_cl", text="Soft Hardness")
sub.prop(soft, "ksrhr_cl", text="Rigid Hardness", slider=True)
sub.prop(soft, "kskhr_cl", text="Kinetic Hardness", slider=True)
sub.prop(soft, "ksshr_cl", text="Soft Hardness", slider=True)
sub.prop(soft, "ksr_split_cl", text="Rigid Impulse Split", slider=True)
sub.prop(soft, "ksk_split_cl", text="Kinetic Impulse Split", slider=True)
sub.prop(soft, "kss_split_cl", text="Soft Impulse Split", slider=True)

split = layout.split()

col = split.column()
col.label(text="Volume:")
col.prop(soft, "kpr", text="Pressure Coefficient")
col.prop(soft, "kvc", text="Volume Conservation")

col = split.column()
col.label(text="Aerodynamics:")
col.prop(soft, "kdg", text="Drag Coefficient")
col.prop(soft, "klf", text="Lift Coefficient")

elif physics_type == 'STATIC':
col = layout.column()
col.prop(game, "use_actor")
Expand Down
103 changes: 51 additions & 52 deletions source/blender/makesrna/intern/rna_object_force.c
Original file line number Diff line number Diff line change
Expand Up @@ -1532,105 +1532,104 @@ static void rna_def_game_softbody(BlenderRNA *brna)
prop = RNA_def_property(srna, "ksrhr_cl", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kSRHR_CL");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "ksrhr_cl",
"Soft vs Rigid Hardness");
RNA_def_property_ui_text(prop, "Soft vs Rigid Hardness", "Soft vs rigid hardness");

prop = RNA_def_property(srna, "kskhr_cl", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kSKHR_CL");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "kskhr_cl",
"Soft vs Kinetic Hardness");
RNA_def_property_ui_text(prop, "Soft vs Kinetic Hardness", "Soft vs kinetic hardness");

prop = RNA_def_property(srna, "ksshr_cl", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kSSHR_CL");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "ksshr_cl",
"Soft vs Soft Hardness");
RNA_def_property_ui_text(prop, "Soft vs Soft Hardness", "Soft vs soft hardness");

prop = RNA_def_property(srna, "ksr_split_cl", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kSR_SPLT_CL");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "ksr_split_cl",
"Rigid Impulse Split");
RNA_def_property_ui_text(prop, "Rigid Impulse Split", "Rigid impulse split");

prop = RNA_def_property(srna, "ksk_split_cl", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kSK_SPLT_CL");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "ksk_split_cl",
"Kinetic Impulse Split");
RNA_def_property_ui_text(prop, "Kinetic Impulse Split", "Kinetic impulse split");

prop = RNA_def_property(srna, "kss_split_cl", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kSS_SPLT_CL");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "kss_split_cl",
"Soft Impulse Split");
RNA_def_property_ui_text(prop, "Soft Impulse Split", "Soft impulse split");

prop = RNA_def_property(srna, "kvcf", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kVCF");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "kvcf",
"Velocity Correction Factor");
RNA_def_property_ui_text(prop, "Velocity Correction Factor", "Velocity correction factor");

prop = RNA_def_property(srna, "kdp", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kDP");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "kdp",
"Damping Coefficient");
RNA_def_property_ui_text(prop, "Damping Coefficient", "Damping coefficient");

prop = RNA_def_property(srna, "kdg", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kDG");
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "kdg",
"Drag Coeffient");
RNA_def_property_ui_text(prop, "Drag Coeffient", "Drag coeffient");

prop = RNA_def_property(srna, "klf", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kLF");
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "klf",
"Lift Coefficient");
RNA_def_property_ui_text(prop, "Lift Coefficient", "Lift coefficient");

prop = RNA_def_property(srna, "kpr", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kPR");
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "kpr",
"Pressure Coefficient");
RNA_def_property_range(prop, -1000.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Pressure Coefficient", "Pressure coefficient");

prop = RNA_def_property(srna, "kvc", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kVC");
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "kvc",
"Volume Conservation Coefficient");

prop = RNA_def_property(srna, "kchr", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kCHR");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "kchr",
"Rigid Contacts Hardness");

prop = RNA_def_property(srna, "kkhr", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kKHR");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "kkhr",
"Kinetic Contacts Hardness");

prop = RNA_def_property(srna, "kshr", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kSHR");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "kshr",
"Soft Contacts Hardness");

prop = RNA_def_property(srna, "kahr", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kAHR");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "kahr",
"Anchors Hardness");
RNA_def_property_ui_text(prop, "Volume Conservation Coefficient", "Volume conservation coefficient");

prop = RNA_def_property(srna, "kchr", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kCHR");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Rigid Contacts Hardness", "Rigid contacts hardness");

prop = RNA_def_property(srna, "kkhr", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kKHR");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Kinetic Contacts Hardness", "Kinetic contacts hardness");

prop = RNA_def_property(srna, "kshr", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kSHR");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Soft Contacts Hardness", "Soft contacts hardness");

prop = RNA_def_property(srna, "kahr", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "kAHR");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Anchors Hardness", "Anchors hardness");
/* Integers */

prop = RNA_def_property(srna, "location_iterations", PROP_INT, PROP_NONE);
prop = RNA_def_property(srna, "position_solver_iterations", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "piterations");
RNA_def_property_range(prop, 1, 1000);
RNA_def_property_ui_text(prop, "Position Solver Iterations", "Position solver iterations");

prop = RNA_def_property(srna, "velocity_solver_iterations", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "viterations");
RNA_def_property_range(prop, 0, 1000);
RNA_def_property_ui_text(prop, "Position Iterations", "Position solver iterations");

RNA_def_property_ui_text(prop, "Velocity Solver Iterations", "Position solver iterations");

prop = RNA_def_property(srna, "drift_solver_iterations", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "diterations");
RNA_def_property_range(prop, 0, 1000);
RNA_def_property_ui_text(prop, "Drift Solver Iterations", "Drift solver iterations");

prop = RNA_def_property(srna, "cluster_solver_iterations", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "citerations");
RNA_def_property_range(prop, 1, 1000);
RNA_def_property_ui_text(prop, "Cluster Solver Iterations", "Cluster solver iterations");

prop = RNA_def_property(srna, "cluster_iterations", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "numclusteriterations");
RNA_def_property_range(prop, 1, 1000);
Expand Down

0 comments on commit 45f9385

Please sign in to comment.