Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

Hierarchy

  • b2Fixture

Index

Constructors

constructor

Methods

GetAABB

  • 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.

    Returns b2AABB

    Fiture's AABB.

GetBody

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

    Returns b2Body

    The parent body.

GetDensity

  • GetDensity(): number
  • Get the density of this fixture.

    Returns number

    Density

GetFilterData

  • Get the contact filtering data.

    Returns b2FilterData

    Filter data.

GetFriction

  • GetFriction(): number
  • Get the coefficient of friction.

    Returns number

    Friction.

GetMassData

  • 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.

    Parameters

    • Optional massData: b2MassData

      This is a reference to a valid b2MassData, if it is null a new b2MassData is allocated and then returned. Default = null.

    Returns b2MassData

    Mass data.

GetNext

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

    Returns b2Fixture

    Next fixture.

GetRestitution

  • GetRestitution(): number
  • Get the coefficient of restitution.

    Returns number

    Restitution.

GetShape

  • 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.

    Returns b2Shape

    Fixture shape.

GetType

  • GetType(): number
  • Get the type of the child shape. You can use this to down cast to the concrete shape.

    Returns number

    Shape type enum.

GetUserData

  • GetUserData(): any
  • Get the user data that was assigned in the fixture definition. Use this to store your application specific data.

    Returns any

    User provided data. Cast to your object type.

IsSensor

  • IsSensor(): boolean
  • Is this fixture a sensor (non-solid)?

    Returns boolean

    True if the shape is a sensor, otherwise false.

RayCast

  • Perform a ray cast against this shape.

    Parameters

    Returns boolean

    True if the ray hits the shape, otherwise false.

SetDensity

  • SetDensity(density: number): void
  • 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.

    Parameters

    • density: number

      The new density.

    Returns void

SetFilterData

  • SetFilterData(filter: any): void
  • Set the contact filtering data. This will not update contacts until the next time step when either parent body is active and awake.

    Parameters

    • filter: any

      The new filter data.

    Returns void

SetFriction

  • SetFriction(friction: number): void
  • Set the coefficient of friction.

    Parameters

    • friction: number

      The new friction coefficient.

    Returns void

SetRestitution

  • SetRestitution(restitution: number): void
  • Get the coefficient of restitution.

    Parameters

    • restitution: number

    Returns void

SetSensor

  • SetSensor(sensor: boolean): void
  • Set if this fixture is a sensor.

    Parameters

    • sensor: boolean

      True to set as a sensor, false to not be a sensor.

    Returns void

SetUserData

  • SetUserData(data: any): void
  • Set the user data. Use this to store your application specific data.

    Parameters

    • data: any

      User provided data.

    Returns void

TestPoint

  • TestPoint(p: b2Vec2): boolean
  • Test a point for containment in this fixture.

    Parameters

    • p: b2Vec2

      Point to test against, in world coordinates.

    Returns boolean

    True if the point is in this shape, otherwise false.

Generated using TypeDoc