Module org.dyn4j

Interface CollisionItemBroadphaseDetector<T extends CollisionBody<E>,​E extends Fixture>

    • Method Detail

      • add

        void add​(T body)
        Adds a new CollisionBody to the broad-phase.

        This will add all the given CollisionBody's Fixtures to the broad-phase.

        If the body has no fixtures, nothing will be added to this broad-phase.

        If the CollisionBody's Fixtures have already been added to this broad-phase they will be updated instead.

        If a Fixture has been added to the CollisionBody and the CollisionBody has already been added to this broad-phase, any new Fixtures will be added, and the existing ones will be updated.

        If a fixture is removed from a CollisionBody, the calling code must call the remove(CollisionBody, Fixture) method for that fixture to be removed from the broad-phase. This method makes no effort to remove fixtures no longer attached to the given body.

        Parameters:
        body - the CollisionBody
      • add

        void add​(T body,
                 E fixture)
        Adds a new Fixture for the given CollisionBody to the broad-phase.
        Parameters:
        body - the body
        fixture - the fixture to add
      • contains

        boolean contains​(T body)
        Returns true if all the Fixtures on the given CollisionBody have been added to this broad-phase.

        If a body is added without any fixtures, this method will return false.

        Parameters:
        body - the CollisionBody
        Returns:
        boolean
      • contains

        boolean contains​(T body,
                         E fixture)
        Returns true if the given Fixture on the given CollisionBody has been added to this broad-phase.
        Parameters:
        body - the CollisionBody
        fixture - the Fixture
        Returns:
        boolean
      • detect

        boolean detect​(T body1,
                       T body2)
        Returns true if the given bodies overlap using their broad-phase representation.
        Parameters:
        body1 - the first body
        body2 - the second body
        Returns:
        boolean
      • detect

        boolean detect​(T body1,
                       E fixture1,
                       T body2,
                       E fixture2)
        Returns true if the given body-fixture pairs overlap using their broad-phase representation.
        Parameters:
        body1 - the first body
        fixture1 - the first fixture
        body2 - the second body
        fixture2 - the second fixture
        Returns:
        boolean
      • getAABB

        AABB getAABB​(T body,
                     E fixture)
        Returns the AABB for the given CollisionBody Fixture.

        NOTE: Some BroadphaseDetectors use modified (expanded for example) AABBs rather than tight fitting AABBs as a performance enhancement. This method returns the AABB used by this detector, and therefore, the modified AABB.

        NOTE: The AABB returned from this method should not be modified. Instead use the AABB.copy() method to create a new instance to modify.

        If the given body-fixture has no shape, this method could return a degenerate AABB.

        Parameters:
        body - the CollisionBody
        fixture - the Fixture
        Returns:
        AABB
      • getAABB

        AABB getAABB​(T body)
        Returns an AABB for the given CollisionBody by taking the union of all the fixture AABBs attached to the body.

        If the given body has no fixtures, this method returns a degenerate AABB.

        Parameters:
        body - the CollisionBody
        Returns:
        AABB
      • isUpdated

        boolean isUpdated​(T body,
                          E fixture)
        Returns true if the given Fixture is included in the updated list.

        If BroadphaseDetector.isUpdateTrackingEnabled() is false, this method will always return true.

        Returns false if the given body-fixture pair is not part of this broad-phase.

        Parameters:
        body - the CollisionBody
        fixture - the Fixture
        Returns:
        boolean
      • remove

        boolean remove​(T body)
        Removes the given CollisionBody from the broad-phase.

        Returns true if all fixtures on the given CollisionBody were removed.

        This method removes all the Fixtures attached to the given CollisionBody from the broad-phase.

        If a fixture is removed from a CollisionBody, the calling code must call the remove(CollisionBody, Fixture) method for that fixture to be removed from the broad-phase. This method makes no effort to remove fixtures no longer attached to the given body.

        Parameters:
        body - the CollisionBody
        Returns:
        boolean
      • remove

        boolean remove​(T body,
                       E fixture)
        Removes the given Fixture for the given CollisionBody from the broad-phase and returns true if it was found.
        Parameters:
        body - the body
        fixture - the fixture to remove
        Returns:
        boolean true if the fixture was found and removed
      • setUpdated

        void setUpdated​(T body)
        This method is intended to force the broad-phase to include this CollisionBody's Fixtures in the updated list to ensure they are checked in the updated-only detection routine.

        The update(CollisionBody) method will only mark a CollisionBody as updated if it's fixtures have moved enough to change the internally stored AABB.

        Parameters:
        body - the CollisionBody
      • setUpdated

        void setUpdated​(T body,
                        E fixture)
        This method is intended to force the broad-phase to include the Fixture in the updated list to ensure they are checked in the updated-only detection routine.

        The update(CollisionBody, Fixture) method will only mark the Fixture as updated if the Fixture has moved enough to change the internally stored AABB.

        Parameters:
        body - the CollisionBody
        fixture - the Fixture
      • update

        void update​(T body)
        Updates all the Fixtures on the given CollisionBody.

        Used when the body or its fixtures have moved or rotated or when fixtures have been added.

        This method updates all the Fixtures attached to the given CollisionBody from the broad-phase, if they exist. If the fixtures on the given body do not exist in the broad-phase, they are added.

        If a fixture is removed from a CollisionBody, the calling code must call the remove(CollisionBody, Fixture) method for that fixture to be removed from the broad-phase. This method makes no effort to remove fixtures no longer attached to the given body.

        Parameters:
        body - the CollisionBody