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

Methods

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

  • GetDensity(): number
  • GetFriction(): number
  • 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.

  • GetRestitution(): number
  • 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(): 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(): 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(): boolean
  • Is this fixture a sensor (non-solid)?

    Returns boolean

    True if the shape is a sensor, otherwise false.

  • 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(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(friction: number): void
  • Set the coefficient of friction.

    Parameters

    • friction: number

      The new friction coefficient.

    Returns void

  • SetRestitution(restitution: number): void
  • 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(data: any): void
  • Set the user data. Use this to store your application specific data.

    Parameters

    • data: any

      User provided data.

    Returns void

  • 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