opal::Simulator Class Reference

#include <Simulator.h>

Inheritance diagram for opal::Simulator:

opal::ODESimulator List of all members.

Public Member Functions

 Simulator ()
virtual void initData (SimulatorData data)
virtual void OPAL_CALL destroy ()=0
virtual bool OPAL_CALL simulate (real dt)
virtual void OPAL_CALL setStepSize (real stepSize)
virtual real OPAL_CALL getStepSize ()
virtual void OPAL_CALL addPostStepEventHandler (PostStepEventHandler *eventHandler)
virtual void OPAL_CALL removePostStepEventHandler (PostStepEventHandler *eventHandler)
virtual size_t OPAL_CALL getNumPostStepEventHandlers () const
virtual PostStepEventHandler
*OPAL_CALL 
getPostStepEventHandler (unsigned int id) const
virtual void OPAL_CALL addGlobalCollisionEventHandler (CollisionEventHandler *eventHandler)
virtual void OPAL_CALL removeGlobalCollisionEventHandler (CollisionEventHandler *eventHandler)
virtual size_t OPAL_CALL getNumGlobalCollisionEventHandlers () const
virtual CollisionEventHandler
*OPAL_CALL 
getGlobalCollisionEventHandler (unsigned int id) const
virtual void OPAL_CALL instantiateBlueprint (BlueprintInstance &instance, const Blueprint &bp, const Matrix44r &offset=Matrix44r(), real scale=1)
virtual void OPAL_CALL setGravity (const Vec3r &gravity)=0
virtual Vec3r OPAL_CALL getGravity () const =0
virtual void OPAL_CALL setSolverAccuracy (SolverAccuracyLevel level)
virtual SolverAccuracyLevel
OPAL_CALL 
getSolverAccuracy () const
virtual void OPAL_CALL setMaxCorrectingVel (real vel)
virtual real OPAL_CALL getMaxCorrectingVel () const
virtual void OPAL_CALL setMaxContacts (unsigned int mc)
virtual unsigned int OPAL_CALL getMaxContacts () const
virtual void OPAL_CALL setUserData (void *data)
virtual void *OPAL_CALL getUserData ()
virtual void OPAL_CALL setupContactGroups (unsigned int group0, unsigned int group1, bool makeContacts)
virtual void OPAL_CALL setupContactGroup (unsigned int group, bool makeContacts)
virtual bool OPAL_CALL groupsMakeContacts (unsigned int group0, unsigned int group1)
virtual void OPAL_CALL setStaticSleepingContactsEnabled (bool enable)
virtual bool OPAL_CALL areStaticSleepingContactsEnabled ()
virtual Solid *OPAL_CALL createSolid ()=0
virtual Solid *OPAL_CALL createPlane (real a, real b, real c, real d, const Material &m=defaults::shape::material)
virtual unsigned int OPAL_CALL getNumSolids () const
virtual Solid *OPAL_CALL getSolid (unsigned int i) const
virtual void OPAL_CALL destroySolid (Solid *s)
virtual void OPAL_CALL destroyAllSolids ()
virtual Joint *OPAL_CALL createJoint ()=0
virtual void OPAL_CALL destroyJoint (Joint *j)
virtual void OPAL_CALL destroyAllJoints ()
virtual ThrusterMotor *OPAL_CALL createThrusterMotor ()
virtual VelocityMotor *OPAL_CALL createVelocityMotor ()
virtual GearedMotor *OPAL_CALL createGearedMotor ()
virtual ServoMotor *OPAL_CALL createServoMotor ()
virtual AttractorMotor *OPAL_CALL createAttractorMotor ()
virtual SpringMotor *OPAL_CALL createSpringMotor ()
virtual void OPAL_CALL destroyMotor (Motor *m)
virtual void OPAL_CALL destroyAllMotors ()
virtual AccelerationSensor
*OPAL_CALL 
createAccelerationSensor ()
virtual InclineSensor *OPAL_CALL createInclineSensor ()
virtual RaycastSensor *OPAL_CALL createRaycastSensor ()
virtual VolumeSensor *OPAL_CALL createVolumeSensor ()
virtual void OPAL_CALL destroySensor (Sensor *s)
virtual void OPAL_CALL destroyAllSensors ()
virtual Space *OPAL_CALL createSpace ()=0
virtual Space *OPAL_CALL getRootSpace ()
virtual std::vector< RaycastResult
> &OPAL_CALL 
internal_fireRay (const Rayr &r, real length, const Solid *attachedSolid, unsigned int rayContactGroup)=0
virtual const VolumeQueryResult
&OPAL_CALL 
internal_queryVolume (const Solid *volume, const Solid *attachedSolid)=0
virtual unsigned long int
OPAL_CALL 
internal_getContactGroupFlags (unsigned int groupNum) const
virtual void OPAL_CALL internal_recordCollision (const CollisionEvent &event)

Protected Member Functions

virtual ~Simulator ()
virtual void stepPhysics ()=0
void addSolid (Solid *s)
void removeSolid (Solid *s)
void addJoint (Joint *j)
void removeJoint (Joint *j)
void addMotor (Motor *m)
void removeMotor (Motor *m)
void addSensor (Sensor *s)
void removeSensor (Sensor *s)
void addSpace (Space *s)
void destroyGarbage ()

Protected Attributes

real mStepSize
real mTimeBuffer
SolverAccuracyLevel mSolverAccuracyLevel
void * mUserData
std::vector< Solid * > mSolidList
std::vector< Joint * > mJointList
std::vector< Motor * > mMotorList
std::vector< Sensor * > mSensorList
bool mIsSolidDestructionSafe
bool mIsJointDestructionSafe
std::vector< Solid * > mSolidGarbageList
std::vector< Joint * > mJointGarbageList
std::vector< Space * > mSpaceList
SpacemRootSpace
unsigned long int mContactGroupFlags [32]
bool mStaticSleepingContactsEnabled
std::vector< PostStepEventHandler * > mPostStepEventHandlers
std::vector< CollisionEventHandler * > mCollisionEventHandlers
real mMaxCorrectingVel
unsigned int mMaxContacts
SimulatorData mData

Detailed Description

A Simulator is an environment that contains simulated objects. It performs collision detection and physical simulation. It is a factory that creates, maintains, and destroys Solids, Joints, Motors, and Sensors.

Definition at line 118 of file Simulator.h.


Constructor & Destructor Documentation

opal::Simulator::Simulator  ) 
 

Definition at line 51 of file Simulator.cpp.

References opal::defaults::contactGroupFlags, opal::defaults::maxContacts, opal::defaults::maxCorrectingVel, mContactGroupFlags, mIsJointDestructionSafe, mIsSolidDestructionSafe, mStaticSleepingContactsEnabled, mTimeBuffer, setMaxContacts(), setMaxCorrectingVel(), setStepSize(), setUserData(), opal::defaults::staticSleepingContactsEnabled, and opal::defaults::stepSize.

opal::Simulator::~Simulator  )  [protected, virtual]
 

Definition at line 79 of file Simulator.cpp.

References destroyAllJoints(), destroyAllMotors(), destroyAllSensors(), destroyAllSolids(), and mSpaceList.


Member Function Documentation

void opal::Simulator::addGlobalCollisionEventHandler CollisionEventHandler eventHandler  )  [virtual]
 

Sets the Simulator's collision event handler.

Parameters:
eventHandler you need to clean it up yourself

Definition at line 268 of file Simulator.cpp.

References mCollisionEventHandlers.

void opal::Simulator::addJoint Joint j  )  [protected]
 

Adds a Joint to the internal list of Joints.

Definition at line 1072 of file Simulator.cpp.

References mJointList.

Referenced by opal::ODESimulator::createJoint().

void opal::Simulator::addMotor Motor m  )  [protected]
 

Adds a Motor to the internal list of Motors.

Definition at line 1107 of file Simulator.cpp.

References mMotorList.

Referenced by createAttractorMotor(), createGearedMotor(), createServoMotor(), createSpringMotor(), createThrusterMotor(), and createVelocityMotor().

void opal::Simulator::addPostStepEventHandler PostStepEventHandler eventHandler  )  [virtual]
 

Sets the Simulator's post-step event handler.

Parameters:
eventHandler you need to clean it up yourself

Definition at line 240 of file Simulator.cpp.

References mPostStepEventHandlers.

void opal::Simulator::addSensor Sensor s  )  [protected]
 

Adds a Sensor to the internal list of Sensors.

Definition at line 1131 of file Simulator.cpp.

References mSensorList.

Referenced by createAccelerationSensor(), createInclineSensor(), createRaycastSensor(), and createVolumeSensor().

void opal::Simulator::addSolid Solid s  )  [protected]
 

Adds a Solid to the internal list of Solids.

Definition at line 1017 of file Simulator.cpp.

References mSolidList.

Referenced by opal::ODESimulator::createSolid().

void opal::Simulator::addSpace Space s  )  [protected]
 

Adds a Space to the internal list of Spaces.

Definition at line 1151 of file Simulator.cpp.

References mSpaceList.

Referenced by opal::ODESimulator::createSpace().

bool opal::Simulator::areStaticSleepingContactsEnabled  )  [virtual]
 

Returns true if contacts are generated between static Solids and sleeping Solids.

Definition at line 801 of file Simulator.cpp.

References mStaticSleepingContactsEnabled.

Referenced by opal::ode_hidden::internal_collisionCallback().

AccelerationSensor * opal::Simulator::createAccelerationSensor  )  [virtual]
 

Creates and returns a pointer to an AccelerationSensor.

Definition at line 944 of file Simulator.cpp.

References addSensor().

AttractorMotor * opal::Simulator::createAttractorMotor  )  [virtual]
 

Creates and returns a pointer to an AttractorMotor.

Definition at line 911 of file Simulator.cpp.

References addMotor().

GearedMotor * opal::Simulator::createGearedMotor  )  [virtual]
 

Creates and returns a pointer to a GearedMotor.

Definition at line 897 of file Simulator.cpp.

References addMotor().

InclineSensor * opal::Simulator::createInclineSensor  )  [virtual]
 

Creates and returns a pointer to an InclineSensor.

Definition at line 951 of file Simulator.cpp.

References addSensor().

virtual Joint* OPAL_CALL opal::Simulator::createJoint  )  [pure virtual]
 

Creates and returns a pointer to a Joint.

Implemented in opal::ODESimulator.

Solid * opal::Simulator::createPlane real  a,
real  b,
real  c,
real  d,
const Material m = defaults::shape::material
[virtual]
 

Helper function for creating a static Solid with a Plane Shape.

Definition at line 812 of file Simulator.cpp.

References opal::PlaneShapeData::abcd, opal::Solid::addShape(), createSolid(), opal::ShapeData::material, and opal::Solid::setStatic().

RaycastSensor * opal::Simulator::createRaycastSensor  )  [virtual]
 

Creates and returns a pointer to a RaycastSensor.

Definition at line 958 of file Simulator.cpp.

References addSensor().

ServoMotor * opal::Simulator::createServoMotor  )  [virtual]
 

Creates and returns a pointer to a ServoMotor.

Definition at line 904 of file Simulator.cpp.

References addMotor().

virtual Solid* OPAL_CALL opal::Simulator::createSolid  )  [pure virtual]
 

Creates and returns a pointer to a Solid.

Implemented in opal::ODESimulator.

Referenced by createPlane().

virtual Space* OPAL_CALL opal::Simulator::createSpace  )  [pure virtual]
 

Creates and returns a pointer to a Space which is a child of the Simulator's root Space.

Implemented in opal::ODESimulator.

SpringMotor * opal::Simulator::createSpringMotor  )  [virtual]
 

Creates and returns a pointer to a SpringMotor.

Definition at line 918 of file Simulator.cpp.

References addMotor().

ThrusterMotor * opal::Simulator::createThrusterMotor  )  [virtual]
 

Creates and returns a pointer to a ThrusterMotor.

Definition at line 883 of file Simulator.cpp.

References addMotor().

VelocityMotor * opal::Simulator::createVelocityMotor  )  [virtual]
 

Creates and returns a pointer to a VelocityMotor.

Definition at line 890 of file Simulator.cpp.

References addMotor().

VolumeSensor * opal::Simulator::createVolumeSensor  )  [virtual]
 

Creates and returns a pointer to a VolumeSensor.

Definition at line 965 of file Simulator.cpp.

References addSensor().

virtual void OPAL_CALL opal::Simulator::destroy  )  [pure virtual]
 

Deallocates everything within the Simulator. This should be called when finished with everything. Simulator implementations should call "delete this" within this function.

Implemented in opal::ODESimulator.

void opal::Simulator::destroyAllJoints  )  [virtual]
 

Immediately destroys all Joints in the Simulator.

Definition at line 875 of file Simulator.cpp.

References mJointList, and removeJoint().

Referenced by ~Simulator().

void opal::Simulator::destroyAllMotors  )  [virtual]
 

Immediately destroys all Motors in the Simulator.

Definition at line 936 of file Simulator.cpp.

References mMotorList, and removeMotor().

Referenced by ~Simulator().

void opal::Simulator::destroyAllSensors  )  [virtual]
 

Immediately destroys all Sensors in the Simulator.

Definition at line 977 of file Simulator.cpp.

References mSensorList, and removeSensor().

Referenced by ~Simulator().

void opal::Simulator::destroyAllSolids  )  [virtual]
 

Immediately destroys all Solids in the Simulator.

Definition at line 855 of file Simulator.cpp.

References mSolidList, and removeSolid().

Referenced by ~Simulator().

void opal::Simulator::destroyGarbage  )  [protected]
 

Destroys all objects marked as garbage. Useful for destroying objects at safe times.

Definition at line 1161 of file Simulator.cpp.

References destroySolid(), and mSolidGarbageList.

void opal::Simulator::destroyJoint Joint j  )  [virtual]
 

Immediately destroys the given Joint. All Motors that depend on this Solid will be automatically disabled.

Definition at line 863 of file Simulator.cpp.

References mIsJointDestructionSafe, mJointGarbageList, and removeJoint().

void opal::Simulator::destroyMotor Motor m  )  [virtual]
 

Immediately destroys the given Motor.

Inform the Simulator of a custom Motor. Custom Motors are allocated and deallocated by the user

Definition at line 931 of file Simulator.cpp.

References removeMotor().

void opal::Simulator::destroySensor Sensor s  )  [virtual]
 

Immediately destroys the given Sensor.

Definition at line 972 of file Simulator.cpp.

References removeSensor().

void opal::Simulator::destroySolid Solid s  )  [virtual]
 

Immediately destroys the given Solid. All Joints, Motors, and Sensors that depend on this Solid will be automatically disabled.

Definition at line 843 of file Simulator.cpp.

References mIsSolidDestructionSafe, mSolidGarbageList, and removeSolid().

Referenced by destroyGarbage().

CollisionEventHandler * opal::Simulator::getGlobalCollisionEventHandler unsigned int  id  )  const [virtual]
 

Returns the Simulator's post-step event handler. If this returns NULL, the Simulator is not using one.

Definition at line 274 of file Simulator.cpp.

References mCollisionEventHandlers.

virtual Vec3r OPAL_CALL opal::Simulator::getGravity  )  const [pure virtual]
 

Returns the gravity used in the simulation.

Implemented in opal::ODESimulator.

Referenced by opal::VelocityMotor::internal_update().

unsigned int opal::Simulator::getMaxContacts  )  const [virtual]
 

Returns the maximum number of physical contacts generated when two Solids collide.

Definition at line 1012 of file Simulator.cpp.

References mMaxContacts.

Referenced by opal::ode_hidden::internal_collisionCallback().

real opal::Simulator::getMaxCorrectingVel  )  const [virtual]
 

Returns the maximum correcting velocity for interpenetrating objects.

Definition at line 1001 of file Simulator.cpp.

References mMaxCorrectingVel.

size_t opal::Simulator::getNumGlobalCollisionEventHandlers  )  const [virtual]
 

Number of stored collision handlers.

Definition at line 292 of file Simulator.cpp.

References mCollisionEventHandlers.

Referenced by opal::ode_hidden::internal_collisionCallback().

size_t opal::Simulator::getNumPostStepEventHandlers  )  const [virtual]
 

Number of stored step handlers.

Definition at line 263 of file Simulator.cpp.

References mPostStepEventHandlers.

unsigned int opal::Simulator::getNumSolids  )  const [virtual]
 

Returns the number of Solids in the Simulator.

Definition at line 833 of file Simulator.cpp.

References mSolidList.

PostStepEventHandler * opal::Simulator::getPostStepEventHandler unsigned int  id  )  const [virtual]
 

Returns the Simulator's post-step event handler. If this returns NULL, the Simulator is not using one.

Definition at line 246 of file Simulator.cpp.

References mPostStepEventHandlers.

Space * opal::Simulator::getRootSpace  )  [virtual]
 

Definition at line 1156 of file Simulator.cpp.

References mRootSpace.

Solid * opal::Simulator::getSolid unsigned int  i  )  const [virtual]
 

Returns a pointer to the Solid at the given index.

Definition at line 838 of file Simulator.cpp.

References mSolidList.

SolverAccuracyLevel opal::Simulator::getSolverAccuracy  )  const [virtual]
 

Returns the accuracy level.

Definition at line 990 of file Simulator.cpp.

References mSolverAccuracyLevel.

real opal::Simulator::getStepSize  )  [virtual]
 

Returns the constant step size used in the simulation.

Definition at line 235 of file Simulator.cpp.

References mStepSize.

Referenced by opal::AccelerationSensor::getGlobalAngularAccel(), opal::AccelerationSensor::getGlobalLinearAccel(), opal::AccelerationSensor::getLocalAngularAccel(), and opal::AccelerationSensor::getLocalLinearAccel().

void * opal::Simulator::getUserData  )  [virtual]
 

Returns the user data pointer (NULL if it has not been set).

Definition at line 715 of file Simulator.cpp.

References mUserData.

bool opal::Simulator::groupsMakeContacts unsigned int  group0,
unsigned int  group1
[virtual]
 

Returns true if the two contact groups are setup to generate contacts when they collide.

Definition at line 777 of file Simulator.cpp.

References internal_getContactGroupFlags().

Referenced by opal::ode_hidden::internal_collisionCallback(), opal::ode_hidden::internal_raycastCollisionCallback(), and opal::ode_hidden::internal_volumeCollisionCallback().

void opal::Simulator::initData SimulatorData  data  )  [virtual]
 

Reimplemented in opal::ODESimulator.

Definition at line 74 of file Simulator.cpp.

References mData.

Referenced by opal::ODESimulator::initData().

void opal::Simulator::instantiateBlueprint BlueprintInstance instance,
const Blueprint bp,
const Matrix44r offset = Matrix44r(),
real  scale = 1
[virtual]
 

Creates instances of all objects in a Blueprint and fills the given BlueprintInstance with pointers of the named objects. The offset transform and scale factor can be used to affect all instantiated objects at once. The scale factor must be greater than zero.

Definition at line 297 of file Simulator.cpp.

References opal::Blueprint::isFinalized(), and OPAL_LOGGER.

virtual std::vector<RaycastResult>& OPAL_CALL opal::Simulator::internal_fireRay const Rayr r,
real  length,
const Solid attachedSolid,
unsigned int  rayContactGroup
[pure virtual]
 

Helper function used for ray casting. Immediately fires a ray into the scene and returns intersections results. Uses the ray's contact group parameter to limit collision checks.

Implemented in opal::ODESimulator.

Referenced by opal::RaycastSensor::firePiercingRay(), and opal::RaycastSensor::fireRay().

unsigned long int opal::Simulator::internal_getContactGroupFlags unsigned int  groupNum  )  const [virtual]
 

Returns the Simulator's contact group flags.

Definition at line 806 of file Simulator.cpp.

References mContactGroupFlags.

Referenced by groupsMakeContacts().

virtual const VolumeQueryResult& OPAL_CALL opal::Simulator::internal_queryVolume const Solid volume,
const Solid attachedSolid
[pure virtual]
 

Helper function used for volume queries.

Implemented in opal::ODESimulator.

Referenced by opal::VolumeSensor::queryVolume().

void opal::Simulator::internal_recordCollision const CollisionEvent event  )  [virtual]
 

Record collisions into global handlers.

Definition at line 218 of file Simulator.cpp.

References mCollisionEventHandlers.

Referenced by opal::ode_hidden::internal_collisionCallback().

void opal::Simulator::removeGlobalCollisionEventHandler CollisionEventHandler eventHandler  )  [virtual]
 

If such handler is stored it will be removed from the list.

Definition at line 279 of file Simulator.cpp.

References mCollisionEventHandlers.

void opal::Simulator::removeJoint Joint j  )  [protected]
 

Removes a Joint from the internal list of Joints.

Definition at line 1077 of file Simulator.cpp.

References mMotorList.

Referenced by destroyAllJoints(), and destroyJoint().

void opal::Simulator::removeMotor Motor m  )  [protected]
 

Removes a Motor from the internal list of Motors.

Definition at line 1112 of file Simulator.cpp.

References opal::Motor::internal_destroy(), and mMotorList.

Referenced by destroyAllMotors(), and destroyMotor().

void opal::Simulator::removePostStepEventHandler PostStepEventHandler eventHandler  )  [virtual]
 

If such handler is stored it will be removed from the list.

Definition at line 251 of file Simulator.cpp.

References mPostStepEventHandlers.

void opal::Simulator::removeSensor Sensor s  )  [protected]
 

Removes a Sensor from the internal list of Sensors.

Definition at line 1136 of file Simulator.cpp.

References opal::Sensor::internal_destroy(), and mSensorList.

Referenced by destroyAllSensors(), and destroySensor().

void opal::Simulator::removeSolid Solid s  )  [protected]
 

Removes a Solid from the internal list of Solids.

Definition at line 1022 of file Simulator.cpp.

References mMotorList.

Referenced by destroyAllSolids(), and destroySolid().

virtual void OPAL_CALL opal::Simulator::setGravity const Vec3r gravity  )  [pure virtual]
 

Sets the gravity used in the simulation.

Implemented in opal::ODESimulator.

void opal::Simulator::setMaxContacts unsigned int  mc  )  [virtual]
 

Sets the maximum number of physical contacts generated when two Solids collide. This number cannot be larger than the global "max max contacts" parameter.

Definition at line 1006 of file Simulator.cpp.

References opal::globals::maxMaxContacts, and mMaxContacts.

Referenced by Simulator().

void opal::Simulator::setMaxCorrectingVel real  vel  )  [virtual]
 

Sets the maximum correcting velocity for interpenetrating objects. The given velocity must be positive.

Reimplemented in opal::ODESimulator.

Definition at line 995 of file Simulator.cpp.

References mMaxCorrectingVel.

Referenced by opal::ODESimulator::setMaxCorrectingVel(), and Simulator().

void opal::Simulator::setSolverAccuracy SolverAccuracyLevel  level  )  [virtual]
 

Sets the accuracy level used by the physics engine's constraint solver.

Reimplemented in opal::ODESimulator.

Definition at line 985 of file Simulator.cpp.

References mSolverAccuracyLevel.

Referenced by opal::ODESimulator::setSolverAccuracy().

void opal::Simulator::setStaticSleepingContactsEnabled bool  enable  )  [virtual]
 

Sets whether contacts should be generated between static Solids and sleeping Solids. Usually this isn't necessary, but sometimes you might want a static Solid to wake up a sleeping dynamic Solid by touching it.

Definition at line 796 of file Simulator.cpp.

References mStaticSleepingContactsEnabled.

void opal::Simulator::setStepSize real  stepSize  )  [virtual]
 

Sets the constant step size used in the simulation. The step size must be greater than zero.

Definition at line 229 of file Simulator.cpp.

References mStepSize.

Referenced by Simulator().

void opal::Simulator::setupContactGroup unsigned int  group,
bool  makeContacts
[virtual]
 

Similar to setupContactGroups. Determines how a single contact group interacts with all other groups. This is useful when you want to e.g. disable collisions between a group and everything else for a "trigger volume." (See setupContactGroups for more details).

Definition at line 767 of file Simulator.cpp.

References setupContactGroups().

void opal::Simulator::setupContactGroups unsigned int  group0,
unsigned int  group1,
bool  makeContacts
[virtual]
 

Defines the interaction between two contact groups. If the last argument is true, the two groups will generate physical points when they collide. Otherwise, they will pass through each other. Keep in mind that certain cases are already ignored when performing collision detection; see comments on Simulator::simulate for more details. Note that contact groups do not affect collision events; two colliding objects might not generate contacts and still generate collision events sent to their CollisionEventHandlers.

Definition at line 720 of file Simulator.cpp.

References mContactGroupFlags, and OPAL_LOGGER.

Referenced by setupContactGroup().

void opal::Simulator::setUserData void *  data  )  [virtual]
 

Set the user data pointer to some external data. The user data is totally user-managed (i.e. it is not destroyed when the Simulator is destroyed).

Definition at line 710 of file Simulator.cpp.

References mUserData.

Referenced by Simulator().

bool opal::Simulator::simulate real  dt  )  [virtual]
 

This function performs collision detection and simulates everything ahead by the given dt. Internally, it steps through the simulation iteratively using a fixed step size (so you can pass in whatever dt you want; it will be broken up into fixed increments automatically). Any "leftover" time will be saved until the next time this is called. The function returns true if at least one time step has been taken. During collision detection, the following cases are ignored when deciding whether to collide two Solids (ignored both for physical contact generation and collision event handling): 1. Two static Solids, each without a CollisionEventHandler. 2. Two Shapes that are part of the same Solid. 3. Two sleeping Solids. 4. Two Solids connected by a fixed Joint. 5. Two Solids connected by a Joint with contacts disabled. 6. Solid0 is static, Solid1 dynamic and is sleeping, static-to-sleeping contacts are ignored by the Simulator, and neither Solid has a CollisionEventHandler. 7. Solid1 is static, Solid0 dynamic and is sleeping, static-to-sleeping contacts are ignored by the Simulator, and neither Solid has a CollisionEventHandler. 8. The two Solids' contact groups do not generate contacts when they collide, and neither Solid has a CollisionEventHandler.

Definition at line 97 of file Simulator.cpp.

References mMotorList, mSensorList, mStepSize, and mTimeBuffer.

virtual void opal::Simulator::stepPhysics  )  [protected, pure virtual]
 

This function is physics engine-specific. It handles collision detection and steps the simulation ahead by a constant step size.

Implemented in opal::ODESimulator.


Member Data Documentation

std::vector<CollisionEventHandler *> opal::Simulator::mCollisionEventHandlers [protected]
 

Global collision handlers.

Definition at line 525 of file Simulator.h.

Referenced by addGlobalCollisionEventHandler(), getGlobalCollisionEventHandler(), getNumGlobalCollisionEventHandlers(), internal_recordCollision(), and removeGlobalCollisionEventHandler().

unsigned long int opal::Simulator::mContactGroupFlags[32] [protected]
 

A set of bitfields used to describe how different contact groups interact.

Definition at line 515 of file Simulator.h.

Referenced by internal_getContactGroupFlags(), setupContactGroups(), and Simulator().

SimulatorData opal::Simulator::mData [protected]
 

data

Definition at line 536 of file Simulator.h.

Referenced by initData().

bool opal::Simulator::mIsJointDestructionSafe [protected]
 

True when it is safe to destroy a Joint (e.g. not in the middle of looping over all the Joint).

Definition at line 498 of file Simulator.h.

Referenced by destroyJoint(), and Simulator().

bool opal::Simulator::mIsSolidDestructionSafe [protected]
 

True when it is safe to destroy a Solid (e.g. not in the middle of looping over all the Solid).

Definition at line 494 of file Simulator.h.

Referenced by destroySolid(), and Simulator().

std::vector<Joint*> opal::Simulator::mJointGarbageList [protected]
 

An internal list of Joints marked as garbage.

Definition at line 504 of file Simulator.h.

Referenced by destroyJoint().

std::vector<Joint*> opal::Simulator::mJointList [protected]
 

An internal list of all Joints.

Definition at line 484 of file Simulator.h.

Referenced by addJoint(), and destroyAllJoints().

unsigned int opal::Simulator::mMaxContacts [protected]
 

The maximum number of physical contacts generated when two Solids collide.

Definition at line 533 of file Simulator.h.

Referenced by getMaxContacts(), and setMaxContacts().

real opal::Simulator::mMaxCorrectingVel [protected]
 

The maximum correcting velocity used when forcing apart interpenetrating objects.

Definition at line 529 of file Simulator.h.

Referenced by getMaxCorrectingVel(), and setMaxCorrectingVel().

std::vector<Motor*> opal::Simulator::mMotorList [protected]
 

An internal list of all Motors.

Definition at line 487 of file Simulator.h.

Referenced by addMotor(), destroyAllMotors(), removeJoint(), removeMotor(), removeSolid(), and simulate().

std::vector<PostStepEventHandler *> opal::Simulator::mPostStepEventHandlers [protected]
 

Pointer to the Simulator's post-step event handler.

Definition at line 522 of file Simulator.h.

Referenced by addPostStepEventHandler(), getNumPostStepEventHandlers(), getPostStepEventHandler(), and removePostStepEventHandler().

Space* opal::Simulator::mRootSpace [protected]
 

parent of all spaces

Definition at line 511 of file Simulator.h.

Referenced by getRootSpace(), and opal::ODESimulator::initData().

std::vector<Sensor*> opal::Simulator::mSensorList [protected]
 

An internal list of all Sensors.

Definition at line 490 of file Simulator.h.

Referenced by addSensor(), destroyAllSensors(), removeSensor(), and simulate().

std::vector<Solid*> opal::Simulator::mSolidGarbageList [protected]
 

An internal list of Solids marked as garbage.

Definition at line 501 of file Simulator.h.

Referenced by destroyGarbage(), and destroySolid().

std::vector<Solid*> opal::Simulator::mSolidList [protected]
 

An internal list of all Solids.

A limit on Solid motion to protect against simulation explosions due to numerical inaccuracy.

Definition at line 481 of file Simulator.h.

Referenced by addSolid(), destroyAllSolids(), getNumSolids(), getSolid(), and opal::ODESimulator::stepPhysics().

SolverAccuracyLevel opal::Simulator::mSolverAccuracyLevel [protected]
 

The accuracy level used internally by the physics engine's constraint solver.

Definition at line 466 of file Simulator.h.

Referenced by getSolverAccuracy(), and setSolverAccuracy().

std::vector<Space*> opal::Simulator::mSpaceList [protected]
 

Spaces are stored here so the user doesn't have to destroy them; they get destroyed when the Simulator is destroyed.

Definition at line 508 of file Simulator.h.

Referenced by addSpace(), and ~Simulator().

bool opal::Simulator::mStaticSleepingContactsEnabled [protected]
 

True if contacts are generated between static Solids and sleeping Solids.

Definition at line 519 of file Simulator.h.

Referenced by areStaticSleepingContactsEnabled(), setStaticSleepingContactsEnabled(), and Simulator().

real opal::Simulator::mStepSize [protected]
 

The constant step size used to break arbitrary simulation dt values into constant chunks.

Definition at line 457 of file Simulator.h.

Referenced by getStepSize(), setStepSize(), and simulate().

real opal::Simulator::mTimeBuffer [protected]
 

Maintains leftover dt from previous simulation steps. This is useful when a dt smaller than the step size is requested; the dt will accumulate until there is enough for a single step.

Definition at line 462 of file Simulator.h.

Referenced by simulate(), and Simulator().

void* opal::Simulator::mUserData [protected]
 

Pointer to user data. This is totally user-managed (i.e. OPAL will never delete it).

Definition at line 470 of file Simulator.h.

Referenced by getUserData(), and setUserData().


The documentation for this class was generated from the following files:
Generated on Tue May 16 17:49:57 2006 for OPAL by  doxygen 1.4.6-NO