Module org.dyn4j

Class Fixture

  • All Implemented Interfaces:
    DataContainer
    Direct Known Subclasses:
    BodyFixture

    public class Fixture
    extends Object
    implements DataContainer
    Represents a geometric piece of a CollisionBody.

    A Fixture has a one-to-one relationship with a Convex Shape, storing additional collision specific information.

    A CollisionBody is composed of many Fixtures to represent its physical shape. While the only shapes supported by the collision detection system are Convex shapes, the composition of multiple Fixtures in a CollisionBody allows the bodies to be non-convex.

    The Fixture's Shape should be translated and rotated using the Shape's methods to move the shape relative to the containing CollisionBody. Other modifications to the shape is not recommended after adding it to a Fixture. To change the shape of a fixture, remove the existing Fixture from the CollisionBody and add a new Fixture with an updated shape instead.

    There's no restriction on reusing Shapes and Fixtures between CollisionBodys, but this is also discouraged to reduce confusion and unexpected behavior (primarily local translations and rotations).

    A Fixture can have a Filter 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 Detail

      • getFilter

        public Filter getFilter()
        Returns the collision filter for this fixture.
        Returns:
        Filter
      • 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 interface DataContainer
        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 interface DataContainer
        Parameters:
        userData - the user data