A* Pathfinding Project
4.0.3
The A* Pathfinding Project for Unity 3D
|
Holds a lookup datastructure to quickly find objects inside rectangles. More...
Holds a lookup datastructure to quickly find objects inside rectangles.
Objects of type T occupy an integer rectangle in the grid and they can be moved efficiently. You can query for all objects that touch a specified rectangle that runs in O(m*k) time where m is the number of objects that the query returns and k is the average number of cells that an object occupies.
All objects must be contained within a rectangle with one point at the origin (inclusive) and one at size (exclusive) that is specified in the constructor.
T | : | class |
Classes | |
class | Item |
class | Root |
Public Member Functions | |
GridLookup (Int2 size) | |
Root | Add (T item, IntRect bounds) |
Add an object to the lookup data structure. | |
Root | GetRoot (T item) |
void | Move (T item, IntRect bounds) |
Move an object to occupy a new set of cells. | |
List< T > | QueryRect (IntRect r) |
Returns all objects inside the cells marked by the rectangle. | |
void | Remove (T item) |
Removes an item from the lookup data structure. | |
Properties | |
Root | AllItems [get] |
Linked list of all items. | |
Private Attributes | |
Root | all = new Root() |
Linked list of all items. | |
Item[] | cells |
Stack< Item > | itemPool = new Stack<Item>() |
Dictionary< T, Root > | rootLookup = new Dictionary<T, Root>() |
Int2 | size |
GridLookup | ( | Int2 | size | ) |
Root Add | ( | T | item, |
IntRect | bounds | ||
) |
Add an object to the lookup data structure.
Root GetRoot | ( | T | item | ) |
void Move | ( | T | item, |
IntRect | bounds | ||
) |
Move an object to occupy a new set of cells.
List<T> QueryRect | ( | IntRect | r | ) |
Returns all objects inside the cells marked by the rectangle.
void Remove | ( | T | item | ) |
Removes an item from the lookup data structure.
|
private |
Linked list of all items.
Note that the first item in the list is a dummy item and does not contain any data.
|
private |
|
private |
|
private |
|
private |
|
get |
Linked list of all items.