A basic square subdivision scheme for finding entities in range More efficient than SpatialSubdivision, but a bit less precise (so the querier will get more entities to perform tests on).
More...
|
| FastSpatialSubdivision () |
|
| FastSpatialSubdivision (const FastSpatialSubdivision &other) |
|
| ~FastSpatialSubdivision () |
|
void | Reset (size_t arrayWidth) |
|
void | Reset (fixed w, fixed h) |
|
FastSpatialSubdivision & | operator= (const FastSpatialSubdivision &other) |
|
bool | operator== (const FastSpatialSubdivision &other) const |
|
bool | operator!= (const FastSpatialSubdivision &rhs) const |
|
void | Add (entity_id_t item, CFixedVector2D position, u32 size) |
| Add an item. More...
|
|
void | Remove (entity_id_t item, CFixedVector2D position, u32 size) |
| Remove an item. More...
|
|
void | Move (entity_id_t item, CFixedVector2D oldPosition, CFixedVector2D newPosition, u32 size) |
| Equivalent to Remove() then Add(), but slightly faster. More...
|
|
void | GetInRange (std::vector< entity_id_t > &out, CFixedVector2D posMin, CFixedVector2D posMax) const |
| Returns a (non sorted) list of items that are either in the square or close to it. More...
|
|
void | GetNear (std::vector< entity_id_t > &out, CFixedVector2D pos, entity_pos_t range) const |
| Returns a (non sorted) list of items that are either in the circle or close to it. More...
|
|
size_t | GetDivisionSize () const |
|
size_t | GetWidth () const |
|
A basic square subdivision scheme for finding entities in range More efficient than SpatialSubdivision, but a bit less precise (so the querier will get more entities to perform tests on).
Items are stored in vectors in fixed-size divisions.
Items have a size (min/max values of their axis-aligned bounding box). If that size is higher than a subdivision's size, they're stored in the "general" vector This means that if too many objects have a size that's big, it'll end up being slow We want subdivisions to be as small as possible yet contain as many items as possible.
It is the caller's responsibility to ensure items are only added once, aren't removed unless they've been added, etc, and that Move/Remove are called with the same coordinates originally passed to Add (since this class doesn't remember which divisions an item occupies).
TODO: If a unit size were to change, it would need to be updated (that doesn't happen for now)