Definition of a "world" implementation. More...
#include <WorldImpl.hpp>
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... | |
WorldImpl & | operator= (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 DynamicTree & | GetTree () const noexcept |
Gets access to the broad-phase dynamic tree information. | |
bool | IsLocked () const noexcept |
Is the world locked (in the middle of a time step). | |
void | ShiftOrigin (Length2 newOrigin) |
Shifts the world origin. More... | |
Length | GetMinVertexRadius () const noexcept |
Gets the minimum vertex radius that shapes in this world can be. | |
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 Proxies & | GetProxies () 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 Body & | GetBody (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 FixtureConf & | GetFixture (FixtureID id) const |
Gets the identified fixture state. More... | |
void | SetFixture (FixtureID id, const FixtureConf &value) |
Sets the identified fixture's state. More... | |
bool | Destroy (FixtureID 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 Proxies & | GetProxies (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 Joint & | GetJoint (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 Contact & | GetContact (ContactID id) const |
Gets the identified contact. More... | |
void | SetContact (ContactID id, const Contact &value) |
Sets the identified contact's state. More... | |
const Manifold & | GetManifold (ContactID id) const |
Gets the 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< Body > | m_bodyBuffer |
Array of body data both used and freed. | |
ArrayAllocator< Contacts > | m_bodyContacts |
Cache of contacts associated with bodies. | |
ArrayAllocator< BodyJoints > | m_bodyJoints |
Cache of joints associated with bodies. | |
ArrayAllocator< Fixtures > | m_bodyFixtures |
Cache of fixtures associated with bodies. More... | |
ArrayAllocator< FixtureConf > | m_fixtureBuffer |
Array of fixture data both used and freed. | |
ArrayAllocator< Proxies > | m_fixtureProxies |
Array of arrays of dynamic tree leaves. | |
ArrayAllocator< Joint > | m_jointBuffer |
Array of joint data both used and freed. | |
ArrayAllocator< Contact > | m_contactBuffer |
Array of contact data both used and freed. | |
ArrayAllocator< Manifold > | m_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< Length > | m_minVertexRadius |
Minimum vertex radius. | |
Positive< Length > | m_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 Body & | GetBody (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 Contact & | GetContact (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 FixtureConf & | GetFixture (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 Joint & | GetJoint (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 DynamicTree & | GetTree (const WorldImpl &world) noexcept |
Gets access to the broad-phase dynamic tree information. | |
Definition of a "world" implementation.
using playrho::d2::WorldImpl::Joints = std::vector<JointID> |
Joints container type.
|
private |
Flag enumeration.
Enumerator | |
---|---|
e_newFixture | New fixture. |
e_locked | Locked. |
e_substepping | Sub-stepping. |
e_stepComplete | Step complete. Used for sub-stepping.
|
|
explicit |
Constructs a world implementation for a world.
def | A customized world configuration or its default value. |
StepConf
data that's given to the world's Step
method. InvalidArgument | if the given max vertex radius is less than the min. |
|
default |
Copy constructor.
Copy constructs this world with a deep copy of the given world.
|
noexcept |
|
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:
ShouldCollide
).contacts
collection is one greater-than it was before this method is called if it returns true
. key | ID's of dynamic tree entries identifying the fixture proxies involved. |
true
if a new contact was indeed added (and created), else false
.
|
inline |
Adds the given dynamic tree leaves to the queue for finding new contacts.
Referenced by CreateAndDestroyProxies(), SetBody(), and SetFixture().
|
private |
Adds to the island based off of a given "seed" body.
Referenced by SolveReg().
|
noexcept |
Clears this world.
Referenced by ~WorldImpl().
BodyID playrho::d2::WorldImpl::CreateBody | ( | const BodyConf & | def = GetDefaultBodyConf() | ) |
Creates a rigid body with the given configuration.
GetBodies()
method. def | A customized body configuration or its default value. |
Destroy(BodyID)
method. WrongState | if this method is called while the world is locked. |
LengthError | if this operation would create more than MaxBodies . |
Referenced by playrho::d2::CreateBody().
FixtureID playrho::d2::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.
GetFixtures()
methods. def | Initial fixture settings. Friction and density must be >= 0. Restitution must be > -infinity and < infinity. |
WrongState | if called while the world is "locked". |
InvalidArgument | if called for a shape with a vertex radius less than the minimum vertex radius. |
InvalidArgument | if called for a shape with a vertex radius greater than the maximum vertex radius. |
Referenced by playrho::d2::CreateFixture(), and SetFixture().
Creates a joint to constrain one or more bodies.
GetJoints()
method. Destroy(JointID)
method. WrongState | if this method is called while the world is locked. |
LengthError | if this operation would create more than MaxJoints . |
InvalidArgument | if the given definition is not allowed. |
Referenced by playrho::d2::CreateJoint().
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.
GetBodies()
method. id | Body to destroy that had been created by this world. |
WrongState | if this method is called while the world is locked. |
Referenced by CreateAndDestroyProxies(), Destroy(), playrho::d2::Destroy(), SetBody(), and SetFixture().
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.
contact | Contact to destroy. |
from | From body. |
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.
fixture | the fixture to be removed. |
WrongState | if this method is called while the world is locked. |
std::out_of_range | If given an invalid fixture identifier. |
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.
GetJoints()
method. joint | Joint to destroy that had been created by this world. |
WrongState | if this method is called while the world is locked. |
std::invalid_argument | If given an invalid identifier. |
|
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().
ContactCounter playrho::d2::WorldImpl::FindNewContacts | ( | ) |
Finds new contacts.
Processes the proxy queue for finding new contacts and adding them to the contacts container.
GetProxies()
will return an empty container. Referenced by SolveReg(), SolveToi(), and Step().
|
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.
Referenced by playrho::d2::GetBodies(), and ShiftOrigin().
|
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.
Referenced by playrho::d2::GetBodiesForProxies().
Gets the identified body.
std::out_of_range | if given an invalid id. |
Referenced by Destroy(), playrho::d2::GetBody(), and SetBody().
|
noexcept |
Gets the extent of the currently valid body range.
BodyID
that is in range for body related functions. Gets the identified contact.
std::out_of_range | If given an invalid contact identifier. |
Referenced by playrho::d2::GetContact().
|
noexcept |
Gets the extent of the currently valid contact range.
ContactID
that is in range for contact related functions.
|
inlinenoexcept |
Gets the world contact range.
ContactListener
to avoid missing contacts. SizedRange< WorldImpl::Contacts::const_iterator > playrho::d2::WorldImpl::GetContacts | ( | BodyID | id | ) | const |
Gets the contacts associated with the identified body.
std::out_of_range | if given an invalid id. |
Referenced by playrho::d2::GetContacts().
const FixtureConf & playrho::d2::WorldImpl::GetFixture | ( | FixtureID | id | ) | const |
Gets the identified fixture state.
std::out_of_range | If given an invalid fixture identifier. |
Referenced by Destroy(), and playrho::d2::GetFixture().
|
noexcept |
Gets the extent of the currently valid fixture range.
FixtureID
that is in range for fixture related functions.
|
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.
Referenced by playrho::d2::GetFixturesForProxies().
|
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.
Referenced by playrho::d2::GetInvDeltaTime().
Gets the identified joint.
std::invalid_argument | If given an invalid identifier. |
Referenced by playrho::d2::GetJoint().
|
noexcept |
Gets the extent of the currently valid joint range.
JointID
that is in range for joint related functions.
|
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.
SizedRange< WorldImpl::BodyJoints::const_iterator > playrho::d2::WorldImpl::GetJoints | ( | BodyID | id | ) | const |
std::out_of_range | if given an invalid id. |
Referenced by playrho::d2::GetJoints().
Gets the identified manifold.
std::out_of_range | If given an invalid contact identifier. |
Referenced by playrho::d2::GetManifold().
|
inlinenoexcept |
Gets the dynamic tree leaves queued for finding new contacts.
Referenced by playrho::d2::GetProxies().
const WorldImpl::Proxies & playrho::d2::WorldImpl::GetProxies | ( | FixtureID | id | ) | const |
Gets the proxies for the identified fixture.
std::out_of_range | If given an invalid fixture identifier. |
|
staticprivatenoexcept |
Gets the soonest contact.
This finds the contact with the lowest (soonest) time of impact.
Referenced by SolveToi().
|
inlinenoexcept |
Gets whether or not sub-stepping is enabled.
Referenced by playrho::d2::GetSubStepping(), and SolveToi().
|
inlinenoexcept |
Whether or not "step" is complete.
The "step" is completed when there are no more TOI events for the current time step.
true
unless sub-stepping is enabled and the step method returned without finishing all of its sub-steps. Referenced by playrho::d2::IsStepComplete(), SolveToi(), and Step().
Assignment operator.
Copy assigns this world with a deep copy of the given world.
|
private |
Processes the contacts of a given body for TOI handling.
This does the following:
[in,out] | id | Identifier of the dynamic/accelerable body to process contacts for. |
[in,out] | island | Island. On return this may contain additional contacts or bodies. |
[in] | toi | Time of impact (TOI). Value between 0 and 1. |
[in] | conf | Step configuration data. |
Referenced by SolveToi().
Sets the identified body.
std::out_of_range | if given an invalid id. |
Referenced by playrho::d2::SetBody().
Sets the identified contact's state.
std::out_of_range | If given an invalid contact identifier. |
Referenced by playrho::d2::SetContact().
void playrho::d2::WorldImpl::SetFixture | ( | FixtureID | id, |
const FixtureConf & | value | ||
) |
Sets the identified fixture's state.
std::out_of_range | If given an invalid fixture identifier. |
std::invalid_argument | If given an invalid fixture state. |
Referenced by playrho::d2::SetFixture().
Sets the identified joint.
std::invalid_argument | If given an invalid identifier. |
Referenced by playrho::d2::SetJoint().
|
inlineprivatenoexcept |
Sets the step complete state.
IsStepComplete()
will return the value set. Referenced by SolveToi().
|
inlinenoexcept |
Enables/disables single stepped continuous physics.
GetSubStepping()
method will return the value this method was called with. Referenced by playrho::d2::SetSubStepping().
void playrho::d2::WorldImpl::ShiftOrigin | ( | Length2 | newOrigin | ) |
Shifts the world origin.
position -= newOrigin
. newOrigin | the new origin with respect to the old origin |
WrongState | if this method is called while the world is locked. |
Referenced by playrho::d2::ShiftOrigin().
|
private |
Solves the step.
Finds islands, integrates and solves constraints, solves position constraints.
Referenced by Step().
|
private |
Solves the given island (regularly).
This:
sweep.pos0
to its sweep.pos1
.sweep.pos1
to the new normalized "solved" position for it.conf | Time step configuration information. |
island | Island of bodies, contacts, and joints to solve for. Must contain at least one body, contact, or joint. |
< Time step.
Referenced by SolveReg().
|
private |
Solves the step using successive time of impact (TOI) events.
Used for continuous physics.
conf | Time step configuration to use. |
Referenced by Step().
|
private |
Solves collisions for the given time of impact.
contactID | Identifier of contact to solve for. |
conf | Time step configuration to solve for. |
|
private |
Solves the time of impact for bodies 0 and 1 of the given island.
This:
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.conf | Time step configuration information. |
island | Island to do time of impact solving for. |
Referenced by SolveToi().
Steps the world simulation according to the given configuration.
Performs position and velocity updating, sleeping of non-moving bodies, updating of the contacts, and notifying the contact listener of begin-contact, end-contact, pre-solve, and post-solve events.
p0
) going velocity 0 (v0
) fast with a sum acceleration of a
, after time t
and barring any collisions, will have a new velocity (v1
) of v0 + (a * t)
and a new position (p1
) of p0 + v1 * t
.conf | Configuration for the simulation step. |
WrongState | if this method is called while the world is locked. |
Referenced by playrho::d2::Step().
|
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().
|
private |
Updates the touching related state and notifies listener (if one given).
maxCirclesRatio
per-step configuration state OR the maxDistanceIters
per-step configuration state.id | Identifies the contact to update. |
conf | Per-step configuration information. |
Referenced by ProcessContactsForTOI(), SolveToi(), and UpdateContacts().
Updates the given body.
Updates the given body's sweep position 1, and its transformation.
body | Body to update. |
pos | New position to set the given body to. |
true
if body's contacts should be flagged for updating, otherwise false
. Referenced by SolveRegIslandViaGS(), and SolveToiViaGS().
|
related |
Creates a fixture per the given configuration.
Destroys the identified fixture.
std::out_of_range | If given an invalid fixture identifier. |
|
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.
Gets the body configuration for the identified body.
std::out_of_range | If given an invalid body identifier. |
|
related |
Gets the extent of the currently valid body range.
Gets the identified contact.
std::out_of_range | If given an invalid contact identifier. |
|
related |
Gets the extent of the currently valid contact range.
ContactID
that is in range for contact related functions.
|
related |
Gets the container of all contacts attached to this body.
ContactListener
. std::out_of_range | If given an invalid body identifier. |
|
related |
Gets the identified fixture state.
std::out_of_range | If given an invalid fixture identifier. |
|
related |
Gets the extent of the currently valid fixture range.
FixtureID
that is in range for fixture related functions.
|
related |
Gets the range of all constant fixtures attached to the given body.
std::out_of_range | If given an invalid body identifier. |
|
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.
|
related |
Gets the extent of the currently valid joint range.
JointID
that is in range for joint related functions.
|
related |
Gets the range of all joints attached to this body.
std::out_of_range | If given an invalid body identifier. |
|
related |
Gets the specified proxy of the identified fixture.
std::out_of_range | If given an invalid fixture identifier. |
|
related |
Gets the count of proxies of the identified fixture.
std::out_of_range | If given an invalid fixture identifier. |
|
related |
Gets whether or not sub-stepping is enabled.
|
related |
Whether or not "step" is complete.
The "step" is completed when there are no more TOI events for the current time step.
true
unless sub-stepping is enabled and the step method returned without finishing all of its sub-steps. Sets the body state for the identified body.
std::out_of_range | If given an invalid body identifier. |
Sets the identified contact's state.
std::out_of_range | If given an invalid contact identifier. |
|
related |
Sets the identified fixture's state.
std::out_of_range | If given an invalid fixture identifier. |
|
related |
Enables/disables single stepped continuous physics.
GetSubStepping()
method will return the value this method was called with. Shifts the world origin.
position -= newOrigin
. world | The world whose origin should be shifted. |
newOrigin | the new origin with respect to the old origin |
WrongState | if this method is called while the world is locked. |
|
private |
Cache of fixtures associated with bodies.
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().
|
private |
Container of contacts.
Referenced by Add(), Clear(), Destroy(), GetContacts(), SolveReg(), SolveToi(), Step(), and UpdateContacts().
|
private |
Inverse delta-t from previous step.
Used to compute time step ratio to support a variable time step.
Referenced by GetInvDeltaTime(), and Step().
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().