git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@265 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
ef8c0a8965
commit
c79486f5ee
|
@ -1,69 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* 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 <http://www.gnu.org/licenses/>. *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
// Libraries
|
|
||||||
#include "PhysicsWorld.h"
|
|
||||||
#include "../constraint/Contact.h"
|
|
||||||
|
|
||||||
// We want to use the ReactPhysics3D namespace
|
|
||||||
using namespace reactphysics3d;
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
PhysicsWorld::PhysicsWorld(const Vector3D& gravity) : gravity(gravity) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
PhysicsWorld::~PhysicsWorld() {
|
|
||||||
// Delete all the constraint
|
|
||||||
for (std::vector<Constraint*>::iterator it = constraintList.begin(); it != constraintList.end(); ) {
|
|
||||||
delete (*it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* 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 <http://www.gnu.org/licenses/>. *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#ifndef PHYSICSWORLD_H
|
|
||||||
#define PHYSICSWORLD_H
|
|
||||||
|
|
||||||
// Libraries
|
|
||||||
#include <vector>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include "../constraint/Constraint.h"
|
|
||||||
#include "../mathematics/mathematics.h"
|
|
||||||
|
|
||||||
// ReactPhysics3D namespace
|
|
||||||
namespace reactphysics3d {
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------
|
|
||||||
Class PhysicsWorld :
|
|
||||||
This class represent a physics world. The physics world contains
|
|
||||||
some bodies.
|
|
||||||
-------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
class PhysicsWorld {
|
|
||||||
private :
|
|
||||||
Vector3D gravity; // Gravity vector of the physics world
|
|
||||||
std::vector<Constraint*> constraintList; // List that contains all the current constraints
|
|
||||||
|
|
||||||
public :
|
|
||||||
PhysicsWorld(const Vector3D& gravity); // Constructor
|
|
||||||
virtual ~PhysicsWorld(); // Destructor
|
|
||||||
|
|
||||||
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
|
|
||||||
};
|
|
||||||
|
|
||||||
// Return a start iterator on the constraint list
|
|
||||||
inline std::vector<Constraint*>::const_iterator PhysicsWorld::getConstraintListStartIterator() const {
|
|
||||||
return constraintList.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return a end iterator on the constraint list
|
|
||||||
inline std::vector<Constraint*>::const_iterator PhysicsWorld::getConstraintListEndIterator() const {
|
|
||||||
return constraintList.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // End of the ReactPhysics3D namespace
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,41 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* 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 <http://www.gnu.org/licenses/>. *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
// Libraries
|
|
||||||
#include "DynamicWorld.h"
|
|
||||||
|
|
||||||
// We want to use the ReactPhysics3D namespace
|
|
||||||
using namespace reactphysics3d;
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
DynamicWorld::DynamicWorld(const Vector3D& gravity)
|
|
||||||
:PhysicsWorld(gravity) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy-constructor
|
|
||||||
DynamicWorld::DynamicWorld(const DynamicWorld& world)
|
|
||||||
:PhysicsWorld(world) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
DynamicWorld::~DynamicWorld() {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* 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 <http://www.gnu.org/licenses/>. *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#ifndef DYNAMICWORLD_H
|
|
||||||
#define DYNAMICWORLD_H
|
|
||||||
|
|
||||||
// Libraries
|
|
||||||
#include "PhysicsWorld.h"
|
|
||||||
|
|
||||||
// Namespace ReactPhysics3D
|
|
||||||
namespace reactphysics3d {
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------
|
|
||||||
Class DynamicWorld :
|
|
||||||
This class represents the world of the physics engine where
|
|
||||||
bodies can moves. This class inherits from the class
|
|
||||||
PhysicsWorld.
|
|
||||||
-------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
class DynamicWorld : public PhysicsWorld {
|
|
||||||
|
|
||||||
public :
|
|
||||||
DynamicWorld(const Vector3D& gravity); // Constructor
|
|
||||||
DynamicWorld(const DynamicWorld& world); // Copy-constructor
|
|
||||||
virtual ~DynamicWorld(); // Destructor
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue
Block a user