diff --git a/Sofa/Component/ODESolver/Forward/src/sofa/component/odesolver/forward/EulerExplicitSolver.cpp b/Sofa/Component/ODESolver/Forward/src/sofa/component/odesolver/forward/EulerExplicitSolver.cpp index 751b783d074..83d0c22b8b8 100644 --- a/Sofa/Component/ODESolver/Forward/src/sofa/component/odesolver/forward/EulerExplicitSolver.cpp +++ b/Sofa/Component/ODESolver/Forward/src/sofa/component/odesolver/forward/EulerExplicitSolver.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -87,10 +88,16 @@ void EulerExplicitSolver::solve(const core::ExecParams* params, sofa::Size nbNonDiagonalMasses = 0; this->getContext()->accept( sofa::core::objectmodel::topDownVisitor - | [&nbNonDiagonalMasses](sofa::core::behavior::BaseMass* mass){nbNonDiagonalMasses++;}); + | [&nbNonDiagonalMasses](sofa::core::behavior::BaseMass* mass) + { + if (mass && !mass->isDiagonal()) + { + nbNonDiagonalMasses++; + } + }); // Mass matrix is diagonal, solution can thus be found by computing acc = f/m - if(nbNonDiagonalMasses == 0.) + if(nbNonDiagonalMasses == 0) { // acc = M^-1 * f computeAcceleration(&mop, acc, f);