Clear forces and constraints together at the start of the time step,

easier to verify.
This commit is contained in:
Lukas Tönne 2014-09-24 08:55:29 +02:00
parent e44187cd5f
commit 6394189e68
3 changed files with 6 additions and 7 deletions

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

@ -129,7 +129,7 @@ bool BPH_mass_spring_solve(struct Implicit_Data *data, float dt, struct Implicit
void BPH_mass_spring_apply_result(struct Implicit_Data *data);
/* Clear the force vector at the beginning of the time step */
void BPH_mass_spring_force_clear(struct Implicit_Data *data);
void BPH_mass_spring_clear_forces(struct Implicit_Data *data);
/* Fictitious forces introduced by moving coordinate systems */
void BPH_mass_spring_force_reference_frame(struct Implicit_Data *data, int index, const float acceleration[3], const float omega[3], const float domega_dt[3]);
/* Simple uniform gravity force */

@ -1281,7 +1281,7 @@ void BPH_mass_spring_add_constraint_ndof2(Implicit_Data *data, int index, const
add_v3_v3(data->z[index], u);
}
void BPH_mass_spring_force_clear(Implicit_Data *data)
void BPH_mass_spring_clear_forces(Implicit_Data *data)
{
int numverts = data->M[0].vcount;
zero_lfvector(data->F, numverts);