Class LazyAABBTree<T extends CollisionBody<E>,E extends Fixture>
- Object
-
- AbstractBroadphaseDetector<T,E>
-
- LazyAABBTree<T,E>
-
- Type Parameters:
T
- theCollisionBody
typeE
- theFixture
type
- All Implemented Interfaces:
BatchBroadphaseDetector<T,E>
,BroadphaseDetector<T,E>
,Shiftable
@Deprecated public final class LazyAABBTree<T extends CollisionBody<E>,E extends Fixture> extends AbstractBroadphaseDetector<T,E> implements BatchBroadphaseDetector<T,E>
Deprecated.Deprecated in 4.0.0. Use a differentBroadphaseDetector
instead.Implementation of a self-balancing axis-aligned bounding box tree broad-phase collision detection algorithm.This class implements a aabb tree broad-phase detector that is based on ideas from
DynamicAABBTree
but with some very critical improvements. This data structure is lazy in the sense that it will build the actual tree as late as possible (hence the name). Performance is optimized for fast detection of collisions, as required by theWorld
class. Raycasting and other functionalities should see no big improvements. Insertion is O(1), update is O(logn) but batch update (update of all bodies) is O(n), remove is O(logn) average but O(n) worse.The class will rebuild the whole tree at each detection and will detect the collisions at the same time in an efficient manner.
This structure keeps the bodies sorted by the radius of their fixtures and rebuilds the tree each time in order to construct better trees.
- Since:
- 3.4.0
- Version:
- 4.0.0
- Author:
- Manolis Tsamis
-
-
Field Summary
-
Fields inherited from interface BroadphaseDetector
DEFAULT_AABB_EXPANSION, DEFAULT_INITIAL_CAPACITY
-
-
Constructor Summary
Constructors Constructor Description LazyAABBTree()
Deprecated.Default constructor.LazyAABBTree(int initialCapacity)
Deprecated.Optional constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
add(T body, E fixture)
Deprecated.Adds a newFixture
for the givenCollisionBody
to the broad-phase.void
batchUpdate()
Deprecated.Destroys the existing tree in O(n) time and prepares for batch-detection while also updating all AABBs.void
clear()
Deprecated.Clears all theCollisionBody
Fixture
s from this broad-phase and any state held by this broadphase.void
clearUpdates()
Deprecated.Clears any internal state that tracks whatCollisionBody
Fixture
s have been updated.boolean
contains(CollisionItem<T,E> item)
Deprecated.Returns true if the givenFixture
on the givenCollisionBody
has been added to this broadphase.boolean
contains(T body, E fixture)
Deprecated.Returns true if the givenFixture
on the givenCollisionBody
has been added to this broadphase.List<CollisionPair<T,E>>
detect(BroadphaseFilter<T,E> filter)
Deprecated.List<CollisionItem<T,E>>
detect(AABB aabb, BroadphaseFilter<T,E> filter)
Deprecated.Iterator<CollisionPair<T,E>>
detectIterator(boolean forceFullDetection)
Deprecated.Performs collision detection on allCollisionBody
Fixture
s that have been added to thisBroadphaseDetector
and returns the list of potential pairs.Iterator<CollisionItem<T,E>>
detectIterator(AABB aabb)
Deprecated.Performs a broad-phase collision test using the givenAABB
and returns the items that overlap.AABB
getAABB(CollisionItem<T,E> item)
Deprecated.Returns the AABB for the givenCollisionBody
Fixture
.double
getAABBExpansion()
Deprecated.Returns theAABB
expansion value used to improve performance of broad-phase updates.boolean
isAABBExpansionSupported()
Deprecated.Returns whether this particularBroadphaseDetector
supports expanding AABBs.boolean
isUpdated(CollisionItem<T,E> item)
Deprecated.Returns true if the givenFixture
is included in the updated list.boolean
isUpdated(T body, E fixture)
Deprecated.Returns true if the givenFixture
is included in the updated list.boolean
isUpdateTrackingEnabled()
Deprecated.Returns true if this broadphase is tracking updated items.boolean
isUpdateTrackingSupported()
Deprecated.Returns whether this particularBroadphaseDetector
supports update tracking.void
optimize()
Deprecated.Attempts to optimize the broadphase based on the current state.List<CollisionItem<T,E>>
raycast(Ray ray, double length, BroadphaseFilter<T,E> filter)
Deprecated.Iterator<CollisionItem<T,E>>
raycastIterator(Ray ray, double length)
Deprecated.Performs a raycast over all the bodies in the broad-phase and returns the items that intersect.boolean
remove(CollisionItem<T,E> item)
Deprecated.Removes the givenFixture
for the givenCollisionBody
from the broad-phase and returns true if it was found.boolean
remove(T body, E fixture)
Deprecated.Removes the givenFixture
for the givenCollisionBody
from the broad-phase and returns true if it was found.void
setUpdated(T body, E fixture)
Deprecated.TheBroadphaseDetector.update(CollisionBody, Fixture)
method will only mark theFixture
as updated if theFixture
has moved enough to change the internally stored AABB.void
shift(Vector2 shift)
Deprecated.Translates the object to match the given coordinate shift.int
size()
Deprecated.Returns the number ofCollisionBody
Fixture
s that are being managed in this broad-phase.boolean
supportsAABBExpansion()
Deprecated.Returns whether this particularBroadphaseDetector
supports expanding AABBs.void
update(T body, E fixture)
Deprecated.Updates the givenCollisionBody
'sFixture
.-
Methods inherited from class AbstractBroadphaseDetector
add, contains, detect, detect, detect, detect, detect, getAABB, getAABB, isUpdated, raycast, remove, setAABBExpansion, setUpdated, setUpdateTrackingEnabled, update
-
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface BroadphaseDetector
add, contains, detect, detect, detect, detect, detect, getAABB, getAABB, isUpdated, raycast, remove, setAABBExpansion, setUpdated, setUpdateTrackingEnabled, update
-
-
-
-
Constructor Detail
-
LazyAABBTree
public LazyAABBTree()
Deprecated.Default constructor.
-
LazyAABBTree
public LazyAABBTree(int initialCapacity)
Deprecated.Optional constructor.Allows fine tuning of the initial capacity of local storage for faster running times.
- Parameters:
initialCapacity
- the initial capacity of local storage- Throws:
IllegalArgumentException
- if initialCapacity is less than zero
-
-
Method Detail
-
batchUpdate
public void batchUpdate()
Deprecated.Destroys the existing tree in O(n) time and prepares for batch-detection while also updating all AABBs. Called byWorld
in each step before detection.- Specified by:
batchUpdate
in interfaceBatchBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
-
add
public void add(T body, E fixture)
Deprecated.Description copied from interface:BroadphaseDetector
Adds a newFixture
for the givenCollisionBody
to the broad-phase.- Specified by:
add
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- the bodyfixture
- the fixture to add
-
remove
public boolean remove(T body, E fixture)
Deprecated.Description copied from interface:BroadphaseDetector
Removes the givenFixture
for the givenCollisionBody
from the broad-phase and returns true if it was found.- Specified by:
remove
in interfaceBroadphaseDetector<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
-
remove
public boolean remove(CollisionItem<T,E> item)
Deprecated.Description copied from interface:BroadphaseDetector
Removes the givenFixture
for the givenCollisionBody
from the broad-phase and returns true if it was found.- Specified by:
remove
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
item
- the collision item- Returns:
- boolean true if the fixture was found and removed
-
update
public void update(T body, E fixture)
Deprecated.Description copied from interface:BroadphaseDetector
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 interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
fixture
- theFixture
that has moved
-
clearUpdates
public void clearUpdates()
Deprecated.Description copied from interface:BroadphaseDetector
Clears any internal state that tracks whatCollisionBody
Fixture
s have been updated.Typically this method would be called from a pipeline after a broadphase collision detection method has been called to clear the state before starting to track new updates.
- Specified by:
clearUpdates
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
-
isUpdated
public boolean isUpdated(T body, E fixture)
Deprecated.Description copied from interface:BroadphaseDetector
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 broadphase.
- Specified by:
isUpdated
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
fixture
- theFixture
- Returns:
- boolean
-
setUpdated
public void setUpdated(T body, E fixture)
Deprecated.Description copied from interface:BroadphaseDetector
TheBroadphaseDetector.update(CollisionBody, Fixture)
method will only mark theFixture
as updated if theFixture
has moved enough to change the internally stored AABB.This method is intended to force the broadphase to include the
Fixture
in the updated list to ensure they are checked in the updated-only detection routine.- Specified by:
setUpdated
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
fixture
- theFixture
-
isUpdated
public boolean isUpdated(CollisionItem<T,E> item)
Deprecated.Description copied from interface:BroadphaseDetector
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 broadphase.
- Specified by:
isUpdated
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
item
- the collision item- Returns:
- boolean
-
getAABB
public AABB getAABB(CollisionItem<T,E> item)
Deprecated.Description copied from interface:BroadphaseDetector
Returns the AABB for the givenCollisionBody
Fixture
.If the body and its fixture have not been added to this broad-phase, a new AABB is created and returned (but not added to broad-phase).
In all cases this method returns the expanded AABB in the case this detector supports it.
NOTE: The
AABB
returned from this method should not be modified. Instead use theAABB.copy()
method to create a new instance to modify.- Specified by:
getAABB
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
item
- the collision item- Returns:
AABB
-
contains
public boolean contains(T body, E fixture)
Deprecated.Description copied from interface:BroadphaseDetector
Returns true if the givenFixture
on the givenCollisionBody
has been added to this broadphase.- Specified by:
contains
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
body
- theCollisionBody
fixture
- theFixture
- Returns:
- boolean
-
contains
public boolean contains(CollisionItem<T,E> item)
Deprecated.Description copied from interface:BroadphaseDetector
Returns true if the givenFixture
on the givenCollisionBody
has been added to this broadphase.- Specified by:
contains
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
item
- the collision item- Returns:
- boolean
-
clear
public void clear()
Deprecated.Description copied from interface:BroadphaseDetector
Clears all theCollisionBody
Fixture
s from this broad-phase and any state held by this broadphase.- Specified by:
clear
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
-
size
public int size()
Deprecated.Description copied from interface:BroadphaseDetector
Returns the number ofCollisionBody
Fixture
s that are being managed in this broad-phase.- Specified by:
size
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Returns:
- int
-
detect
@Deprecated public List<CollisionPair<T,E>> detect(BroadphaseFilter<T,E> filter)
Deprecated.Description copied from interface:BroadphaseDetector
Performs collision detection on allCollisionBody
Fixture
s that have been added to thisBroadphaseDetector
and returns the list of potential pairs.Use the
filter
parameter to further reduce the number of potential pairs.- Specified by:
detect
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Overrides:
detect
in classAbstractBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
filter
- the broad-phase filter- Returns:
- List<
BroadphasePair
> - See Also:
BroadphaseDetector.detect()
-
detectIterator
public Iterator<CollisionPair<T,E>> detectIterator(boolean forceFullDetection)
Deprecated.Description copied from interface:BroadphaseDetector
Performs collision detection on allCollisionBody
Fixture
s that have been added to thisBroadphaseDetector
and returns the list of potential pairs.The returned pairs from this method will depend on the
BroadphaseDetector.isUpdateTrackingEnabled()
flag. If the flag is true, then only updated pairs will be emitted, otherwise all pairs are emitted.Use the forceFullDetection parameter to override this behavior for this call.
NOTE: This method returns
CollisionPair
s that are mutable internally. If you need to store the pairs outside of the iteration, be sure to call theCopyable.copy()
method to create a copy of the pair data.- Specified by:
detectIterator
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
forceFullDetection
- true if a full detection should be performed- Returns:
- Iterator<
CollisionPair
>
-
detect
@Deprecated public List<CollisionItem<T,E>> detect(AABB aabb, BroadphaseFilter<T,E> filter)
Deprecated.Description copied from interface:BroadphaseDetector
Performs a broad-phase collision test using the givenAABB
and returns the items that overlap.Use the
filter
parameter to further reduce the number of items returned.- Specified by:
detect
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Overrides:
detect
in classAbstractBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
aabb
- theAABB
to testfilter
- the broad-phase filter- Returns:
- List<
CollisionItem
> - See Also:
BroadphaseDetector.detect(AABB)
-
detectIterator
public Iterator<CollisionItem<T,E>> detectIterator(AABB aabb)
Deprecated.Description copied from interface:BroadphaseDetector
Performs a broad-phase collision test using the givenAABB
and returns the items that overlap.- Specified by:
detectIterator
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
aabb
- theAABB
to test- Returns:
- Iterator<
CollisionItem
>
-
raycast
@Deprecated public List<CollisionItem<T,E>> raycast(Ray ray, double length, BroadphaseFilter<T,E> filter)
Deprecated.Description copied from interface:BroadphaseDetector
Performs a preliminary raycast over all the bodies in the broad-phase and returns the items that intersect.Use the
filter
parameter to further reduce the number of items returned.- Specified by:
raycast
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Overrides:
raycast
in classAbstractBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
ray
- theRay
length
- the length of the ray; 0.0 for infinite lengthfilter
- the broad-phase filter- Returns:
- List<
BroadphaseItem
> - See Also:
BroadphaseDetector.raycast(Ray, double)
-
raycastIterator
public Iterator<CollisionItem<T,E>> raycastIterator(Ray ray, double length)
Deprecated.Description copied from interface:BroadphaseDetector
Performs a raycast over all the bodies in the broad-phase and returns the items that intersect.- Specified by:
raycastIterator
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Parameters:
ray
- theRay
length
- the length of the ray; 0.0 for infinite length- Returns:
- Iterator<
CollisionItem
>
-
shift
public void shift(Vector2 shift)
Deprecated.Description copied from interface:Shiftable
Translates the object to match the given coordinate shift.
-
getAABBExpansion
public double getAABBExpansion()
Deprecated.Description copied from interface:BroadphaseDetector
Returns theAABB
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.
- Specified by:
getAABBExpansion
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Overrides:
getAABBExpansion
in classAbstractBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Returns:
- double
- See Also:
BroadphaseDetector.setAABBExpansion(double)
-
supportsAABBExpansion
public boolean supportsAABBExpansion()
Deprecated.Description copied from interface:BroadphaseDetector
Returns whether this particularBroadphaseDetector
supports expanding AABBs.- Specified by:
supportsAABBExpansion
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Overrides:
supportsAABBExpansion
in classAbstractBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Returns:
- boolean
-
isUpdateTrackingEnabled
public boolean isUpdateTrackingEnabled()
Deprecated.Description copied from interface:BroadphaseDetector
Returns true if this broadphase is tracking updated items.Tracking updates to the broadphase can have huge performance gains if the majority of objects are stationary or moving slowly enough.
- Specified by:
isUpdateTrackingEnabled
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Overrides:
isUpdateTrackingEnabled
in classAbstractBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Returns:
- boolean
-
isAABBExpansionSupported
public boolean isAABBExpansionSupported()
Deprecated.Description copied from interface:BroadphaseDetector
Returns whether this particularBroadphaseDetector
supports expanding AABBs.- Specified by:
isAABBExpansionSupported
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Overrides:
isAABBExpansionSupported
in classAbstractBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Returns:
- boolean
-
isUpdateTrackingSupported
public boolean isUpdateTrackingSupported()
Deprecated.Description copied from interface:BroadphaseDetector
Returns whether this particularBroadphaseDetector
supports update tracking.- Specified by:
isUpdateTrackingSupported
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Overrides:
isUpdateTrackingSupported
in classAbstractBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
- Returns:
- boolean
-
optimize
public void optimize()
Deprecated.Description copied from interface:BroadphaseDetector
Attempts to optimize the broadphase based on the current state.This method could be very intensive so should only be called if there's a clear benefit.
- Specified by:
optimize
in interfaceBroadphaseDetector<T extends CollisionBody<E>,E extends Fixture>
-
-