Module org.dyn4j

Interface BroadphaseDetector<E extends Collidable<T>,​T extends Fixture>

    • Field Detail

      • DEFAULT_AABB_EXPANSION

        static final double DEFAULT_AABB_EXPANSION
        The default AABB expansion value
        See Also:
        Constant Field Values
      • DEFAULT_INITIAL_CAPACITY

        static final int DEFAULT_INITIAL_CAPACITY
        The default initial capacity of fixtures
        See Also:
        Constant Field Values
    • Method Detail

      • add

        void add​(E collidable)
        Adds a new Collidable to the broad-phase.

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

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

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

        If a fixture is removed from a Collidable, the calling code must call the remove(Collidable, 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 collidable.

        Parameters:
        collidable - the Collidable
        Since:
        3.0.0
      • add

        void add​(E collidable,
                 T fixture)
        Adds a new Fixture for the given Collidable to the broad-phase.
        Parameters:
        collidable - the collidable
        fixture - the fixture to add
        Since:
        3.2.0
      • remove

        void remove​(E collidable)
        Removes the given Collidable from the broad-phase.

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

        If a fixture is removed from a Collidable, the calling code must call the remove(Collidable, 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 collidable.

        Parameters:
        collidable - the Collidable
        Since:
        3.0.0
      • remove

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

        void update​(E collidable)
        Updates all the Fixtures on the given Collidable.

        Used when the collidable or its fixtures have moved or rotated.

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

        If a fixture is removed from a Collidable, the calling code must call the remove(Collidable, 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 collidable.

        Parameters:
        collidable - the Collidable
        Since:
        3.2.0
      • update

        void update​(E collidable,
                    T fixture)
        Updates the given Collidable's Fixture.

        Used when a fixture on a Collidable has moved or rotated.

        This method will add the Fixture if it doesn't currently exist in this broad-phase.

        Parameters:
        collidable - the Collidable
        fixture - the Fixture that has moved
        Since:
        3.2.0
      • getAABB

        AABB getAABB​(E collidable)
        Returns the AABB for the given Collidable.

        The AABB returned is an AABB encompasing all fixtures on the given Collidable. When possible, AABBs from the broad-phase will be used to create this.

        If the collidable doesn't have any fixtures a degenerate AABB is returned.

        Parameters:
        collidable - the Collidable
        Returns:
        AABB
        Since:
        3.2.0
      • getAABB

        AABB getAABB​(E collidable,
                     T fixture)
        Returns the AABB for the given Collidable Fixture.

        If the collidable and its fixture have not been added to this broad-phase, a new AABB is created and returned (but not added to broad-phase).

        Parameters:
        collidable - the Collidable
        fixture - the Fixture
        Returns:
        AABB
        Since:
        3.2.0
      • contains

        boolean contains​(E collidable)
        Returns true if all the Fixtures on the given Collidable have been added to this broad-phase.

        If a collidable is added without any fixtures, this method will return false, since the fixtures, not the collidable, are added to the broad-phase.

        Parameters:
        collidable - the Collidable
        Returns:
        boolean
        Since:
        3.2.0
      • contains

        boolean contains​(E collidable,
                         T fixture)
        Returns true if the given Fixture on the given Collidable has been added to this broadphase.
        Parameters:
        collidable - the Collidable
        fixture - the Fixture
        Returns:
        boolean
        Since:
        3.2.0
      • clear

        void clear()
        Clears all the Collidable Fixtures from this broad-phase.
        Since:
        3.0.0
      • size

        int size()
        Returns the number of Fixtures that are being managed in this broad-phase.
        Returns:
        int
      • detect

        java.util.List<BroadphaseItem<E,​T>> detect​(AABB aabb)
        Performs a broad-phase collision test using the given AABB and returns the items that overlap.
        Parameters:
        aabb - the AABB to test
        Returns:
        List<BroadphaseItem>
        Since:
        3.0.0
      • detect

        java.util.List<BroadphaseItem<E,​T>> detect​(AABB aabb,
                                                         BroadphaseFilter<E,​T> filter)
        Performs a broad-phase collision test using the given AABB and returns the items that overlap.

        Use the filter parameter to further reduce the number of items returned.

        Parameters:
        aabb - the AABB to test
        filter - the broad-phase filter
        Returns:
        List<BroadphaseItem>
        Since:
        3.2.0
        See Also:
        detect(AABB)
      • raycast

        java.util.List<BroadphaseItem<E,​T>> raycast​(Ray ray,
                                                          double length)
        Performs a preliminary raycast over all the collidables in the broad-phase and returns the items that intersect.
        Parameters:
        ray - the Ray
        length - the length of the ray; 0.0 for infinite length
        Returns:
        List<BroadphaseItem>
        Since:
        3.0.0
      • raycast

        java.util.List<BroadphaseItem<E,​T>> raycast​(Ray ray,
                                                          double length,
                                                          BroadphaseFilter<E,​T> filter)
        Performs a preliminary raycast over all the collidables in the broad-phase and returns the items that intersect.

        Use the filter parameter to further reduce the number of items returned.

        Parameters:
        ray - the Ray
        length - the length of the ray; 0.0 for infinite length
        filter - the broad-phase filter
        Returns:
        List<BroadphaseItem>
        Since:
        3.2.0
        See Also:
        raycast(Ray, double)
      • detect

        boolean detect​(E a,
                       E b)
        Returns true if this broad-phase detector considers the given collidables to be in collision.
        Parameters:
        a - the first Collidable
        b - the second Collidable
        Returns:
        boolean
      • supportsAABBExpansion

        boolean supportsAABBExpansion()
        Returns whether this particular BroadphaseDetector supports expanding AABBs.
        Returns:
        boolean
      • getAABBExpansion

        double getAABBExpansion()
        Returns the AABB expansion value used to improve performance of broad-phase updates.

        If supportsAABBExpansion() returns false the value returned is unspecified and should not be taken into account.

        Returns:
        double
        See Also:
        setAABBExpansion(double)
      • setAABBExpansion

        void setAABBExpansion​(double expansion)
        Sets the AABB expansion value used to improve performance of broad-phase updates.

        Increasing this value will cause less updates to the broad-phase but will cause more pairs to be sent to the narrow-phase.

        Note that a broadphase implementation may ignore this value, if supportsAABBExpansion() returns false.

        Parameters:
        expansion - the expansion