From 9677d4fbaecfb283ee5ec57e3e18391f8105b647 Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Mon, 3 May 2010 22:41:07 +0000 Subject: [PATCH] Continue to implement this class git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@313 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- .../engine/ConstraintSolver.cpp | 53 ++++++++++++------- .../reactphysics3d/engine/ConstraintSolver.h | 11 ++-- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/sources/reactphysics3d/engine/ConstraintSolver.cpp b/sources/reactphysics3d/engine/ConstraintSolver.cpp index 9bb9399f..56ec4257 100644 --- a/sources/reactphysics3d/engine/ConstraintSolver.cpp +++ b/sources/reactphysics3d/engine/ConstraintSolver.cpp @@ -36,10 +36,10 @@ ConstraintSolver::~ConstraintSolver() { // Allocate all the matrices needed to solve the LCP problem void ConstraintSolver::allocate() { - unsigned int nbConstraints = 0; + uint nbConstraints = 0; // For each constraint - for (unsigned int c=0; cgetErrorValue()); - unsigned int nbAuxConstraints = constraint->getNbAuxConstraints(); + uint nbAuxConstraints = constraint->getNbAuxConstraints(); // If the current constraint has auxiliary constraints if (nbAuxConstraints > 0) { @@ -114,7 +114,7 @@ void ConstraintSolver::fillInMatrices() { J_sp.fillInSubMatrix(c+1, 0, constraint->getAuxJacobian()); // For each auxiliary constraints - for (unsigned int i=1; igetBody1(); bodyMapping[c+i][1] = constraint->getBody2(); @@ -127,9 +127,9 @@ void ConstraintSolver::fillInMatrices() { } // For each current body that is implied in some constraint - for (unsigned int b=0; b(body); @@ -156,30 +156,43 @@ void ConstraintSolver::freeMemory() { bodyNumberMapping.clear(); // Free the bodyMaping array - for (unsigned int i=0; i @@ -29,7 +30,7 @@ namespace reactphysics3d { // Constants -const unsigned int MAX_LCP_ITERATIONS = 10; // Maximum number of iterations when solving a LCP problem +const uint MAX_LCP_ITERATIONS = 10; // Maximum number of iterations when solving a LCP problem /* ------------------------------------------------------------------- Class ConstrainSolver : @@ -43,11 +44,11 @@ class ConstraintSolver { PhysicsWorld& physicsWorld; // Reference to the physics world std::vector activeConstraints; // Current active constraints in the physics world std::vector constraintBodies; // Bodies that are implied in some constraint - unsigned int nbBodies; // Current number of bodies in the physics world - std::map bodyNumberMapping; // Map a body pointer with its index number + uint nbBodies; // Current number of bodies in the physics world + std::map bodyNumberMapping; // Map a body pointer with its index number Body*** bodyMapping; // 2-dimensional array that contains the mapping of body reference // in the J_sp and B_sp matrices. For instance the cell bodyMapping[i][j] contains - // the integer index of the body that correspond to the 1x6 J_ij matrix in the + // the pointer to the body that correspond to the 1x6 J_ij matrix in the // J_sp matrix. A integer body index refers to its index in the "bodies" std::vector Matrix J_sp; // Sparse representation of the jacobian matrix of all constraints Matrix B_sp; // Useful matrix in sparse representation @@ -63,7 +64,7 @@ class ConstraintSolver { void allocate(); // Allocate all the matrices needed to solve the LCP problem void fillInMatrices(); // Fill in all the matrices needed to solve the LCP problem void freeMemory(); // Free the memory that was allocated in the allocate() method - void computeVectorB(); // Compute the vector b + void computeVectorB(double dt); // Compute the vector b void computeMatrixB_sp(); // Compute the matrix B_sp public: