git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@264 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
d99ed01f7c
commit
ef8c0a8965
|
@ -29,13 +29,6 @@ PhysicsWorld::PhysicsWorld(const Vector3D& gravity)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy-constructor
|
|
||||||
PhysicsWorld::PhysicsWorld(const PhysicsWorld& world) {
|
|
||||||
bodyList = world.bodyList;
|
|
||||||
gravity = world.gravity;
|
|
||||||
isGravityOn = world.isGravityOn;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
PhysicsWorld::~PhysicsWorld() {
|
PhysicsWorld::~PhysicsWorld() {
|
||||||
|
|
||||||
|
@ -87,3 +80,35 @@ void PhysicsWorld::removeBody(Body const* const body) throw(std::invalid_argumen
|
||||||
throw std::invalid_argument("Exception in PhysicsWorld::removeBody() : The argument pointer cannot be NULL");
|
throw std::invalid_argument("Exception in PhysicsWorld::removeBody() : The argument pointer cannot be NULL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a constraint into the physics world
|
||||||
|
void PhysicsWorld::addConstraint(Constraint* constraint) throw(std::invalid_argument) {
|
||||||
|
assert(constraint != 0);
|
||||||
|
constraintList.push_back(constraint);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove a constraint
|
||||||
|
void PhysicsWorld::removeConstraint(Constraint* constraint) throw(std::invalid_argument) {
|
||||||
|
// TODO : Implement this method
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove all collision contacts constraints
|
||||||
|
void PhysicsWorld::removeAllContactConstraints() {
|
||||||
|
// For all constraints
|
||||||
|
for (std::vector<Constraint*>::iterator it = constraintList.begin(); it != constraintList.end(); ) {
|
||||||
|
|
||||||
|
// Try a downcasting
|
||||||
|
Contact* contact = dynamic_cast<Contact*>(*it);
|
||||||
|
|
||||||
|
// If the constraint is a contact
|
||||||
|
if (contact != 0) {
|
||||||
|
// Delete the contact
|
||||||
|
delete (*it);
|
||||||
|
it = constraintList.erase(it);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,20 +31,20 @@ namespace reactphysics3d {
|
||||||
|
|
||||||
/* -------------------------------------------------------------------
|
/* -------------------------------------------------------------------
|
||||||
Class PhysicsWorld :
|
Class PhysicsWorld :
|
||||||
This is an (abstract) class that represents the world of the
|
This class represents the world of the
|
||||||
physics engine. A physics world contains all the bodies of the physics
|
physics engine. The physics world contains all the bodies of the physics
|
||||||
engine.
|
engine.
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
class PhysicsWorld {
|
class PhysicsWorld {
|
||||||
protected :
|
protected :
|
||||||
std::vector<Body*> bodyList; // list that contains all bodies of the physics world
|
std::vector<Body*> bodyList; // list that contains all bodies of the physics world
|
||||||
|
std::vector<Constraint*> constraintList; // List that contains all the current constraints
|
||||||
Vector3D gravity; // Gravity vector of the world
|
Vector3D gravity; // Gravity vector of the world
|
||||||
bool isGravityOn; // True if the gravity force is on
|
bool isGravityOn; // True if the gravity force is on
|
||||||
|
|
||||||
public :
|
public :
|
||||||
PhysicsWorld(const Vector3D& gravity); // Constructor
|
PhysicsWorld(const Vector3D& gravity); // Constructor
|
||||||
PhysicsWorld(const PhysicsWorld&); // Copy-constructor
|
|
||||||
virtual ~PhysicsWorld(); // Destructor
|
virtual ~PhysicsWorld(); // Destructor
|
||||||
|
|
||||||
void addBody(Body* body) throw(std::invalid_argument); // Add a body to the physics world
|
void addBody(Body* body) throw(std::invalid_argument); // Add a body to the physics world
|
||||||
|
@ -54,6 +54,11 @@ class PhysicsWorld {
|
||||||
void setIsGratityOn(bool isGravityOn); // Set the isGravityOn attribute
|
void setIsGratityOn(bool isGravityOn); // Set the isGravityOn attribute
|
||||||
std::vector<Body*>::const_iterator getBodyListStartIterator() const; // Return a start iterator on the body list
|
std::vector<Body*>::const_iterator getBodyListStartIterator() const; // Return a start iterator on the body list
|
||||||
std::vector<Body*>::const_iterator getBodyListEndIterator() const; // Return a end iterator on the body list
|
std::vector<Body*>::const_iterator getBodyListEndIterator() const; // Return a end iterator on the body list
|
||||||
|
void addConstraint(Constraint* constraint) throw(std::invalid_argument); // Add a constraint
|
||||||
|
void removeConstraint(Constraint* constraint) throw(std::invalid_argument); // Remove a constraint
|
||||||
|
void removeAllContactConstraints(); // Remove all collision contacts constraints
|
||||||
|
std::vector<Constraint*>::const_iterator getConstraintListStartIterator() const; // Return a start iterator on the constraint list
|
||||||
|
std::vector<Constraint*>::const_iterator getConstraintListEndIterator() const; // Return a end iterator on the constraint list
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Inline functions --- //
|
// --- Inline functions --- //
|
||||||
|
|
Loading…
Reference in New Issue
Block a user