FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
#include <instancetree.h>
Public Types | |
typedef std::list< Instance * > | InstanceList |
typedef QuadTree< InstanceList, MIN_TREE_SIZE > | InstanceQuadTree |
typedef InstanceQuadTree::Node | InstanceTreeNode |
Public Member Functions | |
InstanceTree () | |
Constructor. More... | |
virtual | ~InstanceTree () |
Destructor. More... | |
void | addInstance (Instance *instance) |
Adds an instance to the quad tree. More... | |
void | removeInstance (Instance *instance) |
Removes an instance from the quad tree. More... | |
void | findInstances (const ModelCoordinate &point, int32_t w, int32_t h, InstanceList &list) |
Find all instances in a given area. More... | |
template<typename Visitor > | |
void | applyVisitor (Visitor &visitor) |
See QuadNode::apply_visitor. More... | |
Public Member Functions inherited from FIFE::FifeClass | |
FifeClass () | |
virtual | ~FifeClass () |
fifeid_t | getFifeId () |
Gets unique id of this instance inside the engine. More... | |
Static Public Attributes | |
static const int32_t | MIN_TREE_SIZE = 2 |
Private Attributes | |
InstanceQuadTree | m_tree |
std::map< Instance *, InstanceTreeNode * > | m_reverse |
Definition at line 42 of file instancetree.h.
typedef std::list<Instance*> FIFE::InstanceTree::InstanceList |
Definition at line 46 of file instancetree.h.
Definition at line 47 of file instancetree.h.
Definition at line 48 of file instancetree.h.
FIFE::InstanceTree::InstanceTree | ( | ) |
Constructor.
Definition at line 42 of file instancetree.cpp.
|
virtual |
Destructor.
Definition at line 45 of file instancetree.cpp.
void FIFE::InstanceTree::addInstance | ( | Instance * | instance | ) |
Adds an instance to the quad tree.
Adds an instance to the quad tree based upon it's location on the layer and it's area.
instance | A pointer to the instance to add. |
Definition at line 48 of file instancetree.cpp.
References FIFE::_log, FIFE::QuadNode< DataType, MinimumSize >::data(), FIFE::QuadTree< DataType, MinimumSize >::find_container(), FL_WARN, FIFE::Location::getLayerCoordinates(), FIFE::Instance::getLocationRef(), m_reverse, m_tree, FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.
Referenced by FIFE::Layer::addInstance(), FIFE::Layer::createInstance(), and FIFE::Instance::setLocation().
|
inline |
Definition at line 93 of file instancetree.h.
References FIFE::QuadTree< DataType, MinimumSize >::apply_visitor(), and m_tree.
Referenced by FIFE::QuadTreeRenderer::render().
void FIFE::InstanceTree::findInstances | ( | const ModelCoordinate & | point, |
int32_t | w, | ||
int32_t | h, | ||
InstanceTree::InstanceList & | list | ||
) |
Find all instances in a given area.
Takes a box as an area then returns a vector filled with all instances that intersect with that box.
point | A ModelCoordinate representing the upper left part of the search area. |
w | The width of the search area in Model Units. |
h | The height of the search area in Model Units. |
list | vector reference that will be filled with all instances within that space. |
Definition at line 98 of file instancetree.cpp.
References FIFE::RectType< T >::contains(), FIFE::QuadTree< DataType, MinimumSize >::find_container(), m_tree, FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.
Referenced by FIFE::CellCache::addInteractOnRuntime(), FIFE::Layer::cellContainsBlockingInstance(), FIFE::CellCache::createCells(), FIFE::Layer::getBlockingInstances(), FIFE::Layer::getInstancesIn(), FIFE::Layer::getInstancesInCircle(), FIFE::Layer::getInstancesInLine(), FIFE::CellCache::removeInteractOnRuntime(), and FIFE::CellCache::resize().
void FIFE::InstanceTree::removeInstance | ( | Instance * | instance | ) |
Removes an instance from the quad tree.
Locates an instance in the quad tree then removes it.
instance | A pointer to the instance to find and remove. |
Definition at line 60 of file instancetree.cpp.
References FIFE::_log, FL_WARN, and m_reverse.
Referenced by FIFE::Layer::deleteInstance(), FIFE::Layer::removeInstance(), and FIFE::Instance::setLocation().
|
private |
Definition at line 100 of file instancetree.h.
Referenced by addInstance(), and removeInstance().
|
private |
Definition at line 99 of file instancetree.h.
Referenced by addInstance(), applyVisitor(), and findInstances().
|
static |
Definition at line 44 of file instancetree.h.