Commit: 2224220d2011a8a61c687a23e3ddb3a7c6e9a2c4
Author: Lukas Tönne
Date:   Sun Oct 12 17:04:04 2014 +0200
Branches: gooseberry
https://developer.blender.org/rB2224220d2011a8a61c687a23e3ddb3a7c6e9a2c4

Unified the main Eigen solver function a bit for constrained/unconstrained
solver variants.

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

M       source/blender/physics/intern/implicit_eigen.cpp

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

diff --git a/source/blender/physics/intern/implicit_eigen.cpp 
b/source/blender/physics/intern/implicit_eigen.cpp
index a6148b6..4543cc0 100644
--- a/source/blender/physics/intern/implicit_eigen.cpp
+++ b/source/blender/physics/intern/implicit_eigen.cpp
@@ -506,36 +506,30 @@ BLI_INLINE void root_to_world_m3(Implicit_Data *data, int 
index, float r[3][3],
 bool BPH_mass_spring_solve(Implicit_Data *data, float dt, ImplicitSolverResult 
*result)
 {
 #ifdef USE_EIGEN_CORE
-       ConjugateGradient cg;
-       cg.setMaxIterations(100);
-       cg.setTolerance(0.01f);
-       
-       id->A = id->M - dt * id->dFdV - dt*dt * id->dFdX;
-       cg.compute(id->A);
-       
-       id->B = dt * id->F + dt*dt * id->dFdX * id->V;
-       id->dV = cg.solve(id->B);
-       
-       id->Vnew = id->V + id->dV;
-       
-       return cg.info() != Eigen::Success;
+       typedef ConjugateGradient solver_t;
 #endif
-
 #ifdef USE_EIGEN_CONSTRAINED_CG
-       ConstraintConjGrad cg;
-       cg.setMaxIterations(100);
-       cg.setTolerance(0.01f);
+       typedef ConstraintConjGrad solver_t;
+#endif
        
        data->iM.construct(data->M);
        data->idFdX.construct(data->dFdX);
        data->idFdV.construct(data->dFdV);
        data->iS.construct(data->S);
        
+       solver_t cg;
+       cg.setMaxIterations(100);
+       cg.setTolerance(0.01f);
+       
+#ifdef USE_EIGEN_CONSTRAINED_CG
+       cg.filter() = data->S;
+#endif
+       
        data->A = data->M - dt * data->dFdV - dt*dt * data->dFdX;
        cg.compute(data->A);
-       cg.filter() = data->S;
        
        data->B = dt * data->F + dt*dt * data->dFdX * data->V;
+       
 #ifdef IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
        printf("==== A ====\n");
        print_lmatrix(id->A);
@@ -546,7 +540,14 @@ bool BPH_mass_spring_solve(Implicit_Data *data, float dt, 
ImplicitSolverResult *
        printf("==== S ====\n");
        print_lmatrix(id->S);
 #endif
+       
+#ifdef USE_EIGEN_CORE
+       data->dV = cg.solve(data->B);
+#endif
+#ifdef USE_EIGEN_CONSTRAINED_CG
        data->dV = cg.solveWithGuess(data->B, data->z);
+#endif
+       
 #ifdef IMPLICIT_PRINT_SOLVER_INPUT_OUTPUT
        printf("==== dV ====\n");
        print_lvector(id->dV);
@@ -567,7 +568,6 @@ bool BPH_mass_spring_solve(Implicit_Data *data, float dt, 
ImplicitSolverResult *
        result->error = cg.error();
        
        return cg.info() != Eigen::Success;
-#endif
 }
 
 /* ================================ */

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

Reply via email to