Interface CollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
-
- Type Parameters:
T
- theCollisionBody
typeE
- theFixture
type
- All Superinterfaces:
BroadphaseDetector<CollisionItem<T,E>>
,BroadphaseDetectorDecorator<CollisionItem<T,E>>
,Shiftable
- All Known Implementing Classes:
CollisionItemBroadphaseDetectorAdapter
public interface CollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture> extends BroadphaseDetectorDecorator<CollisionItem<T,E>>, BroadphaseDetector<CollisionItem<T,E>>
Represents aBroadphaseDetector
specifically used withCollisionBody
-Fixture
CollisionItem
pairs.This interface introduces a number of helper methods to work with
CollisionItem
s while allowing the use of anyBroadphaseDetector
. NOTE: Special care must be taken when removing fixtures from a body. Be sure to call theremove(CollisionBody, Fixture)
method to make sure its removed from the broad-phase. This class makes no attempt to remove fixtures that no longer exist on the body- Since:
- 4.1.0
- Version:
- 4.1.0
- Author:
- William Bittle
-
-
Field Summary
-
Fields inherited from interface BroadphaseDetector
DEFAULT_INITIAL_CAPACITY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
add(T body)
Adds a newCollisionBody
to the broad-phase.void
add(T body, E fixture)
Adds a newFixture
for the givenCollisionBody
to the broad-phase.boolean
contains(T body)
Returns true if all theFixture
s on the givenCollisionBody
have been added to this broad-phase.boolean
contains(T body, E fixture)
Returns true if the givenFixture
on the givenCollisionBody
has been added to this broad-phase.boolean
detect(T body1, E fixture1, T body2, E fixture2)
Returns true if the given body-fixture pairs overlap using their broad-phase representation.boolean
detect(T body1, T body2)
Returns true if the given bodies overlap using their broad-phase representation.AABB
getAABB(T body)
Returns an AABB for the givenCollisionBody
by taking the union of all the fixture AABBs attached to the body.AABB
getAABB(T body, E fixture)
Returns the AABB for the givenCollisionBody
Fixture
.boolean
isUpdated(T body)
Returns true if any of theFixture
s on the givenCollisionBody
are included in the updated list.boolean
isUpdated(T body, E fixture)
Returns true if the givenFixture
is included in the updated list.boolean
remove(T body)
Removes the givenCollisionBody
from the broad-phase.boolean
remove(T body, E fixture)
Removes the givenFixture
for the givenCollisionBody
from the broad-phase and returns true if it was found.void
setUpdated(T body)
This method is intended to force the broad-phase to include thisCollisionBody
'sFixture
s in the updated list to ensure they are checked in the updated-only detection routine.void
setUpdated(T body, E fixture)
This method is intended to force the broad-phase to include theFixture
in the updated list to ensure they are checked in the updated-only detection routine.void
update(T body)
Updates all theFixture
s on the givenCollisionBody
.void
update(T body, E fixture)
Updates the givenCollisionBody
'sFixture
.-
Methods inherited from interface BroadphaseDetector
add, clear, clearUpdates, contains, detect, detect, detect, detect, detect, detectIterator, detectIterator, detectIterator, getAABB, getAABBExpansionMethod, getAABBProducer, getBroadphaseFilter, isUpdated, isUpdateTrackingEnabled, isUpdateTrackingSupported, optimize, raycast, raycastIterator, remove, setUpdated, setUpdateTrackingEnabled, size, update, update
-
Methods inherited from interface BroadphaseDetectorDecorator
getDecoratedBroadphaseDetector
-
-
-
-
Method Detail
-
add
void add(T body)
Adds a newCollisionBody
to the broad-phase.This will add all the given
CollisionBody
'sFixture
s to the broad-phase.If the body has no fixtures, nothing will be added to this broad-phase.
If the
CollisionBody
'sFixture
s have already been added to this broad-phase they will be updated instead.If a
Fixture
has been added to theCollisionBody
and theCollisionBody
has already been added to this broad-phase, any newFixture
s will be added, and the existing ones will be updated.If a fixture is removed from a
CollisionBody
, the calling code must call theremove(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
- theCollisionBody
-
add
void add(T body, E fixture)
Adds a newFixture
for the givenCollisionBody
to the broad-phase.- Parameters:
body
- the bodyfixture
- the fixture to add
-
contains
boolean contains(T body)
Returns true if all theFixture
s on the givenCollisionBody
have been added to this broad-phase.If a body is added without any fixtures, this method will return false.
- Parameters:
body
- theCollisionBody
- Returns:
- boolean
-
contains
boolean contains(T body, E fixture)
Returns true if the givenFixture
on the givenCollisionBody
has been added to this broad-phase.- Parameters:
body
- theCollisionBody
fixture
- theFixture
- 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 bodybody2
- 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 bodyfixture1
- the first fixturebody2
- the second bodyfixture2
- the second fixture- Returns:
- boolean
-
getAABB
AABB getAABB(T body, E fixture)
Returns the AABB for the givenCollisionBody
Fixture
.NOTE: Some
BroadphaseDetector
s 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 theAABB.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
- theCollisionBody
fixture
- theFixture
- Returns:
AABB
-
getAABB
AABB getAABB(T body)
Returns an AABB for the givenCollisionBody
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
- theCollisionBody
- Returns:
AABB
-
isUpdated
boolean isUpdated(T body)
Returns true if any of theFixture
s on the givenCollisionBody
are included in the updated list.If
BroadphaseDetector.isUpdateTrackingEnabled()
is false, this method will always return true.Returns false if the given body is not part of this broad-phase.
- Parameters:
body
- theCollisionBody
- Returns:
- boolean
-
isUpdated
boolean isUpdated(T body, E fixture)
Returns true if the givenFixture
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
- theCollisionBody
fixture
- theFixture
- Returns:
- boolean
-
remove
boolean remove(T body)
Removes the givenCollisionBody
from the broad-phase.Returns true if all fixtures on the given
CollisionBody
were removed.This method removes all the
Fixture
s attached to the givenCollisionBody
from the broad-phase.If a fixture is removed from a
CollisionBody
, the calling code must call theremove(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
- theCollisionBody
- Returns:
- boolean
-
remove
boolean remove(T body, E fixture)
Removes the givenFixture
for the givenCollisionBody
from the broad-phase and returns true if it was found.- Parameters:
body
- the bodyfixture
- 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 thisCollisionBody
'sFixture
s in the updated list to ensure they are checked in the updated-only detection routine.The
update(CollisionBody)
method will only mark aCollisionBody
as updated if it's fixtures have moved enough to change the internally stored AABB.- Parameters:
body
- theCollisionBody
-
setUpdated
void setUpdated(T body, E fixture)
This method is intended to force the broad-phase to include theFixture
in the updated list to ensure they are checked in the updated-only detection routine.The
update(CollisionBody, Fixture)
method will only mark theFixture
as updated if theFixture
has moved enough to change the internally stored AABB.- Parameters:
body
- theCollisionBody
fixture
- theFixture
-
update
void update(T body)
Updates all theFixture
s on the givenCollisionBody
.Used when the body or its fixtures have moved or rotated or when fixtures have been added.
This method updates all the
Fixture
s attached to the givenCollisionBody
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 theremove(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
- theCollisionBody
-
update
void update(T body, E fixture)
Updates the givenCollisionBody
'sFixture
.Used when a fixture on a
CollisionBody
has moved or rotated.This method will add the
Fixture
if it doesn't currently exist in this broad-phase.- Parameters:
body
- theCollisionBody
fixture
- theFixture
that has moved
-
-