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:
authorDaniel Genrich <daniel.genrich@gmx.net>2012-01-23 05:35:14 +0400
committerDaniel Genrich <daniel.genrich@gmx.net>2012-01-23 05:35:14 +0400
commit37e128504257db0c37e31f26a626b2f92b2d10db (patch)
tree222568955cc69f16799ed2207d5e3976015b756a /source/blender
parent62963525ced6a6a286d44eac9cca952aead2ac3f (diff)
Cloth: Add "velocity damping" to damping options. This will help with the "cloth wobbling" problem which accurs quite often when having animated characters with cloth.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/cloth.c1
-rw-r--r--source/blender/blenkernel/intern/implicit.c3
-rw-r--r--source/blender/blenloader/intern/readfile.c14
-rw-r--r--source/blender/makesdna/DNA_cloth_types.h3
-rw-r--r--source/blender/makesdna/DNA_object_force.h2
-rw-r--r--source/blender/makesrna/intern/rna_cloth.c6
6 files changed, 28 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 73428c889dc..33adc2af284 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -130,6 +130,7 @@ void cloth_init ( ClothModifierData *clmd )
clmd->sim_parms->presets = 2; /* cotton as start setting */
clmd->sim_parms->timescale = 1.0f; /* speed factor, describes how fast cloth moves */
clmd->sim_parms->reset = 0;
+ clmd->sim_parms->vel_damping = 1.0f; /* 1.0 = no damping, 0.0 = fully dampened */
clmd->coll_parms->self_friction = 5.0;
clmd->coll_parms->friction = 5.0;
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index 00a2de369a3..757d3ddf9ac 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -1852,6 +1852,9 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
while(step < tf)
{
+ // damping velocity for artistic reasons
+ mul_lfvectorS(id->V, id->V, clmd->sim_parms->vel_damping, numverts);
+
// calculate forces
cloth_calc_force(clmd, frame, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step, id->M);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 28f00f355de..0a92d2ca544 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -13038,6 +13038,20 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
/* put compatibility code here until next subversion bump */
{
+ {
+ Object *ob;
+ for(ob=main->object.first; ob; ob= ob->id.next) {
+ ModifierData *md;
+
+ for (md=ob->modifiers.first; md; md=md->next) {
+ if (md->type==eModifierType_Cloth) {
+ ClothModifierData *clmd = (ClothModifierData*) md;
+ if(clmd->sim_parms)
+ clmd->sim_parms->vel_damping = 1.0f;
+ }
+ }
+ }
+ }
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index 5c333c3fc1f..1079f1db835 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -70,6 +70,7 @@ typedef struct ClothSimSettings
float goalfrict;
float velocity_smooth; /* smoothing of velocities for hair */
float collider_friction; /* friction with colliders */
+ float vel_damping; /* damp the velocity to speed up getting to the resting position */
int stepsPerFrame; /* Number of time steps per frame. */
int flags; /* flags, see CSIMSETT_FLAGS enum above. */
@@ -82,7 +83,7 @@ typedef struct ClothSimSettings
short shapekey_rest; /* vertex group for scaling structural stiffness */
short presets; /* used for presets on GUI */
short reset;
- short pad[3];
+ short pad;
struct EffectorWeights *effector_weights;
} ClothSimSettings;
diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h
index 1707c0d3929..70aeaaacd44 100644
--- a/source/blender/makesdna/DNA_object_force.h
+++ b/source/blender/makesdna/DNA_object_force.h
@@ -186,6 +186,8 @@ typedef struct PointCache {
int endframe; /* simulation end frame */
int editframe; /* frame being edited (runtime only) */
int last_exact; /* last exact frame that's cached */
+ int last_valid; /* used for editing cache - what is the last baked frame */
+ int pad;
/* for external cache files */
int totpoint; /* number of cached points */
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index db6cb28bd98..839c67f6297 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -289,6 +289,12 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Air Damping", "Air has normally some thickness which slows falling things down");
RNA_def_property_update(prop, 0, "rna_cloth_update");
+ prop= RNA_def_property(srna, "vel_damping", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "vel_damping");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Velocity Damping", "Damp velocity to help cloth reach the resting position faster. [1.0 = no damping, 0.0 = fully dampened]");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
+
prop= RNA_def_property(srna, "use_pin_cloth", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_GOAL);
RNA_def_property_ui_text(prop, "Pin Cloth", "Enable pinning of cloth vertices to other objects/positions");