Commit: 6394189e68ac7d3022044e851c9670b10e023cce
Author: Lukas Tönne
Date:   Wed Sep 24 08:55:29 2014 +0200
Branches: master
https://developer.blender.org/rB6394189e68ac7d3022044e851c9670b10e023cce

Clear forces and constraints together at the start of the time step,
easier to verify.

===================================================================

M       source/blender/physics/intern/BPH_mass_spring.cpp
M       source/blender/physics/intern/implicit.h
M       source/blender/physics/intern/implicit_blender.c

===================================================================

diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp 
b/source/blender/physics/intern/BPH_mass_spring.cpp
index fc7d5ef..56923b6 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);
diff --git a/source/blender/physics/intern/implicit.h 
b/source/blender/physics/intern/implicit.h
index 8c860d6..b915b07 100644
--- a/source/blender/physics/intern/implicit.h
+++ b/source/blender/physics/intern/implicit.h
@@ -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 */
diff --git a/source/blender/physics/intern/implicit_blender.c 
b/source/blender/physics/intern/implicit_blender.c
index 7a64df4..0fd46b7 100644
--- a/source/blender/physics/intern/implicit_blender.c
+++ b/source/blender/physics/intern/implicit_blender.c
@@ -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);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to