git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@360 92aac97c-a6ce-11dd-a772-7fcde58d38e6

This commit is contained in:
chappuis.daniel 2010-07-19 19:34:35 +00:00
parent efe29ae94e
commit 5f2b65a8b8
2 changed files with 7 additions and 5 deletions

View File

@ -40,9 +40,8 @@ void LCPProjectedGaussSeidel::solve(Matrix** J_sp, Matrix** B_sp, uint nbConstra
uint nbBodies, Body*** const bodyMapping, std::map<Body*, uint> bodyNumberMapping, uint nbBodies, Body*** const bodyMapping, std::map<Body*, uint> bodyNumberMapping,
const Vector& b, const Vector& lowLimits, const Vector& highLimits, Vector& lambda) const { const Vector& b, const Vector& lowLimits, const Vector& highLimits, Vector& lambda) const {
int size1 = lambda.getNbComponent();
int size2 = lambdaInit.getNbComponent();
lambda = lambdaInit; lambda = lambdaInit;
double* d = new double[nbConstraints]; // TODO : Avoid those kind of memory allocation here for optimization (allocate once in the object) double* d = new double[nbConstraints]; // TODO : Avoid those kind of memory allocation here for optimization (allocate once in the object)
uint indexBody1, indexBody2; uint indexBody1, indexBody2;
double deltaLambda; double deltaLambda;
@ -53,6 +52,9 @@ void LCPProjectedGaussSeidel::solve(Matrix** J_sp, Matrix** B_sp, uint nbConstra
a[i].changeSize(6); a[i].changeSize(6);
} }
// Compute the vector a
computeVectorA(lambda, nbConstraints, bodyMapping, B_sp, bodyNumberMapping, a, nbBodies);
// For each constraint // For each constraint
for (i=0; i<nbConstraints; i++) { for (i=0; i<nbConstraints; i++) {
d[i] = (J_sp[i][0] * B_sp[0][i] + J_sp[i][1] * B_sp[1][i]).getValue(0,0); d[i] = (J_sp[i][0] * B_sp[0][i] + J_sp[i][1] * B_sp[1][i]).getValue(0,0);
@ -79,7 +81,7 @@ void LCPProjectedGaussSeidel::solve(Matrix** J_sp, Matrix** B_sp, uint nbConstra
// Compute the vector a used in the solve() method // Compute the vector a used in the solve() method
// Note that a = B * lambda // Note that a = B * lambda
void LCPProjectedGaussSeidel::computeVectorA(const Vector& lambda, uint nbConstraints, Body*** const bodyMapping, void LCPProjectedGaussSeidel::computeVectorA(const Vector& lambda, uint nbConstraints, Body*** const bodyMapping,
const Matrix** const B_sp, std::map<Body*, uint> bodyNumberMapping, Matrix** B_sp, std::map<Body*, uint> bodyNumberMapping,
Vector* const a, uint nbBodies) const { Vector* const a, uint nbBodies) const {
uint i; uint i;
uint indexBody1, indexBody2; uint indexBody1, indexBody2;

View File

@ -37,8 +37,8 @@ class LCPProjectedGaussSeidel : public LCPSolver {
protected: protected:
void computeVectorA(const Vector& lambda, uint nbConstraints, Body*** const bodyMapping, void computeVectorA(const Vector& lambda, uint nbConstraints, Body*** const bodyMapping,
const Matrix** const B_sp, std::map<Body*, uint> bodyNumberMapping, Matrix** B_sp, std::map<Body*, uint> bodyNumberMapping,
Vector* const a, uint nbBodies) const ; // Compute the vector a used in the solve() method Vector* const a, uint nbBodies) const ; // Compute the vector a used in the solve() method
public: public:
LCPProjectedGaussSeidel(uint maxIterations); // Constructor LCPProjectedGaussSeidel(uint maxIterations); // Constructor