PlayRho  1.1.0
An Interactive Real-Time-Oriented C++ Physics Engine & Library
playrho::d2::WorldImpl Class Reference

Definition of a "world" implementation. More...

#include <WorldImpl.hpp>

Collaboration diagram for playrho::d2::WorldImpl:
[legend]

Classes

struct  ContactToiData
 Contact TOI data. More...
 
struct  ContactUpdateConf
 Contact updating configuration. More...
 
struct  DestroyContactsStats
 Destroy contacts statistics. More...
 
struct  ProcessContactsOutput
 Process contacts output. More...
 
struct  UpdateContactsData
 Update contacts data. More...
 
struct  UpdateContactsStats
 Update contacts statistics. More...
 

Public Types

using Bodies = std::vector< BodyID >
 Bodies container type.
 
using Contacts = std::vector< KeyedContactPtr >
 Contacts container type.
 
using Joints = std::vector< JointID >
 Joints container type. More...
 
using BodyJoints = std::vector< std::pair< BodyID, JointID > >
 Body joints container type.
 
using Fixtures = std::vector< FixtureID >
 Fixtures container type.
 
using ProxyId = DynamicTree::Size
 Proxy ID type alias.
 
using Proxies = std::vector< ProxyId >
 Proxy container type alias.
 
using FixtureListener = std::function< void(FixtureID)>
 Fixture listener.
 
using JointListener = std::function< void(JointID)>
 Joint listener.
 
using ContactListener = std::function< void(ContactID)>
 Contact listener.
 
using ManifoldContactListener = std::function< void(ContactID, const Manifold &)>
 Manifold contact listener.
 
using ImpulsesContactListener = std::function< void(ContactID, const ContactImpulsesList &, unsigned)>
 Impulses contact listener.
 

Public Member Functions

Special Member Functions

Special member functions that are explicitly defined.

 WorldImpl (const WorldConf &def=GetDefaultWorldConf())
 Constructs a world implementation for a world. More...
 
 WorldImpl (const WorldImpl &other)=default
 Copy constructor. More...
 
WorldImploperator= (const WorldImpl &other)=default
 Assignment operator. More...
 
 ~WorldImpl () noexcept
 Destructor. More...
 
Listener Member Functions
void SetFixtureDestructionListener (FixtureListener listener) noexcept
 Register a destruction listener for fixtures.
 
void SetJointDestructionListener (JointListener listener) noexcept
 Register a destruction listener for joints.
 
void SetBeginContactListener (ContactListener listener) noexcept
 Register a begin contact event listener.
 
void SetEndContactListener (ContactListener listener) noexcept
 Register an end contact event listener.
 
void SetPreSolveContactListener (ManifoldContactListener listener) noexcept
 Register a pre-solve contact event listener.
 
void SetPostSolveContactListener (ImpulsesContactListener listener) noexcept
 Register a post-solve contact event listener.
 
Miscellaneous Member Functions
void Clear () noexcept
 Clears this world. More...
 
StepStats Step (const StepConf &conf)
 Steps the world simulation according to the given configuration. More...
 
bool IsStepComplete () const noexcept
 Whether or not "step" is complete. More...
 
bool GetSubStepping () const noexcept
 Gets whether or not sub-stepping is enabled. More...
 
void SetSubStepping (bool flag) noexcept
 Enables/disables single stepped continuous physics. More...
 
const DynamicTreeGetTree () const noexcept
 Gets access to the broad-phase dynamic tree information.
 
bool IsLocked () const noexcept
 Is the world locked (in the middle of a time step).
 
void ShiftOrigin (Length2 newOrigin)
 Shifts the world origin. More...
 
Length GetMinVertexRadius () const noexcept
 Gets the minimum vertex radius that shapes in this world can be.
 
Length GetMaxVertexRadius () const noexcept
 Gets the maximum vertex radius that shapes in this world can be.
 
Frequency GetInvDeltaTime () const noexcept
 Gets the inverse delta time. More...
 
const ProxiesGetProxies () const noexcept
 Gets the dynamic tree leaves queued for finding new contacts. More...
 
void AddProxies (const Proxies &proxies)
 Adds the given dynamic tree leaves to the queue for finding new contacts. More...
 
ContactCounter FindNewContacts ()
 Finds new contacts. More...
 
Body Member Functions

Member functions relating to bodies.

BodyCounter GetBodyRange () const noexcept
 Gets the extent of the currently valid body range. More...
 
SizedRange< Bodies::const_iterator > GetBodies () const noexcept
 Gets the world body range for this constant world. More...
 
SizedRange< Bodies::const_iterator > GetBodiesForProxies () const noexcept
 Gets the bodies-for-proxies range for this world. More...
 
BodyID CreateBody (const BodyConf &def=GetDefaultBodyConf())
 Creates a rigid body with the given configuration. More...
 
const BodyGetBody (BodyID id) const
 Gets the identified body. More...
 
void SetBody (BodyID id, const Body &value)
 Sets the identified body. More...
 
void Destroy (BodyID id)
 Destroys the given body. More...
 
bool IsDestroyed (BodyID id) const noexcept
 Gets whether the given identifier is to a body that's been destroyed.
 
SizedRange< WorldImpl::Contacts::const_iterator > GetContacts (BodyID id) const
 Gets the contacts associated with the identified body. More...
 
SizedRange< WorldImpl::BodyJoints::const_iterator > GetJoints (BodyID id) const
 
SizedRange< WorldImpl::Fixtures::const_iterator > GetFixtures (BodyID id) const
 Gets the range of all constant fixtures attached to this body.
 
Fixture Member Functions

Member functions relating to fixtures.

FixtureCounter GetFixtureRange () const noexcept
 Gets the extent of the currently valid fixture range. More...
 
FixtureID CreateFixture (const FixtureConf &def=FixtureConf{})
 Creates a fixture with the given parameters. More...
 
const FixtureConfGetFixture (FixtureID id) const
 Gets the identified fixture state. More...
 
void SetFixture (FixtureID id, const FixtureConf &value)
 Sets the identified fixture's state. More...
 
bool Destroy (FixtureID fixture)
 Destroys a fixture. More...
 
bool IsDestroyed (FixtureID id) const noexcept
 Gets whether the given identifier is to a fixture that's been destroyed.
 
SizedRange< Fixtures::const_iterator > GetFixturesForProxies () const noexcept
 Gets the fixtures-for-proxies range for this world. More...
 
const ProxiesGetProxies (FixtureID id) const
 Gets the proxies for the identified fixture. More...
 
Joint Member Functions

Member functions relating to joints.

JointCounter GetJointRange () const noexcept
 Gets the extent of the currently valid joint range. More...
 
SizedRange< Joints::const_iterator > GetJoints () const noexcept
 Gets the world joint range. More...
 
JointID CreateJoint (const Joint &def)
 Creates a joint to constrain one or more bodies. More...
 
const JointGetJoint (JointID id) const
 Gets the identified joint. More...
 
void SetJoint (JointID id, const Joint &def)
 Sets the identified joint. More...
 
void Destroy (JointID joint)
 Destroys a joint. More...
 
bool IsDestroyed (JointID id) const noexcept
 Gets whether the given identifier is to a joint that's been destroyed.
 
Contact Member Functions

Member functions relating to contacts.

ContactCounter GetContactRange () const noexcept
 Gets the extent of the currently valid contact range. More...
 
SizedRange< Contacts::const_iterator > GetContacts () const noexcept
 Gets the world contact range. More...
 
const ContactGetContact (ContactID id) const
 Gets the identified contact. More...
 
void SetContact (ContactID id, const Contact &value)
 Sets the identified contact's state. More...
 
const ManifoldGetManifold (ContactID id) const
 Gets the identified manifold. More...
 
bool IsDestroyed (ContactID id) const noexcept
 Gets whether the given identifier is to a contact that's been destroyed.
 

Private Types

enum  Flag : FlagsType { e_newFixture = 0x0001, e_locked = 0x0002, e_substepping = 0x0020, e_stepComplete = 0x0040 }
 Flag enumeration. More...
 
using FlagsType = std::uint32_t
 Flags type data type.
 
using ContactKeyQueue = std::vector< ContactKey >
 Contact key queue type alias.
 
using BodyStack = std::stack< BodyID, std::vector< BodyID > >
 Body stack.
 

Private Member Functions

RegStepStats SolveReg (const StepConf &conf)
 Solves the step. More...
 
IslandStats SolveRegIslandViaGS (const StepConf &conf, const Island &island)
 Solves the given island (regularly). More...
 
void AddToIsland (Island &island, BodyID seed, BodyCounter &remNumBodies, ContactCounter &remNumContacts, JointCounter &remNumJoints)
 Adds to the island based off of a given "seed" body. More...
 
void AddToIsland (Island &island, BodyStack &stack, BodyCounter &remNumBodies, ContactCounter &remNumContacts, JointCounter &remNumJoints)
 Adds to the island.
 
void AddContactsToIsland (Island &island, BodyStack &stack, const Contacts &contacts, BodyID bodyID)
 Adds contacts to the island.
 
void AddJointsToIsland (Island &island, BodyStack &stack, const BodyJoints &joints)
 Adds joints to the island.
 
ToiStepStats SolveToi (const StepConf &conf)
 Solves the step using successive time of impact (TOI) events. More...
 
IslandStats SolveToi (ContactID contactID, const StepConf &conf)
 Solves collisions for the given time of impact. More...
 
IslandStats SolveToiViaGS (const Island &island, const StepConf &conf)
 Solves the time of impact for bodies 0 and 1 of the given island. More...
 
ProcessContactsOutput ProcessContactsForTOI (BodyID id, Island &island, Real toi, const StepConf &conf)
 Processes the contacts of a given body for TOI handling. More...
 
void Remove (BodyID id) noexcept
 Removes the given body from this world.
 
void AddFixture (BodyID id, FixtureID fixture)
 Adds the given fixture to the given body.
 
bool RemoveFixture (BodyID id, FixtureID fixture)
 Removes the given fixture from the given body.
 
void Add (JointID j, bool flagForFiltering=false)
 Updates associated bodies and contacts for specified joint's addition.
 
void Remove (JointID id) noexcept
 Updates associated bodies and contacts for specified joint's removal.
 
void SetStepComplete (bool value) noexcept
 Sets the step complete state. More...
 
void SetAllowSleeping () noexcept
 Sets the allow sleeping state.
 
void UnsetAllowSleeping () noexcept
 Unsets the allow sleeping state.
 
bool HasNewFixtures () const noexcept
 Determines whether this world has new fixtures.
 
void UnsetNewFixtures () noexcept
 Unsets the new fixtures state.
 
DestroyContactsStats DestroyContacts (Contacts &contacts)
 Processes the narrow phase collision for the contacts collection. More...
 
UpdateContactsStats UpdateContacts (const StepConf &conf)
 Update contacts.
 
void Destroy (ContactID contact, const Body *from)
 Destroys the given contact and removes it from its container. More...
 
bool Add (ContactKey key)
 Adds a contact for the proxies identified by the key if appropriate. More...
 
void InternalDestroy (ContactID contact, const Body *from=nullptr)
 Destroys the given contact.
 
ContactCounter Synchronize (const Fixtures &fixtures, const Transformation &xfm1, const Transformation &xfm2, Real multiplier, Length extension)
 Synchronizes the given body. More...
 
void CreateAndDestroyProxies (Length extension)
 Creates and destroys proxies.
 
PreStepStats::counter_type SynchronizeProxies (const StepConf &conf)
 Synchronizes proxies of the bodies for proxies.
 
void Update (ContactID id, const ContactUpdateConf &conf)
 Updates the touching related state and notifies listener (if one given). More...
 

Static Private Member Functions

static Bodies::size_type RemoveUnspeedablesFromIslanded (const std::vector< BodyID > &bodies, const ArrayAllocator< Body > &buffer, std::vector< bool > &islanded)
 Removes unspeedables from the is is-in-island state.
 
static bool UpdateBody (Body &body, const Position &pos)
 Updates the given body. More...
 
static UpdateContactsData UpdateContactTOIs (ArrayAllocator< Contact > &contactBuffer, ArrayAllocator< Body > &bodyBuffer, const ArrayAllocator< FixtureConf > &fixtureBuffer, const Contacts &contacts, const StepConf &conf)
 Updates the contact times of impact.
 
static ContactToiData GetSoonestContact (const Contacts &contacts, const ArrayAllocator< Contact > &buffer) noexcept
 Gets the soonest contact. More...
 

Private Attributes

ArrayAllocator< Bodym_bodyBuffer
 Array of body data both used and freed.
 
ArrayAllocator< Contactsm_bodyContacts
 Cache of contacts associated with bodies.
 
ArrayAllocator< BodyJointsm_bodyJoints
 Cache of joints associated with bodies.
 
ArrayAllocator< Fixturesm_bodyFixtures
 Cache of fixtures associated with bodies. More...
 
ArrayAllocator< FixtureConfm_fixtureBuffer
 Array of fixture data both used and freed.
 
ArrayAllocator< Proxiesm_fixtureProxies
 Array of arrays of dynamic tree leaves.
 
ArrayAllocator< Jointm_jointBuffer
 Array of joint data both used and freed.
 
ArrayAllocator< Contactm_contactBuffer
 Array of contact data both used and freed.
 
ArrayAllocator< Manifoldm_manifoldBuffer
 Array of manifold data both used and freed.
 
DynamicTree m_tree
 Dynamic tree.
 
ContactKeyQueue m_proxyKeys
 Proxy keys.
 
Proxies m_proxies
 Proxies queue.
 
Fixtures m_fixturesForProxies
 Fixtures for proxies queue.
 
Bodies m_bodiesForProxies
 Bodies for proxies queue.
 
Bodies m_bodies
 Body collection.
 
Joints m_joints
 Joint collection.
 
Contacts m_contacts
 Container of contacts. More...
 
Island m_island
 Island buffer.
 
std::vector< bool > m_islandedBodies
 Per body boolean on whether body islanded.
 
std::vector< bool > m_islandedContacts
 Per contact boolean on whether contact islanded.
 
std::vector< bool > m_islandedJoints
 Per joint boolean on whether joint islanded.
 
FixtureListener m_fixtureDestructionListener
 Listener for fixture destruction.
 
JointListener m_jointDestructionListener
 Listener for joint destruction.
 
ContactListener m_beginContactListener
 Listener for beginning contact events.
 
ContactListener m_endContactListener
 Listener for ending contact events.
 
ManifoldContactListener m_preSolveContactListener
 Listener for pre-solving contacts.
 
ImpulsesContactListener m_postSolveContactListener
 Listener for post-solving contacts.
 
FlagsType m_flags = e_stepComplete
 Flags.
 
Frequency m_inv_dt0 = 0
 Inverse delta-t from previous step. More...
 
Positive< Lengthm_minVertexRadius
 Minimum vertex radius.
 
Positive< Lengthm_maxVertexRadius
 Maximum vertex radius. More...
 

Related Functions

(Note that these are not member functions.)

BodyCounter GetBodyRange (const WorldImpl &world) noexcept
 Gets the extent of the currently valid body range. More...
 
BodyID CreateBody (WorldImpl &world, const BodyConf &def=GetDefaultBodyConf())
 Creates a body with the given configuration within the given world.
 
const BodyGetBody (const WorldImpl &world, BodyID id)
 Gets the body configuration for the identified body. More...
 
void SetBody (WorldImpl &world, BodyID id, const Body &value)
 Sets the body state for the identified body. More...
 
void Destroy (WorldImpl &world, BodyID id)
 Destroys the identified body.
 
SizedRange< std::vector< std::pair< BodyID, JointID > >::const_iterator > GetJoints (const WorldImpl &world, BodyID id)
 Gets the range of all joints attached to this body. More...
 
SizedRange< std::vector< FixtureID >::const_iterator > GetFixtures (const WorldImpl &world, BodyID id)
 Gets the range of all constant fixtures attached to the given body. More...
 
SizedRange< std::vector< KeyedContactPtr >::const_iterator > GetContacts (const WorldImpl &world, BodyID id)
 Gets the container of all contacts attached to this body. More...
 
ContactCounter GetContactRange (const WorldImpl &world) noexcept
 Gets the extent of the currently valid contact range. More...
 
const ContactGetContact (const WorldImpl &world, ContactID id)
 Gets the identified contact. More...
 
void SetContact (WorldImpl &world, ContactID id, const Contact &value)
 Sets the identified contact's state. More...
 
FixtureCounter GetFixtureRange (const WorldImpl &world) noexcept
 Gets the extent of the currently valid fixture range. More...
 
FixtureID CreateFixture (WorldImpl &world, const FixtureConf &def)
 Creates a fixture per the given configuration. More...
 
const FixtureConfGetFixture (const WorldImpl &world, FixtureID id)
 Gets the identified fixture state. More...
 
void SetFixture (WorldImpl &world, FixtureID id, const FixtureConf &value)
 Sets the identified fixture's state. More...
 
bool Destroy (WorldImpl &world, FixtureID id)
 Destroys the identified fixture. More...
 
const std::vector< ContactCounter > & GetProxies (const WorldImpl &world, FixtureID id)
 Gets the dynamic tree leaves awaiting processing for the finding of new contacts.
 
ChildCounter GetProxyCount (const WorldImpl &world, FixtureID id)
 Gets the count of proxies of the identified fixture. More...
 
ContactCounter GetProxy (const WorldImpl &world, FixtureID id, ChildCounter child)
 Gets the specified proxy of the identified fixture. More...
 
JointCounter GetJointRange (const WorldImpl &world) noexcept
 Gets the extent of the currently valid joint range. More...
 
JointID CreateJoint (WorldImpl &world, const Joint &def)
 Creates a new joint.
 
void Destroy (WorldImpl &world, JointID id)
 Destroys the identified joint.
 
const JointGetJoint (const WorldImpl &world, JointID id)
 Gets the identified joint's value.
 
void SetJoint (WorldImpl &world, JointID id, const Joint &def)
 Sets the identified joint's new value.
 
void Clear (WorldImpl &world) noexcept
 Clears the given world.
 
void SetFixtureDestructionListener (WorldImpl &world, std::function< void(FixtureID)> listener) noexcept
 Registers a destruction listener for fixtures.
 
void SetJointDestructionListener (WorldImpl &world, std::function< void(JointID)> listener) noexcept
 Registers a destruction listener for joints.
 
void SetBeginContactListener (WorldImpl &world, std::function< void(ContactID)> listener) noexcept
 Registers a begin contact event listener.
 
void SetEndContactListener (WorldImpl &world, std::function< void(ContactID)> listener) noexcept
 Registers an end contact event listener.
 
void SetPreSolveContactListener (WorldImpl &world, std::function< void(ContactID, const Manifold &)> listener) noexcept
 Registers a pre-solve contact event listener.
 
void SetPostSolveContactListener (WorldImpl &world, std::function< void(ContactID, const ContactImpulsesList &, unsigned)> listener) noexcept
 Registers a post-solve contact event listener.
 
StepStats Step (WorldImpl &world, const StepConf &conf)
 Steps the given world the specified amount.
 
void ShiftOrigin (WorldImpl &world, Length2 newOrigin)
 Shifts the world origin. More...
 
SizedRange< std::vector< BodyID >::const_iterator > GetBodies (const WorldImpl &world) noexcept
 Gets the bodies of the specified world.
 
SizedRange< std::vector< BodyID >::const_iterator > GetBodiesForProxies (const WorldImpl &world) noexcept
 Gets the bodies-for-proxies range for this world. More...
 
SizedRange< std::vector< FixtureID >::const_iterator > GetFixturesForProxies (const WorldImpl &world) noexcept
 Gets the fixtures-for-proxies range for this world. More...
 
SizedRange< std::vector< JointID >::const_iterator > GetJoints (const WorldImpl &world) noexcept
 Gets the joints of the specified world.
 
SizedRange< std::vector< KeyedContactPtr >::const_iterator > GetContacts (const WorldImpl &world) noexcept
 Gets the contacts of the specified world.
 
bool IsLocked (const WorldImpl &world) noexcept
 Is the world locked (in the middle of a time step).
 
bool IsStepComplete (const WorldImpl &world) noexcept
 Whether or not "step" is complete. More...
 
bool GetSubStepping (const WorldImpl &world) noexcept
 Gets whether or not sub-stepping is enabled. More...
 
void SetSubStepping (WorldImpl &world, bool value) noexcept
 Enables/disables single stepped continuous physics. More...
 
Length GetMinVertexRadius (const WorldImpl &world) noexcept
 Gets the minimum vertex radius that shapes in this world can be.
 
Length GetMaxVertexRadius (const WorldImpl &world) noexcept
 Gets the maximum vertex radius that shapes in this world can be.
 
Frequency GetInvDeltaTime (const WorldImpl &world) noexcept
 Gets the inverse delta time. More...
 
const DynamicTreeGetTree (const WorldImpl &world) noexcept
 Gets access to the broad-phase dynamic tree information.
 

Detailed Description

Definition of a "world" implementation.

See also
World.

Member Typedef Documentation

◆ Joints

Joints container type.

Note
Cannot be container of Joint instances since joints are polymorphic types.

Member Enumeration Documentation

◆ Flag

Flag enumeration.

Enumerator
e_newFixture 

New fixture.

e_locked 

Locked.

e_substepping 

Sub-stepping.

e_stepComplete 

Step complete.

Used for sub-stepping.

See also
e_substepping.

Constructor & Destructor Documentation

◆ WorldImpl() [1/2]

playrho::d2::WorldImpl::WorldImpl ( const WorldConf def = GetDefaultWorldConf())
explicit

Constructs a world implementation for a world.

Parameters
defA customized world configuration or its default value.
Note
A lot more configurability can be had via the StepConf data that's given to the world's Step method.
Exceptions
InvalidArgumentif the given max vertex radius is less than the min.
See also
Step.

◆ WorldImpl() [2/2]

playrho::d2::WorldImpl::WorldImpl ( const WorldImpl other)
default

Copy constructor.

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

◆ ~WorldImpl()

playrho::d2::WorldImpl::~WorldImpl ( )
noexcept

Destructor.

All physics entities are destroyed and all memory is released.

Note
This will call the Clear() function.
See also
Clear.

Member Function Documentation

◆ Add()

bool playrho::d2::WorldImpl::Add ( ContactKey  key)
private

Adds a contact for the proxies identified by the key if appropriate.

Adds a new contact object to represent a contact between proxy A and proxy B if all of the following are true:

  1. The bodies of the fixtures of the proxies are not the one and the same.
  2. No contact already exists for these two proxies.
  3. The bodies of the proxies should collide (according to ShouldCollide).
  4. The contact filter says the fixtures of the proxies should collide.
  5. There exists a contact-create function for the pair of shapes of the proxies.
    Postcondition
    The size of the contacts collection is one greater-than it was before this method is called if it returns true.
    Parameters
    keyID's of dynamic tree entries identifying the fixture proxies involved.
    Returns
    true if a new contact was indeed added (and created), else false.
    See also
    bool ShouldCollide(const Body& lhs, const Body& rhs) noexcept.

◆ AddProxies()

void playrho::d2::WorldImpl::AddProxies ( const Proxies proxies)
inline

Adds the given dynamic tree leaves to the queue for finding new contacts.

See also
GetProxies, FindNewContacts.

Referenced by CreateAndDestroyProxies(), SetBody(), and SetFixture().

◆ AddToIsland()

void playrho::d2::WorldImpl::AddToIsland ( Island island,
BodyID  seed,
BodyCounter remNumBodies,
ContactCounter remNumContacts,
JointCounter remNumJoints 
)
private

Adds to the island based off of a given "seed" body.

Postcondition
Contacts are listed in the island in the order that bodies provide those contacts.
Joints are listed the island in the order that bodies provide those joints.

Referenced by SolveReg().

◆ Clear()

void playrho::d2::WorldImpl::Clear ( )
noexcept

Clears this world.

Postcondition
The contents of this world have all been destroyed and this world's internal state reset as though it had just been constructed.

Referenced by ~WorldImpl().

◆ CreateBody()

BodyID playrho::d2::WorldImpl::CreateBody ( const BodyConf def = GetDefaultBodyConf())

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() method.
Parameters
defA customized body configuration or its default value.
Returns
Identifier of the newly created body which can later be destroyed by calling the Destroy(BodyID) method.
Exceptions
WrongStateif this method is called while the world is locked.
LengthErrorif this operation would create more than MaxBodies.
See also
Destroy(BodyID), GetBodies.
Physical Entities.

Referenced by playrho::d2::CreateBody().

◆ CreateFixture()

FixtureID playrho::d2::WorldImpl::CreateFixture ( const FixtureConf def = FixtureConf{})

Creates a fixture with the given parameters.

Creates a fixture for attaching a shape and other characteristics to the given body. Fixtures automatically go away when the body is destroyed. Fixtures can also be manually removed and destroyed using the Destroy(FixtureID, bool), or DestroyFixtures() methods.

Note
This function should not be called if the world is locked.
This function does not reset the body's mass data.
Warning
This function is locked during callbacks.
Postcondition
After creating a new fixture, it will show up in the fixture enumeration returned by the GetFixtures() methods.
Parameters
defInitial fixture settings. Friction and density must be >= 0. Restitution must be > -infinity and < infinity.
Returns
Identifier for the created fixture.
Exceptions
WrongStateif called while the world is "locked".
InvalidArgumentif called for a shape with a vertex radius less than the minimum vertex radius.
InvalidArgumentif called for a shape with a vertex radius greater than the maximum vertex radius.
See also
Destroy, GetFixtures
Physical Entities

Referenced by playrho::d2::CreateFixture(), and SetFixture().

◆ CreateJoint()

JointID playrho::d2::WorldImpl::CreateJoint ( const Joint def)

Creates a joint to constrain one or more bodies.

Warning
This function is locked during callbacks.
Note
No references to the configuration are retained. Its value is copied.
Postcondition
The created joint will be present in the range returned from the GetJoints() method.
Returns
Identifier for the newly created joint which can later be destroyed by calling the Destroy(JointID) method.
Exceptions
WrongStateif this method is called while the world is locked.
LengthErrorif this operation would create more than MaxJoints.
InvalidArgumentif the given definition is not allowed.
See also
Physical Entities.
Destroy(JointID), GetJoints.

Referenced by playrho::d2::CreateJoint().

◆ Destroy() [1/4]

void playrho::d2::WorldImpl::Destroy ( BodyID  id)

Destroys the given body.

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

Warning
This automatically deletes all associated shapes and joints.
This function is locked during callbacks.
Behavior is undefined if given a null body.
Behavior is undefined if the passed body was not created by this world.
Note
This function is locked during callbacks.
Postcondition
The destroyed body will no longer be present in the range returned from the GetBodies() method.
None of the body's fixtures will be present in the fixtures-for-proxies collection.
Parameters
idBody to destroy that had been created by this world.
Exceptions
WrongStateif this method is called while the world is locked.
See also
CreateBody(const BodyConf&), GetBodies, GetFixturesForProxies.
Physical Entities.

Referenced by CreateAndDestroyProxies(), Destroy(), playrho::d2::Destroy(), SetBody(), and SetFixture().

◆ Destroy() [2/4]

void playrho::d2::WorldImpl::Destroy ( ContactID  contact,
const Body from 
)
private

Destroys the given contact and removes it from its container.

This updates the contacts container, returns the memory to the allocator, and decrements the contact manager's contact count.

Parameters
contactContact to destroy.
fromFrom body.

◆ Destroy() [3/4]

bool playrho::d2::WorldImpl::Destroy ( FixtureID  fixture)

Destroys a fixture.

This removes the fixture from the broad-phase and destroys all contacts associated with this fixture. All fixtures attached to a body are implicitly destroyed when the body is destroyed.

Warning
This function is locked during callbacks.
Note
This function does not reset the body's mass data.
Parameters
fixturethe fixture to be removed.
Exceptions
WrongStateif this method is called while the world is locked.
std::out_of_rangeIf given an invalid fixture identifier.

◆ Destroy() [4/4]

void playrho::d2::WorldImpl::Destroy ( JointID  joint)

Destroys a joint.

Destroys a given joint that had previously been created by a call to this world's CreateJoint(const JointConf&) method.

Warning
This function is locked during callbacks.
Behavior is undefined if the passed joint was not created by this world.
Note
This may cause the connected bodies to begin colliding.
Postcondition
The destroyed joint will no longer be present in the range returned from the GetJoints() method.
Parameters
jointJoint to destroy that had been created by this world.
Exceptions
WrongStateif this method is called while the world is locked.
std::invalid_argumentIf given an invalid identifier.
See also
CreateJoint(const JointConf&), GetJoints.
Physical Entities.

◆ DestroyContacts()

WorldImpl::DestroyContactsStats playrho::d2::WorldImpl::DestroyContacts ( Contacts contacts)
private

Processes the narrow phase collision for the contacts collection.

This finds and destroys the contacts that need filtering and no longer should collide or that no longer have AABB-based overlapping fixtures. Those contacts that persist and have active bodies (either or both) get their Update methods called with the current contact listener as its argument. Essentially this really just purges contacts that are no longer relevant.

Referenced by Step().

◆ FindNewContacts()

ContactCounter playrho::d2::WorldImpl::FindNewContacts ( )

Finds new contacts.

Processes the proxy queue for finding new contacts and adding them to the contacts container.

Note
New contacts will all have overlapping AABBs.
Postcondition
GetProxies() will return an empty container.
See also
GetProxies.

Referenced by SolveReg(), SolveToi(), and Step().

◆ GetBodies()

SizedRange< WorldImpl::Bodies::const_iterator > playrho::d2::WorldImpl::GetBodies ( ) const
inlinenoexcept

Gets the world body range for this constant world.

Gets a range enumerating the bodies currently existing within this world. These are the bodies that had been created from previous calls to the CreateBody(const BodyConf&) method that haven't yet been destroyed.

Returns
Body range that can be iterated over using its begin and end methods or using ranged-based for-loops.
See also
CreateBody(const BodyConf&).

Referenced by playrho::d2::GetBodies(), and ShiftOrigin().

◆ GetBodiesForProxies()

SizedRange< WorldImpl::Bodies::const_iterator > playrho::d2::WorldImpl::GetBodiesForProxies ( ) const
inlinenoexcept

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

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

See also
Step.

Referenced by playrho::d2::GetBodiesForProxies().

◆ GetBody()

const Body & playrho::d2::WorldImpl::GetBody ( BodyID  id) const

Gets the identified body.

Exceptions
std::out_of_rangeif given an invalid id.

Referenced by Destroy(), playrho::d2::GetBody(), and SetBody().

◆ GetBodyRange()

BodyCounter playrho::d2::WorldImpl::GetBodyRange ( ) const
noexcept

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.

◆ GetContact()

const Contact & playrho::d2::WorldImpl::GetContact ( ContactID  id) const

Gets the identified contact.

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

Referenced by playrho::d2::GetContact().

◆ GetContactRange()

ContactCounter playrho::d2::WorldImpl::GetContactRange ( ) const
noexcept

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]

SizedRange< WorldImpl::Contacts::const_iterator > playrho::d2::WorldImpl::GetContacts ( ) const
inlinenoexcept

Gets the world contact range.

Warning
contacts are created and destroyed in the middle of a time step. Use ContactListener to avoid missing contacts.
Returns
World contacts sized-range.

◆ GetContacts() [2/2]

SizedRange< WorldImpl::Contacts::const_iterator > playrho::d2::WorldImpl::GetContacts ( BodyID  id) const

Gets the contacts associated with the identified body.

Exceptions
std::out_of_rangeif given an invalid id.

Referenced by playrho::d2::GetContacts().

◆ GetFixture()

const FixtureConf & playrho::d2::WorldImpl::GetFixture ( FixtureID  id) const

Gets the identified fixture state.

Exceptions
std::out_of_rangeIf given an invalid fixture identifier.

Referenced by Destroy(), and playrho::d2::GetFixture().

◆ GetFixtureRange()

FixtureCounter playrho::d2::WorldImpl::GetFixtureRange ( ) const
noexcept

Gets the extent of the currently valid fixture range.

Note
This is one higher than the maxium FixtureID that is in range for fixture related functions.

◆ GetFixturesForProxies()

SizedRange< WorldImpl::Fixtures::const_iterator > playrho::d2::WorldImpl::GetFixturesForProxies ( ) const
inlinenoexcept

Gets the fixtures-for-proxies range for this world.

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

See also
Step.

Referenced by playrho::d2::GetFixturesForProxies().

◆ GetInvDeltaTime()

Frequency playrho::d2::WorldImpl::GetInvDeltaTime ( ) const
inlinenoexcept

Gets the inverse delta time.

Gets the inverse delta time that was set on construction or assignment, and updated on every call to the Step() method having a non-zero delta-time.

See also
Step.

Referenced by playrho::d2::GetInvDeltaTime().

◆ GetJoint()

const Joint & playrho::d2::WorldImpl::GetJoint ( JointID  id) const

Gets the identified joint.

Exceptions
std::invalid_argumentIf given an invalid identifier.

Referenced by playrho::d2::GetJoint().

◆ GetJointRange()

JointCounter playrho::d2::WorldImpl::GetJointRange ( ) const
noexcept

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]

SizedRange< WorldImpl::Joints::const_iterator > playrho::d2::WorldImpl::GetJoints ( ) const
inlinenoexcept

Gets the world joint range.

Gets a range enumerating the joints currently existing within this world. These are the joints that had been created from previous calls to the CreateJoint(const JointConf&) method that haven't yet been destroyed.

Returns
World joints sized-range.
See also
CreateJoint(const JointConf&).

◆ GetJoints() [2/2]

SizedRange< WorldImpl::BodyJoints::const_iterator > playrho::d2::WorldImpl::GetJoints ( BodyID  id) const
Exceptions
std::out_of_rangeif given an invalid id.

Referenced by playrho::d2::GetJoints().

◆ GetManifold()

const Manifold & playrho::d2::WorldImpl::GetManifold ( ContactID  id) const

Gets the identified manifold.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

Referenced by playrho::d2::GetManifold().

◆ GetProxies() [1/2]

const WorldImpl::Proxies & playrho::d2::WorldImpl::GetProxies ( ) const
inlinenoexcept

Gets the dynamic tree leaves queued for finding new contacts.

See also
FindNewContacts, AddProxies.

Referenced by playrho::d2::GetProxies().

◆ GetProxies() [2/2]

const WorldImpl::Proxies & playrho::d2::WorldImpl::GetProxies ( FixtureID  id) const

Gets the proxies for the identified fixture.

Exceptions
std::out_of_rangeIf given an invalid fixture identifier.

◆ GetSoonestContact()

WorldImpl::ContactToiData playrho::d2::WorldImpl::GetSoonestContact ( const Contacts contacts,
const ArrayAllocator< Contact > &  buffer 
)
staticprivatenoexcept

Gets the soonest contact.

This finds the contact with the lowest (soonest) time of impact.

Returns
Contact with the least time of impact and its time of impact, or null contact. A non-null contact will be enabled, not have sensors, be active, and impenetrable.

Referenced by SolveToi().

◆ GetSubStepping()

bool playrho::d2::WorldImpl::GetSubStepping ( ) const
inlinenoexcept

Gets whether or not sub-stepping is enabled.

See also
SetSubStepping, IsStepComplete.

Referenced by playrho::d2::GetSubStepping(), and SolveToi().

◆ IsStepComplete()

bool playrho::d2::WorldImpl::IsStepComplete ( ) const
inlinenoexcept

Whether or not "step" is complete.

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

Returns
true unless sub-stepping is enabled and the step method returned without finishing all of its sub-steps.
See also
GetSubStepping, SetSubStepping.

Referenced by playrho::d2::IsStepComplete(), SolveToi(), and Step().

◆ operator=()

WorldImpl& playrho::d2::WorldImpl::operator= ( const WorldImpl other)
default

Assignment operator.

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

◆ ProcessContactsForTOI()

WorldImpl::ProcessContactsOutput playrho::d2::WorldImpl::ProcessContactsForTOI ( BodyID  id,
Island island,
Real  toi,
const StepConf conf 
)
private

Processes the contacts of a given body for TOI handling.

This does the following:

  1. Advances the appropriate associated other bodies to the given TOI (advancing their sweeps and synchronizing their transforms to their new sweeps).
  2. Updates the contact manifolds and touching statuses and notifies listener (if one given) of the appropriate contacts of the body.
  3. Adds those contacts that are still enabled and still touching to the given island (or resets the other bodies advancement).
  4. Adds to the island, those other bodies that haven't already been added of the contacts that got added.
    Note
    Precondition: there should be no lower TOI for which contacts have not already been processed.
    Parameters
    [in,out]idIdentifier of the dynamic/accelerable body to process contacts for.
    [in,out]islandIsland. On return this may contain additional contacts or bodies.
    [in]toiTime of impact (TOI). Value between 0 and 1.
    [in]confStep configuration data.

Referenced by SolveToi().

◆ SetBody()

void playrho::d2::WorldImpl::SetBody ( BodyID  id,
const Body value 
)

Sets the identified body.

Exceptions
std::out_of_rangeif given an invalid id.

Referenced by playrho::d2::SetBody().

◆ SetContact()

void playrho::d2::WorldImpl::SetContact ( ContactID  id,
const Contact value 
)

Sets the identified contact's state.

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

Referenced by playrho::d2::SetContact().

◆ SetFixture()

void playrho::d2::WorldImpl::SetFixture ( FixtureID  id,
const FixtureConf value 
)

Sets the identified fixture's state.

Exceptions
std::out_of_rangeIf given an invalid fixture identifier.
std::invalid_argumentIf given an invalid fixture state.

Referenced by playrho::d2::SetFixture().

◆ SetJoint()

void playrho::d2::WorldImpl::SetJoint ( JointID  id,
const Joint def 
)

Sets the identified joint.

Exceptions
std::invalid_argumentIf given an invalid identifier.

Referenced by playrho::d2::SetJoint().

◆ SetStepComplete()

void playrho::d2::WorldImpl::SetStepComplete ( bool  value)
inlineprivatenoexcept

Sets the step complete state.

Postcondition
IsStepComplete() will return the value set.
See also
IsStepComplete.

Referenced by SolveToi().

◆ SetSubStepping()

void playrho::d2::WorldImpl::SetSubStepping ( bool  flag)
inlinenoexcept

Enables/disables single stepped continuous physics.

Note
This is not normally used. Enabling sub-stepping is meant for testing.
Postcondition
The GetSubStepping() method will return the value this method was called with.
See also
IsStepComplete, GetSubStepping.

Referenced by playrho::d2::SetSubStepping().

◆ ShiftOrigin()

void playrho::d2::WorldImpl::ShiftOrigin ( Length2  newOrigin)

Shifts the world origin.

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
newOriginthe new origin with respect to the old origin
Exceptions
WrongStateif this method is called while the world is locked.

Referenced by playrho::d2::ShiftOrigin().

◆ SolveReg()

RegStepStats playrho::d2::WorldImpl::SolveReg ( const StepConf conf)
private

Solves the step.

Finds islands, integrates and solves constraints, solves position constraints.

Note
This may miss collisions involving fast moving bodies and allow them to tunnel through each other.

Referenced by Step().

◆ SolveRegIslandViaGS()

IslandStats playrho::d2::WorldImpl::SolveRegIslandViaGS ( const StepConf conf,
const Island island 
)
private

Solves the given island (regularly).

This:

  1. Updates every island-body's sweep.pos0 to its sweep.pos1.
  2. Updates every island-body's sweep.pos1 to the new normalized "solved" position for it.
  3. Updates every island-body's velocity to the new accelerated, dampened, and "solved" velocity for it.
  4. Synchronizes every island-body's transform (by updating it to transform one of the body's sweep).
  5. Reports to the listener (if non-null).
Parameters
confTime step configuration information.
islandIsland of bodies, contacts, and joints to solve for. Must contain at least one body, contact, or joint.
Warning
Behavior is undefined if the given island doesn't have at least one body, contact, or joint.
Returns
Island solver results.

< Time step.

Referenced by SolveReg().

◆ SolveToi() [1/2]

ToiStepStats playrho::d2::WorldImpl::SolveToi ( const StepConf conf)
private

Solves the step using successive time of impact (TOI) events.

Used for continuous physics.

Note
This is intended to detect and prevent the tunneling that the faster Solve method may miss.
Parameters
confTime step configuration to use.

Referenced by Step().

◆ SolveToi() [2/2]

IslandStats playrho::d2::WorldImpl::SolveToi ( ContactID  contactID,
const StepConf conf 
)
private

Solves collisions for the given time of impact.

Parameters
contactIDIdentifier of contact to solve for.
confTime step configuration to solve for.
Note
Precondition 1: there is no contact having a lower TOI in this time step that has not already been solved for.
Precondition 2: there is not a lower TOI in the time step for which collisions have not already been processed.

◆ SolveToiViaGS()

IslandStats playrho::d2::WorldImpl::SolveToiViaGS ( const Island island,
const StepConf conf 
)
private

Solves the time of impact for bodies 0 and 1 of the given island.

This:

  1. Updates position 0 of the sweeps of bodies 0 and 1.
  2. Updates position 1 of the sweeps, the transforms, and the velocities of the other bodies in this island.
Precondition
island.bodies contains at least two bodies, the first two of which are bodies 0 and 1.
island.bodies contains appropriate other bodies of the contacts of the two bodies.
island.contacts contains the contact that specified the two identified bodies.
island.contacts contains appropriate other contacts of the two bodies.
Parameters
confTime step configuration information.
islandIsland to do time of impact solving for.
Returns
Island solver results.

Referenced by SolveToi().

◆ Step()

StepStats playrho::d2::WorldImpl::Step ( const StepConf conf)

Steps the world simulation according to the given configuration.

Performs position and velocity updating, sleeping of non-moving bodies, updating of the contacts, and notifying the contact listener of begin-contact, end-contact, pre-solve, and post-solve events.

Warning
Behavior is undefined 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 proxy handling being processed. No physics is performed.
If the given velocity and position iterations are zero, this method 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.
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.
The bodies for proxies queue will be empty.
The fixtures for proxies queue will be empty.
Parameters
confConfiguration for the simulation step.
Returns
Statistics for the step.
Exceptions
WrongStateif this method is called while the world is locked.
See also
GetBodiesForProxies, GetFixturesForProxies.

Referenced by playrho::d2::Step().

◆ Synchronize()

ContactCounter playrho::d2::WorldImpl::Synchronize ( const Fixtures fixtures,
const Transformation xfm1,
const Transformation xfm2,
Real  multiplier,
Length  extension 
)
private

Synchronizes the given body.

This updates the broad phase dynamic tree data for all of the given fixtures.

Referenced by SolveReg(), SolveToi(), and SynchronizeProxies().

◆ Update()

void playrho::d2::WorldImpl::Update ( ContactID  id,
const ContactUpdateConf conf 
)
private

Updates the touching related state and notifies listener (if one given).

Note
Ideally this method is only called when a dependent change has occurred.
Touching related state depends on the following data:
  • The fixtures' sensor states.
  • The fixtures bodies' transformations.
  • The maxCirclesRatio per-step configuration state OR the maxDistanceIters per-step configuration state.
Parameters
idIdentifies the contact to update.
confPer-step configuration information.
See also
GetManifold, IsTouching

Referenced by ProcessContactsForTOI(), SolveToi(), and UpdateContacts().

◆ UpdateBody()

bool playrho::d2::WorldImpl::UpdateBody ( Body body,
const Position pos 
)
staticprivate

Updates the given body.

Updates the given body's sweep position 1, and its transformation.

Parameters
bodyBody to update.
posNew position to set the given body to.
Returns
true if body's contacts should be flagged for updating, otherwise false.

Referenced by SolveRegIslandViaGS(), and SolveToiViaGS().

Friends And Related Function Documentation

◆ CreateFixture()

FixtureID CreateFixture ( WorldImpl world,
const FixtureConf def 
)
related

Creates a fixture per the given configuration.

See also
Destroy(WorldImpl& world, FixtureID id).

◆ Destroy()

bool Destroy ( WorldImpl world,
FixtureID  id 
)
related

Destroys the identified fixture.

Exceptions
std::out_of_rangeIf given an invalid fixture identifier.
See also
CreateFixture(WorldImpl& world, const FixtureConf& def).

◆ GetBodiesForProxies()

SizedRange< std::vector< BodyID >::const_iterator > GetBodiesForProxies ( const WorldImpl world)
related

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

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

See also
WorldImpl::Step.

◆ GetBody()

const Body & GetBody ( const WorldImpl world,
BodyID  id 
)
related

Gets the body configuration for the identified body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetBodyRange()

BodyCounter GetBodyRange ( const WorldImpl world)
related

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.

◆ GetContact()

const Contact & GetContact ( const WorldImpl world,
ContactID  id 
)
related

Gets the identified contact.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ GetContactRange()

ContactCounter GetContactRange ( const WorldImpl world)
related

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()

SizedRange< std::vector< KeyedContactPtr >::const_iterator > GetContacts ( const WorldImpl world,
BodyID  id 
)
related

Gets the container of all contacts attached to this body.

Warning
This collection changes during the time step and you may miss some collisions if you don't use ContactListener.
Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetFixture()

const FixtureConf & GetFixture ( const WorldImpl world,
FixtureID  id 
)
related

Gets the identified fixture state.

Exceptions
std::out_of_rangeIf given an invalid fixture identifier.

◆ GetFixtureRange()

FixtureCounter GetFixtureRange ( const WorldImpl world)
related

Gets the extent of the currently valid fixture range.

Note
This is one higher than the maxium FixtureID that is in range for fixture related functions.

◆ GetFixtures()

SizedRange< std::vector< FixtureID >::const_iterator > GetFixtures ( const WorldImpl world,
BodyID  id 
)
related

Gets the range of all constant fixtures attached to the given body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetFixturesForProxies()

SizedRange< std::vector< FixtureID >::const_iterator > GetFixturesForProxies ( const WorldImpl world)
related

Gets the fixtures-for-proxies range for this world.

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

See also
Step.

◆ GetInvDeltaTime()

Frequency GetInvDeltaTime ( const WorldImpl world)
related

Gets the inverse delta time.

Gets the inverse delta time that was set on construction or assignment, and updated on every call to the Step() method having a non-zero delta-time.

See also
Step.

◆ GetJointRange()

JointCounter GetJointRange ( const WorldImpl world)
related

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()

SizedRange< std::vector< std::pair< BodyID, JointID > >::const_iterator > GetJoints ( const WorldImpl world,
BodyID  id 
)
related

Gets the range of all joints attached to this body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ GetProxy()

ContactCounter GetProxy ( const WorldImpl world,
FixtureID  id,
ChildCounter  child 
)
related

Gets the specified proxy of the identified fixture.

Exceptions
std::out_of_rangeIf given an invalid fixture identifier.

◆ GetProxyCount()

ChildCounter GetProxyCount ( const WorldImpl world,
FixtureID  id 
)
related

Gets the count of proxies of the identified fixture.

Exceptions
std::out_of_rangeIf given an invalid fixture identifier.

◆ GetSubStepping()

bool GetSubStepping ( const WorldImpl world)
related

Gets whether or not sub-stepping is enabled.

See also
SetSubStepping, IsStepComplete.

◆ IsStepComplete()

bool IsStepComplete ( const WorldImpl world)
related

Whether or not "step" is complete.

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

Returns
true unless sub-stepping is enabled and the step method returned without finishing all of its sub-steps.
See also
GetSubStepping, SetSubStepping.

◆ SetBody()

void SetBody ( WorldImpl world,
BodyID  id,
const Body value 
)
related

Sets the body state for the identified body.

Exceptions
std::out_of_rangeIf given an invalid body identifier.

◆ SetContact()

void SetContact ( WorldImpl world,
ContactID  id,
const Contact value 
)
related

Sets the identified contact's state.

Exceptions
std::out_of_rangeIf given an invalid contact identifier.

◆ SetFixture()

void SetFixture ( WorldImpl world,
FixtureID  id,
const FixtureConf value 
)
related

Sets the identified fixture's state.

Exceptions
std::out_of_rangeIf given an invalid fixture identifier.

◆ SetSubStepping()

void SetSubStepping ( WorldImpl world,
bool  value 
)
related

Enables/disables single stepped continuous physics.

Note
This is not normally used. Enabling sub-stepping is meant for testing.
Postcondition
The GetSubStepping() method will return the value this method was called with.
See also
IsStepComplete, GetSubStepping.

◆ ShiftOrigin()

void ShiftOrigin ( WorldImpl world,
Length2  newOrigin 
)
related

Shifts the world origin.

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 should be shifted.
newOriginthe new origin with respect to the old origin
Exceptions
WrongStateif this method is called while the world is locked.

Member Data Documentation

◆ m_bodyFixtures

ArrayAllocator<Fixtures> playrho::d2::WorldImpl::m_bodyFixtures
private

Cache of fixtures associated with bodies.

Todo:
Consider eliminating this variable since calling GetFixtures() isn't done within the World::Step except by World::Synchronize which may be replacable with iterating over the entire fixture array.

Referenced by AddFixture(), Clear(), CreateBody(), Destroy(), GetFixtures(), RemoveFixture(), SetBody(), SolveReg(), SolveToi(), and SynchronizeProxies().

◆ m_contacts

Contacts playrho::d2::WorldImpl::m_contacts
private

Container of contacts.

Note
In the add pair stress-test, 401 bodies can have some 31000 contacts during a given time step.

Referenced by Add(), Clear(), Destroy(), GetContacts(), SolveReg(), SolveToi(), Step(), and UpdateContacts().

◆ m_inv_dt0

Frequency playrho::d2::WorldImpl::m_inv_dt0 = 0
private

Inverse delta-t from previous step.

Used to compute time step ratio to support a variable time step.

Note
4-bytes large.
See also
Step.

Referenced by GetInvDeltaTime(), and Step().

◆ m_maxVertexRadius

Positive<Length> playrho::d2::WorldImpl::m_maxVertexRadius
private

Maximum vertex radius.

This is the maximum shape vertex radius that any bodies' of this world should create fixtures for. Requests to create fixtures for shapes with vertex radiuses bigger than this must be rejected. As an upper bound, this value prevents shapes from getting associated with this world that would otherwise not be able to be simulated due to numerical issues. It can also be set below this upper bound to constrain the differences between shape vertex radiuses to possibly more limited visual ranges.

Referenced by GetMaxVertexRadius(), and Step().


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