Cloth enhancement for upcomming cache changes: support different speed using clmd->sim_parms->timescale

This commit is contained in:
Daniel Genrich
2008-04-09 16:38:26 +00:00
parent 235f793f28
commit 906666a4d8
3 changed files with 8 additions and 5 deletions

View File

@@ -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 )) )
{

View File

@@ -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;

View File

@@ -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;