Arbitrary scaling factor for the structural spring forces (stretching).
This is not nice at all, but for some reason (possibly time scale) the old force values are much too high and cause the solver to become unstable. These will be revisited later anyway, so for now such scaling should be fine.
This commit is contained in:
@@ -341,6 +341,8 @@ DO_INLINE void dfdv_damp(float to[3][3], const float dir[3], float damping)
|
||||
|
||||
static void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, const lVector &X, const lVector &V, float time)
|
||||
{
|
||||
const float structural_scale = 0.001f;
|
||||
|
||||
Cloth *cloth = clmd->clothObject;
|
||||
ClothVertex *verts = cloth->verts;
|
||||
ClothVertex *v1 = &verts[s->ij], *v2 = &verts[s->kl];
|
||||
@@ -397,7 +399,7 @@ static void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, con
|
||||
if (length > L || no_compress) {
|
||||
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
|
||||
|
||||
k = clmd->sim_parms->structural;
|
||||
k = clmd->sim_parms->structural * structural_scale;
|
||||
scaling = k + s->stiffness * fabsf(clmd->sim_parms->max_struct - k);
|
||||
|
||||
k = scaling / (clmd->sim_parms->avg_spring_len + FLT_EPSILON);
|
||||
@@ -418,14 +420,13 @@ static void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, con
|
||||
|
||||
// Ascher & Boxman, p.21: Damping only during elonglation
|
||||
// something wrong with it...
|
||||
madd_v3_v3fl(s->f, dir, clmd->sim_parms->Cdis * dot_v3v3(vel, dir));
|
||||
madd_v3_v3fl(s->f, dir, clmd->sim_parms->Cdis * dot_v3v3(vel, dir) * structural_scale);
|
||||
|
||||
/* VERIFIED */
|
||||
dfdx_spring(s->dfdx, dir, length, L, k);
|
||||
|
||||
/* VERIFIED */
|
||||
dfdv_damp(s->dfdv, dir, clmd->sim_parms->Cdis);
|
||||
|
||||
dfdv_damp(s->dfdv, dir, clmd->sim_parms->Cdis * structural_scale);
|
||||
}
|
||||
}
|
||||
else if (s->type & CLOTH_SPRING_TYPE_GOAL) {
|
||||
|
||||
Reference in New Issue
Block a user