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

An implementation of dynamic tree. More...

#include <gf/spatial/DynamicTree.h>

Public Member Functions

 DynamicTree ()
 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 implementation of dynamic tree.

Constructor & Destructor Documentation

◆ DynamicTree()

gf::DynamicTree::DynamicTree ( )

Constructor.

Member Function Documentation

◆ clear()

void gf::DynamicTree::clear ( )

Remove all the objects from the tree.

◆ insert()

SpatialId gf::DynamicTree::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::DynamicTree::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::DynamicTree::operator[] ( SpatialId  id)

Get the handle associated to a spatial id.

Parameters
idThe spatial id of the object

◆ query()

std::size_t gf::DynamicTree::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::DynamicTree::remove ( SpatialId  id)

Remove an object from the tree.

Parameters
idThe spatial id of the object