|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.nexttext.SpatialList
public class SpatialList
The SpatialList class is used to keep track of the TextObjects in a spatially organised fashion in order to facilitate proximity and collision queries.
At the moment, the list will only contain glyph objects and no groups. Group behaviour based on proximity will have to be deduced from the collisions between the different glyphs.
The SpatialList is updated once each frame by the Simulator, meaning that as objects move during the behaviours step of the simulation the SpatialList becomes unsorted. For this reason, queries for possibly colliding objects will not always be completely accurate. However, this has not proved to be problematic in practice.
The spatial list is maintained using a sweep and prune collision approximation algorithm which use dynamic AABBs (Axis-Aligned Bounding Boxes) to determine proximity or overlap between two objects.
This algorithm is optimised based on the assumption that objects maintain their spatial coherence from frame to frame (ie: object don't travel very far within the span of one frame). As such, insertion of objects in the spatial list is costly (because the list has to be resorted), however once objects have been inserted, maintaining a sorted order is done in nearly O(n) most of the time.
Add description of how to use the class
TO DO: Add/Remove function for Groups
Constructor Summary | |
---|---|
SpatialList()
|
Method Summary | |
---|---|
void |
add(TextObject to)
Adds a TextObject to the spatial list. |
void |
add(TextObjectGlyph to)
Adds a single TextObjectGlyph to the spatial list |
void |
add(TextObjectGroup tog)
Adds all the glyphs part of a TextObjectGroup to the spatial list. |
int |
getNumCollisionTests()
Returns the average number of collision tests performed by the sorting function |
java.util.HashSet<TextObjectGlyph> |
getPotentialCollisions(TextObject to)
Redirects to the proper implementation of getPotentialCollisions based on type (TextObjectGlyph or TextObjectGroup) |
java.util.HashSet<TextObjectGlyph> |
getPotentialCollisions(TextObjectGlyph to)
Given a TextObjectGlyph, get a list of objects which's bounding box are overlapping. |
java.util.HashSet<TextObjectGlyph> |
getPotentialCollisions(TextObjectGroup tog)
Given a TextObjectGroup, find all the glyphs which's bounding boxes are overlapping with any of the given group's glyphs. |
void |
remove(TextObject to)
Removes a TextObject to the spatial list. |
void |
remove(TextObjectGlyph to)
Removes an object from the spatial list |
void |
remove(TextObjectGroup tog)
Removes all the glyphs part of a TextObjectGroup from the spatial list |
void |
update()
Sorts the X and Y axis interval lists. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SpatialList()
Method Detail |
---|
public void update()
public void add(TextObjectGlyph to)
public void remove(TextObjectGlyph to)
public void add(TextObjectGroup tog)
public void add(TextObject to)
public void remove(TextObject to)
public void remove(TextObjectGroup tog)
public java.util.HashSet<TextObjectGlyph> getPotentialCollisions(TextObject to)
public java.util.HashSet<TextObjectGlyph> getPotentialCollisions(TextObjectGlyph to)
to
- A TextObjectGlyph to test for collisionspublic java.util.HashSet<TextObjectGlyph> getPotentialCollisions(TextObjectGroup tog)
public int getNumCollisionTests()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |