ForgeDocs
Documentation for the forge framework
|
Implements a QuadTree, which supports spatial monitoring and spatial querying of positionable objects. The objects can be positioned anywhere, even at negative coordinates. More...
Public Member Functions | |
QuadTree (int worldScale=100) | |
Constructs a new QuadTree that is empty. More... | |
void | AddItem (TItem item, Vector2r position) |
Add a new item to the QuadTree at the given position. More... | |
void | UpdateItem (TItem item, Vector2r previous, Vector2r current) |
Update the position of an item. This will notify monitors of position updates. More... | |
void | RemoveItem (TItem item, Vector2r position) |
Remove an item from the QuadTree. More... | |
TCollection | CollectItems< TCollection > (Bound region, TCollection storage=null) |
Collect all items that are stored inside of the given region. More... | |
void | AddMonitor (IQuadTreeMonitor< TItem > monitor, Bound monitoredRegion) |
Inserts the given monitor into the QuadTree. The monitor will be notified of any entities that enter or leave it. The monitor can be updated or removed. More... | |
void | RemoveMonitor (IQuadTreeMonitor< TItem > monitor, Bound monitoredRegion) |
Removes the given monitor from the quad tree. It will receive a series of OnExit calls during this Remove call. More... | |
void | UpdateMonitor (IQuadTreeMonitor< TItem > monitor, Bound previousRegion, Bound currentRegion) |
Update the position of a monitor. More... | |
Properties | |
IEnumerable< IQuadTreeMonitor < TItem > > | Monitors [get] |
Returns all monitors that are stored in the tree. More... | |
IEnumerable< TItem > | Items [get] |
Returns all items that are stored in the tree. More... | |
Implements a QuadTree, which supports spatial monitoring and spatial querying of positionable objects. The objects can be positioned anywhere, even at negative coordinates.
In regards to implementation details, this is not currently a recursive QuadTree. Instead, the world is divided into a set of chunks which can be queried directly. The size of these chunks can be controlled by the constructor parameter.
T | The type of object stored in the QuadTree |
Forge.Collections.QuadTree< TItem >.QuadTree | ( | int | worldScale = 100 | ) |
Constructs a new QuadTree that is empty.
worldScale | The size of each node inside of the tree. A larger value will result in faster queries over large areas, but a smaller value will result in faster queries over a smaller area. In general, this should be close to your typical query size. |
void Forge.Collections.QuadTree< TItem >.AddItem | ( | TItem | item, |
Vector2r | position | ||
) |
Add a new item to the QuadTree at the given position.
item | The item to add. |
position | The position of the item. |
void Forge.Collections.QuadTree< TItem >.AddMonitor | ( | IQuadTreeMonitor< TItem > | monitor, |
Bound | monitoredRegion | ||
) |
Inserts the given monitor into the QuadTree. The monitor will be notified of any entities that enter or leave it. The monitor can be updated or removed.
monitor | The monitor. |
monitoredRegion | The area that the monitor is viewing. |
TCollection Forge.Collections.QuadTree< TItem >.CollectItems< TCollection > | ( | Bound | region, |
TCollection | storage = null |
||
) |
Collect all items that are stored inside of the given region.
region | The area to collect entities from. |
storage | Where to store the collected entities. |
TCollection | The type of collection to store items in. |
TCollection | : | class | |
TCollection | : | ICollection<TItem> | |
TCollection | : | new() |
void Forge.Collections.QuadTree< TItem >.RemoveItem | ( | TItem | item, |
Vector2r | position | ||
) |
Remove an item from the QuadTree.
item | The item to remove. |
position | The position of the item. |
void Forge.Collections.QuadTree< TItem >.RemoveMonitor | ( | IQuadTreeMonitor< TItem > | monitor, |
Bound | monitoredRegion | ||
) |
Removes the given monitor from the quad tree. It will receive a series of OnExit calls during this Remove call.
monitor | The monitor to remove. |
monitoredRegion | The region that the monitor was monitoring. |
void Forge.Collections.QuadTree< TItem >.UpdateItem | ( | TItem | item, |
Vector2r | previous, | ||
Vector2r | current | ||
) |
Update the position of an item. This will notify monitors of position updates.
item | The item to update the position of. |
previous | The old position of the item. |
current | The updated position of the item. |
void Forge.Collections.QuadTree< TItem >.UpdateMonitor | ( | IQuadTreeMonitor< TItem > | monitor, |
Bound | previousRegion, | ||
Bound | currentRegion | ||
) |
Update the position of a monitor.
monitor | The monitor whose position has changed. |
previousRegion | The previous area that the monitor was watching. |
currentRegion | The new area that the monitor is watching. |
|
get |
Returns all items that are stored in the tree.
|
get |
Returns all monitors that are stored in the tree.