Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Rood <dev@lucarood.com>2018-08-29 01:29:37 +0300
committerLuca Rood <dev@lucarood.com>2018-08-31 17:33:59 +0300
commite3d31b8dfbdc3f4412e12fa1594927098ed0654d (patch)
treeabc629afab10eca51ddc52a3d3550cfcc3291565 /source/blender/blenkernel
parentec3357e03ab1cf3bad48b0460a62761aae206278 (diff)
Cloth: Componentize forces
This separates cloth stiffness and damping forces into tension, compression, and shearing components, allowing more control over the cloth behaviour. This also adds a bending model selector (although the new bending model itself is not implemented in this commit). This is because some of the features implemented here only make sense within the new bending model, while the old model is kept for compatibility. This commit makes non-breaking changes, and thus maintains full compatibility with existing simulations. Reviewed By: brecht Differential Revision: http://developer.blender.org/D3655
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_cloth.h8
-rw-r--r--source/blender/blenkernel/intern/cloth.c18
-rw-r--r--source/blender/blenkernel/intern/particle_system.c2
3 files changed, 22 insertions, 6 deletions
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 82a8d7f4e43..a099ae46d78 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -167,11 +167,17 @@ typedef enum {
CLOTH_SIMSETTINGS_FLAG_TEARING = ( 1 << 4 ),// true if tearing is enabled
CLOTH_SIMSETTINGS_FLAG_SCALING = ( 1 << 8 ), /* is advanced scaling active? */
CLOTH_SIMSETTINGS_FLAG_CCACHE_EDIT = (1 << 12), /* edit cache in editmode */
- CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS = (1 << 13), /* don't allow spring compression */
+ CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS = (1 << 13), /* don't allow spring compression */
CLOTH_SIMSETTINGS_FLAG_SEW = (1 << 14), /* pull ends of loose edges together */
CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH = (1 << 15), /* make simulation respect deformations in the base object */
} CLOTH_SIMSETTINGS_FLAGS;
+/* ClothSimSettings.bending_model. */
+typedef enum {
+ CLOTH_BENDING_LINEAR = 0,
+ CLOTH_BENDING_ANGULAR = 1,
+} CLOTH_BENDING_MODEL;
+
/* COLLISION FLAGS */
typedef enum {
CLOTH_COLLSETTINGS_FLAG_ENABLED = ( 1 << 1 ), /* enables cloth - object collisions */
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index caf5b94b30e..54236785509 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -85,13 +85,18 @@ void cloth_init(ClothModifierData *clmd )
clmd->sim_parms->gravity[0] = 0.0;
clmd->sim_parms->gravity[1] = 0.0;
clmd->sim_parms->gravity[2] = -9.81;
- clmd->sim_parms->structural = 15.0;
- clmd->sim_parms->max_struct = 15.0;
- clmd->sim_parms->shear = 15.0;
+ clmd->sim_parms->tension = 15.0;
+ clmd->sim_parms->max_tension = 15.0;
+ clmd->sim_parms->compression = 15.0;
+ clmd->sim_parms->max_compression = 15.0;
+ clmd->sim_parms->shear = 5.0;
+ clmd->sim_parms->max_shear = 5.0;
clmd->sim_parms->bending = 0.5;
clmd->sim_parms->max_bend = 0.5;
+ clmd->sim_parms->tension_damp = 5.0;
+ clmd->sim_parms->compression_damp = 5.0;
+ clmd->sim_parms->shear_damp = 5.0;
clmd->sim_parms->bending_damping = 0.5;
- clmd->sim_parms->Cdis = 5.0;
clmd->sim_parms->Cvi = 1.0;
clmd->sim_parms->mass = 0.3f;
clmd->sim_parms->stepsPerFrame = 5;
@@ -134,6 +139,8 @@ void cloth_init(ClothModifierData *clmd )
clmd->sim_parms->voxel_cell_size = 0.1f;
+ clmd->sim_parms->bending_model = CLOTH_BENDING_ANGULAR;
+
if (!clmd->sim_parms->effector_weights)
clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL);
@@ -728,6 +735,9 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, Mesh *mesh )
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) {
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1)) {
verts->struct_stiff = dvert->dw [j].weight;
+ }
+
+ if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shear-1)) {
verts->shear_stiff = dvert->dw [j].weight;
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index de4d25a95d9..a5ce7893d3e 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -3171,7 +3171,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
psys->clmd = (ClothModifierData*)modifier_new(eModifierType_Cloth);
psys->clmd->sim_parms->goalspring = 0.0f;
psys->clmd->sim_parms->vel_damping = 1.0f;
- psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_GOAL|CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS;
+ psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_GOAL|CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS;
psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF;
}