- Object
-
- Fixture
-
- All Implemented Interfaces:
DataContainer
- Direct Known Subclasses:
BodyFixture
public class Fixture extends Object implements DataContainer
Represents a geometric piece of aCollisionBody
.A
Fixture
has a one-to-one relationship with aConvex
Shape
, storing additional collision specific information.A
CollisionBody
is composed of manyFixture
s to represent its physical shape. While the only shapes supported by the collision detection system areConvex
shapes, the composition of multipleFixture
s in aCollisionBody
allows the bodies to be non-convex.The
Fixture
'sShape
should be translated and rotated using theShape
's methods to move the shape relative to the containingCollisionBody
. Other modifications to the shape is not recommended after adding it to aFixture
. To change the shape of a fixture, remove the existingFixture
from theCollisionBody
and add a newFixture
with an updated shape instead.There's no restriction on reusing
Shape
s andFixture
s betweenCollisionBody
s, but this is also discouraged to reduce confusion and unexpected behavior (primarily local translations and rotations).A
Fixture
can have aFilter
assigned to enable filtering of collisions between it and other fixtures.A
Fixture
can be flagged as a sensor fixture to enable standard collision detection, but disable collision resolution (response).- Since:
- 2.0.0
- Version:
- 4.0.0
- Author:
- William Bittle
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Filter
getFilter()
Returns the collision filter for this fixture.Convex
getShape()
Object
getUserData()
Gets the custom user data.boolean
isSensor()
Returns true if this fixture is a sensor.void
setFilter(Filter filter)
Sets the collision filter for this fixture.void
setSensor(boolean flag)
Toggles this fixture as a sensor fixture.void
setUserData(Object userData)
Sets the custom user data to the given data.String
toString()
-
-
-
Constructor Detail
-
Fixture
public Fixture(Convex shape)
Minimal constructor.- Parameters:
shape
- theConvex
Shape
for this fixture- Throws:
NullPointerException
- if shape is null
-
-
Method Detail
-
setFilter
public void setFilter(Filter filter)
Sets the collision filter for this fixture.- Parameters:
filter
- the collision filter- Throws:
NullPointerException
- if filter is null; UseFilter.DEFAULT_FILTER
instead
-
isSensor
public boolean isSensor()
Returns true if this fixture is a sensor.A sensor fixture is a fixture that participates in collision detection but does not participate in collision resolution (response).
- Returns:
- boolean
-
setSensor
public void setSensor(boolean flag)
Toggles this fixture as a sensor fixture.A sensor fixture is a fixture that participates in collision detection but does not participate in collision resolution (response).
- Parameters:
flag
- true if this fixture should only sense contacts
-
getUserData
public Object getUserData()
Description copied from interface:DataContainer
Gets the custom user data.- Specified by:
getUserData
in interfaceDataContainer
- Returns:
- Object will return null if not set
-
setUserData
public void setUserData(Object userData)
Description copied from interface:DataContainer
Sets the custom user data to the given data.- Specified by:
setUserData
in interfaceDataContainer
- Parameters:
userData
- the user data
-
-