2010-09-09 19:41:14 +00:00
/********************************************************************************
* ReactPhysics3D physics library , http : //code.google.com/p/reactphysics3d/ *
* Copyright ( c ) 2010 Daniel Chappuis *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Permission is hereby granted , free of charge , to any person obtaining a copy *
* of this software and associated documentation files ( the " Software " ) , to deal *
* in the Software without restriction , including without limitation the rights *
* to use , copy , modify , merge , publish , distribute , sublicense , and / or sell *
* copies of the Software , and to permit persons to whom the Software is *
* furnished to do so , subject to the following conditions : *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software . *
* *
* THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR *
* IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE *
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER *
* LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , *
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN *
* THE SOFTWARE . *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-10 14:31:43 +00:00
# ifndef PHYSICSENGINE_H
# define PHYSICSENGINE_H
// Libraries
# include "PhysicsWorld.h"
2010-02-11 11:31:49 +00:00
# include "../collision/CollisionDetection.h"
2010-06-09 21:40:13 +00:00
# include "ConstraintSolver.h"
2010-02-11 11:31:49 +00:00
# include "../body/RigidBody.h"
2009-02-10 14:31:43 +00:00
# include "Timer.h"
// Namespace ReactPhysics3D
namespace reactphysics3d {
/* -------------------------------------------------------------------
Class PhysicsEngine :
2010-02-11 11:31:49 +00:00
This class represents the physics engine
2009-02-10 14:31:43 +00:00
of the library .
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
class PhysicsEngine {
protected :
2010-02-11 11:31:49 +00:00
PhysicsWorld * world ; // Pointer to the physics world of the physics engine
Timer timer ; // Timer of the physics engine
CollisionDetection collisionDetection ; // Collision detection
2010-06-09 21:40:13 +00:00
ConstraintSolver constraintSolver ; // Constraint solver
2010-07-28 11:19:00 +00:00
2010-07-05 20:52:16 +00:00
void updateAllBodiesMotion ( ) ; // Compute the motion of all bodies and update their positions and orientations
void updatePositionAndOrientationOfBody ( Body * body , const Vector3D & newLinVelocity , const Vector3D & newAngVelocity ) ; // Update the position and orientation of a body
2010-09-01 20:59:35 +00:00
void setInterpolationFactorToAllBodies ( ) ; // Compute and set the interpolation factor to all bodies
2010-07-05 20:52:16 +00:00
void applyGravity ( ) ; // Apply the gravity force to all bodies
2010-09-01 20:59:35 +00:00
public :
2010-08-18 14:50:36 +00:00
PhysicsEngine ( PhysicsWorld * world , double timeStep ) throw ( std : : invalid_argument ) ; // Constructor
~ PhysicsEngine ( ) ; // Destructor
2009-02-10 14:31:43 +00:00
2010-08-18 14:50:36 +00:00
void start ( ) ; // Start the physics simulation
void stop ( ) ; // Stop the physics simulation
void update ( ) throw ( std : : logic_error ) ; // Update the physics simulation
2009-02-10 14:31:43 +00:00
} ;
2009-02-13 11:26:15 +00:00
// --- Inline functions --- //
// Start the physics simulation
inline void PhysicsEngine : : start ( ) {
2010-08-18 14:50:36 +00:00
timer . start ( ) ;
2009-02-13 11:26:15 +00:00
}
inline void PhysicsEngine : : stop ( ) {
2010-08-18 14:50:36 +00:00
timer . stop ( ) ;
2009-02-13 11:26:15 +00:00
}
2009-02-10 14:31:43 +00:00
}
# endif