Modification of the update() method

git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@361 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
chappuis.daniel 2010-07-19 19:35:35 +00:00
parent 5f2b65a8b8
commit 76f066f0d3
2 changed files with 18 additions and 73 deletions

View File

@ -32,61 +32,17 @@ PhysicsEngine::PhysicsEngine(PhysicsWorld* world, const Time& timeStep) throw (s
// Throw an exception
throw std::invalid_argument("Exception in PhysicsEngine constructor : World pointer cannot be NULL");
}
// Creation of the Semi-Implicit Euler integration algorithm
integrationAlgorithm = new SemiImplicitEuler();
}
// Destructor
PhysicsEngine::~PhysicsEngine() {
delete integrationAlgorithm;
}
void PhysicsEngine::update() {
updateCollision();
}
/*
// TODO : Delete this method
// Update the physics simulation
void PhysicsEngine::updateDynamic() {
// Check if the physics simulation is running
if (timer.getIsRunning()) {
// While the time accumulator is not empty
while(timer.getAccumulator() >= timer.getTimeStep().getValue()) {
// For each body in the dynamic world
for(std::vector<Body*>::const_iterator it = world->getBodiesBeginIterator(); it != world->getBodiesEndIterator(); ++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, timer.getTimeStep());
}
}
// Update the timer
timer.update();
}
// For each body in the dynamic world
for(std::vector<Body*>::const_iterator it = world->getBodiesBeginIterator(); it != world->getBodiesEndIterator(); ++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 interpolation factor of the rigid body
// This one will be used to compute the interpolated state
rigidBody->setInterpolationFactor(timer.getInterpolationFactor());
}
}
}
}
*/
// TODO : Delethe this method
// Update the physics simulation
void PhysicsEngine::updateCollision() {
bool existCollision = false;
if (timer.getIsRunning()) {
// Apply the gravity force to all bodies
applyGravity();
@ -112,17 +68,7 @@ void PhysicsEngine::updateCollision() {
constraintSolver.freeMemory();
}
}
/*
// For each body in the the dynamic world
for(std::vector<Body*>::const_iterator it = world->getBodiesBeginIterator(); it != world->getBodiesEndIterator(); ++it) {
// If the body is a RigidBody and if the rigid body motion is enabled
RigidBody* rigidBody = dynamic_cast<RigidBody*>(*it);
if (rigidBody) {
}
}
*/
}
// Compute the motion of all bodies and update their positions and orientations

View File

@ -41,7 +41,6 @@ class PhysicsEngine {
protected :
PhysicsWorld* world; // Pointer to the physics world of the physics engine
Timer timer; // Timer of the physics engine
IntegrationAlgorithm* integrationAlgorithm; // Integration algorithm used to solve differential equations of movement
CollisionDetection collisionDetection; // Collision detection
ConstraintSolver constraintSolver; // Constraint solver