Box2D: b2Fixture Class Reference

| Box2D 2.4.1 A 2D physics engine for games

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
b2Fixture Class Reference

`#include <b2_fixture.h>`

## Public Member Functions
b2Shape::Type | GetType () const
b2Shape * | GetShape ()
const b2Shape * | GetShape () const
void | SetSensor (bool sensor)
| Set if this fixture is a sensor.
bool | IsSensor () const
void | SetFilterData (const b2Filter &filter)
const b2Filter & | GetFilterData () const
| Get the contact filtering data.
void | Refilter ()
| Call this if you want to establish collision that was previously disabled by b2ContactFilter::ShouldCollide.
b2Body * | GetBody ()
const b2Body * | GetBody () const
b2Fixture * | GetNext ()
const b2Fixture * | GetNext () const
b2FixtureUserData & | GetUserData ()
const b2FixtureUserData & | GetUserData () const
bool | TestPoint (const b2Vec2 &p) const
bool | RayCast (b2RayCastOutput *output, const b2RayCastInput &input, int32 childIndex) const
void | GetMassData (b2MassData *massData) const
void | SetDensity (float density)
float | GetDensity () const
| Get the density of this fixture.
float | GetFriction () const
| Get the coefficient of friction.
void | SetFriction (float friction)
float | GetRestitution () const
| Get the coefficient of restitution.
void | SetRestitution (float restitution)
float | GetRestitutionThreshold () const
| Get the restitution velocity threshold.
void | SetRestitutionThreshold (float threshold)
const b2AABB & | GetAABB (int32 childIndex) const
void | Dump (int32 bodyIndex)
| Dump this fixture to the log file.

## Protected Member Functions
void | Create (b2BlockAllocator *allocator, b2Body *body, const b2FixtureDef *def)
void | Destroy (b2BlockAllocator *allocator)
void | CreateProxies (b2BroadPhase *broadPhase, const b2Transform &xf)
void | DestroyProxies (b2BroadPhase *broadPhase)
void | Synchronize (b2BroadPhase *broadPhase, const b2Transform &xf1, const b2Transform &xf2)

## Protected Attributes
float | m_density
b2Fixture * | m_next
b2Body * | m_body
b2Shape * | m_shape
float | m_friction
float | m_restitution
float | m_restitutionThreshold
b2FixtureProxy * | m_proxies
int32 | m_proxyCount
b2Filter | m_filter
bool | m_isSensor
b2FixtureUserData | m_userData

## Friends
class | b2Body
class | b2World
class | b2Contact
class | b2ContactManager

## Detailed Description

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. Fixtures are created via b2Body::CreateFixture.

Warning
  you cannot reuse fixtures.

## Member Function Documentation

## ◆ GetAABB()

const b2AABB & b2Fixture::GetAABB | ( | int32 | childIndex | ) | const
| inline

Get the fixture's AABB. This AABB may be enlarge and/or stale. If you need a more accurate AABB, compute it using the shape and the body transform.

## ◆ GetBody()

b2Body * b2Fixture::GetBody | ( |  | ) |
| inline

Get the parent body of this fixture. This is nullptr if the fixture is not attached.

Returns
  the parent body.

## ◆ GetMassData()

void b2Fixture::GetMassData | ( | b2MassData * | massData | ) | const
| inline

Get the mass data for this fixture. The mass data is based on the density and the shape. The rotational inertia is about the shape's origin. This operation may be expensive.

## ◆ GetNext()

b2Fixture * b2Fixture::GetNext | ( |  | ) |
| inline

Get the next fixture in the parent body's fixture list.

Returns
  the next shape.

## ◆ GetShape()

b2Shape * b2Fixture::GetShape | ( |  | ) |
| inline

Get the child shape. You can modify the child shape, however you should not change the number of vertices because this will crash some collision caching mechanisms. Manipulating the shape may lead to non-physical behavior.

## ◆ GetType()

b2Shape::Type b2Fixture::GetType | ( |  | ) | const
| inline

Get the type of the child shape. You can use this to down cast to the concrete shape.

Returns
  the shape type.

## ◆ GetUserData()

b2FixtureUserData & b2Fixture::GetUserData | ( |  | ) |
| inline

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

## ◆ IsSensor()

bool b2Fixture::IsSensor | ( |  | ) | const
| inline

Is this fixture a sensor (non-solid)?

Returns
  the true if the shape is a sensor.

## ◆ RayCast()

bool b2Fixture::RayCast | ( | b2RayCastOutput * | output,
|  | const b2RayCastInput & | input,
|  | int32 | childIndex
| ) |  | const
| inline

Cast a ray against this shape.

Parameters

  output | the ray-cast results.
  input | the ray-cast input parameters.
  childIndex | the child shape index (e.g. edge index)

## ◆ SetDensity()

void b2Fixture::SetDensity | ( | float | density | ) |
| inline

Set the density of this fixture. This will not automatically adjust the mass of the body. You must call b2Body::ResetMassData to update the body's mass.

## ◆ SetFilterData()

void b2Fixture::SetFilterData | ( | const b2Filter & | filter | ) |

Set the contact filtering data. This will not update contacts until the next time step when either parent body is active and awake. This automatically calls Refilter.

## ◆ SetFriction()

void b2Fixture::SetFriction | ( | float | friction | ) |
| inline

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

## ◆ SetRestitution()

void b2Fixture::SetRestitution | ( | float | restitution | ) |
| inline

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

## ◆ SetRestitutionThreshold()

void b2Fixture::SetRestitutionThreshold | ( | float | threshold | ) |
| inline

Set the restitution threshold. This will not change the restitution threshold of existing contacts.

## ◆ TestPoint()

bool b2Fixture::TestPoint | ( | const b2Vec2 & | p | ) | const
| inline

Test a point for containment in this fixture.

Parameters

  p | a point in world coordinates.

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

- /build/box2d/src/box2d-2.4.2/include/box2d/b2_fixture.h