Box2D  3.0.0
A Real-Time-Oriented 2-D Physics Engine
Public Member Functions | Friends | List of all members
box2d::Fixture Class Reference

Fixture. More...

#include <Fixture.hpp>

Public Member Functions

 Fixture ()=delete
 
BodyGetBody () noexcept
 Gets the parent body of this fixture. More...
 
const BodyGetBody () const noexcept
 Gets the parent body of this fixture. More...
 
const ShapeGetShape () 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 (const Filter filter)
 Sets the contact filtering data. More...
 
Filter GetFilterData () const noexcept
 Gets the contact filtering data. More...
 
void Refilter ()
 Refilter the fixture. More...
 
void * GetUserData () const noexcept
 Get the user data that was assigned in the fixture definition. Use this to store your application specific data. More...
 
void SetUserData (void *data) noexcept
 Set the user data. Use this to store your application specific data. More...
 
void SetDensity (RealNum density) noexcept
 Sets the density of this fixture. More...
 
Density GetDensity () const noexcept
 Gets the density of this fixture. More...
 
RealNum GetFriction () const noexcept
 Gets the coefficient of friction. More...
 
void SetFriction (RealNum friction) noexcept
 Sets the coefficient of friction. This will not change the friction of existing contacts. More...
 
RealNum GetRestitution () const noexcept
 Gets the coefficient of restitution. More...
 
void SetRestitution (RealNum restitution) noexcept
 Sets the coefficient of restitution. This will not change the restitution of existing contacts. More...
 
child_count_t GetProxyCount () const noexcept
 
const FixtureProxyGetProxy (child_count_t index) const noexcept
 
 ~Fixture ()
 Destructor. More...
 

Friends

class FixtureAtty
 

Detailed Description

Fixture.

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 friction, collision filters, etc.

Warning
you cannot reuse fixtures.
Note
Fixtures are created via Body::CreateFixture.
This structure is 56-bytes large (using a 4-byte RealNum on at least one 64-bit architecture/build).

Constructor & Destructor Documentation

◆ Fixture()

box2d::Fixture::Fixture ( )
delete

◆ ~Fixture()

box2d::Fixture::~Fixture ( )
inline

Destructor.

Precondition
Proxy count is zero.
Warning
Behavior is undefined if proxy count is greater than zero.

Member Function Documentation

◆ GetBody() [1/2]

Body * box2d::Fixture::GetBody ( )
inlinenoexcept

Gets the parent body of this fixture.

This is nullptr if the fixture is not attached.

Returns
the parent body.

◆ GetBody() [2/2]

const Body * box2d::Fixture::GetBody ( ) const
inlinenoexcept

Gets the parent body of this fixture.

This is nullptr if the fixture is not attached.

Returns
the parent body.

◆ GetDensity()

Density Fixture::GetDensity ( ) const
noexcept

Gets the density of this fixture.

Returns
Non-negative density in kg/m^2.

◆ GetFilterData()

Filter box2d::Fixture::GetFilterData ( ) const
inlinenoexcept

Gets the contact filtering data.

◆ GetFriction()

RealNum Fixture::GetFriction ( ) const
noexcept

Gets the coefficient of friction.

◆ GetProxy()

const FixtureProxy * Fixture::GetProxy ( child_count_t  index) const
noexcept

◆ GetProxyCount()

child_count_t box2d::Fixture::GetProxyCount ( ) const
inlinenoexcept

◆ GetRestitution()

RealNum Fixture::GetRestitution ( ) const
noexcept

Gets the coefficient of restitution.

◆ GetShape()

const Shape * box2d::Fixture::GetShape ( ) const
inlinenoexcept

Gets the child shape.

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

◆ GetUserData()

void * box2d::Fixture::GetUserData ( ) const
inlinenoexcept

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

◆ IsSensor()

bool box2d::Fixture::IsSensor ( ) const
inlinenoexcept

Is this fixture a sensor (non-solid)?

Returns
the true if the shape is a sensor.

◆ Refilter()

void Fixture::Refilter ( )

Refilter the fixture.

Note
Call this if you want to establish collision that was previously disabled by ContactFilter::ShouldCollide.

◆ SetDensity()

void box2d::Fixture::SetDensity ( RealNum  density)
noexcept

Sets the density of this fixture.

Note
This will not automatically adjust the mass of the body. You must call Body::ResetMassData to update the body's mass.
Warning
Behavior is undefined if given a negative value.
Parameters
densityNon-negative density in kg/m^2.

◆ SetFilterData()

void box2d::Fixture::SetFilterData ( const 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.

◆ SetFriction()

void box2d::Fixture::SetFriction ( RealNum  friction)
noexcept

Sets the coefficient of friction. This will not change the friction of existing contacts.

◆ SetRestitution()

void box2d::Fixture::SetRestitution ( RealNum  restitution)
noexcept

Sets the coefficient of restitution. This will not change the restitution of existing contacts.

◆ SetSensor()

void Fixture::SetSensor ( bool  sensor)
noexcept

Set if this fixture is a sensor.

◆ SetUserData()

void box2d::Fixture::SetUserData ( void *  data)
inlinenoexcept

Set the user data. Use this to store your application specific data.

Friends And Related Function Documentation

◆ FixtureAtty

friend class FixtureAtty
friend

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