diff --git a/sources/reactphysics3d/mathematics/lcp/LCPProjectedGaussSeidel.cpp b/sources/reactphysics3d/mathematics/lcp/LCPProjectedGaussSeidel.cpp index 852fae11..d16bef68 100644 --- a/sources/reactphysics3d/mathematics/lcp/LCPProjectedGaussSeidel.cpp +++ b/sources/reactphysics3d/mathematics/lcp/LCPProjectedGaussSeidel.cpp @@ -40,9 +40,8 @@ void LCPProjectedGaussSeidel::solve(Matrix** J_sp, Matrix** B_sp, uint nbConstra uint nbBodies, Body*** const bodyMapping, std::map bodyNumberMapping, const Vector& b, const Vector& lowLimits, const Vector& highLimits, Vector& lambda) const { - int size1 = lambda.getNbComponent(); - int size2 = lambdaInit.getNbComponent(); lambda = lambdaInit; + double* d = new double[nbConstraints]; // TODO : Avoid those kind of memory allocation here for optimization (allocate once in the object) uint indexBody1, indexBody2; double deltaLambda; @@ -53,6 +52,9 @@ void LCPProjectedGaussSeidel::solve(Matrix** J_sp, Matrix** B_sp, uint nbConstra a[i].changeSize(6); } + // Compute the vector a + computeVectorA(lambda, nbConstraints, bodyMapping, B_sp, bodyNumberMapping, a, nbBodies); + // For each constraint for (i=0; i bodyNumberMapping, + Matrix** B_sp, std::map bodyNumberMapping, Vector* const a, uint nbBodies) const { uint i; uint indexBody1, indexBody2; diff --git a/sources/reactphysics3d/mathematics/lcp/LCPProjectedGaussSeidel.h b/sources/reactphysics3d/mathematics/lcp/LCPProjectedGaussSeidel.h index e51d4d3d..5f5efd4b 100644 --- a/sources/reactphysics3d/mathematics/lcp/LCPProjectedGaussSeidel.h +++ b/sources/reactphysics3d/mathematics/lcp/LCPProjectedGaussSeidel.h @@ -37,8 +37,8 @@ class LCPProjectedGaussSeidel : public LCPSolver { protected: void computeVectorA(const Vector& lambda, uint nbConstraints, Body*** const bodyMapping, - const Matrix** const B_sp, std::map bodyNumberMapping, - Vector* const a, uint nbBodies) const ; // Compute the vector a used in the solve() method + Matrix** B_sp, std::map bodyNumberMapping, + Vector* const a, uint nbBodies) const ; // Compute the vector a used in the solve() method public: LCPProjectedGaussSeidel(uint maxIterations); // Constructor