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

This commit is contained in:
chappuis.daniel 2009-06-29 19:13:57 +00:00
parent f7845abbb7
commit 9c4fddf21d
2 changed files with 11 additions and 5 deletions

View File

@ -19,6 +19,8 @@
// Libraries // Libraries
#include "DynamicEngine.h" #include "DynamicEngine.h"
#include "RK4.h"
#include "Euler.h"
// We want to use the ReactPhysics3D namespace // We want to use the ReactPhysics3D namespace
using namespace reactphysics3d; using namespace reactphysics3d;
@ -31,17 +33,21 @@ DynamicEngine::DynamicEngine(DynamicWorld* world, const Time& timeStep)
// Throw an exception // Throw an exception
throw std::invalid_argument("Exception in PhysicsEngine constructor : World pointer cannot be NULL"); throw std::invalid_argument("Exception in PhysicsEngine constructor : World pointer cannot be NULL");
} }
// Creation of the RK4 integration algorithm
integrationAlgorithm = new RK4();
} }
// Copy-constructor // Copy-constructor
DynamicEngine::DynamicEngine(const DynamicEngine& engine) DynamicEngine::DynamicEngine(const DynamicEngine& engine)
:PhysicsEngine(engine) { :PhysicsEngine(engine) {
numericalIntegrator = engine.numericalIntegrator; integrationAlgorithm = engine.integrationAlgorithm;
} }
// Destructor // Destructor
DynamicEngine::~DynamicEngine() { DynamicEngine::~DynamicEngine() {
// Destroy the integration algorithm
delete integrationAlgorithm;
} }
// Update the state of a rigid body // Update the state of a rigid body
@ -57,7 +63,7 @@ void DynamicEngine::updateBodyState(RigidBody* const rigidBody) {
rigidBody->updatePreviousBodyState(); rigidBody->updatePreviousBodyState();
// Integrate the current body state at time t to get the next state at time t + dt // Integrate the current body state at time t to get the next state at time t + dt
numericalIntegrator.integrate(rigidBody->getCurrentBodyState(), timer.getTime(), timer.getTimeStep()); integrationAlgorithm->integrate(rigidBody->getCurrentBodyState(), timer.getTime(), timer.getTimeStep());
} }
// Update the physics simulation // Update the physics simulation

View File

@ -22,7 +22,7 @@
// Libraries // Libraries
#include "PhysicsEngine.h" #include "PhysicsEngine.h"
#include "NumericalIntegrator.h" #include "IntegrationAlgorithm.h"
#include "../body/Body.h" #include "../body/Body.h"
#include "../body/RigidBody.h" #include "../body/RigidBody.h"
#include "../body/BodyState.h" #include "../body/BodyState.h"
@ -41,7 +41,7 @@ namespace reactphysics3d {
*/ */
class DynamicEngine : public PhysicsEngine { class DynamicEngine : public PhysicsEngine {
protected : protected :
NumericalIntegrator numericalIntegrator; // Numerical integrator used to solve differential equations of movement IntegrationAlgorithm* integrationAlgorithm; // Integration algorithm used to solve differential equations of movement
void updateBodyState(RigidBody* const rigidBody); // Update the state of a rigid body void updateBodyState(RigidBody* const rigidBody); // Update the state of a rigid body