Definition of an independent and simulatable "world". More...
#include <World.hpp>
Public Types | |
using | Bodies = std::vector< BodyID > |
Bodies container type. | |
using | Contacts = std::vector< KeyedContactPtr > |
Container type for keyed contact identifiers. | |
using | Joints = std::vector< JointID > |
Container type for joint identifiers. | |
using | BodyJoints = std::vector< std::pair< BodyID, JointID > > |
Container type for body associated joint identifiers. | |
using | Fixtures = std::vector< FixtureID > |
Container type for fixture identifiers. | |
using | FixtureListener = std::function< void(FixtureID)> |
Listener type for some fixture related events. | |
using | JointListener = std::function< void(JointID)> |
Listener type for some joint related events. | |
using | ContactListener = std::function< void(ContactID)> |
Listener type for some contact related events. | |
using | ManifoldContactListener = std::function< void(ContactID, const Manifold &)> |
Listener type for some manifold contact events. | |
using | ImpulsesContactListener = std::function< void(ContactID, const ContactImpulsesList &, unsigned)> |
Impulses contact listener. | |
Public Member Functions | |
Special Member Functions | |
Special member functions that are explicitly defined. | |
World (const WorldConf &def=GetDefaultWorldConf()) | |
Constructs a world object. More... | |
World (const World &other) | |
Copy constructor. More... | |
World & | operator= (const World &other) |
Assignment operator. More... | |
~World () noexcept | |
Destructor. More... | |
Listener Member Functions | |
void | SetFixtureDestructionListener (const FixtureListener &listener) noexcept |
Registers a destruction listener for fixtures. | |
void | SetJointDestructionListener (const JointListener &listener) noexcept |
Registers a destruction listener for joints. | |
void | SetBeginContactListener (ContactListener listener) noexcept |
Registers a begin contact event listener. | |
void | SetEndContactListener (ContactListener listener) noexcept |
Registers an end contact event listener. | |
void | SetPreSolveContactListener (ManifoldContactListener listener) noexcept |
Registers a pre-solve contact event listener. | |
void | SetPostSolveContactListener (ImpulsesContactListener listener) noexcept |
Registers a post-solve contact event listener. | |
Miscellaneous Member Functions | |
void | Clear () noexcept |
Clears this world. More... | |
StepStats | Step (const StepConf &conf=StepConf{}) |
Steps the world simulation according to the given configuration. More... | |
bool | IsStepComplete () const noexcept |
Whether or not "step" is complete. More... | |
bool | GetSubStepping () const noexcept |
Gets whether or not sub-stepping is enabled. More... | |
void | SetSubStepping (bool flag) noexcept |
Enables/disables single stepped continuous physics. More... | |
const DynamicTree & | GetTree () const noexcept |
Gets access to the broad-phase dynamic tree information. | |
bool | IsLocked () const noexcept |
Is the world locked (in the middle of a time step). | |
void | ShiftOrigin (Length2 newOrigin) |
Shifts the world origin. More... | |
Length | GetMinVertexRadius () const noexcept |
Gets the minimum vertex radius that shapes in this world can be. More... | |
Length | GetMaxVertexRadius () const noexcept |
Gets the maximum vertex radius that shapes in this world can be. More... | |
Frequency | GetInvDeltaTime () const noexcept |
Gets the inverse delta time. More... | |
Body Member Functions. | |
Member functions relating to bodies. | |
BodyCounter | GetBodyRange () const noexcept |
Gets the extent of the currently valid body range. More... | |
SizedRange< Bodies::const_iterator > | GetBodies () const noexcept |
Gets the world body range for this constant world. More... | |
SizedRange< Bodies::const_iterator > | GetBodiesForProxies () const noexcept |
Gets the bodies-for-proxies range for this world. More... | |
BodyID | CreateBody (const BodyConf &def=GetDefaultBodyConf()) |
Creates a rigid body with the given configuration. More... | |
const Body & | GetBody (BodyID id) const |
Gets the state of the identified body. More... | |
void | SetBody (BodyID id, const Body &value) |
Sets the state of the identified body. More... | |
void | Destroy (BodyID id) |
Destroys the identified body. More... | |
SizedRange< Fixtures::const_iterator > | GetFixtures (BodyID id) const |
Gets the range of fixtures attached to the identified body. More... | |
SizedRange< World::BodyJoints::const_iterator > | GetJoints (BodyID id) const |
Gets the range of joints attached to the identified body. More... | |
SizedRange< World::Contacts::const_iterator > | GetContacts (BodyID id) const |
Gets the container of contacts attached to the identified body. More... | |
Fixture Member Functions | |
Member functions relating to fixtures. | |
FixtureCounter | GetFixtureRange () const noexcept |
Gets the extent of the currently valid fixture range. More... | |
FixtureID | CreateFixture (const FixtureConf &def=FixtureConf{}) |
Creates a fixture and attaches it to the identified body. More... | |
const FixtureConf & | GetFixture (FixtureID id) const |
Gets the identified fixture state. More... | |
void | SetFixture (FixtureID id, const FixtureConf &value) |
Sets the identified fixture's state. More... | |
bool | Destroy (FixtureID id) |
Destroys the identified fixture. More... | |
Joint Member Functions | |
Member functions relating to joints. | |
JointCounter | GetJointRange () const noexcept |
Gets the extent of the currently valid joint range. More... | |
SizedRange< Joints::const_iterator > | GetJoints () const noexcept |
Gets the world joint range. More... | |
JointID | CreateJoint (const Joint &def) |
Creates a joint to constrain one or more bodies. More... | |
const Joint & | GetJoint (JointID id) const |
Gets the value of the identified joint. More... | |
void | SetJoint (JointID id, const Joint &def) |
Sets the identified joint to the given value. More... | |
void | Destroy (JointID id) |
Destroys the identified joint. More... | |
Contact Member Functions | |
Member functions relating to contacts. | |
ContactCounter | GetContactRange () const noexcept |
Gets the extent of the currently valid contact range. More... | |
SizedRange< Contacts::const_iterator > | GetContacts () const noexcept |
Gets the world contact range. More... | |
const Contact & | GetContact (ContactID id) const |
Gets the identified contact. More... | |
void | SetContact (ContactID id, const Contact &value) |
Sets the identified contact's state. More... | |
const Manifold & | GetManifold (ContactID id) const |
Gets the collision manifold for the identified contact. More... | |
Private Attributes | |
propagate_const< std::unique_ptr< WorldImpl > > | m_impl |
Pointer to implementation (PIMPL) More... | |
Related Functions | |
(Note that these are not member functions.) | |
AABB | ComputeAABB (const World &world, FixtureID id) |
Computes the AABB for the identified fixture within the given world. | |
AABB | ComputeAABB (const World &world, BodyID id) |
Computes the AABB for the identified body within the given world. | |
bool | RayCast (const World &world, const RayCastInput &input, const FixtureRayCastCB &callback) |
Ray-cast the world for all fixtures in the path of the ray. More... | |
DistanceJointConf | GetDistanceJointConf (const World &world, BodyID bodyA, BodyID bodyB, Length2 anchorA=Length2{}, Length2 anchorB=Length2{}) |
Gets the configuration for the given parameters. | |
FrictionJointConf | GetFrictionJointConf (const World &world, BodyID bodyA, BodyID bodyB, Length2 anchor) |
Gets the confguration for the given parameters. | |
GearJointConf | GetGearJointConf (const World &world, JointID id1, JointID id2, Real ratio=Real{1}) |
Gets the configuration for the given parameters. | |
MotorJointConf | GetMotorJointConf (const World &world, BodyID bA, BodyID bB) |
Gets the confguration for the given parameters. | |
PrismaticJointConf | GetPrismaticJointConf (const World &world, BodyID bA, BodyID bB, const Length2 anchor, const UnitVec axis) |
Gets the configuration for the given parameters. | |
LinearVelocity | GetLinearVelocity (const World &world, const PrismaticJointConf &joint) noexcept |
Gets the current linear velocity of the given configuration. | |
PulleyJointConf | GetPulleyJointConf (const World &world, BodyID bA, BodyID bB, Length2 groundA, Length2 groundB, Length2 anchorA, Length2 anchorB) |
Gets the configuration for the given parameters. | |
RevoluteJointConf | GetRevoluteJointConf (const World &world, BodyID bodyA, BodyID bodyB, Length2 anchor) |
Gets the configuration for the given parameters. | |
Angle | GetAngle (const World &world, const RevoluteJointConf &conf) |
Gets the current angle of the given configuration in the given world. | |
AngularVelocity | GetAngularVelocity (const World &world, const RevoluteJointConf &conf) |
Gets the current angular velocity of the given configuration. | |
WeldJointConf | GetWeldJointConf (const World &world, BodyID bodyA, BodyID bodyB, const Length2 anchor=Length2{}) |
Gets the configuration for the given parameters. | |
WheelJointConf | GetWheelJointConf (const World &world, BodyID bodyA, BodyID bodyB, Length2 anchor, UnitVec axis=UnitVec::GetRight()) |
Gets the definition data for the given parameters. | |
AngularVelocity | GetAngularVelocity (const World &world, const WheelJointConf &conf) |
Gets the angular velocity for the given configuration within the specified world. | |
BodyCounter | GetBodyRange (const World &world) noexcept |
Gets the extent of the currently valid body range. More... | |
SizedRange< std::vector< BodyID >::const_iterator > | GetBodies (const World &world) noexcept |
Gets the bodies of the specified world. | |
SizedRange< std::vector< BodyID >::const_iterator > | GetBodiesForProxies (const World &world) noexcept |
Gets the bodies-for-proxies range for the given world. | |
BodyID | CreateBody (World &world, const BodyConf &def=GetDefaultBodyConf()) |
Creates a rigid body with the given configuration. More... | |
const Body & | GetBody (const World &world, BodyID id) |
Gets the body configuration for the identified body. More... | |
void | SetBody (World &world, BodyID id, const Body &body) |
Sets the body state for the identified body. More... | |
void | Destroy (World &world, BodyID id) |
Destroys the identified body. More... | |
SizedRange< std::vector< FixtureID >::const_iterator > | GetFixtures (const World &world, BodyID id) |
Gets the range of all constant fixtures attached to the given body. More... | |
FixtureCounter | GetFixtureCount (const World &world, BodyID id) |
Gets the count of fixtures associated with the identified body. More... | |
LinearAcceleration2 | GetLinearAcceleration (const World &world, BodyID id) |
Gets this body's linear acceleration. More... | |
AngularAcceleration | GetAngularAcceleration (const World &world, BodyID id) |
Gets this body's angular acceleration. More... | |
Acceleration | GetAcceleration (const World &world, BodyID id) |
Gets the acceleration of the identified body. More... | |
void | SetAcceleration (World &world, BodyID id, LinearAcceleration2 linear, AngularAcceleration angular) |
Sets the linear and rotational accelerations on the body. More... | |
void | SetAcceleration (World &world, BodyID id, LinearAcceleration2 value) |
Sets the linear accelerations on the body. More... | |
void | SetAcceleration (World &world, BodyID id, AngularAcceleration value) |
Sets the rotational accelerations on the body. More... | |
void | SetAcceleration (World &world, BodyID id, Acceleration value) |
Sets the accelerations on the given body. More... | |
void | SetTransformation (World &world, BodyID id, Transformation xfm) |
Sets the transformation of the body. More... | |
void | SetTransform (World &world, BodyID id, Length2 location, Angle angle) |
Sets the position of the body's origin and rotation. More... | |
void | SetLocation (World &world, BodyID id, Length2 value) |
Sets the body's location. More... | |
void | SetAngle (World &world, BodyID id, Angle value) |
Sets the body's angular orientation. More... | |
void | RotateAboutWorldPoint (World &world, BodyID id, Angle amount, Length2 worldPoint) |
Rotates a body a given amount around a point in world coordinates. More... | |
void | RotateAboutLocalPoint (World &world, BodyID id, Angle amount, Length2 localPoint) |
Rotates a body a given amount around a point in body local coordinates. More... | |
Acceleration | CalcGravitationalAcceleration (const World &world, BodyID id) |
Calculates the gravitationally associated acceleration for the given body within its world. More... | |
BodyCounter | GetWorldIndex (const World &world, const BodyID id) noexcept |
Gets the world index for the given body. More... | |
BodyType | GetType (const World &world, BodyID id) |
Gets the type of the identified body. More... | |
void | SetType (World &world, BodyID id, BodyType value, bool resetMassData=true) |
Sets the type of the given body. More... | |
Transformation | GetTransformation (const World &world, BodyID id) |
Gets the body's transformation. More... | |
Length2 | GetLocation (const World &world, BodyID id) |
Convenience function for getting just the location of the identified body. More... | |
Length2 | GetWorldPoint (const World &world, BodyID id, const Length2 localPoint) |
Gets the world coordinates of a point given in coordinates relative to the body's origin. More... | |
UnitVec | GetLocalVector (const World &world, BodyID body, const UnitVec uv) |
Convenience function for getting the local vector of the identified body. More... | |
Length2 | GetLocalPoint (const World &world, BodyID body, const Length2 worldPoint) |
Gets a local point relative to the body's origin given a world point. More... | |
Angle | GetAngle (const World &world, BodyID id) |
Gets the angle of the identified body. More... | |
UnitVec | GetWorldVector (const World &world, BodyID body, UnitVec localVector) |
Convenience function for getting a world vector of the identified body. | |
Velocity | GetVelocity (const World &world, BodyID id) |
Gets the velocity of the identified body. More... | |
void | SetVelocity (World &world, BodyID id, const Velocity &value) |
Sets the body's velocity (linear and angular velocity). More... | |
bool | IsAwake (const World &world, BodyID id) |
Gets the awake/asleep state of this body. More... | |
void | SetAwake (World &world, BodyID id) |
Wakes up the identified body. More... | |
void | UnsetAwake (World &world, BodyID id) |
Sleeps the identified body. More... | |
LinearVelocity2 | GetLinearVelocity (const World &world, BodyID id) |
Gets the linear velocity of the center of mass of the identified body. More... | |
AngularVelocity | GetAngularVelocity (const World &world, BodyID id) |
Gets the angular velocity. More... | |
void | SetVelocity (World &world, BodyID id, const Velocity &value) |
Sets the body's velocity (linear and angular velocity). More... | |
void | SetVelocity (World &world, BodyID id, const LinearVelocity2 &value) |
Sets the velocity of the identified body. More... | |
void | SetVelocity (World &world, BodyID id, AngularVelocity value) |
Sets the velocity of the identified body. More... | |
void | DestroyFixtures (World &world, BodyID id, bool resetMassData=true) |
Destroys fixtures of the identified body. More... | |
bool | IsEnabled (const World &world, BodyID id) |
Gets the enabled/disabled state of the body. More... | |
void | SetEnabled (World &world, BodyID id, bool value) |
Sets the enabled state of the body. More... | |
bool | IsAwake (const World &world, BodyID id) |
Gets the awake/asleep state of this body. More... | |
void | SetAwake (World &world, BodyID id) |
Wakes up the identified body. More... | |
void | UnsetAwake (World &world, BodyID id) |
Sleeps the identified body. More... | |
bool | Awaken (World &world, BodyID id) |
Awakens the body if it's asleep. More... | |
bool | IsMassDataDirty (const World &world, BodyID id) |
Gets whether the body's mass-data is dirty. More... | |
bool | IsFixedRotation (const World &world, BodyID id) |
Gets whether the body has fixed rotation. More... | |
void | SetFixedRotation (World &world, BodyID id, bool value) |
Sets this body to have fixed rotation. More... | |
Length2 | GetWorldCenter (const World &world, BodyID id) |
Get the world position of the center of mass of the specified body. More... | |
InvMass | GetInvMass (const World &world, BodyID id) |
Gets the inverse total mass of the body. More... | |
InvRotInertia | GetInvRotInertia (const World &world, BodyID id) |
Gets the inverse rotational inertia of the body. More... | |
Mass | GetMass (const World &world, BodyID id) |
Gets the mass of the body. More... | |
RotInertia | GetRotInertia (const World &world, BodyID id) |
Gets the rotational inertia of the body. More... | |
Length2 | GetLocalCenter (const World &world, BodyID id) |
Gets the local position of the center of mass of the specified body. More... | |
RotInertia | GetLocalRotInertia (const World &world, BodyID id) |
Gets the rotational inertia of the body about the local origin. More... | |
MassData | GetMassData (const World &world, BodyID id) |
Gets the mass data of the body. More... | |
MassData | ComputeMassData (const World &world, BodyID id) |
Computes the identified body's mass data. More... | |
void | SetMassData (World &world, BodyID id, const MassData &massData) |
Sets the mass properties to override the mass properties of the fixtures. More... | |
void | ResetMassData (World &world, BodyID id) |
Resets the mass data properties. More... | |
SizedRange< std::vector< std::pair< BodyID, JointID > >::const_iterator > | GetJoints (const World &world, BodyID id) |
Gets the range of all joints attached to the identified body. More... | |
bool | IsSpeedable (const World &world, BodyID id) |
Is identified body "speedable". More... | |
bool | IsAccelerable (const World &world, BodyID id) |
Is identified body "accelerable"? More... | |
bool | IsImpenetrable (const World &world, BodyID id) |
Is the body treated like a bullet for continuous collision detection? More... | |
void | SetImpenetrable (World &world, BodyID id) |
Sets the impenetrable status of the identified body. More... | |
void | UnsetImpenetrable (World &world, BodyID id) |
Unsets the impenetrable status of the identified body. More... | |
void | SetImpenetrable (World &world, BodyID id, bool value) |
Convenience function that sets/unsets the impenetrable status of the identified body. More... | |
bool | IsSleepingAllowed (const World &world, BodyID id) |
Gets whether the identified body is allowed to sleep. More... | |
void | SetSleepingAllowed (World &world, BodyID, bool value) |
Sets whether the identified body is allowed to sleep. More... | |
SizedRange< std::vector< KeyedContactPtr >::const_iterator > | GetContacts (const World &world, BodyID id) |
Gets the container of all contacts attached to the identified body. More... | |
Force2 | GetCentripetalForce (const World &world, BodyID id, Length2 axis) |
Gets the centripetal force necessary to put the body into an orbit having the given radius. More... | |
void | ApplyForceToCenter (World &world, BodyID id, Force2 force) |
Applies a force to the center of mass of the given body. More... | |
void | ApplyForce (World &world, BodyID id, Force2 force, Length2 point) |
Apply a force at a world point. More... | |
void | ApplyTorque (World &world, BodyID id, Torque torque) |
Applies a torque. More... | |
void | ApplyLinearImpulse (World &world, BodyID id, Momentum2 impulse, Length2 point) |
Applies an impulse at a point. More... | |
void | ApplyAngularImpulse (World &world, BodyID id, AngularMomentum impulse) |
Applies an angular impulse. More... | |
void | SetForce (World &world, BodyID id, Force2 force, Length2 point) noexcept |
Sets the given amount of force at the given point to the given body. More... | |
void | SetTorque (World &world, BodyID id, Torque torque) noexcept |
Sets the given amount of torque to the given body. More... | |
Frequency | GetLinearDamping (const World &world, BodyID id) |
Gets the linear damping of the body. More... | |
void | SetLinearDamping (World &world, BodyID id, NonNegative< Frequency > linearDamping) |
Sets the linear damping of the body. More... | |
Frequency | GetAngularDamping (const World &world, BodyID id) |
Gets the angular damping of the body. More... | |
void | SetAngularDamping (World &world, BodyID id, NonNegative< Frequency > angularDamping) |
Sets the angular damping of the body. More... | |
BodyCounter | GetAwakeCount (const World &world) noexcept |
Gets the count of awake bodies in the given world. | |
BodyCounter | Awaken (World &world) noexcept |
Awakens all of the bodies in the given world. More... | |
BodyID | FindClosestBody (const World &world, Length2 location) noexcept |
Finds body in given world that's closest to the given location. | |
BodyCounter | GetBodyCount (const World &world) noexcept |
Gets the body count in the given world. More... | |
void | SetAccelerations (World &world, Acceleration acceleration) noexcept |
Sets the accelerations of all the world's bodies to the given value. | |
void | SetAccelerations (World &world, LinearAcceleration2 acceleration) noexcept |
Sets the accelerations of all the world's bodies to the given value. More... | |
void | ClearForces (World &world) noexcept |
Clears forces. More... | |
template<class F > | |
void | SetAccelerations (World &world, F fn) |
Sets the accelerations of all the world's bodies. More... | |
ContactCounter | GetContactRange (const World &world) noexcept |
Gets the extent of the currently valid contact range. More... | |
SizedRange< std::vector< KeyedContactPtr >::const_iterator > | GetContacts (const World &world) noexcept |
Gets the contacts recognized within the given world. | |
const Contact & | GetContact (const World &world, ContactID id) |
Gets the identified contact. More... | |
void | SetContact (World &world, ContactID id, const Contact &value) |
Sets the identified contact's state. More... | |
bool | IsTouching (const World &world, ContactID id) |
Is this contact touching? More... | |
bool | IsAwake (const World &world, ContactID id) |
Gets the awake status of the specified contact. More... | |
void | SetAwake (World &world, ContactID id) |
Sets awake the bodies of the fixtures of the given contact. More... | |
BodyID | GetBodyA (const World &world, ContactID id) |
Gets the body-A of the identified contact if it has one. More... | |
BodyID | GetBodyB (const World &world, ContactID id) |
Gets the body-B of the identified contact if it has one. More... | |
FixtureID | GetFixtureA (const World &world, ContactID id) |
Gets fixture A of the identified contact. More... | |
FixtureID | GetFixtureB (const World &world, ContactID id) |
Gets fixture B of the identified contact. More... | |
ChildCounter | GetChildIndexA (const World &world, ContactID id) |
Get the child primitive index for fixture A. More... | |
ChildCounter | GetChildIndexB (const World &world, ContactID id) |
Get the child primitive index for fixture B. More... | |
TimestepIters | GetToiCount (const World &world, ContactID id) |
Gets the Time Of Impact (TOI) count. More... | |
bool | NeedsFiltering (const World &world, ContactID id) |
Whether or not the contact needs filtering. More... | |
bool | NeedsUpdating (const World &world, ContactID id) |
Whether or not the contact needs updating. More... | |
bool | HasValidToi (const World &world, ContactID id) |
Whether or not the contact has a valid TOI. More... | |
Real | GetToi (const World &world, ContactID id) |
Gets the time of impact (TOI) as a fraction. More... | |
Real | GetDefaultFriction (const World &world, ContactID id) |
Gets the default friction amount for the identified contact. More... | |
Real | GetDefaultRestitution (const World &world, ContactID id) |
Gets the default restitution amount for the identified contact. More... | |
Real | GetFriction (const World &world, ContactID id) |
Gets the friction used with the identified contact. More... | |
Real | GetRestitution (const World &world, ContactID id) |
Gets the restitution used with the identified contact. More... | |
void | SetFriction (World &world, ContactID id, Real friction) |
Sets the friction value for the identified contact. More... | |
void | SetRestitution (World &world, ContactID id, Real restitution) |
Sets the restitution value for the specified contact. More... | |
const Manifold & | GetManifold (const World &world, ContactID id) |
Gets the manifold for the identified contact. More... | |
WorldManifold | GetWorldManifold (const World &world, ContactID id) |
Gets the world manifold for the identified contact. More... | |
void | ResetFriction (World &world, ContactID id) |
Resets the friction mixture to the default value. More... | |
void | ResetRestitution (World &world, ContactID id) |
Resets the restitution to the default value. More... | |
LinearVelocity | GetTangentSpeed (const World &world, ContactID id) |
Gets the tangent speed of the identified contact. More... | |
void | SetTangentSpeed (World &world, ContactID id, LinearVelocity value) |
Sets the desired tangent speed for a conveyor belt behavior. More... | |
bool | IsEnabled (const World &world, ContactID id) |
Gets the enabled status of the identified contact. More... | |
void | SetEnabled (World &world, ContactID id) |
Sets the enabled status of the identified contact. More... | |
void | UnsetEnabled (World &world, ContactID id) |
Unsets the enabled status of the identified contact. More... | |
ContactCounter | GetTouchingCount (const World &world) noexcept |
Gets the touching count for the given world. | |
void | SetEnabled (World &world, ContactID id, bool value) |
Convenience function for setting/unsetting the enabled status of the identified contact based on the value parameter. More... | |
ContactCounter | GetContactCount (const World &world) noexcept |
Gets the count of contacts in the given world. More... | |
FixtureCounter | GetFixtureRange (const World &world) noexcept |
Gets the extent of the currently valid fixture range. More... | |
FixtureCounter | GetFixtureCount (const World &world) noexcept |
Gets the count of fixtures in the given world. More... | |
FixtureID | CreateFixture (World &world, FixtureConf def=FixtureConf{}, bool resetMassData=true) |
Creates a fixture within the specified world. More... | |
FixtureID | CreateFixture (World &world, BodyID id, const Shape &shape, FixtureConf def=FixtureConf{}, bool resetMassData=true) |
Creates a fixture within the specified world. More... | |
template<typename T > | |
FixtureID | CreateFixture (World &world, BodyID id, const T &shapeConf, FixtureConf def=FixtureConf{}, bool resetMassData=true) |
Creates a fixture within the specified world using a configuration of a shape. More... | |
bool | Destroy (World &world, FixtureID id, bool resetMassData=true) |
Destroys the identified fixture. More... | |
Filter | GetFilterData (const World &world, FixtureID id) |
Gets the filter data for the identified fixture. More... | |
void | SetFilterData (World &world, FixtureID id, const Filter &filter) |
Sets the contact filtering data. More... | |
BodyID | GetBody (const World &world, FixtureID id) |
Gets the identifier of the body associated with the identified fixture. More... | |
Transformation | GetTransformation (const World &world, FixtureID id) |
Gets the transformation associated with the given fixture. More... | |
const Shape & | GetShape (const World &world, FixtureID id) |
Gets the shape associated with the identified fixture. More... | |
Real | GetFriction (const World &world, FixtureID id) |
Gets the coefficient of friction of the specified fixture. More... | |
Real | GetRestitution (const World &world, FixtureID id) |
Gets the coefficient of restitution of the specified fixture. More... | |
bool | IsSensor (const World &world, FixtureID id) |
Is the specified fixture a sensor (non-solid)? More... | |
void | SetSensor (World &world, FixtureID id, bool value) |
Sets whether the fixture is a sensor or not. More... | |
AreaDensity | GetDensity (const World &world, FixtureID id) |
Gets the density of this fixture. More... | |
MassData | GetMassData (const World &world, FixtureID id) |
Gets the mass data for the identified fixture in the given world. More... | |
bool | TestPoint (const World &world, FixtureID id, Length2 p) |
Tests a point for containment in a fixture. More... | |
JointCounter | GetJointRange (const World &world) noexcept |
Gets the extent of the currently valid joint range. More... | |
SizedRange< std::vector< JointID >::const_iterator > | GetJoints (const World &world) noexcept |
Gets the joints of the specified world. | |
JointID | CreateJoint (World &world, const Joint &def) |
Creates a new joint within the given world. | |
template<typename T > | |
JointID | CreateJoint (World &world, const T &value) |
Creates a new joint from a configuration. More... | |
void | Destroy (World &world, JointID id) |
Destroys the identified joint. More... | |
TypeID | GetType (const World &world, JointID id) |
Gets the type of the joint. More... | |
const Joint & | GetJoint (const World &world, JointID id) |
Gets the value of the identified joint. More... | |
void | SetJoint (World &world, JointID id, const Joint &def) |
Sets the value of the identified joint. More... | |
template<typename T > | |
void | SetJoint (World &world, JointID id, const T &value) |
Sets a joint's value from a configuration. More... | |
bool | GetCollideConnected (const World &world, JointID id) |
Gets collide connected for the specified joint. More... | |
bool | IsMotorEnabled (const World &world, JointID id) |
Is the joint motor enabled? More... | |
void | EnableMotor (World &world, JointID id, bool value) |
Enable/disable the joint motor. More... | |
bool | IsLimitEnabled (const World &world, JointID id) |
Gets whether the identified joint's limit is enabled. More... | |
void | EnableLimit (World &world, JointID id, bool value) |
Sets whether the identified joint's limit is enabled or not. More... | |
BodyID | GetBodyA (const World &world, JointID id) |
Gets the identifier of body-A of the identified joint. More... | |
BodyID | GetBodyB (const World &world, JointID id) |
Gets the identifier of body-B of the identified joint. More... | |
Length2 | GetLocalAnchorA (const World &world, JointID id) |
Get the anchor point on body-A in local coordinates. More... | |
Length2 | GetLocalAnchorB (const World &world, JointID id) |
Get the anchor point on body-B in local coordinates. More... | |
Momentum2 | GetLinearReaction (const World &world, JointID id) |
Gets the linear reaction on body-B at the joint anchor. More... | |
AngularMomentum | GetAngularReaction (const World &world, JointID id) |
Get the angular reaction on body-B for the identified joint. More... | |
Angle | GetReferenceAngle (const World &world, JointID id) |
Gets the reference-angle property of the identified joint if it has it. More... | |
UnitVec | GetLocalXAxisA (const World &world, JointID id) |
Gets the local-X-axis-A property of the identified joint if it has it. More... | |
UnitVec | GetLocalYAxisA (const World &world, JointID id) |
Gets the local-Y-axis-A property of the identified joint if it has it. More... | |
AngularVelocity | GetMotorSpeed (const World &world, JointID id) |
Gets the motor-speed property of the identied joint if it supports it. More... | |
void | SetMotorSpeed (World &world, JointID id, AngularVelocity value) |
Sets the motor-speed property of the identied joint if it supports it. More... | |
Torque | GetMaxMotorTorque (const World &world, JointID id) |
Gets the max motor torque. More... | |
void | SetMaxMotorTorque (World &world, JointID id, Torque value) |
Sets the maximum motor torque. More... | |
Momentum | GetLinearMotorImpulse (const World &world, JointID id) |
Gets the linear motor impulse of the identified joint if it supports that. More... | |
AngularMomentum | GetAngularMotorImpulse (const World &world, JointID id) |
Gets the angular motor impulse of the identified joint if it has this property. More... | |
RotInertia | GetAngularMass (const World &world, JointID id) |
Gets the computed angular rotational inertia used by the joint. More... | |
Frequency | GetFrequency (const World &world, JointID id) |
Gets the frequency of the identified joint if it has this property. More... | |
void | SetFrequency (World &world, JointID id, Frequency value) |
Sets the frequency of the identified joint if it has this property. More... | |
AngularVelocity | GetAngularVelocity (const World &world, JointID id) |
Gets the angular velocity of the identified joint if it has this property. More... | |
bool | IsEnabled (const World &world, JointID id) |
Gets the enabled/disabled state of the joint. More... | |
JointCounter | GetWorldIndex (const World &world, JointID id) noexcept |
Gets the world index of the given joint. More... | |
Length2 | GetAnchorA (const World &world, JointID id) |
Get the anchor point on body-A in world coordinates. More... | |
Length2 | GetAnchorB (const World &world, JointID id) |
Get the anchor point on body-B in world coordinates. More... | |
Real | GetRatio (const World &world, JointID id) |
Gets the ratio property of the identified joint if it has it. More... | |
Length | GetJointTranslation (const World &world, JointID id) |
Gets the current joint translation. More... | |
Angle | GetAngle (const World &world, JointID id) |
Gets the angle property of the identified joint if it has it. More... | |
Force | GetMotorForce (const World &world, JointID id, Frequency inv_dt) |
Gets the current motor force for the given joint, given the inverse time step. More... | |
Torque | GetMotorTorque (const World &world, JointID id, Frequency inv_dt) |
Gets the current motor torque for the given joint given the inverse time step. More... | |
Length2 | GetLinearOffset (const World &world, JointID id) |
Gets the target linear offset, in frame A. More... | |
void | SetLinearOffset (World &world, JointID id, Length2 value) |
Sets the target linear offset, in frame A. More... | |
Angle | GetAngularOffset (const World &world, JointID id) |
Gets the target angular offset. More... | |
void | SetAngularOffset (World &world, JointID id, Angle value) |
Sets the target angular offset. More... | |
Length2 | GetGroundAnchorA (const World &world, JointID id) |
Get the first ground anchor. More... | |
Length2 | GetGroundAnchorB (const World &world, JointID id) |
Get the second ground anchor. More... | |
Length | GetCurrentLengthA (const World &world, JointID id) |
Get the current length of the segment attached to body-A. More... | |
Length | GetCurrentLengthB (const World &world, JointID id) |
Get the current length of the segment attached to body-B. More... | |
Length2 | GetTarget (const World &world, JointID id) |
Gets the target point. More... | |
void | SetTarget (World &world, JointID id, Length2 value) |
Sets the target point. More... | |
Angle | GetAngularLowerLimit (const World &world, JointID id) |
Get the lower joint limit. More... | |
Angle | GetAngularUpperLimit (const World &world, JointID id) |
Get the upper joint limit. More... | |
void | SetAngularLimits (World &world, JointID id, Angle lower, Angle upper) |
Set the joint limits. More... | |
bool | ShiftOrigin (World &world, JointID id, Length2 value) |
Shifts the origin of the identified joint. More... | |
Real | GetDampingRatio (const World &world, JointID id) |
Gets the damping ratio associated with the identified joint if it has one. More... | |
Length | GetLength (const World &world, JointID id) |
Gets the length associated with the identified joint if it has one. More... | |
LimitState | GetLimitState (const World &world, JointID id) |
Gets the joint's limit state if it has one. More... | |
void | SetAwake (World &world, JointID id) |
Wakes up the joined bodies. More... | |
JointCounter | GetJointCount (const World &world) noexcept |
Gets the count of joints in the given world. More... | |
void | SetFixtureDestructionListener (World &world, std::function< void(FixtureID)> listener) noexcept |
Sets the fixture destruction lister. | |
void | SetJointDestructionListener (World &world, std::function< void(JointID)> listener) noexcept |
Sets the joint destruction lister. | |
void | SetBeginContactListener (World &world, std::function< void(ContactID)> listener) noexcept |
Sets the begin-contact lister. | |
void | SetEndContactListener (World &world, std::function< void(ContactID)> listener) noexcept |
Sets the end-contact lister. | |
void | SetPreSolveContactListener (World &world, std::function< void(ContactID, const Manifold &)> listener) noexcept |
Sets the pre-solve-contact lister. | |
void | SetPostSolveContactListener (World &world, std::function< void(ContactID, const ContactImpulsesList &, unsigned)> listener) noexcept |
Sets the post-solve-contact lister. | |
void | Clear (World &world) noexcept |
Clears this world. More... | |
StepStats | Step (World &world, const StepConf &conf=StepConf{}) |
Steps the given world the specified amount. | |
StepStats | Step (World &world, Time delta, TimestepIters velocityIterations=8, TimestepIters positionIterations=3) |
Steps the world ahead by a given time amount. More... | |
bool | GetSubStepping (const World &world) noexcept |
Gets whether or not sub-stepping is enabled. More... | |
void | SetSubStepping (World &world, bool flag) noexcept |
Enables/disables single stepped continuous physics. More... | |
const DynamicTree & | GetTree (const World &world) noexcept |
Gets the dynamic tree of the given world. | |
FixtureCounter | GetShapeCount (const World &world) noexcept |
Gets the count of unique shapes in the given world. | |
Length | GetMinVertexRadius (const World &world) noexcept |
Gets the min vertex radius that shapes for the given world are allowed to be. | |
Length | GetMaxVertexRadius (const World &world) noexcept |
Gets the max vertex radius that shapes for the given world are allowed to be. | |
void | ShiftOrigin (World &world, Length2 newOrigin) |
Shifts the world origin. More... | |
Definition of an independent and simulatable "world".
The world class manages physics entities, dynamic simulation, and queries. In a physical sense, perhaps this is more like a universe in that entities in a world have no interaction with entities in other worlds. In any case, there's precedence, from a physics-engine standpoint, for this being called a world.
Box2D
which provides a world gravity property). BodyID
, ContactID
, FixtureID
, and JointID
values respectively.
|
explicit |
Constructs a world object.
def | A customized world configuration or its default value. |
StepConf
data that's given to the world's Step
method. InvalidArgument | if the given max vertex radius is less than the min. |
playrho::d2::World::World | ( | const World & | other | ) |
Copy constructor.
Copy constructs this world with a deep copy of the given world.
|
noexcept |
|
noexcept |
Clears this world.
Referenced by playrho::d2::Clear().
BodyID playrho::d2::World::CreateBody | ( | const BodyConf & | def = GetDefaultBodyConf() | ) |
Creates a rigid body with the given configuration.
GetBodies()
method. def | A customized body configuration or its default value. |
Destroy(BodyID)
method. WrongState | if this method is called while the world is locked. |
LengthError | if this operation would create more than MaxBodies . |
Referenced by playrho::d2::CreateBody().
FixtureID playrho::d2::World::CreateFixture | ( | const FixtureConf & | def = FixtureConf{} | ) |
Creates a fixture and attaches it to the identified body.
Creates a fixture for attaching a shape and other characteristics to this body. Fixtures automatically go away when this body is destroyed. Fixtures can also be manually removed and destroyed using the Destroy(FixtureID, bool)
, or DestroyFixtures()
methods.
GetFixtures()
methods.def | Initial fixture settings. Friction and density must be >= 0. Restitution must be > -infinity and < infinity. |
WrongState | if called while the world is "locked". |
std::out_of_range | If given an invalid body identifier. |
InvalidArgument | if called for a shape with a vertex radius less than the minimum vertex radius. |
InvalidArgument | if called for a shape with a vertex radius greater than the maximum vertex radius. |
Referenced by playrho::d2::CreateFixture().
Creates a joint to constrain one or more bodies.
GetJoints()
method. Destroy(JointID)
method. WrongState | if this method is called while the world is locked. |
LengthError | if this operation would create more than MaxJoints . |
Referenced by playrho::d2::CreateJoint().
void playrho::d2::World::Destroy | ( | BodyID | id | ) |
Destroys the identified body.
Destroys the identified body that had previously been created by a call to this world's CreateBody(const BodyConf&)
method.
GetBodies()
method. id | Identifier of body to destroy that had been created by this world. |
WrongState | if this method is called while the world is locked. |
std::out_of_range | If given an invalid body identifier. |
Referenced by playrho::d2::Destroy(), and playrho::d2::DestroyFixtures().
bool playrho::d2::World::Destroy | ( | FixtureID | id | ) |
Destroys the identified fixture.
Destroys a fixture previously created by the CreateFixture(const FixtureConf&)
method. This removes the fixture from the broad-phase and destroys all contacts associated with this fixture. All fixtures attached to a body are implicitly destroyed when the body is destroyed.
ResetMassData()
after fixtures have been destroyed. WrongState | if this function is called while the world is locked. |
std::out_of_range | If given an invalid fixture identifier. |
GetFixtures()
methods.id | the fixture to be removed. |
void playrho::d2::World::Destroy | ( | JointID | id | ) |
Destroys the identified joint.
Destroys the identified joint that had previously been created by a call to this world's CreateJoint(const Joint&)
method.
GetJoints()
method. id | Identifier of joint to destroy that had been created by this world. |
WrongState | if this method is called while the world is locked. |
std::out_of_range | If given an invalid joint identifier. |
|
noexcept |
Gets the world body range for this constant world.
Gets a range enumerating the bodies currently existing within this world. These are the bodies that had been created from previous calls to the CreateBody(const BodyConf&)
method that haven't yet been destroyed.
Referenced by playrho::d2::CalcGravitationalAcceleration(), and playrho::d2::GetShapeCount().
|
noexcept |
Gets the state of the identified body.
std::out_of_range | If given an invalid body identifier. |
Referenced by playrho::d2::GetAnchorA(), playrho::d2::GetAnchorB(), playrho::d2::GetAngle(), playrho::d2::GetAngularVelocity(), playrho::d2::GetBody(), playrho::d2::GetJointTranslation(), playrho::d2::GetTransformation(), playrho::d2::GetWorldManifold(), playrho::d2::IsEnabled(), and playrho::d2::SetAwake().
|
noexcept |
Gets the extent of the currently valid body range.
BodyID
that is in range for body related functions. Gets the identified contact.
std::out_of_range | If given an invalid contact identifier. |
Referenced by playrho::d2::GetContact(), playrho::d2::GetDefaultFriction(), and playrho::d2::GetDefaultRestitution().
|
noexcept |
Gets the extent of the currently valid contact range.
ContactID
that is in range for contact related functions.
|
noexcept |
Gets the world contact range.
ContactListener
to avoid missing contacts. SizedRange< World::Contacts::const_iterator > playrho::d2::World::GetContacts | ( | BodyID | id | ) | const |
Gets the container of contacts attached to the identified body.
ContactListener
. std::out_of_range | If given an invalid body identifier. |
Referenced by playrho::d2::GetContacts().
const FixtureConf & playrho::d2::World::GetFixture | ( | FixtureID | id | ) | const |
Gets the identified fixture state.
std::out_of_range | If given an invalid fixture identifier. |
Referenced by playrho::d2::ComputeMassData(), playrho::d2::GetBody(), playrho::d2::GetDefaultFriction(), playrho::d2::GetDefaultRestitution(), playrho::d2::GetDensity(), playrho::d2::GetFilterData(), playrho::d2::GetShape(), playrho::d2::GetShapeCount(), playrho::d2::GetWorldManifold(), playrho::d2::IsSensor(), playrho::d2::SetFilterData(), and playrho::d2::SetSensor().
|
noexcept |
Gets the extent of the currently valid fixture range.
FixtureID
that is in range for fixture related functions. SizedRange< World::Fixtures::const_iterator > playrho::d2::World::GetFixtures | ( | BodyID | id | ) | const |
Gets the range of fixtures attached to the identified body.
std::out_of_range | If given an invalid body identifier. |
Referenced by playrho::d2::ComputeMassData(), playrho::d2::GetFixtures(), and playrho::d2::GetShapeCount().
|
noexcept |
Gets the inverse delta time.
Gets the inverse delta time that was set on construction or assignment, and updated on every call to the Step()
method having a non-zero delta-time.
Referenced by playrho::d2::Step().
Gets the value of the identified joint.
std::out_of_range | If given an invalid joint identifier. |
Referenced by playrho::d2::GetAnchorA(), playrho::d2::GetAnchorB(), playrho::d2::GetAngle(), playrho::d2::GetAngularReaction(), playrho::d2::GetBodyA(), playrho::d2::GetBodyB(), playrho::d2::GetCollideConnected(), playrho::d2::GetJoint(), playrho::d2::GetJointTranslation(), playrho::d2::GetLinearReaction(), playrho::d2::GetLocalAnchorA(), playrho::d2::GetLocalAnchorB(), playrho::d2::GetReferenceAngle(), playrho::d2::GetType(), and playrho::d2::SetAwake().
|
noexcept |
Gets the extent of the currently valid joint range.
JointID
that is in range for joint related functions.
|
noexcept |
Gets the world joint range.
Gets a range enumerating the joints currently existing within this world. These are the joints that had been created from previous calls to the CreateJoint
method that haven't yet been destroyed.
SizedRange< World::BodyJoints::const_iterator > playrho::d2::World::GetJoints | ( | BodyID | id | ) | const |
Gets the range of joints attached to the identified body.
std::out_of_range | If given an invalid body identifier. |
Referenced by playrho::d2::GetJoints().
Gets the collision manifold for the identified contact.
std::out_of_range | If given an invalid contact identifier. |
Referenced by playrho::d2::GetManifold().
|
noexcept |
Gets the maximum vertex radius that shapes in this world can be.
Referenced by playrho::d2::GetMaxVertexRadius().
|
noexcept |
Gets the minimum vertex radius that shapes in this world can be.
Referenced by playrho::d2::GetMinVertexRadius().
|
noexcept |
Gets whether or not sub-stepping is enabled.
Referenced by playrho::d2::GetSubStepping().
|
noexcept |
Whether or not "step" is complete.
The "step" is completed when there are no more TOI events for the current time step.
true
unless sub-stepping is enabled and the step method returned without finishing all of its sub-steps. Assignment operator.
Copy assigns this world with a deep copy of the given world.
Sets the state of the identified body.
std::out_of_range | If given an invalid body identifier. |
Referenced by playrho::d2::SetAcceleration(), playrho::d2::SetAngularDamping(), playrho::d2::SetAwake(), playrho::d2::SetBody(), playrho::d2::SetEnabled(), playrho::d2::SetFixedRotation(), playrho::d2::SetImpenetrable(), playrho::d2::SetLinearDamping(), playrho::d2::SetMassData(), playrho::d2::SetSleepingAllowed(), playrho::d2::SetTransformation(), playrho::d2::SetType(), playrho::d2::SetVelocity(), playrho::d2::UnsetAwake(), and playrho::d2::UnsetImpenetrable().
Sets the identified contact's state.
std::out_of_range | If given an invalid contact identifier. |
Referenced by playrho::d2::SetContact().
void playrho::d2::World::SetFixture | ( | FixtureID | id, |
const FixtureConf & | value | ||
) |
Sets the identified fixture's state.
std::out_of_range | If given an invalid fixture identifier. |
Referenced by playrho::d2::SetFilterData(), and playrho::d2::SetSensor().
Sets the identified joint to the given value.
std::out_of_range | If given an invalid joint identifier. |
Referenced by playrho::d2::SetJoint().
|
noexcept |
Enables/disables single stepped continuous physics.
GetSubStepping()
method will return the value this method was called with. Referenced by playrho::d2::SetSubStepping().
void playrho::d2::World::ShiftOrigin | ( | Length2 | newOrigin | ) |
Shifts the world origin.
position -= newOrigin
. newOrigin | the new origin with respect to the old origin |
WrongState | if this method is called while the world is locked. |
Referenced by playrho::d2::ShiftOrigin().
Steps the world simulation according to the given configuration.
Performs position and velocity updating, sleeping of non-moving bodies, updating of the contacts, and notifying the contact listener of begin-contact, end-contact, pre-solve, and post-solve events.
p0
) going velocity 0 (v0
) fast with a sum acceleration of a
, after time t
and barring any collisions, will have a new velocity (v1
) of v0 + (a * t)
and a new position (p1
) of p0 + v1 * t
.conf | Configuration for the simulation step. |
WrongState | if this method is called while the world is locked. |
Referenced by playrho::d2::Step().
|
related |
Applies an angular impulse.
world | The world in which the identified body exists. |
id | Identifier of body to apply the angular impulse to. |
impulse | Angular impulse to be applied. |
std::out_of_range | If given an invalid body identifier. |
Apply a force at a world point.
world | World in which body exists. |
id | Identity of body to apply the force to. |
force | World force vector. |
point | World position of the point of application. |
std::out_of_range | If given an invalid body identifier. |
Applies a force to the center of mass of the given body.
world | The world in which the identified body exists. |
id | Identifier of body to apply the force to. |
force | World force vector. |
std::out_of_range | If given an invalid body identifier. |
Applies an impulse at a point.
world | The world in which the identified body exists. |
id | Identifier of body to apply the impulse to. |
impulse | the world impulse vector. |
point | the world position of the point of application. |
std::out_of_range | If given an invalid body identifier. |
Applies a torque.
world | The world in which the identified body exists. |
id | Identifier of body to apply the torque to. |
torque | about the z-axis (out of the screen). |
std::out_of_range | If given an invalid body identifier. |
|
related |
Awakens all of the bodies in the given world.
Calls all of the world's bodies' SetAwake
method.
SetAwake
method that returned true. Awakens the body if it's asleep.
std::out_of_range | If given an invalid body identifier. |
|
related |
Calculates the gravitationally associated acceleration for the given body within its world.
std::out_of_range | If given an invalid body identifier. |
|
related |
Clears this world.
|
related |
Clears forces.
Manually clear the force buffer on all bodies.
Computes the identified body's mass data.
This basically accumulates the mass data over all fixtures.
std::out_of_range | If given an invalid body identifier. |
|
related |
Creates a rigid body with the given configuration.
GetBodies(const World&)
method. world | The world within which to create the body. |
def | A customized body configuration or its default value. |
Destroy(World&, BodyID)
method. WrongState | if this method is called while the world is locked. |
LengthError | if this operation would create more than MaxBodies . |
|
related |
Creates a fixture within the specified world.
WrongState | if called while the world is "locked". |
std::out_of_range | If given an invalid body identifier. |
|
related |
Creates a fixture within the specified world using a configuration of a shape.
This is a convenience function for allowing limited implicit conversions to shapes.
WrongState | if called while the world is "locked". |
std::out_of_range | If given an invalid body identifier. |
|
related |
Creates a fixture within the specified world.
WrongState | if called while the world is "locked". |
std::out_of_range | If given an invalid body identifier in the configuration. |
Creates a new joint from a configuration.
This is a convenience function for allowing limited implicit conversions to joints.
Destroys the identified body.
std::out_of_range | If given an invalid body identifier. |
Destroys the identified fixture.
WrongState | if this function is called while the world is locked. |
std::out_of_range | If given an invalid fixture identifier. |
Destroys the identified joint.
std::out_of_range | If given an invalid joint identifier. |
Destroys fixtures of the identified body.
Destroys all of the fixtures previously created for this body by the CreateFixture(const Shape&, const FixtureConf&, bool)
method.
ResetMassData()
method. GetFixtures()
methods. std::out_of_range | If given an invalid body identifier. |
Sets whether the identified joint's limit is enabled or not.
std::out_of_range | If given an invalid joint identifier. |
Enable/disable the joint motor.
std::out_of_range | If given an invalid joint identifier. |
|
related |
Gets the acceleration of the identified body.
std::out_of_range | If given an invalid body identifier. |
Get the anchor point on body-A in world coordinates.
std::out_of_range | If given an invalid joint identifier. |
Get the anchor point on body-B in world coordinates.
std::out_of_range | If given an invalid joint identifier. |
Gets the angle of the identified body.
std::out_of_range | If given an invalid body identifier. |
Gets the angle property of the identified joint if it has it.
std::out_of_range | If given an invalid joint identifier. |
|
related |
Gets this body's angular acceleration.
std::out_of_range | If given an invalid body identifier. |
Gets the angular damping of the body.
std::out_of_range | If given an invalid body identifier. |
Get the lower joint limit.
std::out_of_range | If given an invalid joint identifier. |
|
related |
Gets the computed angular rotational inertia used by the joint.
std::out_of_range | If given an invalid joint identifier. |
|
related |
Gets the angular motor impulse of the identified joint if it has this property.
std::out_of_range | If given an invalid joint identifier. |
Gets the target angular offset.
std::out_of_range | If given an invalid joint identifier. |
|
related |
Get the angular reaction on body-B for the identified joint.
std::out_of_range | If given an invalid joint identifier. |
Get the upper joint limit.
std::out_of_range | If given an invalid joint identifier. |
|
related |
Gets the angular velocity.
world | World in which body is identified for. |
id | Identifier of body to get the angular velocity for. |
std::out_of_range | If given an invalid body identifier. |
|
related |
Gets the angular velocity of the identified joint if it has this property.
std::out_of_range | If given an invalid joint identifier. |
Gets the body configuration for the identified body.
std::out_of_range | If given an invalid body identifier. |
Gets the identifier of the body associated with the identified fixture.
std::out_of_range | If given an invalid fixture identifier. |
Gets the body-A of the identified contact if it has one.
InvalidBodyID
. std::out_of_range | If given an invalid contact identifier. |
Gets the identifier of body-A of the identified joint.
std::out_of_range | If given an invalid joint identifier. |
Gets the body-B of the identified contact if it has one.
InvalidBodyID
. std::out_of_range | If given an invalid contact identifier. |
Gets the identifier of body-B of the identified joint.
std::out_of_range | If given an invalid joint identifier. |
|
related |
Gets the body count in the given world.
|
related |
Gets the extent of the currently valid body range.
Gets the centripetal force necessary to put the body into an orbit having the given radius.
std::out_of_range | If given an invalid body identifier. |
|
related |
Get the child primitive index for fixture A.
std::out_of_range | If given an invalid contact identifier. |
|
related |
Get the child primitive index for fixture B.
std::out_of_range | If given an invalid contact identifier. |
Gets collide connected for the specified joint.
std::out_of_range | If given an invalid joint identifier. |
Gets the identified contact.
std::out_of_range | If given an invalid contact identifier. |
|
related |
Gets the count of contacts in the given world.
|
related |
Gets the extent of the currently valid contact range.
ContactID
that is in range for contact related functions.
|
related |
Gets the container of all contacts attached to the identified body.
ContactListener
. std::out_of_range | If given an invalid body identifier. |
Get the current length of the segment attached to body-A.
std::out_of_range | If given an invalid joint identifier. |
Get the current length of the segment attached to body-B.
std::out_of_range | If given an invalid joint identifier. |
Gets the damping ratio associated with the identified joint if it has one.
std::out_of_range | If given an invalid joint identifier. |
std::invalid_argument | If the identified joint's type doesn't support this. |
Gets the default friction amount for the identified contact.
std::out_of_range | If given an invalid contact identifier. |
Gets the default restitution amount for the identified contact.
std::out_of_range | If given an invalid contact identifier. |
|
related |
Gets the density of this fixture.
std::out_of_range | If given an invalid fixture identifier. |
Gets the filter data for the identified fixture.
std::out_of_range | If given an invalid fixture identifier. |
Gets fixture A of the identified contact.
std::out_of_range | If given an invalid contact identifier. |
Gets fixture B of the identified contact.
std::out_of_range | If given an invalid contact identifier. |
|
related |
Gets the count of fixtures in the given world.
GetFixtureRange(const World& world)
. WrongState | if called while the world is "locked". |
|
related |
Gets the count of fixtures associated with the identified body.
std::out_of_range | If given an invalid body identifier. |
|
related |
Gets the extent of the currently valid fixture range.
FixtureID
that is in range for fixture related functions.
|
related |
Gets the range of all constant fixtures attached to the given body.
std::out_of_range | If given an invalid body identifier. |
Gets the frequency of the identified joint if it has this property.
std::out_of_range | If given an invalid joint identifier. |
Gets the friction used with the identified contact.
std::out_of_range | If given an invalid contact identifier. |
Gets the coefficient of friction of the specified fixture.
std::out_of_range | If given an invalid fixture identifier. |
Get the first ground anchor.
std::out_of_range | If given an invalid joint identifier. |
Get the second ground anchor.
std::out_of_range | If given an invalid joint identifier. |
Gets the inverse total mass of the body.
std::out_of_range | If given an invalid body identifier. |
|
related |
Gets the inverse rotational inertia of the body.
std::out_of_range | If given an invalid body identifier. |
Gets the value of the identified joint.
std::out_of_range | If given an invalid joint identifier. |
|
related |
Gets the count of joints in the given world.
|
related |
Gets the extent of the currently valid joint range.
JointID
that is in range for joint related functions.
|
related |
Gets the range of all joints attached to the identified body.
std::out_of_range | If given an invalid body identifier. |
Gets the current joint translation.
std::out_of_range | If given an invalid joint identifier. |
Gets the length associated with the identified joint if it has one.
std::out_of_range | If given an invalid joint identifier. |
std::invalid_argument | If the identified joint's type doesn't support this. |
|
related |
Gets the joint's limit state if it has one.
std::out_of_range | If given an invalid joint identifier. |
std::invalid_argument | If the identified joint's type doesn't support this. |
|
related |
Gets this body's linear acceleration.
std::out_of_range | If given an invalid body identifier. |
Gets the linear damping of the body.
std::out_of_range | If given an invalid body identifier. |
Gets the linear motor impulse of the identified joint if it supports that.
std::out_of_range | If given an invalid joint identifier. |
Gets the target linear offset, in frame A.
std::out_of_range | If given an invalid joint identifier. |
Gets the linear reaction on body-B at the joint anchor.
std::out_of_range | If given an invalid joint identifier. |
|
related |
Gets the linear velocity of the center of mass of the identified body.
world | World in which body is identified for. |
id | Identifier of body to get the linear velocity for. |
std::out_of_range | If given an invalid body identifier. |
Get the anchor point on body-A in local coordinates.
std::out_of_range | If given an invalid joint identifier. |
Get the anchor point on body-B in local coordinates.
std::out_of_range | If given an invalid joint identifier. |
Gets the local position of the center of mass of the specified body.
std::out_of_range | If given an invalid body identifier. |
Gets a local point relative to the body's origin given a world point.
world | The world in which the identified body exists. |
body | Identifier of body that the returned point should be relative to. |
worldPoint | point in world coordinates. |
std::out_of_range | If given an invalid body identifier. |
|
related |
Gets the rotational inertia of the body about the local origin.
std::out_of_range | If given an invalid body identifier. |
Convenience function for getting the local vector of the identified body.
std::out_of_range | If given an invalid body identifier. |
Gets the local-X-axis-A property of the identified joint if it has it.
std::out_of_range | If given an invalid joint identifier. |
Gets the local-Y-axis-A property of the identified joint if it has it.
std::out_of_range | If given an invalid joint identifier. |
Convenience function for getting just the location of the identified body.
std::out_of_range | If given an invalid body identifier. |
Gets the manifold for the identified contact.
std::out_of_range | If given an invalid contact identifier. |
Gets the mass of the body.
std::out_of_range | If given an invalid body identifier. |
Gets the mass data of the body.
std::out_of_range | If given an invalid body identifier. |
Gets the mass data for the identified fixture in the given world.
std::out_of_range | If given an invalid fixture identifier. |
Gets the max motor torque.
std::out_of_range | If given an invalid joint identifier. |
Gets the current motor force for the given joint, given the inverse time step.
std::out_of_range | If given an invalid joint identifier. |
|
related |
Gets the motor-speed property of the identied joint if it supports it.
std::out_of_range | If given an invalid joint identifier. |
Gets the current motor torque for the given joint given the inverse time step.
std::out_of_range | If given an invalid joint identifier. |
Gets the ratio property of the identified joint if it has it.
std::out_of_range | If given an invalid joint identifier. |
Gets the reference-angle property of the identified joint if it has it.
std::out_of_range | If given an invalid joint identifier. |
Gets the restitution used with the identified contact.
std::out_of_range | If given an invalid contact identifier. |
Gets the coefficient of restitution of the specified fixture.
std::out_of_range | If given an invalid fixture identifier. |
|
related |
Gets the rotational inertia of the body.
world | The world in which the identified body exists. |
id | Identifier of body to get the rotational inertia for. |
std::out_of_range | If given an invalid body identifier. |
Gets the shape associated with the identified fixture.
std::out_of_range | If given an invalid fixture identifier. |
|
related |
Gets whether or not sub-stepping is enabled.
|
related |
Gets the tangent speed of the identified contact.
std::out_of_range | If given an invalid contact identifier. |
Gets the target point.
std::out_of_range | If given an invalid joint identifier. |
Gets the time of impact (TOI) as a fraction.
std::out_of_range | If given an invalid contact identifier. |
|
related |
Gets the Time Of Impact (TOI) count.
std::out_of_range | If given an invalid contact identifier. |
|
related |
Gets the body's transformation.
std::out_of_range | If given an invalid body identifier. |
|
related |
Gets the transformation associated with the given fixture.
nullptr
as its associated body. std::out_of_range | If given an invalid fixture identifier. |
Gets the type of the identified body.
Gets the type of the joint.
std::out_of_range | If given an invalid joint identifier. |
Gets the velocity of the identified body.
std::out_of_range | If given an invalid body identifier. |
Get the world position of the center of mass of the specified body.
std::out_of_range | If given an invalid body identifier. |
|
related |
Gets the world index for the given body.
std::out_of_range | If given an invalid body identifier. |
|
related |
Gets the world index of the given joint.
std::out_of_range | If given an invalid joint identifier. |
|
related |
Gets the world manifold for the identified contact.
std::out_of_range | If given an invalid contact identifier. |
Gets the world coordinates of a point given in coordinates relative to the body's origin.
world | World context. |
id | Identifier of body that the given point is relative to. |
localPoint | a point measured relative the the body's origin. |
std::out_of_range | If given an invalid body identifier. |
Whether or not the contact has a valid TOI.
std::out_of_range | If given an invalid contact identifier. |
Is identified body "accelerable"?
Indicates whether the body is accelerable, i.e. whether it is effected by forces. Only Dynamic bodies are accelerable.
std::out_of_range | If given an invalid body identifier. |
Gets the awake/asleep state of this body.
std::out_of_range | If given an invalid body identifier. |
Gets the awake/asleep state of this body.
std::out_of_range | If given an invalid body identifier. |
Gets the awake status of the specified contact.
std::out_of_range | If given an invalid contact identifier. |
Gets the enabled/disabled state of the body.
std::out_of_range | If given an invalid body identifier. |
Gets the enabled status of the identified contact.
std::out_of_range | If given an invalid contact identifier. |
Gets the enabled/disabled state of the joint.
std::out_of_range | If given an invalid joint identifier. |
Gets whether the body has fixed rotation.
std::out_of_range | If given an invalid body identifier. |
Is the body treated like a bullet for continuous collision detection?
std::out_of_range | If given an invalid body identifier. |
Gets whether the identified joint's limit is enabled.
std::out_of_range | If given an invalid joint identifier. |
Gets whether the body's mass-data is dirty.
std::out_of_range | If given an invalid body identifier. |
Is the joint motor enabled?
std::out_of_range | If given an invalid joint identifier. |
Is the specified fixture a sensor (non-solid)?
std::out_of_range | If given an invalid fixture identifier. |
Gets whether the identified body is allowed to sleep.
std::out_of_range | If given an invalid body identifier. |
Is identified body "speedable".
Is the body able to have a non-zero speed associated with it. Kinematic and Dynamic bodies are speedable. Static bodies are not.
std::out_of_range | If given an invalid body identifier. |
Is this contact touching?
Touching is defined as either:
std::out_of_range | If given an invalid contact identifier. |
Whether or not the contact needs filtering.
std::out_of_range | If given an invalid contact identifier. |
Whether or not the contact needs updating.
std::out_of_range | If given an invalid contact identifier. |
Resets the friction mixture to the default value.
std::out_of_range | If given an invalid contact identifier. |
Resets the mass data properties.
This resets the mass data to the sum of the mass properties of the fixtures.
CreateFixture
to update the body mass data properties unless SetMassData
is used. std::out_of_range | If given an invalid body identifier. |
Resets the restitution to the default value.
std::out_of_range | If given an invalid contact identifier. |
Rotates a body a given amount around a point in body local coordinates.
This changes both the linear and angular positions of the body.
RotateAboutWorldPoint
function. world | The world in which the identified body exists. |
id | Identifier of body to rotate. |
amount | Amount to rotate body by (in counter-clockwise direction). |
localPoint | Point in local coordinates. |
std::out_of_range | If given an invalid body identifier. |
Rotates a body a given amount around a point in world coordinates.
This changes both the linear and angular positions of the body.
world | The world in which the identified body exists. |
id | Identifier of body to rotate. |
amount | Amount to rotate body by (in counter-clockwise direction). |
worldPoint | Point in world coordinates. |
std::out_of_range | If given an invalid body identifier. |
|
related |
Sets the accelerations on the given body.
world | The world in which the identified body's acceleration should be set. |
id | Identifier of body whose acceleration should be set. |
value | Acceleration value to set. |
std::out_of_range | If given an invalid body identifier. |
|
related |
Sets the rotational accelerations on the body.
std::out_of_range | If given an invalid body identifier. |
|
related |
Sets the linear and rotational accelerations on the body.
world | World in which it all happens. |
id | Identifier of body whose acceleration should be set. |
linear | Linear acceleration. |
angular | Angular acceleration. |
std::out_of_range | If given an invalid body identifier. |
|
related |
Sets the linear accelerations on the body.
std::out_of_range | If given an invalid body identifier. |
|
related |
Sets the accelerations of all the world's bodies.
world | World instance to set the acceleration of all contained bodies for. |
fn | Function or functor with a signature like: Acceleration (*fn)(World&,BodyID) . |
|
related |
Sets the accelerations of all the world's bodies to the given value.
Sets the body's angular orientation.
This instantly adjusts the body to be at the new angular orientation.
world | The world in which the identified body's angle should be set. |
id | Identifier of body to move. |
value | Valid world angle of the body's local origin. Behavior is undefined if value is invalid. |
std::out_of_range | If given an invalid body identifier. |
|
related |
Sets the angular damping of the body.
std::out_of_range | If given an invalid body identifier. |
Set the joint limits.
std::out_of_range | If given an invalid joint identifier. |
Sets the target angular offset.
std::out_of_range | If given an invalid joint identifier. |
Wakes up the identified body.
std::out_of_range | If given an invalid body identifier. |
Wakes up the identified body.
std::out_of_range | If given an invalid body identifier. |
Sets awake the bodies of the fixtures of the given contact.
std::out_of_range | If given an invalid contact identifier. |
Wakes up the joined bodies.
std::out_of_range | If given an invalid joint identifier. |
Sets the body state for the identified body.
std::out_of_range | If given an invalid body identifier. |
Sets the identified contact's state.
std::out_of_range | If given an invalid contact identifier. |
Sets the enabled state of the body.
A disabled body is not simulated and cannot be collided with or woken up. If you pass a flag of true, all fixtures will be added to the broad-phase. If you pass a flag of false, all fixtures will be removed from the broad-phase and all contacts will be destroyed. Fixtures and joints are otherwise unaffected.
WrongState | If call would change body's state when world is locked. |
std::out_of_range | If given an invalid body identifier. |
IsEnabled()
returns the state given to this function. Sets the enabled status of the identified contact.
std::out_of_range | If given an invalid contact identifier. |
Convenience function for setting/unsetting the enabled status of the identified contact based on the value parameter.
std::out_of_range | If given an invalid contact identifier. |
Sets the contact filtering data.
std::out_of_range | If given an invalid fixture identifier. |
Sets this body to have fixed rotation.
std::out_of_range | If given an invalid body identifier. |
Sets the given amount of force at the given point to the given body.
std::out_of_range | If given an invalid body identifier. |
Sets the frequency of the identified joint if it has this property.
std::out_of_range | If given an invalid joint identifier. |
Sets the friction value for the identified contact.
Overrides the default friction mixture.
world | The world in which the contact is identified in. |
id | Identifier of the contact whose friction value should be set. |
friction | Co-efficient of friction value of zero or greater. |
std::out_of_range | If given an invalid contact identifier. |
Sets the impenetrable status of the identified body.
Sets that the body should be treated like a bullet for continuous collision detection.
std::out_of_range | If given an invalid body identifier. |
Convenience function that sets/unsets the impenetrable status of the identified body.
std::out_of_range | If given an invalid body identifier. |
Sets the value of the identified joint.
std::out_of_range | If given an invalid joint identifier. |
Sets a joint's value from a configuration.
This is a convenience function for allowing limited implicit conversions to joints.
|
related |
Sets the linear damping of the body.
std::out_of_range | If given an invalid body identifier. |
Sets the target linear offset, in frame A.
std::out_of_range | If given an invalid joint identifier. |
Sets the body's location.
This instantly adjusts the body to be at the new location.
world | The world in which the identified body's location should be set. |
id | Identifier of body to move. |
value | Valid world location of the body's local origin. Behavior is undefined if value is invalid. |
std::out_of_range | If given an invalid body identifier. |
Sets the mass properties to override the mass properties of the fixtures.
world | The world in which the identified body exists. |
id | Identifier of the body. |
massData | the mass properties. |
std::out_of_range | If given an invalid body identifier. |
Sets the maximum motor torque.
std::out_of_range | If given an invalid joint identifier. |
|
related |
Sets the motor-speed property of the identied joint if it supports it.
std::out_of_range | If given an invalid joint identifier. |
Sets the restitution value for the specified contact.
This override the default restitution mixture.
Sets whether the fixture is a sensor or not.
std::out_of_range | If given an invalid fixture identifier. |
Sets whether the identified body is allowed to sleep.
std::out_of_range | If given an invalid body identifier. |
|
related |
Enables/disables single stepped continuous physics.
GetSubStepping()
method will return the value this method was called with.
|
related |
Sets the desired tangent speed for a conveyor belt behavior.
std::out_of_range | If given an invalid contact identifier. |
Sets the target point.
std::out_of_range | If given an invalid joint identifier. |
Sets the given amount of torque to the given body.
std::out_of_range | If given an invalid body identifier. |
Sets the position of the body's origin and rotation.
This instantly adjusts the body to be at the new position and new orientation.
world | The world in which the identified body's transform should be set. |
id | Identifier of body whose transform is to be set. |
location | Valid world location of the body's local origin. Behavior is undefined if value is invalid. |
angle | Valid world rotation. Behavior is undefined if value is invalid. |
std::out_of_range | If given an invalid body identifier. |
|
related |
Sets the transformation of the body.
This instantly adjusts the body to be at the new transformation.
std::out_of_range | If given an invalid body identifier. |
Sets the type of the given body.
WrongState | if this method is called while the world is locked. |
std::out_of_range | If given an invalid body identifier. |
|
related |
Sets the velocity of the identified body.
std::out_of_range | If given an invalid body identifier. |
|
related |
Sets the velocity of the identified body.
std::out_of_range | If given an invalid body identifier. |
Sets the body's velocity (linear and angular velocity).
std::out_of_range | If given an invalid body identifier. |
Sets the body's velocity (linear and angular velocity).
std::out_of_range | If given an invalid body identifier. |
Shifts the origin of the identified joint.
std::out_of_range | If given an invalid joint identifier. |
Shifts the world origin.
position -= newOrigin
. world | The world whose origin should be shifted. |
newOrigin | the new origin with respect to the old origin |
WrongState | if this method is called while the world is locked. |
|
related |
Steps the world ahead by a given time amount.
Performs position and velocity updating, sleeping of non-moving bodies, updating of the contacts, and notifying the contact listener of begin-contact, end-contact, pre-solve, and post-solve events. If the given velocity and position iterations are more than zero, this method also respectively performs velocity and position resolution of the contacting bodies.
p0
going v0
fast with a sum acceleration of a
, after time t
and barring any collisions, will have a new velocity (v1
) of v0 + (a * t)
and a new position (p1
) of p0 + v1 * t
.world | World to step. |
delta | Time to simulate as a delta from the current state. This should not vary. |
velocityIterations | Number of iterations for the velocity constraint solver. |
positionIterations | Number of iterations for the position constraint solver. The position constraint solver resolves the positions of bodies that overlap. |
Sleeps the identified body.
std::out_of_range | If given an invalid body identifier. |
Unsets the enabled status of the identified contact.
std::out_of_range | If given an invalid contact identifier. |
Unsets the impenetrable status of the identified body.
std::out_of_range | If given an invalid body identifier. |
|
private |
Pointer to implementation (PIMPL)
Referenced by Clear(), CreateBody(), CreateFixture(), CreateJoint(), Destroy(), GetBodies(), GetBodiesForProxies(), GetBody(), GetBodyRange(), GetContact(), GetContactRange(), GetContacts(), GetFixture(), GetFixtureRange(), GetFixtures(), GetInvDeltaTime(), GetJoint(), GetJointRange(), GetJoints(), GetManifold(), GetMaxVertexRadius(), GetMinVertexRadius(), GetSubStepping(), GetTree(), IsLocked(), IsStepComplete(), operator=(), SetBody(), SetContact(), SetFixture(), SetJoint(), ShiftOrigin(), Step(), World(), and ~World().