Gamedev Framework (gf)  0.17.0
A C++14 framework for 2D games
Classes | Public Member Functions | List of all members
gf::SimpleSpatialIndex Class Reference

An very simple spatial index. More...

#include <gf/spatial/SimpleSpatialIndex.h>

Public Member Functions

 SimpleSpatialIndex ()
 Constructor. More...
 
SpatialId insert (Handle handle, const RectF &bounds)
 Insert an object in the tree. More...
 
void modify (SpatialId id, RectF bounds)
 Modify the bounds of an object. More...
 
std::size_t query (const RectF &bounds, SpatialQueryCallback callback, SpatialQuery kind=SpatialQuery::Intersect)
 Query objects in the tree. More...
 
void remove (SpatialId id)
 Remove an object from the tree. More...
 
void clear ()
 Remove all the objects from the tree. More...
 
Handle operator[] (SpatialId id)
 Get the handle associated to a spatial id. More...
 

Detailed Description

An very simple spatial index.

See also
gf::Quadtree, gf::RStarTree

Constructor & Destructor Documentation

◆ SimpleSpatialIndex()

gf::SimpleSpatialIndex::SimpleSpatialIndex ( )

Constructor.

Member Function Documentation

◆ clear()

void gf::SimpleSpatialIndex::clear ( )

Remove all the objects from the tree.

◆ insert()

SpatialId gf::SimpleSpatialIndex::insert ( Handle  handle,
const RectF bounds 
)

Insert an object in the tree.

Parameters
handleA handle that represents the object to insert
boundsThe bounds of the object
Returns
A spatial id

◆ modify()

void gf::SimpleSpatialIndex::modify ( SpatialId  id,
RectF  bounds 
)

Modify the bounds of an object.

Parameters
idThe spatial id of the object
boundsThe new bounds of the object

◆ operator[]()

Handle gf::SimpleSpatialIndex::operator[] ( SpatialId  id)

Get the handle associated to a spatial id.

Parameters
idThe spatial id of the object

◆ query()

std::size_t gf::SimpleSpatialIndex::query ( const RectF bounds,
SpatialQueryCallback  callback,
SpatialQuery  kind = SpatialQuery::Intersect 
)

Query objects in the tree.

Parameters
boundsThe bounds of the query
callbackThe callback to apply to found objects
kindThe kind of spatial query
Returns
The number of objects found

◆ remove()

void gf::SimpleSpatialIndex::remove ( SpatialId  id)

Remove an object from the tree.

Parameters
idThe spatial id of the object