#include <Simulator.h>
Inheritance diagram for opal::Simulator:
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 |
Space * | mRootSpace |
unsigned long int | mContactGroupFlags [32] |
bool | mStaticSleepingContactsEnabled |
std::vector< PostStepEventHandler * > | mPostStepEventHandlers |
std::vector< CollisionEventHandler * > | mCollisionEventHandlers |
real | mMaxCorrectingVel |
unsigned int | mMaxContacts |
SimulatorData | mData |
Definition at line 118 of file Simulator.h.
|
|
Definition at line 79 of file Simulator.cpp. References destroyAllJoints(), destroyAllMotors(), destroyAllSensors(), destroyAllSolids(), and mSpaceList. |
|
Sets the Simulator's collision event handler.
Definition at line 268 of file Simulator.cpp. References mCollisionEventHandlers. |
|
Adds a Joint to the internal list of Joints.
Definition at line 1072 of file Simulator.cpp. References mJointList. Referenced by opal::ODESimulator::createJoint(). |
|
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(). |
|
Sets the Simulator's post-step event handler.
Definition at line 240 of file Simulator.cpp. References mPostStepEventHandlers. |
|
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(). |
|
Adds a Solid to the internal list of Solids.
Definition at line 1017 of file Simulator.cpp. References mSolidList. Referenced by opal::ODESimulator::createSolid(). |
|
Adds a Space to the internal list of Spaces.
Definition at line 1151 of file Simulator.cpp. References mSpaceList. Referenced by opal::ODESimulator::createSpace(). |
|
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(). |
|
Creates and returns a pointer to an AccelerationSensor.
Definition at line 944 of file Simulator.cpp. References addSensor(). |
|
Creates and returns a pointer to an AttractorMotor.
Definition at line 911 of file Simulator.cpp. References addMotor(). |
|
Creates and returns a pointer to a GearedMotor.
Definition at line 897 of file Simulator.cpp. References addMotor(). |
|
Creates and returns a pointer to an InclineSensor.
Definition at line 951 of file Simulator.cpp. References addSensor(). |
|
Creates and returns a pointer to a Joint.
Implemented in opal::ODESimulator. |
|
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(). |
|
Creates and returns a pointer to a RaycastSensor.
Definition at line 958 of file Simulator.cpp. References addSensor(). |
|
Creates and returns a pointer to a ServoMotor.
Definition at line 904 of file Simulator.cpp. References addMotor(). |
|
Creates and returns a pointer to a Solid.
Implemented in opal::ODESimulator. Referenced by createPlane(). |
|
Creates and returns a pointer to a Space which is a child of the Simulator's root Space. Implemented in opal::ODESimulator. |
|
Creates and returns a pointer to a SpringMotor.
Definition at line 918 of file Simulator.cpp. References addMotor(). |
|
Creates and returns a pointer to a ThrusterMotor.
Definition at line 883 of file Simulator.cpp. References addMotor(). |
|
Creates and returns a pointer to a VelocityMotor.
Definition at line 890 of file Simulator.cpp. References addMotor(). |
|
Creates and returns a pointer to a VolumeSensor.
Definition at line 965 of file Simulator.cpp. References addSensor(). |
|
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. |
|
Immediately destroys all Joints in the Simulator.
Definition at line 875 of file Simulator.cpp. References mJointList, and removeJoint(). Referenced by ~Simulator(). |
|
Immediately destroys all Motors in the Simulator.
Definition at line 936 of file Simulator.cpp. References mMotorList, and removeMotor(). Referenced by ~Simulator(). |
|
Immediately destroys all Sensors in the Simulator.
Definition at line 977 of file Simulator.cpp. References mSensorList, and removeSensor(). Referenced by ~Simulator(). |
|
Immediately destroys all Solids in the Simulator.
Definition at line 855 of file Simulator.cpp. References mSolidList, and removeSolid(). Referenced by ~Simulator(). |
|
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. |
|
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(). |
|
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(). |
|
Immediately destroys the given Sensor.
Definition at line 972 of file Simulator.cpp. References removeSensor(). |
|
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(). |
|
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. |
|
Returns the gravity used in the simulation.
Implemented in opal::ODESimulator. Referenced by opal::VelocityMotor::internal_update(). |
|
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(). |
|
Returns the maximum correcting velocity for interpenetrating objects. Definition at line 1001 of file Simulator.cpp. References mMaxCorrectingVel. |
|
Number of stored collision handlers.
Definition at line 292 of file Simulator.cpp. References mCollisionEventHandlers. Referenced by opal::ode_hidden::internal_collisionCallback(). |
|
Number of stored step handlers.
Definition at line 263 of file Simulator.cpp. References mPostStepEventHandlers. |
|
Returns the number of Solids in the Simulator.
Definition at line 833 of file Simulator.cpp. References mSolidList. |
|
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. |
|
Definition at line 1156 of file Simulator.cpp. References mRootSpace. |
|
Returns a pointer to the Solid at the given index.
Definition at line 838 of file Simulator.cpp. References mSolidList. |
|
Returns the accuracy level.
Definition at line 990 of file Simulator.cpp. References mSolverAccuracyLevel. |
|
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(). |
|
Returns the user data pointer (NULL if it has not been set).
Definition at line 715 of file Simulator.cpp. References mUserData. |
|
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(). |
|
Reimplemented in opal::ODESimulator. Definition at line 74 of file Simulator.cpp. References mData. Referenced by opal::ODESimulator::initData(). |
|
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. |
|
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(). |
|
Returns the Simulator's contact group flags.
Definition at line 806 of file Simulator.cpp. References mContactGroupFlags. Referenced by groupsMakeContacts(). |
|
Helper function used for volume queries.
Implemented in opal::ODESimulator. Referenced by opal::VolumeSensor::queryVolume(). |
|
Record collisions into global handlers.
Definition at line 218 of file Simulator.cpp. References mCollisionEventHandlers. Referenced by opal::ode_hidden::internal_collisionCallback(). |
|
If such handler is stored it will be removed from the list.
Definition at line 279 of file Simulator.cpp. References mCollisionEventHandlers. |
|
Removes a Joint from the internal list of Joints.
Definition at line 1077 of file Simulator.cpp. References mMotorList. Referenced by destroyAllJoints(), and destroyJoint(). |
|
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(). |
|
If such handler is stored it will be removed from the list.
Definition at line 251 of file Simulator.cpp. References mPostStepEventHandlers. |
|
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(). |
|
Removes a Solid from the internal list of Solids.
Definition at line 1022 of file Simulator.cpp. References mMotorList. Referenced by destroyAllSolids(), and destroySolid(). |
|
Sets the gravity used in the simulation.
Implemented in opal::ODESimulator. |
|
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(). |
|
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(). |
|
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(). |
|
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. |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
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. |
|
This function is physics engine-specific. It handles collision detection and steps the simulation ahead by a constant step size. Implemented in opal::ODESimulator. |
|
Global collision handlers.
Definition at line 525 of file Simulator.h. Referenced by addGlobalCollisionEventHandler(), getGlobalCollisionEventHandler(), getNumGlobalCollisionEventHandlers(), internal_recordCollision(), and removeGlobalCollisionEventHandler(). |
|
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(). |
|
data
Definition at line 536 of file Simulator.h. Referenced by initData(). |
|
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(). |
|
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(). |
|
An internal list of Joints marked as garbage.
Definition at line 504 of file Simulator.h. Referenced by destroyJoint(). |
|
An internal list of all Joints.
Definition at line 484 of file Simulator.h. Referenced by addJoint(), and destroyAllJoints(). |
|
The maximum number of physical contacts generated when two Solids collide. Definition at line 533 of file Simulator.h. Referenced by getMaxContacts(), and setMaxContacts(). |
|
The maximum correcting velocity used when forcing apart interpenetrating objects. Definition at line 529 of file Simulator.h. Referenced by getMaxCorrectingVel(), and setMaxCorrectingVel(). |
|
An internal list of all Motors.
Definition at line 487 of file Simulator.h. Referenced by addMotor(), destroyAllMotors(), removeJoint(), removeMotor(), removeSolid(), and simulate(). |
|
Pointer to the Simulator's post-step event handler.
Definition at line 522 of file Simulator.h. Referenced by addPostStepEventHandler(), getNumPostStepEventHandlers(), getPostStepEventHandler(), and removePostStepEventHandler(). |
|
parent of all spaces
Definition at line 511 of file Simulator.h. Referenced by getRootSpace(), and opal::ODESimulator::initData(). |
|
An internal list of all Sensors.
Definition at line 490 of file Simulator.h. Referenced by addSensor(), destroyAllSensors(), removeSensor(), and simulate(). |
|
An internal list of Solids marked as garbage.
Definition at line 501 of file Simulator.h. Referenced by destroyGarbage(), and destroySolid(). |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
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(). |
|
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(). |