Cloth: Change ClothVertex::xrest to actually store the rest position.

Originally the value was only needed when building the springs,
so a pointer to the input data was somewhat ok. However, recalculating
spring length dynamically requires keeping the actual value around.
This commit is contained in:
Alexander Gavrilov
2016-04-18 18:48:22 +03:00
parent fcfbe27826
commit 2a9ddc808d
2 changed files with 3 additions and 3 deletions

View File

@@ -115,7 +115,7 @@ typedef struct ClothVertex {
float mass; /* mass / weight of the vertex */
float goal; /* goal, from SB */
float impulse[3]; /* used in collision.c */
float *xrest; /* temporary valid for building springs */
float xrest[3]; /* rest position of the vertex */
unsigned int impulse_count; /* same as above */
float avg_spring_len; /* average length of connected springs */
float struct_stiff;

View File

@@ -819,11 +819,11 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
mul_m4_v3(ob->obmat, verts->x);
if ( shapekey_rest ) {
verts->xrest= shapekey_rest[i];
copy_v3_v3(verts->xrest, shapekey_rest[i]);
mul_m4_v3(ob->obmat, verts->xrest);
}
else
verts->xrest = verts->x;
copy_v3_v3(verts->xrest, verts->x);
}
/* no GUI interface yet */