APIdia Launch Partner
Top Fields Constructors Methods
com.badlogic.gdx.physics.box2d

public Class Fixture

extends Object
Class Inheritance
Imports
com.badlogic.gdx.math.Vector2, com.badlogic.gdx.physics.box2d.Shape.Type, com.badlogic.gdx.utils.GdxRuntimeException

Field Summary

Modifier and TypeField and Description
protected long
addr

the address of the fixture

private Body
body

body

private boolean
dirtyFilter

flag to indicate if filter data needs to be updated with a JNI call

private final Filter
filter

the fixture filter data

protected Shape
shape

the shape, initialized lazy

private final short[]
tmp

Get the contact filtering data.

protected Object
userData

user specified data

Constructor Summary

AccessConstructor and Description
protected
Fixture(Body body, long
the address of the fixture
addr
)

Constructs a new fixture

Method Summary

Modifier and TypeMethod and Description
public Body
getBody()

Get the parent body of this fixture.

public float
getDensity()

Get the density of this fixture.

public Filter
getFilterData()

Get the contact filtering data.

public float
getFriction()

Get the coefficient of friction.

public float
getRestitution()

Get the coefficient of restitution.

public Shape
getShape()

Returns the shape of this fixture

public Shape.Type

Returns:

the shape type.
getType
()

Get the type of the child shape.

public Object
getUserData()

Returns: custom user data

public boolean

Returns:

the true if the shape is a sensor.
isSensor
()

Is this fixture a sensor (non-solid)?

private native float
jniGetDensity(long addr)

private native void
jniGetFilterData(long addr, short[] filter)

private native float
jniGetFriction(long addr)

private native float
jniGetRestitution(long addr)

private native long
jniGetShape(long addr)

private native int
jniGetType(long addr)

private native boolean
jniIsSensor(long addr)

private native void
jniRefilter(long addr)

private native void
jniSetDensity(long addr, float density)

private native void
jniSetFilterData(long addr, short categoryBits, short maskBits, short groupIndex)

private native void
jniSetFriction(long addr, float friction)

private native void
jniSetRestitution(long addr, float restitution)

private native void
jniSetSensor(long addr, boolean sensor)

private native boolean
jniTestPoint(long addr, float x, float y)

public void
refilter()

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

protected void
reset(Body body, long addr)

public void
setDensity(float density)

Set the density of this fixture.

public void
setFilterData(Filter filter)

Set the contact filtering data.

public void
setFriction(float friction)

Set the coefficient of friction.

public void
setRestitution(float restitution)

Set the coefficient of restitution.

public void
setSensor(boolean sensor)

Set if this fixture is a sensor.

public void
setUserData(Object userData)

Sets custom user data.

public boolean
testPoint(Vector2
a point in world coordinates.
p
)

Test a point for containment in this fixture.

public boolean
testPoint(float
the x-coordinate
x
,
float
the y-coordinate
y
)

Test a point for containment in this fixture.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addrback to summary
protected long addr

the address of the fixture

bodyback to summary
private Body body

body

dirtyFilterback to summary
private boolean dirtyFilter

flag to indicate if filter data needs to be updated with a JNI call

filterback to summary
private final Filter filter

the fixture filter data

shapeback to summary
protected Shape shape

the shape, initialized lazy

tmpback to summary
private final short[] tmp

Get the contact filtering data.

userDataback to summary
protected Object userData

user specified data

Constructor Detail

Fixtureback to summary
protected Fixture(Body body, long addr)

Constructs a new fixture

Parameters
addr:long

the address of the fixture

Method Detail

getBodyback to summary
public Body getBody()

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

getDensityback to summary
public float getDensity()

Get the density of this fixture.

getFilterDataback to summary
public Filter getFilterData()

Get the contact filtering data. Modifying the returned Filter without calling setFilterData can result in unpredictable behaviour.

getFrictionback to summary
public float getFriction()

Get the coefficient of friction.

getRestitutionback to summary
public float getRestitution()

Get the coefficient of restitution.

getShapeback to summary
public Shape getShape()

Returns the shape of this fixture

getTypeback to summary
public Shape.Type getType()

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

Returns:Shape.Type

the shape type.

getUserDataback to summary
public Object getUserData()
Returns:Object

custom user data

isSensorback to summary
public boolean isSensor()

Is this fixture a sensor (non-solid)?

Returns:boolean

the true if the shape is a sensor.

jniGetDensityback to summary
private native float jniGetDensity(long addr)
jniGetFilterDataback to summary
private native void jniGetFilterData(long addr, short[] filter)
jniGetFrictionback to summary
private native float jniGetFriction(long addr)
jniGetRestitutionback to summary
private native float jniGetRestitution(long addr)
jniGetShapeback to summary
private native long jniGetShape(long addr)
jniGetTypeback to summary
private native int jniGetType(long addr)
jniIsSensorback to summary
private native boolean jniIsSensor(long addr)
jniRefilterback to summary
private native void jniRefilter(long addr)
jniSetDensityback to summary
private native void jniSetDensity(long addr, float density)
jniSetFilterDataback to summary
private native void jniSetFilterData(long addr, short categoryBits, short maskBits, short groupIndex)
jniSetFrictionback to summary
private native void jniSetFriction(long addr, float friction)
jniSetRestitutionback to summary
private native void jniSetRestitution(long addr, float restitution)
jniSetSensorback to summary
private native void jniSetSensor(long addr, boolean sensor)
jniTestPointback to summary
private native boolean jniTestPoint(long addr, float x, float y)
refilterback to summary
public void refilter()

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

resetback to summary
protected void reset(Body body, long addr)
setDensityback to summary
public void setDensity(float density)

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.

setFilterDataback to summary
public void setFilterData(Filter 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.

setFrictionback to summary
public void setFriction(float friction)

Set the coefficient of friction.

setRestitutionback to summary
public void setRestitution(float restitution)

Set the coefficient of restitution.

setSensorback to summary
public void setSensor(boolean sensor)

Set if this fixture is a sensor.

setUserDataback to summary
public void setUserData(Object userData)

Sets custom user data.

testPointback to summary
public boolean testPoint(Vector2 p)

Test a point for containment in this fixture.

Parameters
p:Vector2

a point in world coordinates.

testPointback to summary
public boolean testPoint(float x, float y)

Test a point for containment in this fixture.

Parameters
x:float

the x-coordinate

y:float

the y-coordinate