From a0acfd51959e1bdbc52588914cedb12bae975f84 Mon Sep 17 00:00:00 2001 From: Xuchen Han Date: Sun, 15 Sep 2019 12:06:28 -0700 Subject: [PATCH] code clean up and optimization --- src/BulletSoftBody/btDeformableBodySolver.cpp | 5 ++--- src/BulletSoftBody/btDeformableNeoHookeanForce.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/BulletSoftBody/btDeformableBodySolver.cpp b/src/BulletSoftBody/btDeformableBodySolver.cpp index 4ea724d06..21739ccd3 100644 --- a/src/BulletSoftBody/btDeformableBodySolver.cpp +++ b/src/BulletSoftBody/btDeformableBodySolver.cpp @@ -22,7 +22,7 @@ btDeformableBodySolver::btDeformableBodySolver() : m_numNodes(0) , m_cg(20) -, m_maxNewtonIterations(5) +, m_maxNewtonIterations(10) , m_newtonTolerance(1e-4) , m_lineSearch(true) { @@ -86,7 +86,7 @@ void btDeformableBodySolver::solveDeformableConstraints(btScalar solverdt) updateEnergy(scale); f1 = m_objective->totalEnergy(solverdt)+kineticEnergy(); f2 = f0 - alpha * scale * inner_product; - } while (!(f1 < f2)); // if anything here is nan then the search continues + } while (!(f1 < f2+SIMD_EPSILON)); // if anything here is nan then the search continues revertDv(); updateDv(scale); } @@ -155,7 +155,6 @@ btScalar btDeformableBodySolver::computeDescentStep(TVStack& ddv, const TVStack& btScalar inner_product = m_cg.dot(residual, m_ddv); btScalar res_norm = m_objective->computeNorm(residual); btScalar tol = 1e-5 * res_norm * m_objective->computeNorm(m_ddv); - if (inner_product < -tol) { std::cout << "Looking backwards!" << std::endl; diff --git a/src/BulletSoftBody/btDeformableNeoHookeanForce.h b/src/BulletSoftBody/btDeformableNeoHookeanForce.h index 66affa3d3..c40aaf4a7 100644 --- a/src/BulletSoftBody/btDeformableNeoHookeanForce.h +++ b/src/BulletSoftBody/btDeformableNeoHookeanForce.h @@ -32,7 +32,7 @@ public: m_lambda_damp = damping * m_lambda; } - btDeformableNeoHookeanForce(btScalar mu, btScalar lambda, btScalar damping = 0.05): m_mu(mu), m_lambda(lambda) + btDeformableNeoHookeanForce(btScalar mu, btScalar lambda, btScalar damping = 0): m_mu(mu), m_lambda(lambda) { m_mu_damp = damping * m_mu; m_lambda_damp = damping * m_lambda;