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

This commit is contained in:
chappuis.daniel 2010-02-06 19:13:13 +00:00
parent b70e418bd7
commit d99ed01f7c
3 changed files with 20 additions and 20 deletions

View File

@ -20,6 +20,8 @@
// Libraries // Libraries
#include "CollisionEngine.h" #include "CollisionEngine.h"
#include <cfloat> #include <cfloat>
#include <GL/freeglut.h> // TODO : Remove this in the final version
#include <GL/gl.h> // TODO : Remove this in the final version
// We want to use the ReactPhysics3D namespace // We want to use the ReactPhysics3D namespace
using namespace reactphysics3d; using namespace reactphysics3d;

View File

@ -18,39 +18,38 @@
***************************************************************************/ ***************************************************************************/
// Libraries // Libraries
#include "CollisionWorld.h" #include "PhysicsWorld.h"
#include "../constraint/Contact.h" #include "../constraint/Contact.h"
// We want to use the ReactPhysics3D namespace // We want to use the ReactPhysics3D namespace
using namespace reactphysics3d; using namespace reactphysics3d;
// Constructor // Constructor
CollisionWorld::CollisionWorld(const Vector3D& gravity) PhysicsWorld::PhysicsWorld(const Vector3D& gravity) : gravity(gravity) {
:DynamicWorld(gravity) {
} }
// Destructor // Destructor
CollisionWorld::~CollisionWorld() { PhysicsWorld::~PhysicsWorld() {
// Delete all the constraint // Delete all the constraint
for (std::vector<Constraint*>::iterator it = constraintList.begin(); it != constraintList.end(); ) { for (std::vector<Constraint*>::iterator it = constraintList.begin(); it != constraintList.end(); ) {
delete (*it); delete (*it);
} }
} }
// Add a constraint into the collision world // Add a constraint into the physics world
void CollisionWorld::addConstraint(Constraint* constraint) throw(std::invalid_argument) { void PhysicsWorld::addConstraint(Constraint* constraint) throw(std::invalid_argument) {
assert(constraint != 0); assert(constraint != 0);
constraintList.push_back(constraint); constraintList.push_back(constraint);
} }
// Remove a constraint // Remove a constraint
void CollisionWorld::removeConstraint(Constraint* constraint) throw(std::invalid_argument) { void PhysicsWorld::removeConstraint(Constraint* constraint) throw(std::invalid_argument) {
// TODO : Implement this method // TODO : Implement this method
} }
// Remove all collision contacts constraints // Remove all collision contacts constraints
void CollisionWorld::removeAllContactConstraints() { void PhysicsWorld::removeAllContactConstraints() {
// For all constraints // For all constraints
for (std::vector<Constraint*>::iterator it = constraintList.begin(); it != constraintList.end(); ) { for (std::vector<Constraint*>::iterator it = constraintList.begin(); it != constraintList.end(); ) {

View File

@ -17,13 +17,12 @@
* along with ReactPhysics3D. If not, see <http://www.gnu.org/licenses/>. * * along with ReactPhysics3D. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/ ***************************************************************************/
#ifndef COLLISIONWORLD_H #ifndef PHYSICSWORLD_H
#define COLLISIONWORLD_H #define PHYSICSWORLD_H
// Libraries // Libraries
#include <vector> #include <vector>
#include <stdexcept> #include <stdexcept>
#include "DynamicWorld.h"
#include "../constraint/Constraint.h" #include "../constraint/Constraint.h"
#include "../mathematics/mathematics.h" #include "../mathematics/mathematics.h"
@ -31,19 +30,19 @@
namespace reactphysics3d { namespace reactphysics3d {
/* ------------------------------------------------------------------- /* -------------------------------------------------------------------
Class CollisionWorld : Class PhysicsWorld :
This class represent a physics world where bodies can collide This class represent a physics world. The physics world contains
against each other. This class inherits from the class some bodies.
DynamicWorld.
------------------------------------------------------------------- -------------------------------------------------------------------
*/ */
class CollisionWorld : public DynamicWorld { class PhysicsWorld {
private : private :
Vector3D gravity; // Gravity vector of the physics world
std::vector<Constraint*> constraintList; // List that contains all the current constraints std::vector<Constraint*> constraintList; // List that contains all the current constraints
public : public :
CollisionWorld(const Vector3D& gravity); // Constructor PhysicsWorld(const Vector3D& gravity); // Constructor
~CollisionWorld(); // Destructor virtual ~PhysicsWorld(); // Destructor
void addConstraint(Constraint* constraint) throw(std::invalid_argument); // Add a constraint void addConstraint(Constraint* constraint) throw(std::invalid_argument); // Add a constraint
void removeConstraint(Constraint* constraint) throw(std::invalid_argument); // Remove a constraint void removeConstraint(Constraint* constraint) throw(std::invalid_argument); // Remove a constraint
@ -53,12 +52,12 @@ class CollisionWorld : public DynamicWorld {
}; };
// Return a start iterator on the constraint list // Return a start iterator on the constraint list
inline std::vector<Constraint*>::const_iterator CollisionWorld::getConstraintListStartIterator() const { inline std::vector<Constraint*>::const_iterator PhysicsWorld::getConstraintListStartIterator() const {
return constraintList.begin(); return constraintList.begin();
} }
// Return a end iterator on the constraint list // Return a end iterator on the constraint list
inline std::vector<Constraint*>::const_iterator CollisionWorld::getConstraintListEndIterator() const { inline std::vector<Constraint*>::const_iterator PhysicsWorld::getConstraintListEndIterator() const {
return constraintList.end(); return constraintList.end();
} }