[Bf-blender-cvs] [5721918] cloth-improvements: Separate shear damping from structural damping
Luca Rood
noreply at git.blender.org
Mon Dec 5 18:51:07 CET 2016
Commit: 5721918848c9a4add4e0e4b038945fdf85ec1153
Author: Luca Rood
Date: Wed Nov 30 17:44:27 2016 -0200
Branches: cloth-improvements
https://developer.blender.org/rB5721918848c9a4add4e0e4b038945fdf85ec1153
Separate shear damping from structural damping
===================================================================
M release/scripts/startup/bl_ui/properties_physics_cloth.py
M source/blender/blenkernel/intern/cloth.c
M source/blender/makesdna/DNA_cloth_types.h
M source/blender/makesrna/intern/rna_cloth.c
M source/blender/physics/intern/BPH_mass_spring.cpp
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index 32bfdda..b5acbcb 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -93,7 +93,8 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
col = split.column()
col.label(text="Damping:")
- col.prop(cloth, "spring_damping", text="Spring")
+ col.prop(cloth, "structural_damping", text="Structural")
+ col.prop(cloth, "shear_damping", text="Shear")
col.prop(cloth, "air_damping", text="Air")
col.prop(cloth, "vel_damping", text="Velocity")
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index ca80d29..bc07f35 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -87,7 +87,8 @@ void cloth_init(ClothModifierData *clmd )
clmd->sim_parms->bending = 0.5;
clmd->sim_parms->max_bend = 0.5;
clmd->sim_parms->bending_damping = 0.5;
- clmd->sim_parms->Cdis = 5.0;
+ clmd->sim_parms->struct_damp = 5.0;
+ clmd->sim_parms->shear_damp = 5.0;
clmd->sim_parms->Cvi = 1.0;
clmd->sim_parms->mass = 0.3f;
clmd->sim_parms->stepsPerFrame = 5;
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index cd8ae30..3266fed 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -49,7 +49,8 @@
typedef struct ClothSimSettings {
struct LinkNode *cache; /* UNUSED atm */
float mingoal; /* see SB */
- float Cdis; /* Mechanical damping of springs. */
+ float struct_damp; /* Mechanical damping of structural springs. */
+ float shear_damp; /* Mechanical damping of structural springs. */
float Cvi; /* Viscous/fluid damping. */
float gravity[3]; /* Gravity/external force vector. */
float dt; /* This is the duration of our time step, computed. */
@@ -100,7 +101,7 @@ typedef struct ClothSimSettings {
short presets; /* used for presets on GUI */
short reset;
- char pad0[2];
+ char pad0[6];
struct EffectorWeights *effector_weights;
} ClothSimSettings;
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index 6a12654..eab538c 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -550,10 +550,17 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_cloth_update");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- prop = RNA_def_property(srna, "spring_damping", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "Cdis");
+ prop = RNA_def_property(srna, "structural_damping", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "struct_damp");
RNA_def_property_range(prop, 0.0f, 50.0f);
- RNA_def_property_ui_text(prop, "Spring Damping",
+ RNA_def_property_ui_text(prop, "Structural Spring Damping",
+ "Damping of cloth velocity (higher = more smooth, less jiggling)");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+ prop = RNA_def_property(srna, "shear_damping", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "shear_damp");
+ RNA_def_property_range(prop, 0.0f, 50.0f);
+ RNA_def_property_ui_text(prop, "Shear Spring Damping",
"Damping of cloth velocity (higher = more smooth, less jiggling)");
RNA_def_property_update(prop, 0, "rna_cloth_update");
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index cbfed19..fa26f68 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -363,10 +363,10 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
if (s->type & CLOTH_SPRING_TYPE_SEWING) {
// TODO: verify, half verified (couldn't see error)
// sewing springs usually have a large distance at first so clamp the force so we don't get tunnelling through colission objects
- BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, k, parms->Cdis, no_compress, parms->max_sewing, s->f, s->dfdx, s->dfdv);
+ BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, k, parms->struct_damp, no_compress, parms->max_sewing, s->f, s->dfdx, s->dfdv);
}
else {
- BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, k, parms->Cdis, no_compress, 0.0f, s->f, s->dfdx, s->dfdv);
+ BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, k, parms->struct_damp, no_compress, 0.0f, s->f, s->dfdx, s->dfdv);
}
#endif
}
@@ -379,7 +379,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
scaling = parms->shear + s->stiffness * fabsf(parms->max_shear - parms->shear);
k = scaling / (s->restlen + FLT_EPSILON);
- BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, k, parms->Cdis, no_compress, 0.0f, s->f, s->dfdx, s->dfdv);
+ BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, k, parms->shear_damp, no_compress, 0.0f, s->f, s->dfdx, s->dfdv);
#endif
}
else if (s->type & CLOTH_SPRING_TYPE_GOAL) {
More information about the Bf-blender-cvs
mailing list