PlayRho  2.0.0
An interactive physics engine & library.
playrho::d2::World Class Reference

Definition of an independent and simulatable "world". More...

#include <playrho/d2/World.hpp>

Public Member Functions

 World (const World &other)
 Copy constructs this world with a deep copy of the given world. More...
 
 World (const WorldConf &def=WorldConf{})
 Constructs a world object. More...
 
template<typename T , typename DT = std::decay_t<T>, typename Tp = std::enable_if_t<!std::is_same_v<DT, World> && !std::is_same_v<DT, WorldConf>, DT>, typename = std::enable_if_t<std::is_constructible_v<DT, T>>>
 World (T &&arg)
 Polymorphic initializing constructor. More...
 
 World (World &&other) noexcept
 Move constructs this world. More...
 
 ~World () noexcept
 Destroys all contained physics entities and releases all related resources. More...
 
Worldoperator= (const World &other)
 Copy assigns this world with a deep copy of the given world. More...
 
Worldoperator= (World &&other) noexcept
 Move assigns this world. More...
 

Friends

void Clear (World &world) noexcept
 Clears the given world. More...
 
BodyID CreateBody (World &world, const Body &body, bool resetMassData)
 Creates a rigid body within the world that's a copy of the given one. More...
 
JointID CreateJoint (World &world, const Joint &def)
 Creates a new joint within the given world. More...
 
ShapeID CreateShape (World &world, const Shape &def)
 Creates an identifiable copy of the given shape within the specified world. More...
 
void Destroy (World &world, BodyID id)
 Destroys the identified body. More...
 
void Destroy (World &world, JointID id)
 Destroys the identified joint. More...
 
void Destroy (World &world, ShapeID id)
 Destroys the identified shape. More...
 
std::vector< BodyIDGetBodies (const World &world)
 Gets the valid world body identifiers container for this constant world. More...
 
std::vector< BodyIDGetBodiesForProxies (const World &world)
 Gets the bodies-for-proxies container for this world. More...
 
Body GetBody (const World &world, BodyID id)
 Gets the state of the identified body. More...
 
BodyCounter GetBodyRange (const World &world) noexcept
 Gets the extent of the currently valid body range. More...
 
Contact GetContact (const World &world, ContactID id)
 Gets the identified contact. More...
 
ContactCounter GetContactRange (const World &world) noexcept
 Gets the extent of the currently valid contact range. More...
 
std::vector< KeyedContactIDGetContacts (const World &world)
 Gets the contacts identified within the given world. More...
 
std::vector< std::tuple< ContactKey, ContactID > > GetContacts (const World &world, BodyID id)
 Gets the container of contacts attached to the identified body. More...
 
Frequency GetInvDeltaTime (const World &world) noexcept
 Gets the inverse delta time. More...
 
Joint GetJoint (const World &world, JointID id)
 Gets the value of the identified joint. More...
 
JointCounter GetJointRange (const World &world) noexcept
 Gets the extent of the currently valid joint range. More...
 
std::vector< JointIDGetJoints (const World &world)
 Gets the joints of the specified world. More...
 
std::vector< std::pair< BodyID, JointID > > GetJoints (const World &world, BodyID id)
 Gets the container of valid joints attached to the identified body. More...
 
Manifold GetManifold (const World &world, ContactID id)
 Gets the manifold for the identified contact. More...
 
std::optional< pmr::StatsResource::StatsGetResourceStats (const World &world) noexcept
 Gets the polymorphic memory resource allocator statistics of the specified world. More...
 
Shape GetShape (const World &world, ShapeID id)
 Gets the shape associated with the identifier. More...
 
ShapeCounter GetShapeRange (const World &world) noexcept
 Gets the extent of the currently valid shape range. More...
 
std::vector< ShapeIDGetShapes (const World &world, BodyID id)
 Gets the identities of the shapes associated with the identified body. More...
 
bool GetSubStepping (const World &world) noexcept
 Gets whether or not sub-stepping is enabled. More...
 
const DynamicTreeGetTree (const World &world)
 Gets access to the broad-phase dynamic tree information. More...
 
TypeID GetType (const World &world) noexcept
 Gets the identifier of the type of data the given world can be casted to. More...
 
Interval< Positive< Length > > GetVertexRadiusInterval (const World &world) noexcept
 Gets the vertex radius interval allowable for the given world. More...
 
bool IsLocked (const World &world) noexcept
 Is the specified world locked. More...
 
bool IsStepComplete (const World &world) noexcept
 Whether or not "step" is complete. More...
 
bool operator!= (const World &lhs, const World &rhs) noexcept
 Inequality operator for world comparisons. More...
 
bool operator== (const World &lhs, const World &rhs) noexcept
 Equality operator for world comparisons. More...
 
void SetBeginContactListener (World &world, ContactFunction listener) noexcept
 Sets the begin-contact lister. More...
 
void SetBody (World &world, BodyID id, const Body &body)
 Sets the state of the identified body. More...
 
void SetContact (World &world, ContactID id, const Contact &value)
 Sets the identified contact's state. More...
 
void SetDetachListener (World &world, BodyShapeFunction listener) noexcept
 Sets the detach listener for shapes detaching from bodies. More...
 
void SetEndContactListener (World &world, ContactFunction listener) noexcept
 Sets the end-contact lister. More...
 
void SetJoint (World &world, JointID id, const Joint &def)
 Sets the value of the identified joint. More...
 
void SetJointDestructionListener (World &world, JointFunction listener) noexcept
 Sets the destruction listener for joints. More...
 
void SetManifold (World &world, ContactID id, const Manifold &value)
 Sets the identified manifold's state. More...
 
void SetPostSolveContactListener (World &world, ContactImpulsesFunction listener) noexcept
 Sets the post-solve-contact lister. More...
 
void SetPreSolveContactListener (World &world, ContactManifoldFunction listener) noexcept
 Sets the pre-solve-contact lister. More...
 
void SetShape (World &world, ShapeID, const Shape &def)
 Sets the identified shape to the new value. More...
 
void SetShapeDestructionListener (World &world, ShapeFunction listener) noexcept
 Sets the destruction listener for shapes. More...
 
void SetSubStepping (World &world, bool flag) noexcept
 Enables/disables single stepped continuous physics. More...
 
void ShiftOrigin (World &world, const Length2 &newOrigin)
 Shifts the origin of the specified world. More...
 
StepStats Step (World &world, const StepConf &conf)
 Steps the given world simulation according to the given configuration. More...
 
template<typename T >
std::add_pointer_t< std::add_const_t< T > > TypeCast (const World *value) noexcept
 Casts the given world into its current underlying configuration value. More...
 
template<typename T >
std::add_pointer_t< T > TypeCast (World *value) noexcept
 Casts the given world into its current configuration value. More...
 

Related Functions

(Note that these are not member functions.)

void ApplyAngularImpulse (World &world, BodyID id, AngularMomentum impulse)
 Applies an angular impulse. More...
 
void ApplyForce (World &world, BodyID id, const Force2 &force, const Length2 &point)
 Apply a force at a world point. More...
 
void ApplyForceToCenter (World &world, BodyID id, const Force2 &force)
 Applies a force to the center of mass of the given body. More...
 
void ApplyLinearImpulse (World &world, BodyID id, const Momentum2 &impulse, const Length2 &point)
 Applies an impulse at a point. More...
 
void ApplyTorque (World &world, BodyID id, Torque torque)
 Applies a torque. More...
 
void Attach (World &world, BodyID id, const Shape &shape, bool resetMassData=true)
 Creates the shape within the world and then associates it with the validly identified body. More...
 
void Attach (World &world, BodyID id, ShapeID shapeID, bool resetMassData=true)
 Associates a validly identified shape with the validly identified body. More...
 
BodyCounter Awaken (World &world)
 Awakens all of the "speedable" bodies in the given world. More...
 
bool Awaken (World &world, BodyID id)
 Awakens the body if it's asleep and "speedable". More...
 
Acceleration CalcGravitationalAcceleration (const World &world, BodyID id)
 Calculates the gravitationally associated acceleration for the given body within its world. More...
 
void ClearForces (World &world)
 Clears forces. More...
 
AABB ComputeAABB (const World &world, BodyID bodyID, ShapeID shapeID)
 Computes the AABB for the identified shape relative to the identified body within the given world. More...
 
AABB ComputeAABB (const World &world, BodyID id)
 Computes the AABB for the identified body within the given world. More...
 
AABB ComputeIntersectingAABB (const World &world, BodyID bA, ShapeID sA, ChildCounter iA, BodyID bB, ShapeID sB, ChildCounter iB)
 Computes the intersecting AABB for the given pair of body-shape-index values. More...
 
AABB ComputeIntersectingAABB (const World &world, const Contact &contact)
 Computes the intersecting AABB for the given contact. More...
 
MassData ComputeMassData (const World &world, BodyID id)
 Computes the identified body's mass data. More...
 
MassData ComputeMassData (const World &world, const Span< const ShapeID > &ids)
 Computes the mass data total of the identified shapes. More...
 
BodyID CreateBody (World &world, const BodyConf &def, bool resetMassData=true)
 Creates a rigid body with the given configuration. More...
 
template<typename T >
JointID CreateJoint (World &world, const T &value)
 Creates a new joint from a configuration. More...
 
template<typename T >
auto CreateShape (World &world, const T &shapeConf) -> decltype(CreateShape(world, Shape{shapeConf}))
 Creates a shape within the specified world using a configuration of the shape. More...
 
bool Detach (World &world, BodyID id, bool resetMassData=true)
 Disassociates all of the associated shape from the validly identified body. More...
 
bool Detach (World &world, BodyID id, ShapeID shapeID, bool resetMassData=true)
 Disassociates a validly identified shape from the validly identified body. More...
 
void EnableLimit (World &world, JointID id, bool value)
 Sets whether the identified joint's limit is enabled or not. More...
 
void EnableMotor (World &world, JointID id, bool value)
 
BodyID FindClosestBody (const World &world, const Length2 &location)
 Finds body in given world that's closest to the given location. More...
 
Acceleration GetAcceleration (const World &world, BodyID id)
 Gets the acceleration of the identified body. More...
 
Length2 GetAnchorA (const World &world, JointID id)
 
Length2 GetAnchorB (const World &world, JointID id)
 
Angle GetAngle (const World &world, BodyID id)
 Gets the angle of the identified body. More...
 
Angle GetAngle (const World &world, const RevoluteJointConf &conf)
 Gets the current angle of the given configuration in the given world. More...
 
Angle GetAngle (const World &world, JointID id)
 Gets the angle property of the identified joint if it has it. More...
 
AngularAcceleration GetAngularAcceleration (const World &world, BodyID id)
 Gets this body's angular acceleration. More...
 
Frequency GetAngularDamping (const World &world, BodyID id)
 Gets the angular damping of the body. More...
 
Angle GetAngularLowerLimit (const World &world, JointID id)
 
RotInertia GetAngularMass (const World &world, JointID id)
 Gets the computed angular rotational inertia used by the joint. More...
 
AngularMomentum GetAngularMotorImpulse (const World &world, JointID id)
 Gets the angular motor impulse of the identified joint if it has this property. More...
 
Angle GetAngularOffset (const World &world, JointID id)
 Gets the target angular offset. More...
 
AngularMomentum GetAngularReaction (const World &world, JointID id)
 Get the angular reaction on body-B for the identified joint. More...
 
Angle GetAngularUpperLimit (const World &world, JointID id)
 
AngularVelocity GetAngularVelocity (const World &world, BodyID id)
 Gets the angular velocity. More...
 
AngularVelocity GetAngularVelocity (const World &world, const RevoluteJointConf &conf)
 Gets the current angular velocity of the given configuration. More...
 
AngularVelocity GetAngularVelocity (const World &world, const WheelJointConf &conf)
 Gets the angular velocity for the given configuration within the specified world. More...
 
AngularVelocity GetAngularVelocity (const World &world, JointID id)
 Gets the angular velocity of the identified joint if it has this property. More...
 
ShapeCounter GetAssociationCount (const World &world)
 Gets the count of body-shape associations in the given world. More...
 
BodyCounter GetAwakeCount (const World &world)
 Gets the count of awake bodies in the given world. More...
 
BodyID GetBodyA (const World &world, ContactID id)
 Gets the body-A of the identified contact if it has one. More...
 
BodyID GetBodyA (const World &world, JointID id)
 Gets the identifier of body-A of the identified joint. More...
 
BodyID GetBodyB (const World &world, ContactID id)
 Gets the body-B of the identified contact if it has one. More...
 
BodyID GetBodyB (const World &world, JointID id)
 Gets the identifier of body-B of the identified joint. More...
 
BodyCounter GetBodyCount (const World &world) noexcept
 Gets the body count in the given world. More...
 
Force2 GetCentripetalForce (const World &world, BodyID id, const Length2 &axis)
 Gets the centripetal force necessary to put the body into an orbit having the given radius. More...
 
ChildCounter GetChildIndexA (const World &world, ContactID id)
 Gets the child primitive index A for the identified contact. More...
 
ChildCounter GetChildIndexB (const World &world, ContactID id)
 Gets the child primitive index B for the identified contact. More...
 
bool GetCollideConnected (const World &world, JointID id)
 Gets collide connected for the specified joint. More...
 
ContactCounter GetContactCount (const World &world) noexcept
 Gets the count of contacts in the given world. 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...
 
Real GetDampingRatio (const World &world, JointID id)
 Gets the damping ratio associated with the identified joint if it has one. 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...
 
NonNegative< AreaDensityGetDensity (const World &world, ShapeID id)
 Gets the density of this shape. More...
 
DistanceJointConf GetDistanceJointConf (const World &world, BodyID bodyA, BodyID bodyB, const Length2 &anchorA=Length2{}, const Length2 &anchorB=Length2{})
 Gets the configuration for a joint with the given parameters. More...
 
Filter GetFilterData (const World &world, ShapeID id)
 Gets the filter data for the identified shape. More...
 
Frequency GetFrequency (const World &world, JointID id)
 Gets the frequency of the identified joint if it has this property. More...
 
NonNegativeFF< RealGetFriction (const World &world, ContactID id)
 Gets the friction used with the identified contact. More...
 
NonNegativeFF< RealGetFriction (const World &world, ShapeID id)
 Gets the coefficient of friction of the specified shape. More...
 
FrictionJointConf GetFrictionJointConf (const World &world, BodyID bodyA, BodyID bodyB, const Length2 &anchor)
 Gets the confguration for the given parameters. More...
 
GearJointConf GetGearJointConf (const World &world, JointID id1, JointID id2, Real ratio=Real{1})
 Gets the configuration for the given parameters. More...
 
Length2 GetGroundAnchorA (const World &world, JointID id)
 
Length2 GetGroundAnchorB (const World &world, JointID id)
 
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...
 
JointCounter GetJointCount (const World &world)
 
Length GetJointTranslation (const World &world, JointID id)
 Gets the current joint translation. 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...
 
LinearAcceleration2 GetLinearAcceleration (const World &world, BodyID id)
 Gets this body's linear acceleration. More...
 
Frequency GetLinearDamping (const World &world, BodyID id)
 Gets the linear damping of the body. More...
 
Momentum GetLinearMotorImpulse (const World &world, JointID id)
 Gets the linear motor impulse of the identified joint if it supports that. More...
 
Length2 GetLinearOffset (const World &world, JointID id)
 Gets the target linear offset, in frame A. More...
 
Momentum2 GetLinearReaction (const World &world, JointID id)
 Gets the linear reaction on body-B at the joint anchor. More...
 
LinearVelocity2 GetLinearVelocity (const World &world, BodyID id)
 Gets the linear velocity of the center of mass of the identified body. More...
 
LinearVelocity GetLinearVelocity (const World &world, const PrismaticJointConf &joint) noexcept
 Gets the current linear velocity of the given configuration. More...
 
Length2 GetLocalAnchorA (const World &world, JointID id)
 
Length2 GetLocalAnchorB (const World &world, JointID id)
 
Length2 GetLocalCenter (const World &world, BodyID id)
 Gets the local position of the center of mass of the specified body. More...
 
Length2 GetLocalPoint (const World &world, BodyID id, const Length2 &worldPoint)
 Gets a local point relative to the body's origin given a world point. More...
 
RotInertia GetLocalRotInertia (const World &world, BodyID id)
 Gets the rotational inertia of the body about the local origin. More...
 
UnitVec GetLocalVector (const World &world, BodyID body, const UnitVec &uv)
 Convenience function for getting the local vector of the identified body. 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...
 
Length2 GetLocation (const World &world, BodyID id)
 Convenience function for getting just the location of the identified body. More...
 
Mass GetMass (const World &world, BodyID id)
 Gets the mass of the body. More...
 
MassData GetMassData (const World &world, BodyID id)
 Gets the mass data of the body. More...
 
MassData GetMassData (const World &world, ShapeID id)
 Gets the mass data for the identified shape in the given world. More...
 
Torque GetMaxMotorTorque (const World &world, JointID id)
 Gets the max motor torque. 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...
 
MotorJointConf GetMotorJointConf (const World &world, BodyID bA, BodyID bB)
 Gets the confguration for the given parameters. More...
 
AngularVelocity GetMotorSpeed (const World &world, JointID id)
 Gets the motor-speed property of the identied joint if it supports it. 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...
 
PrismaticJointConf GetPrismaticJointConf (const World &world, BodyID bA, BodyID bB, const Length2 &anchor, const UnitVec &axis)
 Gets the configuration for the given parameters. More...
 
PulleyJointConf GetPulleyJointConf (const World &world, BodyID bA, BodyID bB, const Length2 &groundA, const Length2 &groundB, const Length2 &anchorA, const Length2 &anchorB)
 Gets the configuration for the given parameters. More...
 
Real GetRatio (const World &world, JointID id)
 Gets the ratio property of the identified joint if it has it. More...
 
Angle GetReferenceAngle (const World &world, JointID id)
 Gets the reference-angle property of the identified joint if it has it. More...
 
Real GetRestitution (const World &world, ContactID id)
 Gets the restitution used with the identified contact. More...
 
Real GetRestitution (const World &world, ShapeID id)
 Gets the coefficient of restitution of the specified shape. More...
 
RevoluteJointConf GetRevoluteJointConf (const World &world, BodyID bodyA, BodyID bodyB, const Length2 &anchor)
 Gets the configuration for the given parameters. More...
 
RotInertia GetRotInertia (const World &world, BodyID id)
 Gets the rotational inertia of the body. More...
 
ShapeID GetShapeA (const World &world, ContactID id)
 Gets shape A of the identified contact. More...
 
ShapeID GetShapeB (const World &world, ContactID id)
 Gets shape B of the identified contact. More...
 
ShapeCounter GetShapeCount (const World &world, BodyID id)
 Gets the count of shapes associated with the identified body. More...
 
LinearVelocity GetTangentSpeed (const World &world, ContactID id)
 Gets the tangent speed of the identified contact. More...
 
Length2 GetTarget (const World &world, JointID id)
 Gets the target point. More...
 
std::optional< UnitIntervalFF< Real > > GetToi (const World &world, ContactID id)
 Gets the time of impact (TOI) as a fraction or empty value. More...
 
TimestepIters GetToiCount (const World &world, ContactID id)
 Gets the Time Of Impact (TOI) count. More...
 
ContactCounter GetTouchingCount (const World &world)
 Gets the touching count for the given world. More...
 
Transformation GetTransformation (const World &world, BodyID id)
 Gets the body's transformation. More...
 
BodyType GetType (const World &world, BodyID id)
 Gets the type of the identified body. More...
 
TypeID GetType (const World &world, JointID id)
 Gets the type of the joint. More...
 
TypeID GetType (const World &world, ShapeID id)
 Gets the type of the shape. More...
 
ShapeCounter GetUsedShapesCount (const World &world) noexcept
 Gets the count of uniquely identified shapes that are in use - i.e. that are attached to bodies. More...
 
Velocity GetVelocity (const World &world, BodyID id)
 Gets the velocity of the identified body. More...
 
WeldJointConf GetWeldJointConf (const World &world, BodyID bodyA, BodyID bodyB, const Length2 &anchor=Length2{})
 Gets the configuration for the given parameters. More...
 
WheelJointConf GetWheelJointConf (const World &world, BodyID bodyA, BodyID bodyB, const Length2 &anchor, const UnitVec &axis=UnitVec::GetRight())
 Gets the definition data for the given parameters. More...
 
Length2 GetWorldCenter (const World &world, BodyID id)
 Get the world position of the center of mass of the specified body. More...
 
BodyCounter GetWorldIndex (const World &, BodyID id) noexcept
 Gets the world index for the given body. More...
 
JointCounter GetWorldIndex (const World &, JointID id) noexcept
 Gets the world index of the given joint. More...
 
WorldManifold GetWorldManifold (const World &world, ContactID id)
 Gets the world manifold for the identified contact. 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 GetWorldVector (const World &world, BodyID id, const UnitVec &localVector)
 Convenience function for getting a world vector of the identified body. More...
 
bool HasValidToi (const World &world, ContactID id)
 Whether or not the contact has a valid TOI. More...
 
bool IsAccelerable (const World &world, BodyID id)
 Is identified body "accelerable"? More...
 
bool IsAwake (const World &world, BodyID id)
 Gets the awake/asleep state of this body. More...
 
bool IsAwake (const World &world, ContactID id)
 Gets the awake status of the specified contact. More...
 
bool IsEnabled (const World &world, BodyID id)
 Gets the enabled/disabled state of the body. More...
 
bool IsEnabled (const World &world, ContactID id)
 Gets the enabled status of the identified contact. More...
 
bool IsEnabled (const World &world, JointID id)
 Gets the enabled/disabled state of the joint. More...
 
bool IsFixedRotation (const World &world, BodyID id)
 Gets whether the body has fixed rotation. More...
 
bool IsImpenetrable (const World &world, BodyID id)
 Is the body treated like a bullet for continuous collision detection? More...
 
bool IsLimitEnabled (const World &world, JointID id)
 Gets whether the identified joint's limit is enabled. More...
 
bool IsMassDataDirty (const World &world, BodyID id)
 Gets whether the body's mass-data is dirty. More...
 
bool IsMotorEnabled (const World &world, JointID id)
 
bool IsSensor (const World &world, ShapeID id)
 Is the specified shape a sensor (non-solid)? More...
 
bool IsSleepingAllowed (const World &world, BodyID id)
 Gets whether the identified body is allowed to sleep. More...
 
bool IsSpeedable (const World &world, BodyID id)
 Is identified body "speedable". More...
 
bool IsTouching (const World &world, ContactID id)
 Is this contact touching? More...
 
auto MakeTouchingMap (const World &world) -> std::map< std::pair< Contactable, Contactable >, ContactID >
 Makes a map of contacts in the given world that are in the touching state.
 
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 RayCast (const World &world, const RayCastInput &input, const ShapeRayCastCB &callback)
 Ray-cast the world for all fixtures in the path of the ray. More...
 
void ResetFriction (World &world, ContactID id)
 
void ResetMassData (World &world, BodyID id)
 Resets the mass data properties. More...
 
void ResetRestitution (World &world, ContactID id)
 
void Rotate (World &world, ShapeID id, const UnitVec &value)
 Rotates all of the given shape's vertices by the given amount. More...
 
void RotateAboutLocalPoint (World &world, BodyID id, Angle amount, const Length2 &localPoint)
 Rotates a body a given amount around a point in body local coordinates. More...
 
void RotateAboutWorldPoint (World &world, BodyID id, Angle amount, const Length2 &worldPoint)
 Rotates a body a given amount around a point in world coordinates. More...
 
auto SameTouching (const World &lhs, const World &rhs) -> bool
 Determines whether the given worlds have the same touching contacts & manifolds.
 
void Scale (World &world, ShapeID id, const Vec2 &value)
 Scales all of the given shape's vertices by the given amount. More...
 
void SetAcceleration (World &world, BodyID id, AngularAcceleration value)
 Sets the rotational accelerations on the body. More...
 
void SetAcceleration (World &world, BodyID id, const Acceleration &value)
 Sets the accelerations on the given body. More...
 
void SetAcceleration (World &world, BodyID id, const LinearAcceleration2 &linear, AngularAcceleration angular)
 Sets the linear and rotational accelerations on the body. More...
 
void SetAcceleration (World &world, BodyID id, const LinearAcceleration2 &value)
 Sets the linear accelerations on the body. More...
 
void SetAccelerations (World &world, const Acceleration &acceleration)
 Sets the accelerations of all the world's bodies to the given value. More...
 
void SetAccelerations (World &world, const LinearAcceleration2 &acceleration)
 Sets the accelerations of all the world's bodies to the given value. More...
 
template<class F >
void SetAccelerations (World &world, F fn)
 Sets the accelerations of all the world's bodies. More...
 
void SetAngle (World &world, BodyID id, Angle value)
 Sets the body's angular orientation. More...
 
void SetAngularDamping (World &world, BodyID id, NonNegative< Frequency > angularDamping)
 Sets the angular damping of the body. More...
 
void SetAngularLimits (World &world, JointID id, Angle lower, Angle upper)
 
void SetAngularOffset (World &world, JointID id, Angle value)
 Sets the target angular offset. More...
 
void SetAwake (World &world, BodyID id)
 Wakes up the identified body. More...
 
void SetAwake (World &world, ContactID id)
 Sets awake the bodies of the given contact. More...
 
void SetAwake (World &world, JointID id)
 Wakes up the joined bodies. More...
 
void SetDensity (World &world, ShapeID id, NonNegative< AreaDensity > value)
 Sets the density of this shape. More...
 
void SetEnabled (World &world, BodyID id, bool value)
 Sets the enabled state of the body. More...
 
void SetEnabled (World &world, ContactID id)
 Sets the enabled status of the identified contact. More...
 
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...
 
void SetFilterData (World &world, ShapeID id, const Filter &filter)
 Convenience function for setting the contact filtering data. More...
 
void SetFixedRotation (World &world, BodyID id, bool value)
 Sets this body to have fixed rotation. More...
 
void SetForce (World &world, BodyID id, const Force2 &force, const Length2 &point)
 Sets the given amount of force at the given point to the given body. More...
 
void SetFrequency (World &world, JointID id, Frequency value)
 Sets the frequency of the identified joint if it has this property. More...
 
void SetFriction (World &world, ContactID id, NonNegative< Real > friction)
 Sets the friction value for the identified contact. More...
 
void SetFriction (World &world, ShapeID id, NonNegative< Real > value)
 Convenience function for setting the coefficient of friction of the specified shape. More...
 
void SetImpenetrable (World &world, BodyID id)
 Sets 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...
 
template<typename T >
void SetJoint (World &world, JointID id, const T &value)
 Sets a joint's value from a configuration. More...
 
void SetLinearDamping (World &world, BodyID id, NonNegative< Frequency > linearDamping)
 Sets the linear damping of the body. More...
 
void SetLinearOffset (World &world, JointID id, const Length2 &value)
 Sets the target linear offset, in frame A. More...
 
void SetLocation (World &world, BodyID id, const Length2 &value)
 Sets the body's location. More...
 
void SetMassData (World &world, BodyID id, const MassData &massData)
 Sets the mass properties to override the mass properties of the fixtures. More...
 
void SetMaxMotorTorque (World &world, JointID id, Torque value)
 
void SetMotorSpeed (World &world, JointID id, AngularVelocity value)
 Sets the motor-speed property of the identied joint if it supports it. More...
 
void SetRestitution (World &world, ContactID id, Real restitution)
 Sets the restitution value for the specified contact. More...
 
void SetRestitution (World &world, ShapeID id, Real value)
 Sets the coefficient of restitution of the specified shape. More...
 
void SetSensor (World &world, ShapeID id, bool value)
 Convenience function for setting whether the shape is a sensor or not. More...
 
void SetSleepingAllowed (World &world, BodyID, bool value)
 Sets whether the identified body is allowed to sleep. More...
 
void SetTangentSpeed (World &world, ContactID id, LinearVelocity value)
 Sets the desired tangent speed for a conveyor belt behavior. More...
 
void SetTarget (World &world, JointID id, const Length2 &value)
 Sets the target point. More...
 
void SetTorque (World &world, BodyID id, Torque torque)
 Sets the given amount of torque to the given body. More...
 
void SetTransform (World &world, BodyID id, const Length2 &location, Angle angle)
 Sets the position of the body's origin and rotation. More...
 
void SetTransformation (World &world, BodyID id, const Transformation &value)
 Sets the transformation of the body. More...
 
void SetType (World &world, BodyID id, BodyType value, bool resetMassData=true)
 Sets the type of the given body. More...
 
void SetVelocity (World &world, BodyID id, AngularVelocity value)
 Sets the velocity of the identified body. More...
 
void SetVelocity (World &world, BodyID id, const LinearVelocity2 &value)
 Sets 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 ShiftOrigin (World &world, JointID id, const Length2 &value)
 Shifts the origin of the identified joint. More...
 
StepStats Step (World &world, Time delta, TimestepIters velocityIterations=StepConf::DefaultRegVelocityIters, TimestepIters positionIterations=StepConf::DefaultRegPositionIters)
 Steps the world ahead by a given time amount. More...
 
bool TestPoint (const World &world, BodyID bodyId, ShapeID shapeId, const Length2 &p)
 Tests a point for containment in a shape associated with a body. More...
 
void Translate (World &world, ShapeID id, const Length2 &value)
 Translates all of the given shape's vertices by the given amount. More...
 
template<typename T >
TypeCast (const World &value)
 Converts the given joint into its current configuration value. More...
 
template<typename T >
TypeCast (World &&value)
 Converts the given joint into its current configuration value. More...
 
template<typename T >
TypeCast (World &value)
 Converts the given joint into its current configuration value. More...
 
void UnsetAwake (World &world, BodyID id)
 Sleeps the identified body. More...
 
void UnsetEnabled (World &world, ContactID id)
 Unsets the enabled status of the identified contact. More...
 
void UnsetImpenetrable (World &world, BodyID id)
 Unsets the impenetrable status of the identified body. More...
 

Detailed Description

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.

Note
World instances do not themselves have any force or acceleration properties. They simply utilize the acceleration property of the bodies they manage. This is different than some other engines (like Box2D which provides a world gravity property).
World instances are composed of — i.e. contain and own — body, contact, shape, and joint entities. These are identified by BodyID, ContactID, ShapeID, and JointID values respectively.
This class uses the pointer to implementation (PIMPL) technique and non-vitural interface (NVI) pattern to provide a complete layer of abstraction from the actual implementations used. This forms a "compilation firewall" — or application binary interface (ABI) — to help provide binary stability while facilitating experimentation and optimization.
This class's design provides a "polymorphic value type" offering polymorphism without public inheritance. This is based on a technique that's described by Sean Parent in his January 2017 Norwegian Developers Conference London talk "Better Code: Runtime Polymorphism".
Invariant
GetType(const World& world) for a world in a valid and specified state, always returns the ID for the type which a TypeCast function template can be instantiated for when called with the world object, to access the underlying typed data of that world.
Attention
For example, the following could be used to create a dynamic body having a one meter radius disk shape:
auto world = World{};
const auto shape = CreateShape(world, Shape{DiskShapeConf{1_m}});
const auto body = CreateBody(world, BodyConf{}.Use(BodyType::Dynamic).Use(shape));
friend ShapeID CreateShape(World &world, const Shape &def)
Creates an identifiable copy of the given shape within the specified world.
Definition: World.hpp:1048
World(const WorldConf &def=WorldConf{})
Constructs a world object.
Definition: World.cpp:28
friend BodyID CreateBody(World &world, const Body &body, bool resetMassData)
Creates a rigid body within the world that's a copy of the given one.
Definition: World.cpp:50
See also
BodyID, ContactID, ShapeID, JointID, Physical Entities.
https://en.wikipedia.org/wiki/Non-virtual_interface_pattern
https://en.wikipedia.org/wiki/Application_binary_interface
https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Polymorphic_Value_Types
https://en.cppreference.com/w/cpp/language/pimpl
https://youtu.be/QGcVXgEVMJg

Constructor & Destructor Documentation

◆ World() [1/4]

playrho::d2::World::World ( const WorldConf def = WorldConf{})
explicit

Constructs a world object.

Constructs a world object using the default world implementation class that's instantiated with the given configuraion.

Note
More configurability can be had via the StepConf data given to the Step(World&, const StepConf&) function.
Parameters
defA customized world configuration or its default value.
Postcondition
GetType(const World&) for the created object returns the value returned by GetTypeID<AabbTreeWorld>().
GetBodyCount(const World&), GetJointCount(const World&), GetContactCount(const World&) for the created object all return 0.
GetBodies(const World&), GetJoints(const World&), GetContacts(const World&) for the created object all return empty containers.
IsLocked(const World&), GetSubStepping(const World&) all return false.
See also
Step(World&, const StepConf&).

◆ World() [2/4]

playrho::d2::World::World ( const World other)

Copy constructs this world with a deep copy of the given world.

Parameters
otherThe world to copy construct this one from.
Exceptions
std::bad_allocif memory cannot be allocated.
Postcondition
The state of the created object is equal to the state of the copied from object.
See also
operator==(const World&, const World&).

◆ World() [3/4]

playrho::d2::World::World ( World &&  other)
inlinenoexcept

Move constructs this world.

Parameters
otherThe world to move construct this one from.
Postcondition
this is what other used to be.
other is in a "valid but unspecified state". The only thing it can be used for, is as the destination of an assignment.

◆ World() [4/4]

template<typename T , typename DT = std::decay_t<T>, typename Tp = std::enable_if_t<!std::is_same_v<DT, World> && !std::is_same_v<DT, WorldConf>, DT>, typename = std::enable_if_t<std::is_constructible_v<DT, T>>>
playrho::d2::World::World ( T &&  arg)
inlineexplicit

Polymorphic initializing constructor.

Constructor for constructing an instance from any class supporting the World functionality.

Parameters
argA value of a world-concept supporting type to construct this object from.
Exceptions
std::bad_allocif there's a failure allocating storage for the given value.
Postcondition
GetType(const World&) for the created object returns the value returned by GetTypeID<std::decay_t<T>>().

◆ ~World()

playrho::d2::World::~World ( )
noexcept

Destroys all contained physics entities and releases all related resources.

Note
This calls the Clear(World&) function.
See also
Clear.

Member Function Documentation

◆ operator=() [1/2]

World & playrho::d2::World::operator= ( const World other)

Copy assigns this world with a deep copy of the given world.

Note
Provides the strong exception guarantee. If this operation throws an exception, the state of this object is unchanged.
Parameters
otherThe other world to copy assign from.
Exceptions
std::bad_allocif memory cannot be allocated.
Postcondition
On success: the state of the assigned-to object is equal to the state of the copied from object.
See also
operator==(const World&, const World&).

◆ operator=() [2/2]

World& playrho::d2::World::operator= ( World &&  other)
inlinenoexcept

Move assigns this world.

Parameters
otherThe other world to move assign from.
Postcondition
this is what other used to be.
other is in a "valid but unspecified state". The only thing it can be used for, is as the destination of an assignment.

Friends And Related Function Documentation

◆ ApplyAngularImpulse()

void ApplyAngularImpulse ( World world,
BodyID  id,
AngularMomentum  impulse 
)
related

Applies an angular impulse.

Parameters
worldThe world in which the identified body exists.
idIdentifier of body to apply the angular impulse to.
impulseAngular impulse to be applied.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ ApplyForce()

void ApplyForce ( World world,
BodyID  id,
const Force2 force,
const Length2 point 
)
related

Apply a force at a world point.

Note
If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity.
Non-zero forces wakes up the body.
Parameters
worldWorld in which body exists.
idIdentity of body to apply the force to.
forceWorld force vector.
pointWorld position of the point of application.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ ApplyForceToCenter()

void ApplyForceToCenter ( World world,
BodyID  id,
const Force2 force 
)
related

Applies a force to the center of mass of the given body.

Note
Non-zero forces wakes up the body.
Parameters
worldThe world in which the identified body exists.
idIdentifier of body to apply the force to.
forceWorld force vector.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ ApplyLinearImpulse()

void ApplyLinearImpulse ( World world,
BodyID  id,
const Momentum2 impulse,
const Length2 point 
)
related

Applies an impulse at a point.

Note
This immediately modifies the velocity.
This also modifies the angular velocity if the point of application is not at the center of mass.
Non-zero impulses wakes up the body.
Parameters
worldThe world in which the identified body exists.
idIdentifier of body to apply the impulse to.
impulsethe world impulse vector.
pointthe world position of the point of application.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ ApplyTorque()

void ApplyTorque ( World world,
BodyID  id,
Torque  torque 
)
related

Applies a torque.

Note
This affects the angular velocity without affecting the linear velocity of the center of mass.
Non-zero forces wakes up the body.
Parameters
worldThe world in which the identified body exists.
idIdentifier of body to apply the torque to.
torqueabout the z-axis (out of the screen).
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ Attach() [1/2]

void Attach ( World world,
BodyID  id,
const Shape shape,
bool  resetMassData = true 
)
related

Creates the shape within the world and then associates it with the validly identified body.

Exceptions
std::out_of_rangeIf given an invalid body.
WrongStateif this function is called while the world is locked.
See also
GetShapes, ResetMassData.

◆ Attach() [2/2]

void Attach ( World world,
BodyID  id,
ShapeID  shapeID,
bool  resetMassData = true 
)
related

Associates a validly identified shape with the validly identified body.

Note
This function should not be called if the world is locked.
Exceptions
std::out_of_rangeIf given an invalid body or shape identifier.
WrongStateif this function is called while the world is locked.
See also
GetShapes, ResetMassData.

◆ Awaken() [1/2]

BodyCounter Awaken ( World world)
related

Awakens all of the "speedable" bodies in the given world.

Convenience function for calling Awaken(World&, BodyID) for all bodies identified in the given world.

Parameters
worldThe world whose bodies are to be awoken.
Returns
Sum total of calls to Awaken(World&, BodyID) that returned true.
Postcondition
On normal return: IsAwake(const World&, BodyID) returns true for all the "speedable" bodies of the given world.
See also
GetBodies(const World&), Awaken(World&, BodyID), IsAwake(const World&, BodyID), IsSpeedable(BodyType).

◆ Awaken() [2/2]

bool Awaken ( World world,
BodyID  id 
)
related

Awakens the body if it's asleep and "speedable".

Parameters
worldThe world for which the identified body is to be awoken.
idIdentifier of the body within the world to awaken.
Returns
true if SetAwake(World&, BodyID) was called on the identified body, false otherwise.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
Postcondition
On returning true: IsAwake(const World&, BodyID) returns true for the given world and identified body.
See also
IsAwake(const World&, BodyID), IsSpeedable(BodyType), GetType(const World&, BodyID), SetAwake(World&, BodyID).

◆ CalcGravitationalAcceleration()

Acceleration CalcGravitationalAcceleration ( const World world,
BodyID  id 
)
related

Calculates the gravitationally associated acceleration for the given body within its world.

Returns
Zero acceleration if given body is has no mass, else the acceleration of the body due to the gravitational attraction to the other bodies.
Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ Clear

void Clear ( World world)
friend

Clears the given world.

Note
This calls the joint and shape destruction listeners (if they're set), for all defined joints and shapes, before clearing anything. Any exceptions thrown from these listeners are ignored.
Parameters
worldThe world to clear.
Postcondition
The contents of this world have all been destroyed and this world's internal state is reset as though it had just been constructed.
See also
SetJointDestructionListener, SetShapeDestructionListener.

◆ ClearForces()

void ClearForces ( World world)
related

Clears forces.

Manually clear the force buffer on all bodies.

Exceptions
WrongStateif this function is called while the world is locked.

◆ ComputeAABB() [1/2]

AABB ComputeAABB ( const World world,
BodyID  bodyID,
ShapeID  shapeID 
)
related

Computes the AABB for the identified shape relative to the identified body within the given world.

Parameters
worldThe world in which the given body and shape identifiers identify a body and shape.
bodyIDIdentifier of the body the identified shape is associated with.
shapeIDIdentifier of the shape associated with the identified body to compute the AABB for.
See also
ComputeAABB(const World&, BodyID).

◆ ComputeAABB() [2/2]

AABB ComputeAABB ( const World world,
BodyID  id 
)
related

Computes the AABB for the identified body within the given world.

Parameters
worldThe world in which the given body identifier identifies a body.
idIdentifier of the body to compute the AABB for.
See also
ComputeAABB(const World&, BodyID, ShapeID).

◆ ComputeIntersectingAABB() [1/2]

AABB ComputeIntersectingAABB ( const World world,
BodyID  bA,
ShapeID  sA,
ChildCounter  iA,
BodyID  bB,
ShapeID  sB,
ChildCounter  iB 
)
related

Computes the intersecting AABB for the given pair of body-shape-index values.

The intersecting AABB for the given pair of body-shape-index values is the intersection of the AABB for child A of shape A of body A with the AABB for child B of shape B of body B.

◆ ComputeIntersectingAABB() [2/2]

AABB ComputeIntersectingAABB ( const World world,
const Contact contact 
)
related

Computes the intersecting AABB for the given contact.

Parameters
worldThe world for which the given contact relates to.
contactThe contact identifying bodies, shapes, and children with world to compute the intersecting AABB for.

◆ ComputeMassData() [1/2]

MassData ComputeMassData ( const World world,
BodyID  id 
)
related

Computes the identified body's mass data.

This basically accumulates the mass data over all fixtures.

Note
The center is the mass weighted sum of all fixture centers. Divide it by the mass to get the averaged center.
Returns
accumulated mass data for all fixtures associated with the given body.
Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ ComputeMassData() [2/2]

MassData ComputeMassData ( const World world,
const Span< const ShapeID > &  ids 
)
related

Computes the mass data total of the identified shapes.

This basically accumulates the mass data over all shapes.

Note
The center is the mass weighted sum of all shape centers. Divide it by the mass to get the averaged center.
Returns
accumulated mass data for all shapes identified.
Exceptions
std::out_of_rangeIf given an invalid shape identifier.

◆ CreateBody [1/2]

BodyID CreateBody ( World world,
const Body body = Body{},
bool  resetMassData = true 
)
friend

Creates a rigid body within the world that's a copy of the given one.

Note
This function should not be used while the world is locked — as it is during callbacks. If it is, it will throw an exception or abort your program.
No references to the configuration are retained. Its value is copied.
Parameters
worldThe world within which to create the body.
bodyA customized body or its default value.
resetMassDataWhether or not the mass data of the body should be reset.
Returns
Identifier of the newly created body which can later be destroyed by calling the Destroy(BodyID) function.
Exceptions
WrongStateif this function is called while the world is locked.
LengthErrorif this operation would create more than MaxBodies.
std::out_of_rangeif the given body references any out of range shape identifiers.
Postcondition
The created body's identifier will be present in the container returned from the GetBodies(const World&) function.
Calling GetBody(const World&, BodyID) with the returned body identifer returns the body given to this create function.
See also
Destroy(World& world, BodyID), GetBodies(const World&), ResetMassData, GetShapeRange.
Physical Entities.

◆ CreateBody() [2/2]

BodyID CreateBody ( World world,
const BodyConf def,
bool  resetMassData = true 
)
related

Creates a rigid body with the given configuration.

Warning
This function should not be used while the world is locked — as it is during callbacks. If it is, it will throw an exception or abort your program.
Note
No references to the configuration are retained. Its value is copied.
Postcondition
The created body will be present in the range returned from the GetBodies(const World&) function.
Parameters
worldThe world within which to create the body.
defA customized body configuration or its default value.
resetMassDataWhether or not the mass data of the body should be reset.
Returns
Identifier of the newly created body which can later be destroyed by calling the Destroy(World&, BodyID) function.
Exceptions
WrongStateif this function is called while the world is locked.
LengthErrorif this operation would create more than MaxBodies.
See also
Destroy(World& world, BodyID), GetBodies(const World&), ResetMassData.
Physical Entities.

◆ CreateJoint [1/2]

JointID CreateJoint ( World world,
const Joint def 
)
friend

Creates a new joint within the given world.

Parameters
worldThe world in which the specified joint is to be created within.
defState of the joint to create within the world.
Exceptions
WrongStateif this function is called while the world is locked.
Postcondition
On success: GetJoints(const World&) for this same world will contain the identifier returned by this function; GetJoint(const World&, JointID) for world and the returned identifier, returns def .

◆ CreateJoint() [2/2]

template<typename T >
JointID CreateJoint ( World world,
const T &  value 
)
related

Creates a new joint from a configuration.

This is a convenience function for allowing limited implicit conversions to joints.

Exceptions
WrongStateif this function is called while the world is locked.

◆ CreateShape [1/2]

ShapeID CreateShape ( World world,
const Shape def 
)
friend

Creates an identifiable copy of the given shape within the specified world.

Exceptions
InvalidArgumentif called for a shape with a vertex radius that's not within the world's allowable vertex radius interval.
WrongStateif this function is called while the world is locked.
LengthErrorif this operation would create more than MaxShapes.
See also
Destroy(World&, ShapeID), GetShape, SetShape, GetVertexRadiusInterval.

◆ CreateShape() [2/2]

template<typename T >
auto CreateShape ( World world,
const T &  shapeConf 
) -> decltype(CreateShape(world, Shape{shapeConf}))
related

Creates a shape within the specified world using a configuration of the shape.

This is a convenience function for allowing limited implicit conversions to shapes.

Exceptions
InvalidArgumentif called for a shape with a vertex radius that's not within the world's allowable vertex radius interval.
WrongStateif called while the world is "locked".
See also
CreateShape(World& world, const Shape& def), GetVertexRadiusInterval.

◆ Destroy [1/3]

void Destroy ( World world,
BodyID  id 
)
friend

Destroys the identified body.

Destroys the identified body that had previously been created by a call to this world's CreateBody(const BodyConf&) function.

Note
This automatically deletes all associated shapes and joints.
This function is locked during callbacks. The detatch listener, if set, is called for every shape associated with the identified body.
Parameters
worldThe world from which to delete the identified body from.
idIdentifier of body to destroy that had been created in world.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an out of range body identifier.
Postcondition
On success: the destroyed body's identifier is no longer present in the container returned from the GetBodies(const World&) function; the count returned by GetBodyCount(const World&) will be one less than before this was called; GetBodyRange(const World&) will be unchanged.
See also
CreateBody, GetBodies, GetBodyCount, GetBodyRange, SetDetachListener, IsLocked.
Physical Entities.

◆ Destroy [2/3]

void Destroy ( World world,
JointID  id 
)
friend

Destroys the identified joint.

Parameters
worldThe world in which the specified joint is to be destroyed from.
idIdentifier of the joint to destroy.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an out of range joint identifier.
Postcondition
On success: the given identifier is no longer within those returned by GetJoints(const World&), the count returned by GetJointCount(const World&) will be one less than before this was called.
See also
CreateJoint, IsLocked, GetJointRange.

◆ Destroy [3/3]

void Destroy ( World world,
ShapeID  id 
)
friend

Destroys the identified shape.

Parameters
worldThe world in which the specified shape is to be destroyed from.
idIdentifier of the shape to destroy.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an out of range identifier.
Postcondition
On success: no body in the specified world will have the identified shape attached to it; GetShapeRange(const World&) will be unchanged.
See also
CreateShape, IsLocked, GetShapeRange.

◆ Detach() [1/2]

bool Detach ( World world,
BodyID  id,
bool  resetMassData = true 
)
related

Disassociates all of the associated shape from the validly identified body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.
WrongStateif this function is called while the world is locked.
See also
Attach, ResetMassData.

◆ Detach() [2/2]

bool Detach ( World world,
BodyID  id,
ShapeID  shapeID,
bool  resetMassData = true 
)
related

Disassociates a validly identified shape from the validly identified body.

Exceptions
std::out_of_rangeIf given an invalid body or shape identifier.
WrongStateif this function is called while the world is locked.
See also
ResetMassData.

◆ EnableLimit()

void EnableLimit ( World world,
JointID  id,
bool  value 
)
related

Sets whether the identified joint's limit is enabled or not.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid joint identifier.

◆ EnableMotor()

void EnableMotor ( World world,
JointID  id,
bool  value 
)
related

Enable/disable the joint motor.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid joint identifier.

◆ FindClosestBody()

BodyID FindClosestBody ( const World world,
const Length2 location 
)
related

Finds body in given world that's closest to the given location.

Parameters
worldThe world to find closest body to location in.
locationLocation in the given world to find the closest body to.
Returns
Identifier of the closest body, or InvalidBodyID.

◆ GetAcceleration()

Acceleration GetAcceleration ( const World world,
BodyID  id 
)
related

Gets the acceleration of the identified body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.
See also
SetAcceleration(World&, BodyID, LinearAcceleration2, AngularAcceleration).

◆ GetAnchorA()

Length2 GetAnchorA ( const World world,
JointID  id 
)
related

Get the anchor point on body-A in world coordinates.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetAnchorB()

Length2 GetAnchorB ( const World world,
JointID  id 
)
related

Get the anchor point on body-B in world coordinates.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetAngle() [1/3]

Angle GetAngle ( const World world,
BodyID  id 
)
related

Gets the angle of the identified body.

Returns
the current world rotation angle.
Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetAngle() [2/3]

Angle GetAngle ( const World world,
const RevoluteJointConf conf 
)
related

Gets the current angle of the given configuration in the given world.

Parameters
worldThe world the given joint configuration relates to.
confConfiguration of the joint to get the angle for.
Exceptions
std::out_of_rangeIf given an invalid body identifier in the joint configuration.

◆ GetAngle() [3/3]

Angle GetAngle ( const World world,
JointID  id 
)
related

Gets the angle property of the identified joint if it has it.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetAngularAcceleration()

AngularAcceleration GetAngularAcceleration ( const World world,
BodyID  id 
)
related

Gets this body's angular acceleration.

Exceptions
std::out_of_rangeIf given an invalid body identifier.
See also
GetAcceleration(const World& world, BodyID id).

◆ GetAngularDamping()

Frequency GetAngularDamping ( const World world,
BodyID  id 
)
related

Gets the angular damping of the body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetAngularLowerLimit()

Angle GetAngularLowerLimit ( const World world,
JointID  id 
)
related

Get the lower joint limit.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetAngularMass()

RotInertia GetAngularMass ( const World world,
JointID  id 
)
related

Gets the computed angular rotational inertia used by the joint.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetAngularMotorImpulse()

AngularMomentum GetAngularMotorImpulse ( const World world,
JointID  id 
)
related

Gets the angular motor impulse of the identified joint if it has this property.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetAngularOffset()

Angle GetAngularOffset ( const World world,
JointID  id 
)
related

Gets the target angular offset.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetAngularReaction()

AngularMomentum GetAngularReaction ( const World world,
JointID  id 
)
related

Get the angular reaction on body-B for the identified joint.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetAngularUpperLimit()

Angle GetAngularUpperLimit ( const World world,
JointID  id 
)
related

Get the upper joint limit.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetAngularVelocity() [1/4]

AngularVelocity GetAngularVelocity ( const World world,
BodyID  id 
)
related

Gets the angular velocity.

Parameters
worldWorld in which body is identified for.
idIdentifier of body to get the angular velocity for.
Returns
the angular velocity.
Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetAngularVelocity() [2/4]

AngularVelocity GetAngularVelocity ( const World world,
const RevoluteJointConf conf 
)
related

Gets the current angular velocity of the given configuration.

Parameters
worldThe world the given joint configuration relates to.
confConfiguration of the joint to get the angular velocity for.
Exceptions
std::out_of_rangeIf given an invalid body identifier in the joint configuration.

◆ GetAngularVelocity() [3/4]

AngularVelocity GetAngularVelocity ( const World world,
const WheelJointConf conf 
)
related

Gets the angular velocity for the given configuration within the specified world.

Parameters
worldThe world the given joint configuration relates to.
confConfiguration of the joint to get the angular velocity for.
Exceptions
std::out_of_rangeIf given an invalid body identifier in the joint configuration.

◆ GetAngularVelocity() [4/4]

AngularVelocity GetAngularVelocity ( const World world,
JointID  id 
)
related

Gets the angular velocity of the identified joint if it has this property.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetAssociationCount()

ShapeCounter GetAssociationCount ( const World world)
related

Gets the count of body-shape associations in the given world.

Parameters
worldThe world in which to get the shape association count for.
See also
GetUsedShapesCount.

◆ GetAwakeCount()

BodyCounter GetAwakeCount ( const World world)
related

Gets the count of awake bodies in the given world.

Parameters
worldThe world for which to get the awake count for.
See also
Awaken.

◆ GetBodies

std::vector<BodyID> GetBodies ( const World world)
friend

Gets the valid world body identifiers container for this constant world.

Gets a container enumerating the identifiers of bodies currently existing within this world. These are the bodies that had been created from previous calls to CreateBody(World&, const Body&) that haven't yet been destroyed by a call to Destroy(World& world, BodyID) or to Clear(World&).

Parameters
worldThe world whose body identifiers are to be returned for.
Returns
Container of body identifiers.
See also
CreateBody(World&, const Body&), Destroy(World& world, BodyID), Clear(World&).

◆ GetBodiesForProxies

std::vector<BodyID> GetBodiesForProxies ( const World world)
friend

Gets the bodies-for-proxies container for this world.

Provides insight on what bodies have been queued for proxy processing during the next call to the world step function.

See also
Step.
Todo:
Remove this function from this class - access from implementation instead.

◆ GetBody

Body GetBody ( const World world,
BodyID  id 
)
friend

Gets the state of the identified body.

Exceptions
std::out_of_rangeIf given an out of range body identifier.
See also
CreateBody(World&, const Body&, bool), SetBody(World&, BodyID, const Body&), GetBodyRange.

◆ GetBodyA() [1/2]

BodyID GetBodyA ( const World world,
ContactID  id 
)
related

Gets the body-A of the identified contact if it has one.

Returns
Identification of the body-A or InvalidBodyID.
Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ GetBodyA() [2/2]

BodyID GetBodyA ( const World world,
JointID  id 
)
related

Gets the identifier of body-A of the identified joint.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetBodyB() [1/2]

BodyID GetBodyB ( const World world,
ContactID  id 
)
related

Gets the body-B of the identified contact if it has one.

Returns
Identification of the body-B or InvalidBodyID.
Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ GetBodyB() [2/2]

BodyID GetBodyB ( const World world,
JointID  id 
)
related

Gets the identifier of body-B of the identified joint.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetBodyCount()

BodyCounter GetBodyCount ( const World world)
related

Gets the body count in the given world.

Returns
0 or higher.

◆ GetBodyRange

BodyCounter GetBodyRange ( const World world)
friend

Gets the extent of the currently valid body range.

Note
This is one higher than the maxium BodyID that is in range for body related functions.
Parameters
worldThe world whose body range is to be returned for.

◆ GetCentripetalForce()

Force2 GetCentripetalForce ( const World world,
BodyID  id,
const Length2 axis 
)
related

Gets the centripetal force necessary to put the body into an orbit having the given radius.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetChildIndexA()

ChildCounter GetChildIndexA ( const World world,
ContactID  id 
)
related

Gets the child primitive index A for the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ GetChildIndexB()

ChildCounter GetChildIndexB ( const World world,
ContactID  id 
)
related

Gets the child primitive index B for the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ GetCollideConnected()

bool GetCollideConnected ( const World world,
JointID  id 
)
related

Gets collide connected for the specified joint.

Note
Modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.
Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetContact

Contact GetContact ( const World world,
ContactID  id 
)
friend

Gets the identified contact.

Exceptions
std::out_of_rangeIf given an out of range contact identifier.
See also
GetContantRange.

◆ GetContactCount()

ContactCounter GetContactCount ( const World world)
related

Gets the count of contacts in the given world.

Note
Not all contacts are for shapes that are actually touching. Some contacts are for shapes which merely have overlapping AABBs.
Returns
0 or higher.

◆ GetContactRange

ContactCounter GetContactRange ( const World world)
friend

Gets the extent of the currently valid contact range.

Note
This is one higher than the maxium ContactID that is in range for contact related functions.

◆ GetContacts [1/2]

std::vector<KeyedContactID> GetContacts ( const World world)
friend

Gets the contacts identified within the given world.

Note
Further information for each element of the returned container is available from functions like GetContact or GetManifold.

◆ GetContacts [2/2]

std::vector<std::tuple<ContactKey, ContactID> > GetContacts ( const World world,
BodyID  id 
)
friend

Gets the container of contacts attached to the identified body.

Warning
This collection changes during the time step and you may miss some collisions if you don't use ContactFunction.
Exceptions
std::out_of_rangeIf given an out of range body identifier.
See also
GetBodyRange.

◆ GetCurrentLengthA()

Length GetCurrentLengthA ( const World world,
JointID  id 
)
related

Get the current length of the segment attached to body-A.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetCurrentLengthB()

Length GetCurrentLengthB ( const World world,
JointID  id 
)
related

Get the current length of the segment attached to body-B.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetDampingRatio()

Real GetDampingRatio ( const World world,
JointID  id 
)
related

Gets the damping ratio associated with the identified joint if it has one.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.
std::invalid_argumentIf the identified joint's type doesn't support this.

◆ GetDefaultFriction()

Real GetDefaultFriction ( const World world,
ContactID  id 
)
related

Gets the default friction amount for the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.
See also
SetFriction.

◆ GetDefaultRestitution()

Real GetDefaultRestitution ( const World world,
ContactID  id 
)
related

Gets the default restitution amount for the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.
See also
SetRestitution.

◆ GetDensity()

NonNegative< AreaDensity > GetDensity ( const World world,
ShapeID  id 
)
related

Gets the density of this shape.

Returns
Non-negative density (in mass per area).
Exceptions
std::out_of_rangeIf given an invalid identifier.

◆ GetDistanceJointConf()

DistanceJointConf GetDistanceJointConf ( const World world,
BodyID  bodyA,
BodyID  bodyB,
const Length2 anchorA = Length2{},
const Length2 anchorB = Length2{} 
)
related

Gets the configuration for a joint with the given parameters.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetFilterData()

Filter GetFilterData ( const World world,
ShapeID  id 
)
related

Gets the filter data for the identified shape.

Exceptions
std::out_of_rangeIf given an invalid identifier.
See also
SetFilterData.

◆ GetFrequency()

Frequency GetFrequency ( const World world,
JointID  id 
)
related

Gets the frequency of the identified joint if it has this property.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetFriction() [1/2]

NonNegativeFF< Real > GetFriction ( const World world,
ContactID  id 
)
related

Gets the friction used with the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.
See also
SetFriction.

◆ GetFriction() [2/2]

NonNegativeFF< Real > GetFriction ( const World world,
ShapeID  id 
)
related

Gets the coefficient of friction of the specified shape.

Returns
Value of 0 or higher.
Exceptions
std::out_of_rangeIf given an invalid identifier.

◆ GetFrictionJointConf()

FrictionJointConf GetFrictionJointConf ( const World world,
BodyID  bodyA,
BodyID  bodyB,
const Length2 anchor 
)
related

Gets the confguration for the given parameters.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetGearJointConf()

GearJointConf GetGearJointConf ( const World world,
JointID  id1,
JointID  id2,
Real  ratio = Real{1} 
)
related

Gets the configuration for the given parameters.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetGroundAnchorA()

Length2 GetGroundAnchorA ( const World world,
JointID  id 
)
related

Get the first ground anchor.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetGroundAnchorB()

Length2 GetGroundAnchorB ( const World world,
JointID  id 
)
related

Get the second ground anchor.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetInvDeltaTime

Frequency GetInvDeltaTime ( const World world)
friend

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 function having a non-zero delta-time.

Parameters
worldThe world whose inverse delta time is to be returned for.
See also
Step.

◆ GetInvMass()

InvMass GetInvMass ( const World world,
BodyID  id 
)
related

Gets the inverse total mass of the body.

Returns
Value of zero or more representing the body's inverse mass (in 1/kg).
Exceptions
std::out_of_rangeIf given an invalid body identifier.
See also
SetMassData.

◆ GetInvRotInertia()

InvRotInertia GetInvRotInertia ( const World world,
BodyID  id 
)
related

Gets the inverse rotational inertia of the body.

Returns
Inverse rotational inertia (in 1/kg-m^2).
Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetJoint

Joint GetJoint ( const World world,
JointID  id 
)
friend

Gets the value of the identified joint.

Exceptions
std::out_of_rangeIf given an out of range joint identifier.
See also
GetJointRange.

◆ GetJointCount()

JointCounter GetJointCount ( const World world)
related

Gets the count of joints in the given world.

Returns
0 or higher.

◆ GetJointRange

JointCounter GetJointRange ( const World world)
friend

Gets the extent of the currently valid joint range.

Note
This is one higher than the maxium JointID that is in range for joint related functions.

◆ GetJoints [1/2]

std::vector<JointID> GetJoints ( const World world)
friend

Gets the joints of the specified world.

Note
These are joints created by previous calls to CreateJoint(World&, const Joint&) that haven't yet been destroyed by a call to Destroy(World& world, JointID) or Clear(World&).
See also
CreateJoint(World&, const Joint&), Destroy(World& world, JointID), Clear(World&).

◆ GetJoints [2/2]

std::vector<std::pair<BodyID, JointID> > GetJoints ( const World world,
BodyID  id 
)
friend

Gets the container of valid joints attached to the identified body.

Exceptions
std::out_of_rangeIf given an out of range body identifier.
See also
CreateJoint, GetBodyRange.

◆ GetJointTranslation()

Length GetJointTranslation ( const World world,
JointID  id 
)
related

Gets the current joint translation.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetLength()

Length GetLength ( const World world,
JointID  id 
)
related

Gets the length associated with the identified joint if it has one.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.
std::invalid_argumentIf the identified joint's type doesn't support this.

◆ GetLimitState()

LimitState GetLimitState ( const World world,
JointID  id 
)
related

Gets the joint's limit state if it has one.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.
std::invalid_argumentIf the identified joint's type doesn't support this.

◆ GetLinearAcceleration()

LinearAcceleration2 GetLinearAcceleration ( const World world,
BodyID  id 
)
related

Gets this body's linear acceleration.

Exceptions
std::out_of_rangeIf given an invalid body identifier.
See also
GetAcceleration(const World& world, BodyID id).

◆ GetLinearDamping()

Frequency GetLinearDamping ( const World world,
BodyID  id 
)
related

Gets the linear damping of the body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetLinearMotorImpulse()

Momentum GetLinearMotorImpulse ( const World world,
JointID  id 
)
related

Gets the linear motor impulse of the identified joint if it supports that.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetLinearOffset()

Length2 GetLinearOffset ( const World world,
JointID  id 
)
related

Gets the target linear offset, in frame A.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetLinearReaction()

Momentum2 GetLinearReaction ( const World world,
JointID  id 
)
related

Gets the linear reaction on body-B at the joint anchor.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetLinearVelocity() [1/2]

LinearVelocity2 GetLinearVelocity ( const World world,
BodyID  id 
)
related

Gets the linear velocity of the center of mass of the identified body.

Parameters
worldWorld in which body is identified for.
idIdentifier of body to get the linear velocity for.
Returns
the linear velocity of the center of mass.
Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetLinearVelocity() [2/2]

LinearVelocity GetLinearVelocity ( const World world,
const PrismaticJointConf joint 
)
related

Gets the current linear velocity of the given configuration.

Exceptions
std::out_of_rangeIf given an invalid body identifier in the given joint conifguration.

◆ GetLocalAnchorA()

Length2 GetLocalAnchorA ( const World world,
JointID  id 
)
related

Get the anchor point on body-A in local coordinates.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetLocalAnchorB()

Length2 GetLocalAnchorB ( const World world,
JointID  id 
)
related

Get the anchor point on body-B in local coordinates.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetLocalCenter()

Length2 GetLocalCenter ( const World world,
BodyID  id 
)
related

Gets the local position of the center of mass of the specified body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetLocalPoint()

Length2 GetLocalPoint ( const World world,
BodyID  id,
const Length2 worldPoint 
)
related

Gets a local point relative to the body's origin given a world point.

Parameters
worldThe world in which the identified body exists.
idIdentifier of body that the returned point should be relative to.
worldPointpoint in world coordinates.
Returns
the corresponding local point relative to the body's origin.
Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetLocalRotInertia()

RotInertia GetLocalRotInertia ( const World world,
BodyID  id 
)
related

Gets the rotational inertia of the body about the local origin.

Returns
the rotational inertia.
Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetLocalVector()

UnitVec GetLocalVector ( const World world,
BodyID  body,
const UnitVec uv 
)
related

Convenience function for getting the local vector of the identified body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetLocalXAxisA()

UnitVec GetLocalXAxisA ( const World world,
JointID  id 
)
related

Gets the local-X-axis-A property of the identified joint if it has it.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetLocalYAxisA()

UnitVec GetLocalYAxisA ( const World world,
JointID  id 
)
related

Gets the local-Y-axis-A property of the identified joint if it has it.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetLocation()

Length2 GetLocation ( const World world,
BodyID  id 
)
related

Convenience function for getting just the location of the identified body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.
See also
GetTransformation(const World& world, BodyID id).

◆ GetManifold

Manifold GetManifold ( const World world,
ContactID  id 
)
friend

Gets the manifold for the identified contact.

Note
There is a manifold for every contact and vice-versa.
Exceptions
std::out_of_rangeIf given an out of range contact identifier.
See also
SetManifold, GetContantRange.

◆ GetMass()

Mass GetMass ( const World world,
BodyID  id 
)
related

Gets the mass of the body.

Note
This may be the total calculated mass or it may be the set mass of the body.
Returns
Value of zero or more representing the body's mass.
Exceptions
std::out_of_rangeIf given an invalid body identifier.
See also
GetInvMass, SetMassData

◆ GetMassData() [1/2]

MassData GetMassData ( const World world,
BodyID  id 
)
related

Gets the mass data of the body.

Returns
Data structure containing the mass, inertia, and center of the body.
Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetMassData() [2/2]

MassData GetMassData ( const World world,
ShapeID  id 
)
related

Gets the mass data for the identified shape in the given world.

Exceptions
std::out_of_rangeIf given an invalid identifier.

◆ GetMaxMotorTorque()

Torque GetMaxMotorTorque ( const World world,
JointID  id 
)
related

Gets the max motor torque.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetMotorForce()

Force GetMotorForce ( const World world,
JointID  id,
Frequency  inv_dt 
)
related

Gets the current motor force for the given joint, given the inverse time step.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetMotorJointConf()

MotorJointConf GetMotorJointConf ( const World world,
BodyID  bA,
BodyID  bB 
)
related

Gets the confguration for the given parameters.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetMotorSpeed()

AngularVelocity GetMotorSpeed ( const World world,
JointID  id 
)
related

Gets the motor-speed property of the identied joint if it supports it.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.
See also
SetMotorSpeed(World& world, JointID id, AngularVelocity value)

◆ GetMotorTorque()

Torque GetMotorTorque ( const World world,
JointID  id,
Frequency  inv_dt 
)
related

Gets the current motor torque for the given joint given the inverse time step.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetPrismaticJointConf()

PrismaticJointConf GetPrismaticJointConf ( const World world,
BodyID  bA,
BodyID  bB,
const Length2 anchor,
const UnitVec axis 
)
related

Gets the configuration for the given parameters.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetPulleyJointConf()

PulleyJointConf GetPulleyJointConf ( const World world,
BodyID  bA,
BodyID  bB,
const Length2 groundA,
const Length2 groundB,
const Length2 anchorA,
const Length2 anchorB 
)
related

Gets the configuration for the given parameters.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetRatio()

Real GetRatio ( const World world,
JointID  id 
)
related

Gets the ratio property of the identified joint if it has it.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetReferenceAngle()

Angle GetReferenceAngle ( const World world,
JointID  id 
)
related

Gets the reference-angle property of the identified joint if it has it.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetResourceStats

std::optional<pmr::StatsResource::Stats> GetResourceStats ( const World world)
friend

Gets the polymorphic memory resource allocator statistics of the specified world.

Note
This will be the empty value unless the world configuration the given world was constructed with specified the collection of these statistics.
This information can be used to tweak the world configuration to pre-allocate enough space to avoid the less deterministic performance behavior of dynamic memory allocation during world step processing that may otherwise occur.
Parameters
worldThe world to get the memory resource allocator statistics for.
See also
WorldConf.

◆ GetRestitution() [1/2]

Real GetRestitution ( const World world,
ContactID  id 
)
related

Gets the restitution used with the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.
See also
SetRestitution(World& world, ContactID id, Real restitution)

◆ GetRestitution() [2/2]

Real GetRestitution ( const World world,
ShapeID  id 
)
related

Gets the coefficient of restitution of the specified shape.

Exceptions
std::out_of_rangeIf given an invalid identifier.

◆ GetRevoluteJointConf()

RevoluteJointConf GetRevoluteJointConf ( const World world,
BodyID  bodyA,
BodyID  bodyB,
const Length2 anchor 
)
related

Gets the configuration for the given parameters.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetRotInertia()

RotInertia GetRotInertia ( const World world,
BodyID  id 
)
related

Gets the rotational inertia of the body.

Parameters
worldThe world in which the identified body exists.
idIdentifier of body to get the rotational inertia for.
Returns
the rotational inertia.
Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetShape

Shape GetShape ( const World world,
ShapeID  id 
)
friend

Gets the shape associated with the identifier.

Exceptions
std::out_of_rangeIf given an out of range identifier.
See also
GetShapeRange.

◆ GetShapeA()

ShapeID GetShapeA ( const World world,
ContactID  id 
)
related

Gets shape A of the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ GetShapeB()

ShapeID GetShapeB ( const World world,
ContactID  id 
)
related

Gets shape B of the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ GetShapeCount()

ShapeCounter GetShapeCount ( const World world,
BodyID  id 
)
related

Gets the count of shapes associated with the identified body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.
See also
GetShapes(const World& world, BodyID id).

◆ GetShapeRange

ShapeCounter GetShapeRange ( const World world)
friend

Gets the extent of the currently valid shape range.

Note
This is one higher than the maxium ShapeID that is in range for shape related functions.

◆ GetShapes

std::vector<ShapeID> GetShapes ( const World world,
BodyID  id 
)
friend

Gets the identities of the shapes associated with the identified body.

Exceptions
std::out_of_rangeIf given an out of range body identifier.
See also
GetBodyRange, CreateBody, SetBody.

◆ GetSubStepping

bool GetSubStepping ( const World world)
friend

Gets whether or not sub-stepping is enabled.

Parameters
worldThe world to return whether sub-stepping is enabled for.
See also
SetSubStepping, IsStepComplete.

◆ GetTangentSpeed()

LinearVelocity GetTangentSpeed ( const World world,
ContactID  id 
)
related

Gets the tangent speed of the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ GetTarget()

Length2 GetTarget ( const World world,
JointID  id 
)
related

Gets the target point.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetToi()

std::optional< UnitIntervalFF< Real > > GetToi ( const World world,
ContactID  id 
)
related

Gets the time of impact (TOI) as a fraction or empty value.

Returns
Time of impact fraction in the range of 0 to 1 if set (where 1 means no actual impact in current time slot), otherwise empty.
Exceptions
std::out_of_rangeIf given an invalid contact identifier.
See also
HasValidToi.

◆ GetToiCount()

TimestepIters GetToiCount ( const World world,
ContactID  id 
)
related

Gets the Time Of Impact (TOI) count.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ GetTouchingCount()

ContactCounter GetTouchingCount ( const World world)
related

Gets the touching count for the given world.

Basically a convenience function for iterating over all contact identifiers returned from GetContacts(const World&) for the given world and counting for how many IsTouching(const World&, ContactID) returns true.

See also
GetContacts(const World&), IsTouching(const World&, ContactID).

◆ GetTransformation()

Transformation GetTransformation ( const World world,
BodyID  id 
)
related

Gets the body's transformation.

Exceptions
std::out_of_rangeIf given an invalid body identifier.
See also
SetTransformation(World& world, BodyID id, Transformation xfm).

◆ GetTree

const DynamicTree& GetTree ( const World world)
friend

Gets access to the broad-phase dynamic tree information.

Todo:
Consider removing this function. This function exposes the implementation detail of the broad-phase contact detection system.

◆ GetType [1/4]

TypeID GetType ( const World world)
friend

Gets the identifier of the type of data the given world can be casted to.

Parameters
worldThe world for which an identifier of the type of its underlying value is to be returned.
See also
TypeCast.

◆ GetType() [2/4]

BodyType GetType ( const World world,
BodyID  id 
)
related

Gets the type of the identified body.

See also
SetType(World& world, BodyID id, BodyType value)

◆ GetType() [3/4]

TypeID GetType ( const World world,
JointID  id 
)
related

Gets the type of the joint.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetType() [4/4]

TypeID GetType ( const World world,
ShapeID  id 
)
related

Gets the type of the shape.

Exceptions
std::out_of_rangeIf given an invalid identifier.

◆ GetUsedShapesCount()

ShapeCounter GetUsedShapesCount ( const World world)
related

Gets the count of uniquely identified shapes that are in use - i.e. that are attached to bodies.

Parameters
worldThe world in which to get the used shapes count for.
See also
GetAssociationCount.

◆ GetVelocity()

Velocity GetVelocity ( const World world,
BodyID  id 
)
related

Gets the velocity of the identified body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.
See also
SetVelocity(World& world, BodyID id, const Velocity& value).

◆ GetVertexRadiusInterval

Interval<Positive<Length> > GetVertexRadiusInterval ( const World world)
friend

Gets the vertex radius interval allowable for the given world.

Parameters
worldThe world whose allowable vertex radius interval is to be returned for.
See also
CreateShape(World&, const Shape&).

◆ GetWeldJointConf()

WeldJointConf GetWeldJointConf ( const World world,
BodyID  bodyA,
BodyID  bodyB,
const Length2 anchor = Length2{} 
)
related

Gets the configuration for the given parameters.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetWheelJointConf()

WheelJointConf GetWheelJointConf ( const World world,
BodyID  bodyA,
BodyID  bodyB,
const Length2 anchor,
const UnitVec axis = UnitVec::GetRight() 
)
related

Gets the definition data for the given parameters.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetWorldCenter()

Length2 GetWorldCenter ( const World world,
BodyID  id 
)
related

Get the world position of the center of mass of the specified body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetWorldIndex() [1/2]

BodyCounter GetWorldIndex ( const World ,
BodyID  id 
)
related

Gets the world index for the given body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetWorldIndex() [2/2]

JointCounter GetWorldIndex ( const World ,
JointID  id 
)
related

Gets the world index of the given joint.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ GetWorldManifold()

WorldManifold GetWorldManifold ( const World world,
ContactID  id 
)
related

Gets the world manifold for the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ GetWorldPoint()

Length2 GetWorldPoint ( const World world,
BodyID  id,
const Length2 localPoint 
)
related

Gets the world coordinates of a point given in coordinates relative to the body's origin.

Parameters
worldWorld context.
idIdentifier of body that the given point is relative to.
localPointa point measured relative the the body's origin.
Returns
the same point expressed in world coordinates.
Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetWorldVector()

UnitVec GetWorldVector ( const World world,
BodyID  id,
const UnitVec localVector 
)
related

Convenience function for getting a world vector of the identified body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ HasValidToi()

bool HasValidToi ( const World world,
ContactID  id 
)
related

Whether or not the contact has a valid TOI.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.
See also
GetToi.

◆ IsAccelerable()

bool IsAccelerable ( const World world,
BodyID  id 
)
related

Is identified body "accelerable"?

Indicates whether the body is accelerable, i.e. whether it is effected by forces. Only Dynamic bodies are accelerable.

Returns
true if the body is accelerable, false otherwise.
Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ IsAwake() [1/2]

bool IsAwake ( const World world,
BodyID  id 
)
related

Gets the awake/asleep state of this body.

Warning
Being awake may or may not imply being speedable.
Returns
true if the body is awake.
Exceptions
std::out_of_rangeIf given an invalid body identifier.
See also
SetAwake(World& world, BodyID id), UnsetAwake(BodyID id).

◆ IsAwake() [2/2]

bool IsAwake ( const World world,
ContactID  id 
)
related

Gets the awake status of the specified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.
See also
SetAwake.

◆ IsEnabled() [1/3]

bool IsEnabled ( const World world,
BodyID  id 
)
related

Gets the enabled/disabled state of the body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.
See also
SetEnabled.

◆ IsEnabled() [2/3]

bool IsEnabled ( const World world,
ContactID  id 
)
related

Gets the enabled status of the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ IsEnabled() [3/3]

bool IsEnabled ( const World world,
JointID  id 
)
related

Gets the enabled/disabled state of the joint.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ IsFixedRotation()

bool IsFixedRotation ( const World world,
BodyID  id 
)
related

Gets whether the body has fixed rotation.

Exceptions
std::out_of_rangeIf given an invalid body identifier.
See also
SetFixedRotation.

◆ IsImpenetrable()

bool IsImpenetrable ( const World world,
BodyID  id 
)
related

Is the body treated like a bullet for continuous collision detection?

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ IsLimitEnabled()

bool IsLimitEnabled ( const World world,
JointID  id 
)
related

Gets whether the identified joint's limit is enabled.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ IsLocked

bool IsLocked ( const World world)
friend

Is the specified world locked.

Used to detect whether being called while already within the execution of the Step(World&, const StepConf&) function - which sets this "lock".

Parameters
worldThe world to return whether it's in a locked state or not.
See also
Step(World&, const StepConf&).

◆ IsMassDataDirty()

bool IsMassDataDirty ( const World world,
BodyID  id 
)
related

Gets whether the body's mass-data is dirty.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ IsMotorEnabled()

bool IsMotorEnabled ( const World world,
JointID  id 
)
related

Is the joint motor enabled?

Exceptions
std::out_of_rangeIf given an invalid joint identifier.
See also
EnableMotor(World& world, JointID joint, bool value)

◆ IsSensor()

bool IsSensor ( const World world,
ShapeID  id 
)
related

Is the specified shape a sensor (non-solid)?

Returns
the true if the shape is a sensor.
Exceptions
std::out_of_rangeIf given an invalid identifier.
See also
SetSensor.

◆ IsSleepingAllowed()

bool IsSleepingAllowed ( const World world,
BodyID  id 
)
related

Gets whether the identified body is allowed to sleep.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ IsSpeedable()

bool IsSpeedable ( const World world,
BodyID  id 
)
related

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.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ IsStepComplete

bool IsStepComplete ( const World world)
friend

Whether or not "step" is complete.

The "step" is completed when there are no more TOI events for the current time step.

Parameters
worldThe world to return whether the step is completed for.
Returns
true unless sub-stepping is enabled and the step function returned without finishing all of its sub-steps.
See also
GetSubStepping, SetSubStepping, Step.

◆ IsTouching()

bool IsTouching ( const World world,
ContactID  id 
)
related

Is this contact touching?

Touching is defined as either:

  1. This contact's manifold has more than 0 contact points, or
  2. This contact has sensors and the two shapes of this contact are found to be overlapping.
    Returns
    true if this contact is said to be touching, false otherwise.
    Exceptions
    std::out_of_rangeIf given an invalid contact identifier.

◆ NeedsFiltering()

bool NeedsFiltering ( const World world,
ContactID  id 
)
related

Whether or not the contact needs filtering.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ NeedsUpdating()

bool NeedsUpdating ( const World world,
ContactID  id 
)
related

Whether or not the contact needs updating.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ operator!=

bool operator!= ( const World lhs,
const World rhs 
)
friend

Inequality operator for world comparisons.

Parameters
lhsLeft hand side world of the infix binary inequality operator.
rhsRight hand side world of the infix binary inequality operator.
Returns
true if lhs is not equal to rhs , false otherwise.

◆ operator==

bool operator== ( const World lhs,
const World rhs 
)
friend

Equality operator for world comparisons.

Parameters
lhsLeft hand side world of the infix binary equality operator.
rhsRight hand side world of the infix binary equality operator.
Returns
true if lhs is equal to rhs , false otherwise.

◆ ResetFriction()

void ResetFriction ( World world,
ContactID  id 
)
related

Resets the friction mixture to the default value.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ ResetMassData()

void ResetMassData ( World world,
BodyID  id 
)
related

Resets the mass data properties.

This resets the mass data to the sum of the mass properties of the fixtures.

Note
This function must be called after associating new shapes to the body to update the body mass data properties unless SetMassData is used.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
See also
SetMassData, Attach, Detach.

◆ ResetRestitution()

void ResetRestitution ( World world,
ContactID  id 
)
related

Resets the restitution to the default value.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ Rotate()

void Rotate ( World world,
ShapeID  id,
const UnitVec value 
)
related

Rotates all of the given shape's vertices by the given amount.

Note
This may throw std::bad_alloc or any exception that's thrown by the constructor for the model's underlying data type.
Exceptions
std::bad_allocif there's a failure allocating storage.
std::out_of_rangeIf given an invalid identifier.

◆ RotateAboutLocalPoint()

void RotateAboutLocalPoint ( World world,
BodyID  id,
Angle  amount,
const Length2 localPoint 
)
related

Rotates a body a given amount around a point in body local coordinates.

This changes both the linear and angular positions of the body.

Note
Manipulating a body's position this way may cause non-physical behavior.
This is a convenience function that translates the local point into world coordinates and then calls the RotateAboutWorldPoint function.
Parameters
worldThe world in which the identified body exists.
idIdentifier of body to rotate.
amountAmount to rotate body by (in counter-clockwise direction).
localPointPoint in local coordinates.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ RotateAboutWorldPoint()

void RotateAboutWorldPoint ( World world,
BodyID  id,
Angle  amount,
const Length2 worldPoint 
)
related

Rotates a body a given amount around a point in world coordinates.

This changes both the linear and angular positions of the body.

Note
Manipulating a body's position this way may cause non-physical behavior.
Parameters
worldThe world in which the identified body exists.
idIdentifier of body to rotate.
amountAmount to rotate body by (in counter-clockwise direction).
worldPointPoint in world coordinates.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ Scale()

void Scale ( World world,
ShapeID  id,
const Vec2 value 
)
related

Scales all of the given shape's vertices by the given amount.

Note
This may throw std::bad_alloc or any exception that's thrown by the constructor for the model's underlying data type.
Exceptions
std::bad_allocif there's a failure allocating storage.
std::out_of_rangeIf given an invalid identifier.

◆ SetAcceleration() [1/4]

void SetAcceleration ( World world,
BodyID  id,
AngularAcceleration  value 
)
related

Sets the rotational accelerations on the body.

Note
This has no effect on non-accelerable bodies.
A non-zero acceleration will also awaken the body.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
See also
GetAcceleration(const World& world, BodyID id).

◆ SetAcceleration() [2/4]

void SetAcceleration ( World world,
BodyID  id,
const Acceleration value 
)
related

Sets the accelerations on the given body.

Note
This has no effect on non-accelerable bodies.
A non-zero acceleration will also awaken the body.
Parameters
worldThe world in which the identified body's acceleration should be set.
idIdentifier of body whose acceleration should be set.
valueAcceleration value to set.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
See also
GetAcceleration(const World& world, BodyID id).

◆ SetAcceleration() [3/4]

void SetAcceleration ( World world,
BodyID  id,
const LinearAcceleration2 linear,
AngularAcceleration  angular 
)
related

Sets the linear and rotational accelerations on the body.

Note
This has no effect on non-accelerable bodies.
A non-zero acceleration will also awaken the body.
Parameters
worldWorld in which it all happens.
idIdentifier of body whose acceleration should be set.
linearLinear acceleration.
angularAngular acceleration.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
See also
GetAcceleration(const World& world, BodyID id).

◆ SetAcceleration() [4/4]

void SetAcceleration ( World world,
BodyID  id,
const LinearAcceleration2 value 
)
related

Sets the linear accelerations on the body.

Note
This has no effect on non-accelerable bodies.
A non-zero acceleration will also awaken the body.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
See also
GetAcceleration(const World& world, BodyID id).

◆ SetAccelerations() [1/3]

void SetAccelerations ( World world,
const Acceleration acceleration 
)
related

Sets the accelerations of all the world's bodies to the given value.

Exceptions
WrongStateif this function is called while the world is locked.

◆ SetAccelerations() [2/3]

void SetAccelerations ( World world,
const LinearAcceleration2 acceleration 
)
related

Sets the accelerations of all the world's bodies to the given value.

Note
This will leave the angular acceleration alone.
Exceptions
WrongStateif this function is called while the world is locked.

◆ SetAccelerations() [3/3]

template<class F >
void SetAccelerations ( World world,
fn 
)
related

Sets the accelerations of all the world's bodies.

Parameters
worldWorld instance to set the acceleration of all contained bodies for.
fnFunction or functor with a signature like: Acceleration (*fn)(World&,BodyID).
Exceptions
WrongStateif this function is called while the world is locked.
Postcondition
On success: GetAcceleration(const World&, BodyID) will return the acceleration assigned to it by the given function.
See also
SetAcceleration(World&,BodyID,const Acceleration&), GetAcceleration(const World&,BodyID).

◆ SetAngle()

void SetAngle ( World world,
BodyID  id,
Angle  value 
)
related

Sets the body's angular orientation.

This instantly adjusts the body to be at the new angular orientation.

Warning
Manipulating a body's angle this way can cause non-physical behavior!
Parameters
worldThe world in which the identified body's angle should be set.
idIdentifier of body to move.
valueValid world angle of the body's local origin.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
See also
GetAngle(const World& world, BodyID id).

◆ SetAngularDamping()

void SetAngularDamping ( World world,
BodyID  id,
NonNegative< Frequency angularDamping 
)
related

Sets the angular damping of the body.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ SetAngularLimits()

void SetAngularLimits ( World world,
JointID  id,
Angle  lower,
Angle  upper 
)
related

Set the joint limits.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid joint identifier.

◆ SetAngularOffset()

void SetAngularOffset ( World world,
JointID  id,
Angle  value 
)
related

Sets the target angular offset.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid joint identifier.

◆ SetAwake() [1/3]

void SetAwake ( World world,
BodyID  id 
)
related

Wakes up the identified body.

Note
This wakes up any associated contacts that had been asleep.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
See also
IsAwake(const World& world, BodyID id), UnsetAwake(World& world, BodyID id).

◆ SetAwake() [2/3]

void SetAwake ( World world,
ContactID  id 
)
related

Sets awake the bodies of the given contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ SetAwake() [3/3]

void SetAwake ( World world,
JointID  id 
)
related

Wakes up the joined bodies.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid joint identifier.

◆ SetBeginContactListener

void SetBeginContactListener ( World world,
ContactFunction  listener 
)
friend

Sets the begin-contact lister.

Note
This listener is called during calls to the Step(World&,const StepConf&) function for every contact that transitions from not previously touching, to touching in the step.
Parameters
worldThe world to set the listener for.
listenerFunction that the world is to call on these events.
See also
SetEndContactListener(World&, ContactFunction).

◆ SetBody

void SetBody ( World world,
BodyID  id,
const Body body 
)
friend

Sets the state of the identified body.

Parameters
worldThe world containing the identified body whose state is to be set.
idIdentifier of the body whose state is to be set.
bodyNew state of the identified body.
Exceptions
std::out_of_rangeif id is out of range, or if the given body references any shape identifiers that are out of range.
InvalidArgumentif the specified ID was destroyed.
Postcondition
On success: GetBody(const World&, BodyID) for world and id returns the value of body .
See also
GetBody(const World&, BodyID), GetBodyRange, GetShapeRange.

◆ SetContact

void SetContact ( World world,
ContactID  id,
const Contact value 
)
friend

Sets the identified contact's state.

Parameters
worldThe world of the contact whose state is to be set.
idIdentifier of the contact whose state is to be set.
valueValue the contact is to be set to. The new state: is not allowed to change whether the contact is awake, is not allowed to change whether the contact is impenetrable, is not allowed to change whether the contact is for a sensor, is not allowed to change the TOI of the contact, is not allowed to change the TOI count of the contact. Otherwise, this function will throw an InvalidArgument exception and not change anything.
Exceptions
std::out_of_rangeIf given an out of range contact identifier or the new contact value references an out of range identifier.
InvalidArgumentif the identifier is to a freed contact or if the new state is not allowable.
See also
GetContact, GetContactRange.

◆ SetDensity()

void SetDensity ( World world,
ShapeID  id,
NonNegative< AreaDensity value 
)
related

Sets the density of this shape.

Exceptions
std::out_of_rangeIf given an invalid identifier.

◆ SetDetachListener

void SetDetachListener ( World world,
BodyShapeFunction  listener 
)
friend

Sets the detach listener for shapes detaching from bodies.

Note
This listener is called on Destroy(World&,BodyID) for every shape associated with that identified body.
Parameters
worldThe world to set the listener for.
listenerFunction that the world is to call on these events.
See also
Destroy(World&,BodyID).

◆ SetEnabled() [1/3]

void SetEnabled ( World world,
BodyID  id,
bool  value 
)
related

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.

Note
A disabled body is still owned by a World object and remains in the world's body container.
You may continue to create/destroy fixtures and joints on disabled bodies.
Fixtures on a disabled body are implicitly disabled and will not participate in collisions, ray-casts, or queries.
Joints connected to a disabled body are implicitly disabled.
Exceptions
WrongStateIf call would change body's state when world is locked.
std::out_of_rangeIf given an invalid body identifier.
Postcondition
IsEnabled() returns the state given to this function.
See also
IsEnabled.

◆ SetEnabled() [2/3]

void SetEnabled ( World world,
ContactID  id 
)
related

Sets the enabled status of the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ SetEnabled() [3/3]

void SetEnabled ( World world,
ContactID  id,
bool  value 
)
related

Convenience function for setting/unsetting the enabled status of the identified contact based on the value parameter.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.
See also
IsEnabled(const World&, ContactID).

◆ SetEndContactListener

void SetEndContactListener ( World world,
ContactFunction  listener 
)
friend

Sets the end-contact lister.

Note
This listener is called during calls to the Step(World&,const StepConf&) function for every contact that transitions from previously touching, to no longer touching in the step.
Parameters
worldThe world to set the listener for.
listenerFunction that the world is to call on these events.
See also
SetBeginContactListener(World&, ContactFunction).

◆ SetFilterData()

void SetFilterData ( World world,
ShapeID  id,
const Filter filter 
)
related

Convenience function for setting the contact filtering data.

Note
This won't update contacts until the next time step when either parent body is speedable and awake.
This automatically refilters contacts.
Exceptions
std::out_of_rangeIf given an invalid identifier.
See also
GetFilterData.

◆ SetFixedRotation()

void SetFixedRotation ( World world,
BodyID  id,
bool  value 
)
related

Sets this body to have fixed rotation.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
Note
This also causess the mass data to be reset.
See also
IsFixedRotation.

◆ SetForce()

void SetForce ( World world,
BodyID  id,
const Force2 force,
const Length2 point 
)
related

Sets the given amount of force at the given point to the given body.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ SetFrequency()

void SetFrequency ( World world,
JointID  id,
Frequency  value 
)
related

Sets the frequency of the identified joint if it has this property.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid joint identifier.

◆ SetFriction() [1/2]

void SetFriction ( World world,
ContactID  id,
NonNegative< Real friction 
)
related

Sets the friction value for the identified contact.

Note
Overrides the default friction mixture. You can call this in "pre-solve" listeners. This value persists until set or reset.
Parameters
worldThe world in which the contact is identified in.
idIdentifier of the contact whose friction value should be set.
frictionCo-efficient of friction value of zero or greater.
Postcondition
GetFriction(world, id) returns the value set.
Exceptions
std::out_of_rangeIf given an invalid contact identifier.
See also
GetFriction(const World&, ContactID).

◆ SetFriction() [2/2]

void SetFriction ( World world,
ShapeID  id,
NonNegative< Real value 
)
related

Convenience function for setting the coefficient of friction of the specified shape.

Exceptions
std::out_of_rangeIf given an invalid identifier.
See also
GetFriction.

◆ SetImpenetrable() [1/2]

void SetImpenetrable ( World world,
BodyID  id 
)
related

Sets the impenetrable status of the identified body.

Sets that the body should be treated like a bullet for continuous collision detection.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ SetImpenetrable() [2/2]

void SetImpenetrable ( World world,
BodyID  id,
bool  value 
)
related

Convenience function that sets/unsets the impenetrable status of the identified body.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ SetJoint [1/2]

void SetJoint ( World world,
JointID  id,
const Joint def 
)
friend

Sets the value of the identified joint.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an out of range joint identifier.
See also
GetJointRange.

◆ SetJoint() [2/2]

template<typename T >
void SetJoint ( World world,
JointID  id,
const T &  value 
)
related

Sets a joint's value from a configuration.

This is a convenience function for allowing limited implicit conversions to joints.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an out of range joint identifier.
See also
GetJointRange.

◆ SetJointDestructionListener

void SetJointDestructionListener ( World world,
JointFunction  listener 
)
friend

Sets the destruction listener for joints.

Note
This listener is called on Clear(World&) for every joint. It's also called on Destroy(BodyID) for every joint associated with the identified body.
Parameters
worldThe world to set the listener for.
listenerFunction that the world is to call on these events.
See also
Clear(World&), Destroy(BodyID).

◆ SetLinearDamping()

void SetLinearDamping ( World world,
BodyID  id,
NonNegative< Frequency linearDamping 
)
related

Sets the linear damping of the body.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ SetLinearOffset()

void SetLinearOffset ( World world,
JointID  id,
const Length2 value 
)
related

Sets the target linear offset, in frame A.

Exceptions
std::out_of_rangeIf given an invalid joint identifier.

◆ SetLocation()

void SetLocation ( World world,
BodyID  id,
const Length2 value 
)
related

Sets the body's location.

This instantly adjusts the body to be at the new location.

Warning
Manipulating a body's location this way can cause non-physical behavior!
Parameters
worldThe world in which the identified body's location should be set.
idIdentifier of body to move.
valueValid world location of the body's local origin.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
See also
GetLocation(const World& world, BodyID id).

◆ SetManifold

void SetManifold ( World world,
ContactID  id,
const Manifold value 
)
friend

Sets the identified manifold's state.

Note
There is a manifold for every contact and vice-versa.
Parameters
worldThe world of the manifold whose state is to be set.
idIdentifier of the manifold whose state is to be set.
valueValue the manifold is to be set to. The new state: TODO: is not allowed to change whether the contact is awake, TODO: is not allowed to change whether the contact is impenetrable. Otherwise, throws InvalidArgument exception and doesn't change anything.
Exceptions
std::out_of_rangeIf given an out of range contact identifier or the new manifold value references an out of range identifier.
InvalidArgumentif the identifier is to a freed contact or if the new state is not allowable.
See also
GetManifold, GetContactRange.

◆ SetMassData()

void SetMassData ( World world,
BodyID  id,
const MassData massData 
)
related

Sets the mass properties to override the mass properties of the fixtures.

Note
This changes the center of mass position.
Creating or destroying fixtures can also alter the mass.
This function has no effect if the body isn't dynamic.
Parameters
worldThe world in which the identified body exists.
idIdentifier of the body.
massDatathe mass properties.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ SetMaxMotorTorque()

void SetMaxMotorTorque ( World world,
JointID  id,
Torque  value 
)
related

Sets the maximum motor torque.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid joint identifier.

◆ SetMotorSpeed()

void SetMotorSpeed ( World world,
JointID  id,
AngularVelocity  value 
)
related

Sets the motor-speed property of the identied joint if it supports it.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid joint identifier.
See also
GetMotorSpeed(const World& world, JointID id)

◆ SetPostSolveContactListener

void SetPostSolveContactListener ( World world,
ContactImpulsesFunction  listener 
)
friend

Sets the post-solve-contact lister.

Note
This listener is called during calls to the Step(World&,const StepConf&) function for every contact that was "solved" during regular processing or TOI processing (or both).
Parameters
worldThe world to set the listener for.
listenerFunction that the world is to call on these events.
See also
SetPreSolveContactListener(World&, ContactManifoldFunction).

◆ SetPreSolveContactListener

void SetPreSolveContactListener ( World world,
ContactManifoldFunction  listener 
)
friend

Sets the pre-solve-contact lister.

Note
This listener is called during calls to the Step(World&,const StepConf&) function for every non-sensor contact that is touching.
Parameters
worldThe world to set the listener for.
listenerFunction that the world is to call on these events.
See also
SetPostSolveContactListener(World&, ContactImpulsesFunction).

◆ SetRestitution() [1/2]

void SetRestitution ( World world,
ContactID  id,
Real  restitution 
)
related

Sets the restitution value for the specified contact.

This override the default restitution mixture.

Note
You can call this in "pre-solve" listeners.
The value persists until you set or reset.

◆ SetRestitution() [2/2]

void SetRestitution ( World world,
ShapeID  id,
Real  value 
)
related

Sets the coefficient of restitution of the specified shape.

Exceptions
std::out_of_rangeIf given an invalid identifier.

◆ SetSensor()

void SetSensor ( World world,
ShapeID  id,
bool  value 
)
related

Convenience function for setting whether the shape is a sensor or not.

Exceptions
std::out_of_rangeIf given an invalid identifier.
See also
IsSensor.

◆ SetShape

void SetShape ( World world,
ShapeID  id,
const Shape def 
)
friend

Sets the identified shape to the new value.

Exceptions
std::out_of_rangeIf given an out of range shape identifier.
See also
CreateShape, GetShapeRange.

◆ SetShapeDestructionListener

void SetShapeDestructionListener ( World world,
ShapeFunction  listener 
)
friend

Sets the destruction listener for shapes.

Note
This listener is called on Clear(World&) for every shape.
Parameters
worldThe world to set the listener for.
listenerFunction that the world is to call on these events.
See also
Clear(World&).

◆ SetSleepingAllowed()

void SetSleepingAllowed ( World world,
BodyID  ,
bool  value 
)
related

Sets whether the identified body is allowed to sleep.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ SetSubStepping

void SetSubStepping ( World world,
bool  flag 
)
friend

Enables/disables single stepped continuous physics.

Note
This is not normally used. Enabling sub-stepping is meant for testing.
Parameters
worldThe world to set whether or not to do sub-stepping for.
flagtrue to enable sub-stepping, false to disable it.
Postcondition
The GetSubStepping() function will return the value this function was called with.
See also
IsStepComplete, GetSubStepping.

◆ SetTangentSpeed()

void SetTangentSpeed ( World world,
ContactID  id,
LinearVelocity  value 
)
related

Sets the desired tangent speed for a conveyor belt behavior.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ SetTarget()

void SetTarget ( World world,
JointID  id,
const Length2 value 
)
related

Sets the target point.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid joint identifier.

◆ SetTorque()

void SetTorque ( World world,
BodyID  id,
Torque  torque 
)
related

Sets the given amount of torque to the given body.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ SetTransform()

void SetTransform ( World world,
BodyID  id,
const Length2 location,
Angle  angle 
)
related

Sets the position of the body's origin and rotation.

This instantly adjusts the body to be at the new position and new orientation.

Warning
Manipulating a body's transform can cause non-physical behavior!
Note
Contacts are updated on the next call to World::Step.
Parameters
worldThe world in which the identified body's transform should be set.
idIdentifier of body whose transform is to be set.
locationValid world location of the body's local origin.
angleValid world rotation.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ SetTransformation()

void SetTransformation ( World world,
BodyID  id,
const Transformation value 
)
related

Sets the transformation of the body.

This instantly adjusts the body to be at the new transformation.

Warning
Manipulating a body's transformation can cause non-physical behavior!
Note
Contacts are updated on the next call to World::Step.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
See also
GetTransformation(const World& world, BodyID id).

◆ SetType()

void SetType ( World world,
BodyID  id,
BodyType  value,
bool  resetMassData = true 
)
related

Sets the type of the given body.

Note
This may alter the body's mass and velocity.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
See also
GetType(const World& world, BodyID id), ResetMassData.

◆ SetVelocity() [1/3]

void SetVelocity ( World world,
BodyID  id,
AngularVelocity  value 
)
related

Sets the velocity of the identified body.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ SetVelocity() [2/3]

void SetVelocity ( World world,
BodyID  id,
const LinearVelocity2 value 
)
related

Sets the velocity of the identified body.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

◆ SetVelocity() [3/3]

void SetVelocity ( World world,
BodyID  id,
const Velocity value 
)
related

Sets the body's velocity (linear and angular velocity).

Note
This function does nothing if this body is not speedable.
A non-zero velocity will awaken this body.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
See also
GetVelocity(BodyID), SetAwake, SetUnderActiveTime.

◆ ShiftOrigin [1/2]

void ShiftOrigin ( World world,
const Length2 newOrigin 
)
friend

Shifts the origin of the specified world.

Note
Useful for large worlds.
The body shift formula is: position -= newOrigin.
Postcondition
The "origin" of this world's bodies, joints, and the board-phase dynamic tree have been translated per the shift amount and direction.
Parameters
worldThe world whose origin is to be shifted.
newOriginthe new origin with respect to the old origin
Exceptions
WrongStateif this function is called while the world is locked.

◆ ShiftOrigin() [2/2]

bool ShiftOrigin ( World world,
JointID  id,
const Length2 value 
)
related

Shifts the origin of the identified joint.

Note
This only effects joints having points in world coordinates.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid joint identifier.

◆ Step [1/2]

StepStats Step ( World world,
const StepConf conf = StepConf{} 
)
friend

Steps the given 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.

Warning
Behavior is not specified if given a negative step time delta.
Varying the step time delta may lead to non-physical behaviors.
Note
Calling this with a zero step time delta results only in fixtures and bodies registered for special handling being processed. No physics is performed.
If the given velocity and position iterations are zero, this function doesn't do velocity or position resolutions respectively of the contacting bodies.
While body velocities are updated accordingly (per the sum of forces acting on them), body positions (barring any collisions) are updated as if they had moved the entire time step at those resulting velocities. In other words, a body initially at position 0 (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.
While this function is running, some listener functions could get called. Meanwhile some functions on World can only operate while the world is not in the middle of being updated by this function. Listeners can use the IsLocked(const World& world) function to detect whether they've been called in this case or not and then act accordingly.
Postcondition
Static bodies are unmoved.
Kinetic bodies are moved based on their previous velocities.
Dynamic bodies are moved based on their previous velocities, gravity, applied forces, applied impulses, masses, damping, and the restitution and friction values of their fixtures when they experience collisions.
Parameters
worldThe world to simulate a step for.
confConfiguration for the simulation step.
Returns
Statistics for the step.
Exceptions
WrongStateif this function is called while the world is locked.
See also
IsLocked(const World&).

◆ Step() [2/2]

StepStats Step ( World world,
Time  delta,
TimestepIters  velocityIterations = StepConf::DefaultRegVelocityIters,
TimestepIters  positionIterations = StepConf::DefaultRegPositionIters 
)
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 function also respectively performs velocity and position resolution of the contacting bodies.

Note
While body velocities are updated accordingly (per the sum of forces acting on them), body positions (barring any collisions) are updated as if they had moved the entire time step at those resulting velocities. In other words, a body initially at 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.
Warning
Varying the time step may lead to non-physical behaviors.
Postcondition
Static bodies are unmoved.
Kinetic bodies are moved based on their previous velocities.
Dynamic bodies are moved based on their previous velocities, gravity, applied forces, applied impulses, masses, damping, and the restitution and friction values of their fixtures when they experience collisions.
Parameters
worldWorld to step.
deltaTime to simulate as a delta from the current state. This should not vary.
velocityIterationsNumber of iterations for the velocity constraint solver.
positionIterationsNumber of iterations for the position constraint solver. The position constraint solver resolves the positions of bodies that overlap.

◆ Translate()

void Translate ( World world,
ShapeID  id,
const Length2 value 
)
related

Translates all of the given shape's vertices by the given amount.

Note
This may throw std::bad_alloc or any exception that's thrown by the constructor for the model's underlying data type.
Exceptions
std::bad_allocif there's a failure allocating storage.
std::out_of_rangeIf given an invalid identifier.

◆ TypeCast() [1/5]

template<typename T >
T TypeCast ( const World value)
related

Converts the given joint into its current configuration value.

Note
The design for this was based off the design of the C++17 std::any class and its associated std::any_cast function. The code for this is based off of the std::any implementation from the LLVM Project.
Exceptions
std::bad_castIf the given template parameter type isn't the type of this joint's configuration value.
See also
https://llvm.org/

◆ TypeCast [2/5]

template<typename T >
std::add_pointer_t<std::add_const_t<T> > TypeCast ( const World value)
friend

Casts the given world into its current underlying configuration value.

Note
The design for this was based off the design of the C++17 std::any class and its associated std::any_cast function. The code for this is based off of the std::any code from the LLVM Project.
Template Parameters
Ttype to cast the underlying value of the given world to, if matching the actual type of the underlying value.
Parameters
valuePointer to the world whose underlying value, if it's type is the type of the template parameter, is to be returned.
See also
GetType(const World&).
https://llvm.org/

◆ TypeCast() [3/5]

template<typename T >
T TypeCast ( World &&  value)
related

Converts the given joint into its current configuration value.

Note
The design for this was based off the design of the C++17 std::any class and its associated std::any_cast function. The code for this is based off of the std::any implementation from the LLVM Project.
See also
https://llvm.org/

◆ TypeCast() [4/5]

template<typename T >
T TypeCast ( World value)
related

Converts the given joint into its current configuration value.

Note
The design for this was based off the design of the C++17 std::any class and its associated std::any_cast function. The code for this is based off of the std::any implementation from the LLVM Project.
See also
https://llvm.org/

◆ TypeCast [5/5]

template<typename T >
std::add_pointer_t<T> TypeCast ( World value)
friend

Casts the given world into its current configuration value.

Note
The design for this was based off the design of the C++17 std::any class and its associated std::any_cast function. The code for this is based off of the std::any implementation from the LLVM Project.
Template Parameters
Ttype to cast the underlying value of the given world to, if matching the actual type of the underlying value.
Parameters
valuePointer to the world whose underlying value, if it's type is the type of the template parameter, is to be returned.
See also
GetType(const World&).
https://llvm.org/

◆ UnsetAwake()

void UnsetAwake ( World world,
BodyID  id 
)
related

Sleeps the identified body.

Note
This sleeps any associated contacts whose other body is also asleep.
Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.
See also
IsAwake(const World& world, BodyID id), SetAwake(World& world, BodyID id).

◆ UnsetEnabled()

void UnsetEnabled ( World world,
ContactID  id 
)
related

Unsets the enabled status of the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ UnsetImpenetrable()

void UnsetImpenetrable ( World world,
BodyID  id 
)
related

Unsets the impenetrable status of the identified body.

Exceptions
WrongStateif this function is called while the world is locked.
std::out_of_rangeIf given an invalid body identifier.

The documentation for this class was generated from the following files: