An AABB dynamic-tree based world implementation. More...
#include <playrho/d2/AabbTreeWorld.hpp>
Classes | |
struct | ContactUpdateConf |
The contact updating configuration. More... | |
Public Types | |
using | ProxyKey = std::tuple< ContactKey, Contactable, Contactable > |
Broad phase generated data for identifying potentially new contacts. More... | |
Public Member Functions | |
AabbTreeWorld (AabbTreeWorld &&other) noexcept | |
Move constructor. More... | |
AabbTreeWorld (const AabbTreeWorld &other) | |
Copy constructor. More... | |
AabbTreeWorld (const WorldConf &conf=WorldConf{}) | |
Constructs a world implementation for a world. More... | |
~AabbTreeWorld () noexcept | |
Destructor. More... | |
AabbTreeWorld & | operator= (AabbTreeWorld &&other)=delete |
Move assignment is explicitly deleted. More... | |
AabbTreeWorld & | operator= (const AabbTreeWorld &other)=delete |
Copy assignment is explicitly deleted. More... | |
Friends | |
void | Clear (AabbTreeWorld &world) noexcept |
Clears this world. More... | |
BodyID | CreateBody (AabbTreeWorld &world, Body body) |
Creates a rigid body that's a copy of the given one. More... | |
JointID | CreateJoint (AabbTreeWorld &world, Joint def) |
Creates a joint to constrain one or more bodies. More... | |
ShapeID | CreateShape (AabbTreeWorld &world, Shape def) |
Creates an identifiable copy of the given shape within this world. More... | |
void | Destroy (AabbTreeWorld &world, BodyID id) |
Destroys the identified body. More... | |
void | Destroy (AabbTreeWorld &world, JointID id) |
Destroys a joint. More... | |
void | Destroy (AabbTreeWorld &world, ShapeID id) |
Destroys the identified shape removing any body associations with it first. More... | |
const BodyIDs & | GetBodies (const AabbTreeWorld &world) noexcept |
Gets a container of valid world body identifiers for this constant world. More... | |
const BodyIDs & | GetBodiesForProxies (const AabbTreeWorld &world) noexcept |
Gets the bodies-for-proxies container for this world. More... | |
const Body & | GetBody (const AabbTreeWorld &world, BodyID id) |
Gets the identified body. More... | |
BodyCounter | GetBodyRange (const AabbTreeWorld &world) noexcept |
Gets the extent of the currently valid body range. More... | |
const Contact & | GetContact (const AabbTreeWorld &world, ContactID id) |
Gets the identified contact. More... | |
ContactCounter | GetContactRange (const AabbTreeWorld &world) noexcept |
Gets the extent of the currently valid contact range. More... | |
KeyedContactIDs | GetContacts (const AabbTreeWorld &world) |
Gets a container of valid world contact identifiers. More... | |
const BodyContactIDs & | GetContacts (const AabbTreeWorld &world, BodyID id) |
Gets the contacts associated with the identified body. More... | |
const BodyShapeIDs & | GetFixturesForProxies (const AabbTreeWorld &world) noexcept |
Gets the fixtures-for-proxies for this world. More... | |
Frequency | GetInvDeltaTime (const AabbTreeWorld &world) noexcept |
Gets the inverse delta time. More... | |
const Joint & | GetJoint (const AabbTreeWorld &world, JointID id) |
Gets the identified joint. More... | |
JointCounter | GetJointRange (const AabbTreeWorld &world) noexcept |
Gets the extent of the currently valid joint range. More... | |
const JointIDs & | GetJoints (const AabbTreeWorld &world) noexcept |
Gets the container of joint IDs of the given world. More... | |
const BodyJointIDs & | GetJoints (const AabbTreeWorld &world, BodyID id) |
const Manifold & | GetManifold (const AabbTreeWorld &world, ContactID id) |
Gets the identified manifold. More... | |
const ProxyIDs & | GetProxies (const AabbTreeWorld &world) noexcept |
Gets the dynamic tree leaves queued for finding new contacts. | |
const ProxyIDs & | GetProxies (const AabbTreeWorld &world, BodyID id) |
Gets the proxies for the identified body. More... | |
std::optional< pmr::StatsResource::Stats > | GetResourceStats (const AabbTreeWorld &world) noexcept |
Gets the resource statistics of the specified world. | |
const Shape & | GetShape (const AabbTreeWorld &world, ShapeID id) |
Gets the identified shape. More... | |
ShapeCounter | GetShapeRange (const AabbTreeWorld &world) noexcept |
Gets the extent of the currently valid shape range. More... | |
bool | GetSubStepping (const AabbTreeWorld &world) noexcept |
Gets whether or not sub-stepping is enabled. More... | |
const DynamicTree & | GetTree (const AabbTreeWorld &world) noexcept |
Gets access to the broad-phase dynamic tree information. | |
Interval< Positive< Length > > | GetVertexRadiusInterval (const AabbTreeWorld &world) noexcept |
Gets the vertex radius interval allowable for the given world. More... | |
bool | IsLocked (const AabbTreeWorld &world) noexcept |
Is the world locked (in the middle of a time step). | |
bool | IsStepComplete (const AabbTreeWorld &world) noexcept |
Whether or not "step" is complete. More... | |
bool | operator!= (const AabbTreeWorld &lhs, const AabbTreeWorld &rhs) |
Inequality operator for world comparisons. | |
bool | operator== (const AabbTreeWorld &lhs, const AabbTreeWorld &rhs) |
Equality operator for world comparisons. | |
void | SetBeginContactListener (AabbTreeWorld &world, ContactFunction listener) noexcept |
Register a begin contact event listener. | |
void | SetBody (AabbTreeWorld &world, BodyID id, Body value) |
Sets the identified body. More... | |
void | SetContact (AabbTreeWorld &world, ContactID id, Contact value) |
Sets the identified contact's state. More... | |
void | SetDetachListener (AabbTreeWorld &world, BodyShapeFunction listener) noexcept |
Registers a detach listener for shapes detaching from bodies. | |
void | SetEndContactListener (AabbTreeWorld &world, ContactFunction listener) noexcept |
Register an end contact event listener. | |
void | SetJoint (AabbTreeWorld &world, JointID id, Joint def) |
Sets the identified joint. More... | |
void | SetJointDestructionListener (AabbTreeWorld &world, JointFunction listener) noexcept |
Register a destruction listener for joints. More... | |
void | SetManifold (AabbTreeWorld &world, ContactID id, const Manifold &value) |
Sets the identified manifold. More... | |
void | SetPostSolveContactListener (AabbTreeWorld &world, ContactImpulsesFunction listener) noexcept |
Register a post-solve contact event listener. | |
void | SetPreSolveContactListener (AabbTreeWorld &world, ContactManifoldFunction listener) noexcept |
Register a pre-solve contact event listener. | |
void | SetShape (AabbTreeWorld &world, ShapeID id, Shape def) |
Sets the value of the identified shape. More... | |
void | SetShapeDestructionListener (AabbTreeWorld &world, ShapeFunction listener) noexcept |
Registers a destruction listener for shapes. More... | |
void | SetSubStepping (AabbTreeWorld &world, bool flag) noexcept |
Enables/disables single stepped continuous physics. More... | |
void | ShiftOrigin (AabbTreeWorld &world, const Length2 &newOrigin) |
Shifts the world origin. More... | |
StepStats | Step (AabbTreeWorld &world, const StepConf &conf) |
Steps the world simulation according to the given configuration. More... | |
Related Functions | |
(Note that these are not member functions.) | |
void | Attach (AabbTreeWorld &world, BodyID id, ShapeID shapeID) |
Associates a validly identified shape with the validly identified body. More... | |
BodyID | CreateBody (AabbTreeWorld &world, const BodyConf &def) |
Creates a body within the world that's a copy of the given one. | |
bool | Detach (AabbTreeWorld &world, BodyID id, ShapeID shapeID) |
Disassociates a validly identified shape from the validly identified body. More... | |
const std::vector< ShapeID > & | GetShapes (const AabbTreeWorld &world, BodyID id) |
Disassociates all of the associated shape from the validly identified body. More... | |
An AABB dynamic-tree based world implementation.
using playrho::d2::AabbTreeWorld::ProxyKey = std::tuple<ContactKey, Contactable, Contactable> |
Broad phase generated data for identifying potentially new contacts.
Stores the contact-key followed by the key's min contactable then max contactable data.
Constructs a world implementation for a world.
conf | A customized world configuration or its default value. |
StepConf
data that's given to the world's Step
function. GetResourceStats(const AabbTreeWorld&)
for this world returns an empty value if conf.doStats
is false, a non-empty value otherwise. GetVertexRadiusInterval(const AabbTreeWorld&)
for this world returns conf.vertexRadius
. playrho::d2::AabbTreeWorld::AabbTreeWorld | ( | const AabbTreeWorld & | other | ) |
Copy constructor.
Basically copy constructs this world as a deep copy of the given world.
GetResourceStats(const AabbTreeWorld&)
for this world returns an empty value if GetResourceStats(other)
returns an empty value, a non-empty value that's zero initialized otherwise. GetVertexRadiusInterval(const AabbTreeWorld&)
for this world returns the same value as GetVertexRadiusInterval(other)
.
|
noexcept |
Move constructor.
GetResourceStats(const AabbTreeWorld&)
for this world returns an empty value if GetResourceStats(other)
returned an empty value, a non-empty value that's zero initialized otherwise. GetVertexRadiusInterval(const AabbTreeWorld&)
for this world returns the value of GetVertexRadiusInterval(other)
just before this call.
|
noexcept |
|
delete |
Move assignment is explicitly deleted.
|
delete |
Copy assignment is explicitly deleted.
|
related |
Associates a validly identified shape with the validly identified body.
std::out_of_range | If given an invalid body or shape identifier. |
WrongState | if this function is called while the world is locked. |
|
friend |
Clears this world.
Referenced by ~AabbTreeWorld().
|
friend |
Creates a rigid body that's a copy of the given one.
GetBodies(const AabbTreeWorld&)
function. world | The world within which to create the body. |
body | A customized body or its default value. |
Destroy(BodyID)
function. WrongState | if this function is called while the world is locked. |
LengthError | if this operation would create more than MaxBodies . |
std::out_of_range | if the given body references any invalid shape identifiers. |
|
friend |
Creates a joint to constrain one or more bodies.
GetJoints(const AabbTreeWorld&)
function. Destroy(JointID)
function. WrongState | if this function is called while the world is locked. |
LengthError | if this operation would create more than MaxJoints . |
InvalidArgument | if the given definition is not allowed. |
std::out_of_range | if the given joint references any invalid body id. |
|
friend |
Creates an identifiable copy of the given shape within this world.
InvalidArgument | if called for a shape with a vertex radius that's not within the world's allowable vertex radius interval. |
WrongState | if this function is called while the world is locked. |
LengthError | if this operation would create more than MaxShapes . |
|
friend |
Destroys the identified body.
Destroys a given body that had previously been created by a call to this world's CreateBody(const Body&)
function.
world | The world within which the identified body is to be destroyed. |
id | Identifier of body to destroy that had been created by this world. |
WrongState | if this function is called while the world is locked. |
std::out_of_range | If given an invalid body identifier. |
GetBodies(const AabbTreeWorld&)
function; none of the body's fixtures will be present in the fixtures-for-proxies collection; IsDestroyed(const AabbTreeWorld& world, BodyID)
for world
and id
returns true.
|
friend |
Destroys a joint.
Destroys a given joint that had previously been created by a call to this world's CreateJoint(const Joint&)
function.
world | The world within which the identified joint is to be destroyed. |
id | Identifier of joint to destroy that had been created by this world. |
GetJoints(const AabbTreeWorld&)
function; IsDestroyed(const AabbTreeWorld&,JointID)
returns true. WrongState | if this function is called while the world is locked. |
|
friend |
Destroys the identified shape removing any body associations with it first.
world | The world from which the identified shape is to be destroyed. |
id | Identifier of the shape to destroy. |
WrongState | if this function is called while the world is locked. |
std::out_of_range | If given an invalid shape identifier. |
IsDestroyed(const AabbTreeWorld& world, ShapeID)
for world
and id
returns true.
|
related |
Disassociates a validly identified shape from the validly identified body.
std::out_of_range | If given an invalid body or shape identifier. |
WrongState | if this function is called while the world is locked. |
|
friend |
Gets a container of valid world body identifiers for this constant world.
Gets a container of identifiers of bodies currently existing within this world. These are the bodies that had been created from previous calls to the CreateBody(const Body&)
function that haven't yet been destroyed.
|
friend |
Gets the bodies-for-proxies container for this world.
Provides insight on what bodies have been queued for proxy processing during the next call to the world step function.
|
friend |
Gets the identified body.
std::out_of_range | if given an invalid id. |
|
friend |
Gets the extent of the currently valid body range.
BodyID
that is in range for body related functions.
|
friend |
Gets the identified contact.
std::out_of_range | If given an invalid contact identifier. |
|
friend |
Gets the extent of the currently valid contact range.
ContactID
that is in range for contact related functions.
|
friend |
Gets a container of valid world contact identifiers.
ContactFunction
to avoid missing contacts.
|
friend |
Gets the contacts associated with the identified body.
std::out_of_range | if given an invalid id. |
|
friend |
Gets the fixtures-for-proxies for this world.
Provides insight on what fixtures have been queued for proxy processing during the next call to the world step function.
|
friend |
|
friend |
Gets the identified joint.
std::out_of_range | if given an invalid ID. |
|
friend |
Gets the extent of the currently valid joint range.
JointID
that is in range for joint related functions.
|
friend |
Gets the container of joint IDs of the given world.
Gets a container enumerating the joints currently existing within this world. These are the joints that had been created from previous calls to the CreateJoint(const Joint&)
function that haven't yet been destroyed.
|
friend |
std::out_of_range | if given an invalid id. |
|
friend |
Gets the identified manifold.
std::out_of_range | If given an invalid contact identifier. |
|
friend |
Gets the proxies for the identified body.
std::out_of_range | If given an invalid identifier. |
|
friend |
Gets the identified shape.
std::out_of_range | If given an invalid shape identifier. |
|
friend |
Gets the extent of the currently valid shape range.
ShapeID
that is in range for shape related functions.
|
related |
Disassociates all of the associated shape from the validly identified body.
std::out_of_range | If given an invalid body identifier. |
WrongState | if this function is called while the world is locked. |
|
friend |
Gets whether or not sub-stepping is enabled.
|
friend |
Gets the vertex radius interval allowable for the given world.
|
friend |
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 function returned without finishing all of its sub-steps.
|
friend |
Sets the identified body.
WrongState | if this function is called while the world is locked. |
std::out_of_range | if given an invalid id of if the given body references any invalid shape identifiers. |
InvalidArgument | if the specified ID was destroyed. |
|
friend |
Sets the identified contact's state.
world | The world of the contact whose state is to be set. |
id | Identifier of the contact whose state is to be set. |
value | Value the contact is to be set to. |
std::out_of_range | If given an invalid contact identifier or an invalid identifier in the new contact value. |
InvalidArgument | if the identifier is to a freed contact or if the new state is not allowable. |
|
friend |
Sets the identified joint.
WrongState | if this function is called while the world is locked. |
std::out_of_range | if given an invalid ID or the given joint references any invalid body ID. |
InvalidArgument | if the specified ID was destroyed. |
|
friend |
|
friend |
Sets the identified manifold.
std::out_of_range | If given an invalid contact identifier. |
|
friend |
Sets the value of the identified shape.
WrongState | if this function is called while the world is locked. |
std::out_of_range | If given an invalid identifier. |
InvalidArgument | if the specified ID was destroyed. |
|
friend |
Registers a destruction listener for shapes.
Clear(AabbTreeWorld&)
for every shape.
|
friend |
Enables/disables single stepped continuous physics.
GetSubStepping()
function will return the value this function was called with.
|
friend |
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 function is called while the world is locked. |
|
friend |
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
.world | The world that is to be stepped. |
conf | Configuration for the simulation step. |
conf.linearSlop
is significant enough compared to GetVertexRadiusInterval(const AabbTreeWorld& world).GetMax()
. WrongState | if this function is called while the world is locked. |