diff --git a/sources/reactphysics3d/engine/ConstraintSolver.cpp b/sources/reactphysics3d/engine/ConstraintSolver.cpp
index dfd309a2..f47eedac 100644
--- a/sources/reactphysics3d/engine/ConstraintSolver.cpp
+++ b/sources/reactphysics3d/engine/ConstraintSolver.cpp
@@ -54,8 +54,8 @@ void ConstraintSolver::allocate() {
activeConstraints.push_back(constraint);
// Add the two bodies of the constraint in the constraintBodies list
- constraintBodies.push_back(constraint->getBody1());
- constraintBodies.push_back(constraint->getBody2());
+ constraintBodies.insert(constraint->getBody1());
+ constraintBodies.insert(constraint->getBody2());
// Fill in the body number maping
bodyNumberMapping.insert(std::pair
(constraint->getBody1(), bodyNumberMapping.size()));
@@ -148,8 +148,9 @@ void ConstraintSolver::fillInMatrices() {
Body* body;
Vector v(6);
Vector f(6);
- for (uint b=0; b::iterator it = constraintBodies.begin(); it != constraintBodies.end(); it++, b++) {
+ body = *it;
uint bodyNumber = bodyNumberMapping.at(body);
// TODO : Use polymorphism and remove this downcasting
@@ -283,8 +284,8 @@ void ConstraintSolver::solve(double dt) {
// Update the velocity of each body
// TODO : Put this code somewhere else
- for (int i=0; i(constraintBodies.at(i));
+ for (std::set::iterator it = constraintBodies.begin(); it != constraintBodies.end(); it++) {
+ RigidBody* body = dynamic_cast(*it);
//std::cout << "Velocity Y before : " << body->getCurrentBodyState().getLinearVelocity().getY() << std::endl;
//std::cout << "Velocity Y after : " << V[bodyNumberMapping[constraintBodies.at(i)]].getValue(1) << std::endl;
}
diff --git a/sources/reactphysics3d/engine/ConstraintSolver.h b/sources/reactphysics3d/engine/ConstraintSolver.h
index cb1a08a6..6b9133b5 100644
--- a/sources/reactphysics3d/engine/ConstraintSolver.h
+++ b/sources/reactphysics3d/engine/ConstraintSolver.h
@@ -27,6 +27,7 @@
#include "../integration/IntegrationAlgorithm.h" // TODO : Delete this
#include "PhysicsWorld.h"
#include