An association between a body and a shape. More...

#include <Fixture.hpp>

Public Member Functions

NonNull< Body * > GetBody () const noexcept
 Gets the parent body of this fixture. More...
 
Shape GetShape () const noexcept
 Gets the child shape. More...
 
void SetSensor (bool sensor) noexcept
 Set if this fixture is a sensor. More...
 
bool IsSensor () const noexcept
 Is this fixture a sensor (non-solid)? More...
 
void SetFilterData (Filter filter)
 Sets the contact filtering data. More...
 
Filter GetFilterData () const noexcept
 Gets the contact filtering data. More...
 
void Refilter ()
 Re-filter the fixture. More...
 
void * GetUserData () const noexcept
 
void SetUserData (void *data) noexcept
 Sets the user data. More...
 
AreaDensity GetDensity () const noexcept
 Gets the density of this fixture. More...
 
Real GetFriction () const noexcept
 Gets the coefficient of friction. More...
 
Real GetRestitution () const noexcept
 Gets the coefficient of restitution. More...
 
ChildCounter GetProxyCount () const noexcept
 Gets the proxy count. More...
 
FixtureProxy GetProxy (ChildCounter index) const noexcept
 Gets the proxy for the given index. More...
 
Span< const FixtureProxyGetProxies () const noexcept
 Gets the proxies. More...
 

Friends

class FixtureAtty
 

Related Functions

(Note that these are not member functions.)

AABB ComputeAABB (const Fixture &fixture) noexcept
 Computes the AABB for the given fixture. More...
 
MassData GetMassData (const Fixture &f)
 Computes the mass data for the given fixture. More...
 
bool TestPoint (const Fixture &f, Length2 p) noexcept
 Tests a point for containment in a fixture. More...
 
void SetAwake (const Fixture &f) noexcept
 Sets the associated body's sleep status to awake. More...
 
Transformation GetTransformation (const Fixture &f) noexcept
 Gets the transformation associated with the given fixture. More...
 
bool ShouldCollide (const Fixture &fixtureA, const Fixture &fixtureB) noexcept
 Whether contact calculations should be performed between the two fixtures. More...
 
FixtureConf GetFixtureConf (const Fixture &fixture) noexcept
 Gets the fixture definition for the given fixture. More...
 

Detailed Description

An association between a body and a shape.

A fixture is used to attach a shape to a body for collision detection. A fixture inherits its transform from its parent. Fixtures hold additional non-geometric data such as collision filters, etc.

Warning
you cannot reuse fixtures.
Note
Fixtures should be created using the Body::CreateFixture method.
Destroy these using the Body::Destroy(Fixture*, bool) method.
This structure is 56-bytes large (using a 4-byte Real on at least one 64-bit architecture/build).
See also
Body, Shape
Examples
World.cpp.

Definition at line 61 of file Fixture.hpp.

Member Function Documentation

◆ GetBody()

NonNull< Body * > playrho::d2::Fixture::GetBody ( ) const
inlinenoexcept

Gets the parent body of this fixture.

Returns
Non-null pointer to the parent body.
Examples
World.cpp.

Definition at line 227 of file Fixture.hpp.

◆ GetShape()

Shape playrho::d2::Fixture::GetShape ( ) const
inlinenoexcept

Gets the child shape.

The shape is not modifiable. Use a new fixture instead.

Definition at line 202 of file Fixture.hpp.

◆ SetSensor()

void playrho::d2::Fixture::SetSensor ( bool  sensor)
noexcept

Set if this fixture is a sensor.

Definition at line 60 of file Fixture.cpp.

◆ IsSensor()

bool playrho::d2::Fixture::IsSensor ( ) const
inlinenoexcept

Is this fixture a sensor (non-solid)?

Returns
the true if the shape is a sensor.

Definition at line 207 of file Fixture.hpp.

◆ SetFilterData()

void playrho::d2::Fixture::SetFilterData ( Filter  filter)
inline

Sets the contact filtering data.

Note
This won't update contacts until the next time step when either parent body is speedable and awake.
This automatically calls Refilter.

Definition at line 237 of file Fixture.hpp.

◆ GetFilterData()

Filter playrho::d2::Fixture::GetFilterData ( ) const
inlinenoexcept

Gets the contact filtering data.

Definition at line 212 of file Fixture.hpp.

◆ Refilter()

void playrho::d2::Fixture::Refilter ( )

Re-filter the fixture.

Note
Call this if you want to establish collision that was previously disabled by ShouldCollide(const Fixture&, const Fixture&).
See also
bool ShouldCollide(const Fixture& fixtureA, const Fixture& fixtureB) noexcept

Definition at line 40 of file Fixture.cpp.

◆ GetUserData()

void * playrho::d2::Fixture::GetUserData ( ) const
inlinenoexcept

Get the user data that was assigned in the fixture definition. Use this to store your application specific data.

Definition at line 217 of file Fixture.hpp.

◆ SetUserData()

void playrho::d2::Fixture::SetUserData ( void *  data)
inlinenoexcept

Sets the user data.

Note
Use this to store your application specific data.

Definition at line 222 of file Fixture.hpp.

◆ GetDensity()

AreaDensity playrho::d2::Fixture::GetDensity ( ) const
inlinenoexcept

Gets the density of this fixture.

Returns
Non-negative density (in mass per area).

Definition at line 288 of file Fixture.hpp.

◆ GetFriction()

Real playrho::d2::Fixture::GetFriction ( ) const
inlinenoexcept

Gets the coefficient of friction.

Returns
Value of 0 or higher.

Definition at line 278 of file Fixture.hpp.

◆ GetRestitution()

Real playrho::d2::Fixture::GetRestitution ( ) const
inlinenoexcept

Gets the coefficient of restitution.

Definition at line 283 of file Fixture.hpp.

◆ GetProxyCount()

ChildCounter playrho::d2::Fixture::GetProxyCount ( ) const
inlinenoexcept

Gets the proxy count.

Note
This will be zero until a world step has been run since this fixture's creation.

Definition at line 232 of file Fixture.hpp.

◆ GetProxy()

FixtureProxy playrho::d2::Fixture::GetProxy ( ChildCounter  index) const
noexcept

Gets the proxy for the given index.

Warning
Behavior is undefined if given an invalid index.
Returns
Fixture proxy value.

Definition at line 34 of file Fixture.cpp.

◆ GetProxies()

Span< const FixtureProxy > playrho::d2::Fixture::GetProxies ( ) const
inlinenoexcept

Gets the proxies.

Definition at line 243 of file Fixture.hpp.

Friends And Related Function Documentation

◆ FixtureAtty

friend class FixtureAtty
friend

Definition at line 128 of file Fixture.hpp.

◆ ComputeAABB()

AABB ComputeAABB ( const Fixture fixture)
related

Computes the AABB for the given fixture.

This is the AABB of the entire shape of the given fixture at the body's location for the given fixture.

Definition at line 72 of file AABB.cpp.

◆ GetMassData()

MassData GetMassData ( const Fixture f)
related

Computes the mass data for the given fixture.

The mass data is based on the density and the shape of the fixture. The rotational inertia is about the shape's origin.

Note
This operation may be expensive.
Parameters
fFixture to compute the mass data for.

Definition at line 182 of file MassData.cpp.

◆ SetAwake()

void SetAwake ( const Fixture f)
related

Sets the associated body's sleep status to awake.

Note
This is a convenience function that simply looks up the fixture's body and calls that body' SetAwake method.
Parameters
fFixture whose body should be awoken.

Definition at line 85 of file Fixture.cpp.

◆ GetTransformation()

Transformation GetTransformation ( const Fixture f)
related

Gets the transformation associated with the given fixture.

Warning
Behavior is undefined if the fixture doesn't have an associated body - i.e. behavior is undefined if the fixture has nullptr as its associated body.
Examples
Body.cpp.

Definition at line 90 of file Fixture.cpp.

◆ ShouldCollide()

bool ShouldCollide ( const Fixture fixtureA,
const Fixture fixtureB 
)
related

Whether contact calculations should be performed between the two fixtures.

Returns
true if contact calculations should be performed between these two fixtures; false otherwise.

Definition at line 319 of file Fixture.hpp.

◆ GetFixtureConf()

FixtureConf GetFixtureConf ( const Fixture fixture)
related

Gets the fixture definition for the given fixture.

Parameters
fixtureFixture to get the definition for.

Definition at line 28 of file FixtureConf.cpp.


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