vrsode::PhysicsManager Class Reference

central dynamics and collsion manager. More...

#include <PhysicsManager.h>

Inheritance diagram for vrsode::PhysicsManager:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 PhysicsManager ()
 ctor.
 ~PhysicsManager ()
 dtor.
bool runningMultiThreaded ()
 whether we are running as a seperated thread.
void registerCollisionBody (VRS::SO< CollisionBody >)
 register a collision body at the manager.
void registerPhysicsBody (VRS::SO< PhysicsBody >)
 register a physics body at the manager.
void unregisterCollisionBody (VRS::SO< CollisionBody >)
 unregister a collision body.
void unregisterPhysicsBody (VRS::SO< PhysicsBody >)
 unregister a physics body.
const std::vector< VRS::SO<
PhysicsBody > > & 
physicsBodies () const
 get all registered physics bodies.
const std::vector< VRS::SO<
CollisionBody > > & 
collisionBodies () const
 get all registered collsion bodies.
unsigned int physicsBodyCount () const
 number of registered physics bodies.
unsigned int collisionBodyCount () const
 number of registered collsion bodies.
void setDebugNodesGlobal (bool p_debugNodes=true)
 enable debug mode globally.
const dWorldID worldId () const
 get the worldId.
const dSpaceID spaceId () const
 get the spaceId.
const dJointGroupID collisionContactGroupId () const
 get collision contact group id.
const unsigned int maxCollisionContacts () const
 maximum contacts.
void setMaxCollisionContacts (unsigned int)
 set the max number of collsion contacts.
const bool isInitialised () const
 get whether the physics manager is initialised.
void init ()
 init the physics manager.
void tick (double)
 this function ticks the physics system one step ahead.
void update (double)
 update the physics world.
void release ()
 shut down the physics manager.
void setStepTime (double)
 set the time between physics steps.
double stepTime ()
 get the time between physics steps.
void setStepSize (double)
 set step size for physics steps.
double stepSize ()
 get size of physics steps.
void setUpdateSpeed (double)
 set the update speed.
double updateSpeed ()
 get the update speed.
void setUpdateResolution (unsigned int)
 set update resolution.
unsigned int updateResolution ()
 update resolution.
bool keepRunning ()
 whether the physics manager should keep updating
void stop ()
 stop the physics managers update loop.
void setPerformanceAutoAdjust (bool)
 performance auto adjust
bool performanceAutoAdjust ()
 performance auto adjust
std::string odeVersionString ()
 returns an ode version string

Static Public Member Functions

static void startThread ()
 start the physics manager in its own thread
static void terminate ()
 wait for the thread to exit.
static PhysicsManagerget ()
 singleton accessor.
static int updateWorker (void *)
 threaded function which runs continous physics updates.

Protected Member Functions

void update ()

Private Member Functions

void applyTransformations ()
std::vector< VRS::SO< PhysicsBody
> >::iterator 
findPhysicsBody (VRS::SO< PhysicsBody >)
std::vector< VRS::SO< CollisionBody
> >::iterator 
findCollisionBody (VRS::SO< CollisionBody >)
double currentTime ()

Private Attributes

dWorldID m_worldId
dSpaceID m_spaceId
dJointGroupID m_collisionContactGroupId
unsigned int m_maxCollisionContacts
bool m_performanceAutoAdjust
bool m_initialised
std::vector< VRS::SO< PhysicsBody > > m_physicsBodies
std::vector< VRS::SO< CollisionBody > > m_collisionBodies

Static Private Attributes

static unsigned int m_updateResolution
static double m_stepSize
static double m_stepTime
static bool m_keepRunning
static bool m_runningMultiThreaded
static PhysicsManagerm_instance
static SDL_Thread * m_thread

Detailed Description

central dynamics and collsion manager.

this object is resposable for creating, updating and administrating the dynamics and collision engine.

Definition at line 41 of file PhysicsManager.h.


Constructor & Destructor Documentation

vrsode::PhysicsManager::PhysicsManager (  ) 

ctor.

Definition at line 25 of file PhysicsManager.cpp.

References init(), m_initialised, m_maxCollisionContacts, and m_performanceAutoAdjust.

Referenced by get().

Here is the call graph for this function:

Here is the caller graph for this function:

vrsode::PhysicsManager::~PhysicsManager (  ) 

dtor.

Definition at line 33 of file PhysicsManager.cpp.

References m_initialised, and release().

Here is the call graph for this function:


Member Function Documentation

void vrsode::PhysicsManager::applyTransformations (  )  [private]

Definition at line 224 of file PhysicsManager.cpp.

References m_physicsBodies.

Referenced by update(), and updateWorker().

Here is the caller graph for this function:

std::vector< VRS::SO< PhysicsBody > >::iterator vrsode::PhysicsManager::findPhysicsBody ( VRS::SO< PhysicsBody  )  [private]

Definition at line 232 of file PhysicsManager.cpp.

References m_physicsBodies.

Referenced by unregisterPhysicsBody().

Here is the caller graph for this function:

std::vector< VRS::SO< CollisionBody > >::iterator vrsode::PhysicsManager::findCollisionBody ( VRS::SO< CollisionBody  )  [private]

Definition at line 244 of file PhysicsManager.cpp.

References m_collisionBodies.

Referenced by unregisterCollisionBody().

Here is the caller graph for this function:

double vrsode::PhysicsManager::currentTime (  )  [private]

Definition at line 498 of file PhysicsManager.cpp.

Referenced by updateWorker().

Here is the caller graph for this function:

void vrsode::PhysicsManager::update (  )  [protected]

Definition at line 192 of file PhysicsManager.cpp.

References random_utils::ThreadSafeObject::lock(), stepSize(), tick(), random_utils::ThreadSafeObject::unlock(), and updateResolution().

Referenced by updateWorker().

Here is the call graph for this function:

Here is the caller graph for this function:

static void vrsode::PhysicsManager::startThread (  )  [inline, static]

start the physics manager in its own thread

Definition at line 92 of file PhysicsManager.h.

References get(), isInitialised(), m_runningMultiThreaded, m_thread, and updateWorker().

Here is the call graph for this function:

static void vrsode::PhysicsManager::terminate (  )  [inline, static]

wait for the thread to exit.

Definition at line 103 of file PhysicsManager.h.

References random_utils::ThreadSafeCanvas::get(), get(), m_runningMultiThreaded, m_thread, release(), and stop().

Here is the call graph for this function:

bool vrsode::PhysicsManager::runningMultiThreaded (  ) 

whether we are running as a seperated thread.

Definition at line 542 of file PhysicsManager.cpp.

References m_runningMultiThreaded.

void vrsode::PhysicsManager::registerCollisionBody ( VRS::SO< CollisionBody  ) 

register a collision body at the manager.

Definition at line 40 of file PhysicsManager.cpp.

References vrsode::g_initialCollisionCategory, vrsode::g_initialCollisionPartnerCategories, and m_collisionBodies.

void vrsode::PhysicsManager::registerPhysicsBody ( VRS::SO< PhysicsBody  ) 

register a physics body at the manager.

Definition at line 50 of file PhysicsManager.cpp.

References vrsode::g_initialCollisionCategory, vrsode::g_initialCollisionPartnerCategories, and m_physicsBodies.

Referenced by vrsode::PhysicsBody::PhysicsBody().

Here is the caller graph for this function:

void vrsode::PhysicsManager::unregisterCollisionBody ( VRS::SO< CollisionBody  ) 

unregister a collision body.

Definition at line 60 of file PhysicsManager.cpp.

References findCollisionBody(), m_collisionBodies, and spaceId().

Referenced by vrsode::PhysicsBody::destroy(), and vrsode::CollisionBody::destroy().

Here is the call graph for this function:

Here is the caller graph for this function:

void vrsode::PhysicsManager::unregisterPhysicsBody ( VRS::SO< PhysicsBody  ) 

unregister a physics body.

Definition at line 73 of file PhysicsManager.cpp.

References findPhysicsBody(), m_physicsBodies, and spaceId().

Here is the call graph for this function:

const std::vector< VRS::SO< PhysicsBody > > & vrsode::PhysicsManager::physicsBodies (  )  const

get all registered physics bodies.

this functions return the list of all registeres physics bodies.

Definition at line 122 of file PhysicsManager.cpp.

References m_physicsBodies.

const std::vector< VRS::SO< CollisionBody > > & vrsode::PhysicsManager::collisionBodies (  )  const

get all registered collsion bodies.

this functions return the list of all registeres collsion bodies.

Definition at line 128 of file PhysicsManager.cpp.

References m_collisionBodies.

unsigned int vrsode::PhysicsManager::physicsBodyCount (  )  const

number of registered physics bodies.

this functions returns the number of registered physics bodies.

Definition at line 134 of file PhysicsManager.cpp.

References m_physicsBodies.

unsigned int vrsode::PhysicsManager::collisionBodyCount (  )  const

number of registered collsion bodies.

this functions returns the number of registered collsion bodies.

Definition at line 140 of file PhysicsManager.cpp.

References m_collisionBodies.

static PhysicsManager* vrsode::PhysicsManager::get (  )  [inline, static]

singleton accessor.

this function provides you with a pointer to the physicsmanager

Definition at line 167 of file PhysicsManager.h.

References m_instance, and PhysicsManager().

Referenced by random_racer::ItemDistributor::checkForCollisionsAndRotate(), vrsode::CollisionBody::CollisionBody(), vrsode::PhysicsBody::destroy(), vrsode::CollisionBody::destroy(), vrsode::NearCallback(), vrsode::PhysicsBody::PhysicsBody(), vrsode::PhysicsJointBall::PhysicsJointBall(), vrsode::PhysicsJointHinge::PhysicsJointHinge(), vrsode::PhysicsJointHinge2::PhysicsJointHinge2(), vrsode::PhysicsJointSlider::PhysicsJointSlider(), vrsode::PhysicsJointUniversal::PhysicsJointUniversal(), startThread(), and terminate().

Here is the call graph for this function:

Here is the caller graph for this function:

void vrsode::PhysicsManager::setDebugNodesGlobal ( bool  p_debugNodes = true  ) 

enable debug mode globally.

enables debug mode for all registered objects.

Definition at line 256 of file PhysicsManager.cpp.

References m_collisionBodies, and m_physicsBodies.

const dWorldID vrsode::PhysicsManager::worldId (  )  const

get the worldId.

return the current world id, the id for the ode world.

Definition at line 98 of file PhysicsManager.cpp.

References m_worldId.

Referenced by vrsode::PhysicsBody::PhysicsBody().

Here is the caller graph for this function:

const dSpaceID vrsode::PhysicsManager::spaceId (  )  const

get the spaceId.

return the space id, the id for the space the ode collisions are living in.

Definition at line 92 of file PhysicsManager.cpp.

References m_spaceId.

Referenced by unregisterCollisionBody(), and unregisterPhysicsBody().

Here is the caller graph for this function:

const dJointGroupID vrsode::PhysicsManager::collisionContactGroupId (  )  const

get collision contact group id.

this returns the id for the collision contact group.

Note:
the group handling may change in future.

Definition at line 116 of file PhysicsManager.cpp.

References m_collisionContactGroupId.

const unsigned int vrsode::PhysicsManager::maxCollisionContacts (  )  const

maximum contacts.

this function returns the maximum number off handles collision contacts.

Note:
the group handling may change in future.

Definition at line 104 of file PhysicsManager.cpp.

References m_maxCollisionContacts.

Referenced by vrsode::NearCallback().

Here is the caller graph for this function:

void vrsode::PhysicsManager::setMaxCollisionContacts ( unsigned  int  ) 

set the max number of collsion contacts.

this function sets the maximum number off handles collision contacts.

Note:
the group handling may change in future.

Definition at line 110 of file PhysicsManager.cpp.

References m_maxCollisionContacts.

const bool vrsode::PhysicsManager::isInitialised (  )  const

get whether the physics manager is initialised.

Definition at line 86 of file PhysicsManager.cpp.

References m_initialised.

Referenced by release(), startThread(), and tick().

Here is the caller graph for this function:

void vrsode::PhysicsManager::init (  ) 

init the physics manager.

this funcitons sets up the ode world and configures the collison and dynamics engine.

Definition at line 146 of file PhysicsManager.cpp.

References m_collisionContactGroupId, m_initialised, m_spaceId, and m_worldId.

Referenced by PhysicsManager().

Here is the caller graph for this function:

void vrsode::PhysicsManager::tick ( double   ) 

this function ticks the physics system one step ahead.

this does not synchronize to vrs, so, if you want this, call update.

Definition at line 170 of file PhysicsManager.cpp.

References isInitialised(), m_collisionBodies, m_collisionContactGroupId, m_physicsBodies, m_spaceId, m_worldId, and vrsode::NearCallback().

Referenced by update().

Here is the call graph for this function:

Here is the caller graph for this function:

void vrsode::PhysicsManager::update ( double   ) 

update the physics world.

this function step the physics world. You can provide a value, which defines the amount of time in seconds simulated in this step.

Definition at line 200 of file PhysicsManager.cpp.

References applyTransformations(), tick(), and updateResolution().

Here is the call graph for this function:

void vrsode::PhysicsManager::release (  ) 

shut down the physics manager.

this destructs the ode world, frees resources and so on.

Definition at line 209 of file PhysicsManager.cpp.

References isInitialised(), m_collisionContactGroupId, m_initialised, m_spaceId, and m_worldId.

Referenced by terminate(), and ~PhysicsManager().

Here is the call graph for this function:

Here is the caller graph for this function:

void vrsode::PhysicsManager::setStepTime ( double   ) 

set the time between physics steps.

for realistic behaviour, stepTime() == stepSize()

Definition at line 394 of file PhysicsManager.cpp.

References m_stepTime.

double vrsode::PhysicsManager::stepTime (  ) 

get the time between physics steps.

Definition at line 400 of file PhysicsManager.cpp.

References m_stepTime.

Referenced by updateWorker().

Here is the caller graph for this function:

void vrsode::PhysicsManager::setStepSize ( double   ) 

set step size for physics steps.

see setStepTime().

Definition at line 382 of file PhysicsManager.cpp.

References m_stepSize.

double vrsode::PhysicsManager::stepSize (  ) 

get size of physics steps.

Definition at line 388 of file PhysicsManager.cpp.

References m_stepSize.

Referenced by update().

Here is the caller graph for this function:

void vrsode::PhysicsManager::setUpdateSpeed ( double   ) 

set the update speed.

Note:
sets stepSize and stepTime.

Definition at line 510 of file PhysicsManager.cpp.

References m_stepSize, and updateSpeed().

Here is the call graph for this function:

double vrsode::PhysicsManager::updateSpeed (  ) 

get the update speed.

Note:
updateSpeed() == stepSize() / stepTime().

Definition at line 518 of file PhysicsManager.cpp.

References m_stepSize, and m_stepTime.

Referenced by setUpdateSpeed().

Here is the caller graph for this function:

void vrsode::PhysicsManager::setUpdateResolution ( unsigned  int  ) 

set update resolution.

higher resolution needs more performance, but is more precise.

Definition at line 524 of file PhysicsManager.cpp.

References m_updateResolution.

Referenced by updateWorker().

Here is the caller graph for this function:

unsigned int vrsode::PhysicsManager::updateResolution (  ) 

update resolution.

higher resolution needs more performance, but is more precise.

Definition at line 530 of file PhysicsManager.cpp.

References m_updateResolution.

Referenced by update(), and updateWorker().

Here is the caller graph for this function:

int vrsode::PhysicsManager::updateWorker ( void *   )  [static]

threaded function which runs continous physics updates.

Definition at line 418 of file PhysicsManager.cpp.

References applyTransformations(), currentTime(), random_utils::ThreadSafeCanvas::get(), keepRunning(), m_runningMultiThreaded, m_updateResolution, performanceAutoAdjust(), setUpdateResolution(), stepTime(), update(), and updateResolution().

Referenced by startThread().

Here is the call graph for this function:

Here is the caller graph for this function:

bool vrsode::PhysicsManager::keepRunning (  ) 

whether the physics manager should keep updating

Definition at line 406 of file PhysicsManager.cpp.

References m_keepRunning.

Referenced by updateWorker().

Here is the caller graph for this function:

void vrsode::PhysicsManager::stop (  ) 

stop the physics managers update loop.

Definition at line 412 of file PhysicsManager.cpp.

References m_keepRunning.

Referenced by terminate().

Here is the caller graph for this function:

void vrsode::PhysicsManager::setPerformanceAutoAdjust ( bool   ) 

performance auto adjust

Definition at line 504 of file PhysicsManager.cpp.

References m_performanceAutoAdjust.

bool vrsode::PhysicsManager::performanceAutoAdjust (  ) 

performance auto adjust

Definition at line 536 of file PhysicsManager.cpp.

References m_performanceAutoAdjust.

Referenced by updateWorker().

Here is the caller graph for this function:

std::string vrsode::PhysicsManager::odeVersionString (  ) 

returns an ode version string

Definition at line 548 of file PhysicsManager.cpp.


Member Data Documentation

dWorldID vrsode::PhysicsManager::m_worldId [private]

Definition at line 43 of file PhysicsManager.h.

Referenced by init(), release(), tick(), and worldId().

dSpaceID vrsode::PhysicsManager::m_spaceId [private]

Definition at line 44 of file PhysicsManager.h.

Referenced by init(), release(), spaceId(), and tick().

dJointGroupID vrsode::PhysicsManager::m_collisionContactGroupId [private]

Definition at line 45 of file PhysicsManager.h.

Referenced by collisionContactGroupId(), init(), release(), and tick().

unsigned int vrsode::PhysicsManager::m_maxCollisionContacts [private]

Definition at line 47 of file PhysicsManager.h.

Referenced by maxCollisionContacts(), PhysicsManager(), and setMaxCollisionContacts().

unsigned int vrsode::PhysicsManager::m_updateResolution [static, private]

Definition at line 50 of file PhysicsManager.h.

Referenced by setUpdateResolution(), updateResolution(), and updateWorker().

double vrsode::PhysicsManager::m_stepSize [static, private]

Definition at line 51 of file PhysicsManager.h.

Referenced by setStepSize(), setUpdateSpeed(), stepSize(), and updateSpeed().

double vrsode::PhysicsManager::m_stepTime [static, private]

Definition at line 52 of file PhysicsManager.h.

Referenced by setStepTime(), stepTime(), and updateSpeed().

bool vrsode::PhysicsManager::m_keepRunning [static, private]

Definition at line 53 of file PhysicsManager.h.

Referenced by keepRunning(), and stop().

bool vrsode::PhysicsManager::m_runningMultiThreaded [static, private]

Definition at line 54 of file PhysicsManager.h.

Referenced by runningMultiThreaded(), startThread(), terminate(), and updateWorker().

bool vrsode::PhysicsManager::m_performanceAutoAdjust [private]

Definition at line 56 of file PhysicsManager.h.

Referenced by performanceAutoAdjust(), PhysicsManager(), and setPerformanceAutoAdjust().

PhysicsManager * vrsode::PhysicsManager::m_instance [static, private]

Definition at line 58 of file PhysicsManager.h.

Referenced by get().

bool vrsode::PhysicsManager::m_initialised [private]

Definition at line 59 of file PhysicsManager.h.

Referenced by init(), isInitialised(), PhysicsManager(), release(), and ~PhysicsManager().

std::vector<VRS::SO<PhysicsBody> > vrsode::PhysicsManager::m_physicsBodies [private]

Definition at line 61 of file PhysicsManager.h.

Referenced by applyTransformations(), findPhysicsBody(), physicsBodies(), physicsBodyCount(), registerPhysicsBody(), setDebugNodesGlobal(), tick(), and unregisterPhysicsBody().

std::vector<VRS::SO<CollisionBody> > vrsode::PhysicsManager::m_collisionBodies [private]

Definition at line 62 of file PhysicsManager.h.

Referenced by collisionBodies(), collisionBodyCount(), findCollisionBody(), registerCollisionBody(), setDebugNodesGlobal(), tick(), and unregisterCollisionBody().

SDL_Thread * vrsode::PhysicsManager::m_thread [static, private]

Definition at line 64 of file PhysicsManager.h.

Referenced by startThread(), and terminate().


The documentation for this class was generated from the following files:
Generated on Fri May 11 21:02:19 2007 for Random Racer by  doxygen 1.5.1