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

This commit is contained in:
chappuis.daniel 2010-06-08 21:02:11 +00:00
parent decc06037a
commit 903e543695
7 changed files with 47 additions and 16 deletions

View File

@ -29,6 +29,13 @@ using namespace reactphysics3d;
// Constructor
Contact::Contact(Body* const body1, Body* const body2, const Vector3D& normal, double penetrationDepth, const Vector3D& point)
:Constraint(body1, body2, 2, true), normal(normal), penetrationDepth(penetrationDepth), point(point) {
body1Jacobian.changeSize(1,6);
body2Jacobian.changeSize(1,6);
auxJacobian.changeSize(nbAuxConstraints, 12);
auxLowerBounds.changeSize(nbAuxConstraints);
auxUpperBounds.changeSize(nbAuxConstraints);
auxErrorValues.changeSize(nbAuxConstraints);
body1Jacobian = Matrix(1, 6);
body2Jacobian = Matrix(1, 6);
auxJacobian = Matrix(nbAuxConstraints, 12);

View File

@ -86,10 +86,8 @@ void PhysicsEngine::updateCollision() {
// While the time accumulator is not empty
while(timer.getAccumulator() >= timer.getTimeStep().getValue()) {
// Compute the collision detection
if (collisionDetection.computeCollisionDetection()) {
// TODO : Delete this ----------------------------------------------------------
for (std::vector<Constraint*>::iterator it = world->getConstraintsBeginIterator(); it != world->getConstraintsEndIterator(); ++it) {
RigidBody* rigidBody1 = dynamic_cast<RigidBody*>((*it)->getBody1());

View File

@ -27,7 +27,7 @@ using namespace reactphysics3d;
// Constructor without argument
Matrix::Matrix()
:nbRow(0), nbColumn(0) {
array = 0;
}
// Constructor of the class Matrix
@ -123,6 +123,28 @@ Matrix::~Matrix() {
delete this->array;
}
void Matrix::changeSize(uint newNbRows, uint newNbColumns) {
if (array) {
// Destruction of the dynamic array
for(int i=0; i<nbRow; ++i) {
delete array[i];
}
delete this->array;
}
// Create the two dimensional dynamic array
array = new double*[newNbRows];
assert(array != 0); // Array pointer musn't be null
for(int i=0; i<newNbRows; ++i) {
array[i] = new double[newNbColumns];
}
nbColumn = newNbColumns;
nbRow = newNbRows;
}
// Function that return the cofactor matrix by removing row i and column j
Matrix Matrix::getCofactor(int i, int j) const throw(std::invalid_argument) {

View File

@ -66,6 +66,7 @@ class Matrix {
void fillInSubMatrix(unsigned int i, unsigned int j, const Matrix& subMatrix); // Fill in a sub-matrix of the current matrix with another matrix
void initWithValue(double value); // Initialize all the matrix with the given value
void display() const; // TO DELETE
void changeSize(uint nbRows, uint nbColumns);
// --- Overloaded operators --- //
Matrix operator+(const Matrix& matrix2) const throw(MathematicsException); // Overloaded operator for addition

View File

@ -26,7 +26,7 @@ using namespace reactphysics3d;
// Constructor without argument
Vector::Vector()
:nbComponent(0) {
tab = 0;
}
// Constructor of the class Vector
@ -148,6 +148,20 @@ Vector Vector::crossProduct(const Vector& vector) const throw(MathematicsExcepti
}
}
void Vector::changeSize(uint newSize) {
if (tab) {
delete[] tab;
}
nbComponent = newSize;
tab = new double[nbComponent];
// Fill the array with the value of the vector
for (int i=0; i<nbComponent; ++i) {
tab[i] = 0.0;
}
}
// Overloaded operator for addition
Vector Vector::operator+(const Vector& vector) const throw(MathematicsException) {
// Check the size of the two vectors

View File

@ -164,17 +164,6 @@ inline Vector operator*(double number, const Vector& vector) {
return vector * number;
}
void Vector::changeSize(uint newSize) {
delete[] tab;
nbComponent = newSize;
tab = new double[nbComponent];
// Fill the array with the value of the vector
for (int i=0; i<nbComponent; ++i) {
tab[i] = 0.0;
}
}
} // End of the ReactPhysics3D namespace
#endif

View File

@ -73,7 +73,7 @@ inline void LCPSolver::setLambdaInit(const Vector& lambdaInit) {
}
// Set the maximum number of iterations
void LCPSolver::setMaxIterations(uint maxIterations) {
inline void LCPSolver::setMaxIterations(uint maxIterations) {
assert(maxIterations > 0);
this->maxIterations = maxIterations;
}