git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@206 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
ef629b355d
commit
2640f92755
|
@ -27,7 +27,6 @@ using namespace reactphysics3d;
|
|||
// Constructor
|
||||
CollisionEngine::CollisionEngine(CollisionWorld* world, const Time& timeStep)
|
||||
:DynamicEngine(world, timeStep) {
|
||||
|
||||
}
|
||||
|
||||
// Destructor
|
||||
|
@ -37,43 +36,27 @@ CollisionEngine::~CollisionEngine() {
|
|||
|
||||
// Update the physics simulation
|
||||
void CollisionEngine::update() {
|
||||
|
||||
CollisionWorld* collisionWorld = dynamic_cast<CollisionWorld*>(world);
|
||||
assert(collisionWorld != 0);
|
||||
|
||||
// While the time accumulator is not empty
|
||||
while(timer.getAccumulator() >= timer.getTimeStep().getValue()) {
|
||||
|
||||
// Remove all old collision contact constraints
|
||||
collisionWorld->removeAllContactConstraints();
|
||||
|
||||
Time timeFirst(0); // First collision time
|
||||
Time timeLast(DBL_MAX); // Last collision separation time
|
||||
|
||||
// Compute the collision detection
|
||||
if (collisionDetection.computeCollisionDetection(collisionWorld, timer.getTimeStep(), timeFirst)) {
|
||||
// For each body in the dynamic world
|
||||
for(std::vector<Body*>::const_iterator it = world->getBodyListStartIterator(); it != world->getBodyListEndIterator(); ++it) {
|
||||
// If the body is a RigidBody and if the rigid body motion is enabled
|
||||
RigidBody* rigidBody = dynamic_cast<RigidBody*>(*it);
|
||||
if (rigidBody && rigidBody->getIsMotionEnabled()) {
|
||||
// Update the state of the rigid body
|
||||
updateBodyState(rigidBody, timeFirst);
|
||||
}
|
||||
|
||||
// Stop the body (TO DELETE)
|
||||
rigidBody->setIsMotionEnabled(false); // TODO : DELETE THIS
|
||||
}
|
||||
if (collisionDetection.computeCollisionDetection(collisionWorld)) {
|
||||
// TODO : Do collision response here
|
||||
}
|
||||
else {
|
||||
// For each body in the dynamic world
|
||||
for(std::vector<Body*>::const_iterator it = world->getBodyListStartIterator(); it != world->getBodyListEndIterator(); ++it) {
|
||||
// If the body is a RigidBody and if the rigid body motion is enabled
|
||||
RigidBody* rigidBody = dynamic_cast<RigidBody*>(*it);
|
||||
if (rigidBody && rigidBody->getIsMotionEnabled()) {
|
||||
// Update the state of the rigid body with an entire time step
|
||||
updateBodyState(rigidBody, timer.getTimeStep());
|
||||
std::cout << "NO NO NO" << std::endl; // TODO : DELETE THIS
|
||||
}
|
||||
|
||||
// For each body in the dynamic world
|
||||
for(std::vector<Body*>::const_iterator it = world->getBodyListStartIterator(); it != world->getBodyListEndIterator(); ++it) {
|
||||
// If the body is a RigidBody and if the rigid body motion is enabled
|
||||
RigidBody* rigidBody = dynamic_cast<RigidBody*>(*it);
|
||||
if (rigidBody && rigidBody->getIsMotionEnabled()) {
|
||||
// Update the state of the rigid body with an entire time step
|
||||
updateBodyState(rigidBody, timer.getTimeStep());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +64,7 @@ void CollisionEngine::update() {
|
|||
timer.update();
|
||||
}
|
||||
|
||||
// For each body in the dynamic world
|
||||
// For each body in the the dynamic world
|
||||
for(std::vector<Body*>::const_iterator it = world->getBodyListStartIterator(); it != world->getBodyListEndIterator(); ++it) {
|
||||
// If the body is a RigidBody and if the rigid body motion is enabled
|
||||
RigidBody* rigidBody = dynamic_cast<RigidBody*>(*it);
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace reactphysics3d {
|
|||
class CollisionEngine : public DynamicEngine {
|
||||
private :
|
||||
CollisionDetection collisionDetection; // Collision detection
|
||||
// ConstraintSolver constraintSolver; // Constraint solver
|
||||
// ConstraintSolver constraintSolver; // Constraint solver
|
||||
|
||||
public :
|
||||
CollisionEngine(CollisionWorld* world, const Time& timeStep); // Constructor
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
|
||||
// Libraries
|
||||
#include "DynamicEngine.h"
|
||||
#include "RK4.h"
|
||||
#include "Euler.h"
|
||||
#include "integration/RungeKutta.h"
|
||||
|
||||
// We want to use the ReactPhysics3D namespace
|
||||
using namespace reactphysics3d;
|
||||
|
@ -35,7 +34,7 @@ DynamicEngine::DynamicEngine(DynamicWorld* world, const Time& timeStep)
|
|||
}
|
||||
|
||||
// Creation of the RK4 integration algorithm
|
||||
integrationAlgorithm = new RK4();
|
||||
integrationAlgorithm = new RungeKutta4();
|
||||
}
|
||||
|
||||
// Copy-constructor
|
||||
|
@ -67,7 +66,6 @@ void DynamicEngine::updateBodyState(RigidBody* const rigidBody, const Time& time
|
|||
|
||||
// If the body state has changed, we have to update some informations in the rigid body
|
||||
rigidBody->update();
|
||||
|
||||
}
|
||||
|
||||
// Update the physics simulation
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
// Libraries
|
||||
#include "PhysicsEngine.h"
|
||||
#include "IntegrationAlgorithm.h"
|
||||
#include "../integration/IntegrationAlgorithm.h"
|
||||
#include "../body/Body.h"
|
||||
#include "../body/RigidBody.h"
|
||||
#include "../body/BodyState.h"
|
||||
|
|
Loading…
Reference in New Issue
Block a user