diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-10-04 18:11:50 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-01-20 11:30:03 +0300 |
commit | c1f4542f0f5d00ed47b679bc41ce1d5d33d462ab (patch) | |
tree | 037a3c5032f6c2dc9b04eb9fb2ec21f54d9edbca /source/blender/physics/intern/BPH_mass_spring.cpp | |
parent | a5f207de79c3630918d5db633f06bc7c94fe8299 (diff) |
Removed block matrix indices storage from ClothSpring struct.
This is not necessary: the implicit solver data can keep track instead
of how many off-diagonal matrix blocks are in use (provided the
allocation limit is calculated correctly). Every time a spring is
created it then simply increments this counter and uses the block index
locally - no need to store this persistently.
Diffstat (limited to 'source/blender/physics/intern/BPH_mass_spring.cpp')
-rw-r--r-- | source/blender/physics/intern/BPH_mass_spring.cpp | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp index 6a768f10d11..72639fbfc74 100644 --- a/source/blender/physics/intern/BPH_mass_spring.cpp +++ b/source/blender/physics/intern/BPH_mass_spring.cpp @@ -92,19 +92,6 @@ int BPH_cloth_solver_init(Object *UNUSED(ob), ClothModifierData *clmd) BPH_mass_spring_set_vertex_mass(id, i, verts[i].mass); } - // init springs - i = 0; - LinkNode *link = cloth->springs; - for (; link; link = link->next) { - ClothSpring *spring = (ClothSpring *)link->link; - - spring->matrix_ij_kl = BPH_mass_spring_init_spring(id, i++, spring->ij, spring->kl); - if (spring->type == CLOTH_SPRING_TYPE_BENDING_ANG) { - spring->matrix_kl_mn = BPH_mass_spring_init_spring(id, i++, spring->kl, spring->mn); - spring->matrix_ij_mn = BPH_mass_spring_init_spring(id, i++, spring->ij, spring->mn); - } - } - for (i = 0; i < cloth->numverts; i++) { BPH_mass_spring_set_motion_state(id, i, verts[i].x, ZERO); } @@ -379,10 +366,10 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, if (s->type & CLOTH_SPRING_TYPE_SEWING) { // TODO: verify, half verified (couldn't see error) // sewing springs usually have a large distance at first so clamp the force so we don't get tunnelling through colission objects - BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, s->matrix_ij_kl, s->restlen, k, parms->Cdis, no_compress, parms->max_sewing, s->f, s->dfdx, s->dfdv); + BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, k, parms->Cdis, no_compress, parms->max_sewing, s->f, s->dfdx, s->dfdv); } else { - BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, s->matrix_ij_kl, s->restlen, k, parms->Cdis, no_compress, 0.0f, s->f, s->dfdx, s->dfdv); + BPH_mass_spring_force_spring_linear(data, s->ij, s->kl, s->restlen, k, parms->Cdis, no_compress, 0.0f, s->f, s->dfdx, s->dfdv); } #endif } @@ -400,7 +387,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, scaling = parms->goalspring + s->stiffness * fabsf(parms->max_struct - parms->goalspring); k = verts[s->ij].goal * scaling / (parms->avg_spring_len + FLT_EPSILON); - BPH_mass_spring_force_spring_goal(data, s->ij, s->matrix_ij_kl, goal_x, goal_v, k, parms->goalfrict * 0.01f, s->f, s->dfdx, s->dfdv); + BPH_mass_spring_force_spring_goal(data, s->ij, goal_x, goal_v, k, parms->goalfrict * 0.01f, s->f, s->dfdx, s->dfdv); #endif } else if (s->type & CLOTH_SPRING_TYPE_BENDING) { /* calculate force of bending springs */ @@ -415,7 +402,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, scaling = parms->bending_damping; cb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON)); - BPH_mass_spring_force_spring_bending(data, s->ij, s->kl, s->matrix_ij_kl, s->restlen, kb, cb, s->f, s->dfdx, s->dfdv); + BPH_mass_spring_force_spring_bending(data, s->ij, s->kl, s->restlen, kb, cb, s->f, s->dfdx, s->dfdv); #endif } else if (s->type & CLOTH_SPRING_TYPE_BENDING_ANG) { @@ -431,7 +418,7 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, cb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON)); /* XXX assuming same restlen for ij and jk segments here, this can be done correctly for hair later */ - BPH_mass_spring_force_spring_bending_angular(data, s->ij, s->kl, s->mn, s->matrix_ij_kl, s->matrix_kl_mn, s->matrix_ij_mn, s->target, kb, cb); + BPH_mass_spring_force_spring_bending_angular(data, s->ij, s->kl, s->mn, s->target, kb, cb); { float x_kl[3], x_mn[3], v[3], d[3]; |