Class CollisionItemBroadphaseDetectorAdapter<T extends CollisionBody<E>,E extends Fixture>
- Object
-
- BroadphaseDetectorDecoratorAdapter<CollisionItem<T,E>>
-
- CollisionItemBroadphaseDetectorAdapter<T,E>
-
- Type Parameters:
T
- theCollisionBody
typeE
- theFixture
type
- All Implemented Interfaces:
BroadphaseDetector<CollisionItem<T,E>>
,BroadphaseDetectorDecorator<CollisionItem<T,E>>
,CollisionItemBroadphaseDetector<T,E>
,Shiftable
public final class CollisionItemBroadphaseDetectorAdapter<T extends CollisionBody<E>,E extends Fixture> extends BroadphaseDetectorDecoratorAdapter<CollisionItem<T,E>> implements CollisionItemBroadphaseDetector<T,E>
Wraps anyBroadphaseDetector
for use as aCollisionItemBroadphaseDetector
.- Since:
- 4.1.0
- Version:
- 4.1.0
- Author:
- William Bittle
-
-
Field Summary
-
Fields inherited from class BroadphaseDetectorDecoratorAdapter
detector
-
Fields inherited from interface BroadphaseDetector
DEFAULT_INITIAL_CAPACITY
-
-
Constructor Summary
Constructors Constructor Description CollisionItemBroadphaseDetectorAdapter(BroadphaseDetector<CollisionItem<T,E>> detector)
Minimal constructor.
-
Method Summary
All Methods Instance Methods Concrete 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 class BroadphaseDetectorDecoratorAdapter
add, clear, clearUpdates, contains, detect, detect, detect, detect, detect, detectIterator, detectIterator, detectIterator, getAABB, getAABBExpansionMethod, getAABBProducer, getBroadphaseFilter, getDecoratedBroadphaseDetector, isUpdated, isUpdateTrackingEnabled, isUpdateTrackingSupported, optimize, raycast, raycastIterator, remove, setUpdated, setUpdateTrackingEnabled, shift, size, update, update
-
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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
-
-
-
-
Constructor Detail
-
CollisionItemBroadphaseDetectorAdapter
public CollisionItemBroadphaseDetectorAdapter(BroadphaseDetector<CollisionItem<T,E>> detector)
Minimal constructor.- Parameters:
detector
- the broad-phase detector to wrap
-
-
Method Detail
-
add
public void add(T body)
Description copied from interface:CollisionItemBroadphaseDetector
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 theCollisionItemBroadphaseDetector.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.- Specified by:
add
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
-
add
public void add(T body, E fixture)
Description copied from interface:CollisionItemBroadphaseDetector
Adds a newFixture
for the givenCollisionBody
to the broad-phase.- Specified by:
add
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- the bodyfixture
- the fixture to add
-
contains
public boolean contains(T body)
Description copied from interface:CollisionItemBroadphaseDetector
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.
- Specified by:
contains
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
- Returns:
- boolean
-
contains
public boolean contains(T body, E fixture)
Description copied from interface:CollisionItemBroadphaseDetector
Returns true if the givenFixture
on the givenCollisionBody
has been added to this broad-phase.- Specified by:
contains
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
fixture
- theFixture
- Returns:
- boolean
-
detect
public boolean detect(T body1, T body2)
Description copied from interface:CollisionItemBroadphaseDetector
Returns true if the given bodies overlap using their broad-phase representation.- Specified by:
detect
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body1
- the first bodybody2
- the second body- Returns:
- boolean
-
detect
public boolean detect(T body1, E fixture1, T body2, E fixture2)
Description copied from interface:CollisionItemBroadphaseDetector
Returns true if the given body-fixture pairs overlap using their broad-phase representation.- Specified by:
detect
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body1
- the first bodyfixture1
- the first fixturebody2
- the second bodyfixture2
- the second fixture- Returns:
- boolean
-
getAABB
public AABB getAABB(T body, E fixture)
Description copied from interface:CollisionItemBroadphaseDetector
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.
- Specified by:
getAABB
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
fixture
- theFixture
- Returns:
AABB
-
getAABB
public AABB getAABB(T body)
Description copied from interface:CollisionItemBroadphaseDetector
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.
- Specified by:
getAABB
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
- Returns:
AABB
-
isUpdated
public boolean isUpdated(T body)
Description copied from interface:CollisionItemBroadphaseDetector
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.
- Specified by:
isUpdated
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
- Returns:
- boolean
-
isUpdated
public boolean isUpdated(T body, E fixture)
Description copied from interface:CollisionItemBroadphaseDetector
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.
- Specified by:
isUpdated
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
fixture
- theFixture
- Returns:
- boolean
-
remove
public boolean remove(T body)
Description copied from interface:CollisionItemBroadphaseDetector
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 theCollisionItemBroadphaseDetector.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.- Specified by:
remove
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
- Returns:
- boolean
-
remove
public boolean remove(T body, E fixture)
Description copied from interface:CollisionItemBroadphaseDetector
Removes the givenFixture
for the givenCollisionBody
from the broad-phase and returns true if it was found.- Specified by:
remove
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- the bodyfixture
- the fixture to remove- Returns:
- boolean true if the fixture was found and removed
-
setUpdated
public void setUpdated(T body)
Description copied from interface:CollisionItemBroadphaseDetector
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
CollisionItemBroadphaseDetector.update(CollisionBody)
method will only mark aCollisionBody
as updated if it's fixtures have moved enough to change the internally stored AABB.- Specified by:
setUpdated
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
-
setUpdated
public void setUpdated(T body, E fixture)
Description copied from interface:CollisionItemBroadphaseDetector
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
CollisionItemBroadphaseDetector.update(CollisionBody, Fixture)
method will only mark theFixture
as updated if theFixture
has moved enough to change the internally stored AABB.- Specified by:
setUpdated
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
fixture
- theFixture
-
update
public void update(T body)
Description copied from interface:CollisionItemBroadphaseDetector
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 theCollisionItemBroadphaseDetector.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.- Specified by:
update
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
-
update
public void update(T body, E fixture)
Description copied from interface:CollisionItemBroadphaseDetector
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.- Specified by:
update
in interfaceCollisionItemBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
fixture
- theFixture
that has moved
-
-