public class Fixture

  1. Object
  2. 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. Fixtures are created via Body::CreateFixture.
Warning. you cannot reuse fixtures.

Fields

public float m_density
public Fixture m_next
public Body m_body
public Shape m_shape
public float m_friction
public float m_restitution
public FixtureProxy[] m_proxies
public int m_proxyCount
public final Filter m_filter
public boolean m_isSensor
public Object m_userData

Constructors

public Fixture()

Methods

public ShapeType getType()Get the type of the child shape.
public Shape getShape()Get the child shape.
public boolean isSensor()Is this fixture a sensor (non-solid)?
public void setSensor(boolean sensor)Set if this fixture is a sensor.
public void setFilterData(Filter filter)Set the contact filtering data.
public Filter getFilterData()Get the contact filtering data.
public void refilter()Call this if you want to establish collision that was previously disabled by ContactFilter::ShouldCollide.
public Body getBody()Get the parent body of this fixture.
public Fixture getNext()Get the next fixture in the parent body’s fixture list.
public void setDensity(float density)
public float getDensity()
public Object getUserData()Get the user data that was assigned in the fixture definition.
public void setUserData(Object data)Set the user data.
public boolean testPoint(Vec2 p)Test a point for containment in this fixture.
public boolean raycast(RayCastOutput output, RayCastInput input, int childIndex)Cast a ray against this shape.
public void getMassData(MassData massData)Get the mass data for this fixture.
public float getFriction()Get the coefficient of friction.
public void setFriction(float friction)Set the coefficient of friction.
public float getRestitution()Get the coefficient of restitution.
public void setRestitution(float restitution)Set the coefficient of restitution.
public AABB getAABB(int childIndex)Get the fixture’s AABB.
public void dump(int bodyIndex)Dump this fixture to the log file.
public void create(Body body, FixtureDef def)
public void destroy()
public void createProxies(BroadPhase broadPhase, Transform xf)
public void destroyProxies(BroadPhase broadPhase)Internal method
protected void synchronize(BroadPhase broadPhase, Transform transform1, Transform transform2)Internal method

Inherited methods

Field details

m_density

public float m_density

m_next

public Fixture m_next

m_body

public Body m_body

m_shape

public Shape m_shape

m_friction

public float m_friction

m_restitution

public float m_restitution

m_proxies

public FixtureProxy[] m_proxies

m_proxyCount

public int m_proxyCount

m_filter

public final Filter m_filter

m_isSensor

public boolean m_isSensor

m_userData

public Object m_userData

Constructor details

Fixture

public Fixture()

Method details

getType

public ShapeType getType()
Get the type of the child shape. You can use this to down cast to the concrete shape.

Returns

the shape type.

getShape

public Shape 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.

isSensor

public boolean isSensor()
Is this fixture a sensor (non-solid)?

Returns

the true if the shape is a sensor.

setSensor

public void setSensor(boolean sensor)
Set if this fixture is a sensor.

setFilterData

public void setFilterData(Filter filter)
Set the contact filtering data. This is an expensive operation and should not be called frequently. This will not update contacts until the next time step when either parent body is awake. This automatically calls refilter.

getFilterData

public Filter getFilterData()
Get the contact filtering data.

refilter

public void refilter()
Call this if you want to establish collision that was previously disabled by ContactFilter::ShouldCollide.

getBody

public Body getBody()
Get the parent body of this fixture. This is NULL if the fixture is not attached.

Returns

the parent body.

getNext

public Fixture getNext()
Get the next fixture in the parent body’s fixture list.

Returns

the next shape.

setDensity

public void setDensity(float density)

getDensity

public float getDensity()

getUserData

public Object getUserData()
Get the user data that was assigned in the fixture definition. Use this to store your application specific data.

setUserData

public void setUserData(Object data)
Set the user data. Use this to store your application specific data.

testPoint

public boolean testPoint(Vec2 p)
Test a point for containment in this fixture. This only works for convex shapes.

Parameters

p Vec2
a point in world coordinates.

raycast

public boolean raycast(RayCastOutput output, RayCastInput input, int childIndex)
Cast a ray against this shape.

Parameters

output RayCastOutput
the ray-cast results.
input RayCastInput
the ray-cast input parameters.
childIndex int
Not documented.

getMassData

public void getMassData(MassData massData)
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.

getFriction

public float getFriction()
Get the coefficient of friction.

setFriction

public void setFriction(float friction)
Set the coefficient of friction. This will not change the friction of existing contacts.

getRestitution

public float getRestitution()
Get the coefficient of restitution.

setRestitution

public void setRestitution(float restitution)
Set the coefficient of restitution. This will not change the restitution of existing contacts.

getAABB

public AABB getAABB(int childIndex)
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.

dump

public void dump(int bodyIndex)
Dump this fixture to the log file.

create

public void create(Body body, FixtureDef def)

destroy

public void destroy()

createProxies

public void createProxies(BroadPhase broadPhase, Transform xf)

destroyProxies

public void destroyProxies(BroadPhase broadPhase)
Internal method

synchronize

protected void synchronize(BroadPhase broadPhase, Transform transform1, Transform transform2)
Internal method