diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2008-04-09 20:38:26 +0400 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2008-04-09 20:38:26 +0400 |
commit | 906666a4d87b7812e0945acb5803be3ca43fcdbb (patch) | |
tree | 706cbe78eebbb004990ea6f32956de55bf608794 /source | |
parent | 235f793f28bebf1fdfbc94bf8fc2f0c3ac727c49 (diff) |
Cloth enhancement for upcomming cache changes: support different speed using clmd->sim_parms->timescale
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/cloth.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/implicit.c | 6 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_cloth_types.h | 4 |
3 files changed, 8 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 1ece51a9425..6123b1b5e35 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -135,6 +135,7 @@ void cloth_init ( ClothModifierData *clmd ) clmd->sim_parms->firstcachedframe = -1.0; clmd->sim_parms->avg_spring_len = 0.0; clmd->sim_parms->presets = 2; /* cotton as start setting */ + clmd->sim_parms->timescale = 1.0f; /* speed factor, describes how fast cloth moves */ clmd->coll_parms->self_friction = 5.0; clmd->coll_parms->friction = 5.0; @@ -447,7 +448,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd,Object *ob, DerivedMesh *d } // unused in the moment, calculated seperately in implicit.c - clmd->sim_parms->dt = 1.0f / clmd->sim_parms->stepsPerFrame; + clmd->sim_parms->dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame; if ( ( clmd->clothObject == NULL ) || (clmd->clothObject && (numverts != clmd->clothObject->numverts )) ) { diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 4c39f36800c..639ce188235 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1387,7 +1387,9 @@ void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec init_lfvector(lF, gravity, numverts); - // multiply lF with mass matrix + /* multiply lF with mass matrix + // force = mass * acceleration (in this case: gravity) + */ for(i = 0; i < (long)numverts; i++) { float temp[3]; @@ -1528,7 +1530,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase Cloth *cloth = clmd->clothObject; ClothVertex *verts = cloth->verts; unsigned int numverts = cloth->numverts; - float dt = 1.0f / clmd->sim_parms->stepsPerFrame; + float dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame; Implicit_Data *id = cloth->implicit; int result = 0; diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h index 53fbd1ff72c..b8a6ddddfa7 100644 --- a/source/blender/makesdna/DNA_cloth_types.h +++ b/source/blender/makesdna/DNA_cloth_types.h @@ -85,8 +85,8 @@ typedef struct ClothSimSettings int firstcachedframe; float avg_spring_len; /* used for normalized springs */ short presets; /* used for presets on GUI */ - short pad; - int pad2; + short pad; + float timescale; /* parameter how fast cloth runs */ } ClothSimSettings; |