diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-10-12 19:04:04 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-01-20 11:30:04 +0300 |
commit | 4cdf0ab5cf91b58a51e3fcc63bd80d124ba06470 (patch) | |
tree | 8014bc376e717ce57d67b5bc917ebf0a1483de71 /source/blender | |
parent | 2356264ca9e3fc5f0ce68f1fd402ebf25e9caa91 (diff) |
Unified the main Eigen solver function a bit for constrained/unconstrained
solver variants.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/physics/intern/implicit_eigen.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/source/blender/physics/intern/implicit_eigen.cpp b/source/blender/physics/intern/implicit_eigen.cpp index a6148b65816..4543cc0a3d3 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 } /* ================================ */ |