From 6394189e68ac7d3022044e851c9670b10e023cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Wed, 24 Sep 2014 08:55:29 +0200 Subject: Clear forces and constraints together at the start of the time step, easier to verify. --- source/blender/physics/intern/BPH_mass_spring.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source/blender/physics/intern/BPH_mass_spring.cpp') diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp index fc7d5ef039b..56923b6603a 100644 --- a/source/blender/physics/intern/BPH_mass_spring.cpp +++ b/source/blender/physics/intern/BPH_mass_spring.cpp @@ -222,8 +222,6 @@ static void cloth_setup_constraints(ClothModifierData *clmd, ColliderContacts *c const float ZERO[3] = {0.0f, 0.0f, 0.0f}; - BPH_mass_spring_clear_constraints(data); - for (v = 0; v < numverts; v++) { if (verts[v].flags & CLOTH_VERT_FLAG_PINNED) { /* pinned vertex constraints */ @@ -506,9 +504,6 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), ListB MFace *mfaces = cloth->mfaces; unsigned int numverts = cloth->numverts; - /* initialize forces to zero */ - BPH_mass_spring_force_clear(data); - #ifdef CLOTH_FORCE_GRAVITY /* global acceleration (gravitation) */ if (clmd->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { @@ -644,6 +639,10 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase * while (step < tf) { ImplicitSolverResult result; + /* initialize forces to zero */ + BPH_mass_spring_clear_forces(id); + BPH_mass_spring_clear_constraints(id); + /* copy velocities for collision */ for (i = 0; i < numverts; i++) { BPH_mass_spring_get_motion_state(id, i, NULL, verts[i].tv); -- cgit v1.2.3