From 7b60c4dac85f68f8f1fd2ee54e51d97e8435735a Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Wed, 8 Jul 2009 14:54:27 +0000 Subject: [PATCH] git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@171 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- .../reactphysics3d/engine/CollisionWorld.cpp | 45 +++++++++++++ .../reactphysics3d/engine/CollisionWorld.h | 67 +++++++++++++++++++ .../reactphysics3d/engine/PhysicsWorld.cpp | 3 +- 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 sources/reactphysics3d/engine/CollisionWorld.cpp create mode 100644 sources/reactphysics3d/engine/CollisionWorld.h diff --git a/sources/reactphysics3d/engine/CollisionWorld.cpp b/sources/reactphysics3d/engine/CollisionWorld.cpp new file mode 100644 index 00000000..f6d917e6 --- /dev/null +++ b/sources/reactphysics3d/engine/CollisionWorld.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** +* Copyright (C) 2009 Daniel Chappuis * +**************************************************************************** +* This file is part of ReactPhysics3D. * +* * +* ReactPhysics3D is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* ReactPhysics3D is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with ReactPhysics3D. If not, see . * +***************************************************************************/ + +// Libraries +#include "CollisionWorld.h" + +// We want to use the ReactPhysics3D namespace +using namespace reactphysics3d; + +// Constructor +CollisionWorld::CollisionWorld(const Vector3D& gravity) + :DynamicWorld(gravity) { + +} + +// Destructor +CollisionWorld::~CollisionWorld() { + +} + +// Add a constraint +void CollisionWorld::addConstraint(Constraint* constraint) throw(std::invalid_argument) { + // TODO : Implement this method +} + +// Remove a constraint +void CollisionWorld::removeConstraint(Constraint* constraint) throw(std::invalid_argument) { + // TODO : Implement this method +} diff --git a/sources/reactphysics3d/engine/CollisionWorld.h b/sources/reactphysics3d/engine/CollisionWorld.h new file mode 100644 index 00000000..7e4dc4e5 --- /dev/null +++ b/sources/reactphysics3d/engine/CollisionWorld.h @@ -0,0 +1,67 @@ +/*************************************************************************** +* Copyright (C) 2009 Daniel Chappuis * +**************************************************************************** +* This file is part of ReactPhysics3D. * +* * +* ReactPhysics3D is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* ReactPhysics3D is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with ReactPhysics3D. If not, see . * +***************************************************************************/ + +#ifndef COLLISIONWORLD_H +#define COLLISIONWORLD_H + +// Libraries +#include +#include +#include "DynamicWorld.h" +#include "../constraint/Constraint.h" +#include "../mathematics/mathematics.h" + +// ReactPhysics3D namespace +namespace reactphysics3d { + +/* ------------------------------------------------------------------- + Class CollisionWorld : + This class represent a physics world where bodies can collide + against each other. This class inherits from the class + DynamicWorld. + ------------------------------------------------------------------- +*/ +class CollisionWorld : public DynamicWorld { + private : + std::vector constraintList; // List that contains all the current constraints + + public : + CollisionWorld(const Vector3D& gravity); // Constructor + ~CollisionWorld(); // Destructor + + void addConstraint(Constraint* constraint) throw(std::invalid_argument); // Add a constraint + void removeConstraint(Constraint* constraint) throw(std::invalid_argument); // Remove a constraint + std::vector::const_iterator getConstraintListStartIterator() const; // Return a start iterator on the constraint list + std::vector::const_iterator getConstraintListEndIterator() const; // Return a end iterator on the constraint list +}; + +// Return a start iterator on the constraint list +inline std::vector::const_iterator CollisionWorld::getConstraintListStartIterator() const { + return constraintList.begin(); +} + +// Return a end iterator on the constraint list +inline std::vector::const_iterator CollisionWorld::getConstraintListEndIterator() const { + return constraintList.end(); +} + + +} // End of the ReactPhysics3D namespace + +#endif diff --git a/sources/reactphysics3d/engine/PhysicsWorld.cpp b/sources/reactphysics3d/engine/PhysicsWorld.cpp index 25be3a7f..ba3a5550 100644 --- a/sources/reactphysics3d/engine/PhysicsWorld.cpp +++ b/sources/reactphysics3d/engine/PhysicsWorld.cpp @@ -24,7 +24,8 @@ using namespace reactphysics3d; // Constructor -PhysicsWorld::PhysicsWorld(const Vector3D& gravity) : gravity(gravity), isGravityOn(true) { +PhysicsWorld::PhysicsWorld(const Vector3D& gravity) + : gravity(gravity), isGravityOn(true) { }