The MapKdTree class is used to help manage drawing aesop Maps and Zones (see aesop::Map and aesop::Zone). More...
Classes | |
struct | aesop::map_draw_stats_t |
struct | aesop::kd_node_t |
class | aesop::MapKdTree |
top-level object that manages the full kd-tree More... | |
Typedefs | |
typedef void(* | aesop::kdtree_callback_fn )(IN const kd_node_t &node, IN void *context) |
typedef void(* | aesop::kdtree_object_fn )(IN glut::Renderable *model, IN const glut::render_context_t &rc, IN glut::RenderQueue *rq, IN void *context) |
Functions | |
void | aesop::map_draw_stats_t::clear (void) throw () |
virtual MapDynamics * | aesop::MapKdTree::getMapDynamics (void)=0 throw () |
get the underlying MapDynamics object | |
virtual void | aesop::MapKdTree::walkNodes (IN kdtree_callback_fn callback, IN void *context)=0 |
visit all nodes in the tree in arbitrary order | |
virtual void | aesop::MapKdTree::walkFrontToBack (IN const glut::render_context_t &rc, IN glut::RenderQueue *rq, IN kdtree_object_fn callback, IN void *context)=0 |
visit all objects in the tree, walking front to back | |
static smart_ptr< MapKdTree > | aesop::MapKdTree::create (IN smart_ptr< MapDynamics > &map) |
void | aesop::drawMap (IN MapKdTree *mapKdTree, IN const glut::render_context_t &rc, IN glut::RenderQueue *rq, OUT map_draw_stats_t &stats) |
helper method to draw a KdTree map. | |
Variables | |
int | aesop::map_draw_stats_t::nObjects |
number of objects drawn | |
int | aesop::kd_node_t::depth |
root-->depth=0, then increases |
The MapKdTree class is used to help manage drawing aesop Maps and Zones (see aesop::Map and aesop::Zone).
Internally, the MapKdTree maintains a kd-tree which provides efficient front-to-back traversal of all objects near the viewer within the view frustum. The MapKdTree is also aware of zone visibility flags and will use that to optimize tree walking. Furthermore, the MapKdTree is aware of virtual zones and will make objects in virtual leaf zones available for rendering if they should be visible.
In general, when walking a large 3D scee for rendering, you should:
In addition, the MapKdTree class knows how to update dynamic objects it contains. It will remove them and re-insert them at updated positions whenever you call MapKdTree::update().
The goal is to make things easy for the client: when you have a MapDynamics object, create a MapKdTree object for it, and then you can use the MapKdTree to efficiently render everything in the map. As a client, just call MapKdTree::walkFrontToBack() and you'll be given objects to render in the proper order (and these will only be objects within the view frustum and in zones visible to the viewer).
typedef void(* aesop::kdtree_callback_fn)(IN const kd_node_t &node, IN void *context) |
Definition at line 101 of file map-kdtree.h.
typedef void(* aesop::kdtree_object_fn)(IN glut::Renderable *model, IN const glut::render_context_t &rc, IN glut::RenderQueue *rq, IN void *context) |
Definition at line 104 of file map-kdtree.h.
void aesop::map_draw_stats_t::clear | ( | void | ) | throw () [inline, inherited] |
Definition at line 85 of file map-kdtree.h.
virtual MapDynamics* aesop::MapKdTree::getMapDynamics | ( | void | ) | throw () [pure virtual, inherited] |
get the underlying MapDynamics object
virtual void aesop::MapKdTree::walkNodes | ( | IN kdtree_callback_fn | callback, | |
IN void * | context | |||
) | [pure virtual, inherited] |
visit all nodes in the tree in arbitrary order
virtual void aesop::MapKdTree::walkFrontToBack | ( | IN const glut::render_context_t & | rc, | |
IN glut::RenderQueue * | rq, | |||
IN kdtree_object_fn | callback, | |||
IN void * | context | |||
) | [pure virtual, inherited] |
visit all objects in the tree, walking front to back
smart_ptr< MapKdTree > aesop::MapKdTree::create | ( | IN smart_ptr< MapDynamics > & | map | ) | [static, inherited] |
Definition at line 1038 of file map-kdtree.cpp.
void aesop::drawMap | ( | IN MapKdTree * | mapKdTree, | |
IN const glut::render_context_t & | rc, | |||
IN glut::RenderQueue * | rq, | |||
OUT map_draw_stats_t & | stats | |||
) |
helper method to draw a KdTree map.
Caller must provide an (empty) glut::RenderQueue object, which this routine uses to render transparent polygons.
int aesop::map_draw_stats_t::nObjects [inherited] |
number of objects drawn
Definition at line 90 of file map-kdtree.h.
int aesop::kd_node_t::depth [inherited] |
root-->depth=0, then increases
Definition at line 97 of file map-kdtree.h.