#include <Octree.h>
Inheritance diagram for hxa7241_graphics::OctreeAgent< TYPE >:
Public Member Functions | |
virtual | ~OctreeAgent () |
virtual bool | isOverlappingCellV (const void *pItem, const Vector3r &lowerCorner, const Vector3r &upperCorner) const |
void-to-type forwarders | |
virtual dword | getSubcellOverlapsV (const void *pItem, const Vector3r &lower, const Vector3r &middle, const Vector3r &upper) const |
Protected Member Functions | |
OctreeAgent () | |
standard object services --------------------------------------------------- | |
virtual bool | isOverlappingCell (const TYPE &item, const Vector3r &lowerCorner, const Vector3r &upperCorner) const =0 |
queries -------------------------------------------------------------------- | |
virtual dword | getSubcellOverlaps (const TYPE &item, const Vector3r &lowerCorner, const Vector3r &middlePoint, const Vector3r &upperCorner) const |
default implementation |
Client of Octree must define a concrete derivative of OctreeAgent<ItemType>.
This is similar to a proxy: it is an intermediary for an Octree to query its typeless subject items, when inserting or removing.
The overlap methods are to determine an item's relation to a cell or cells, for insertion or removal. The parameters supply the bounds of the cell.
Return value of getSubcellOverlaps is 8 bits, each bit is a bool corresponding to a subcell, the high bit for subcell 7, the low bit for subcell 0.
Subcell numbering:
y z 6 7 |/ 2 3 4 5 -x 0 1in binary:
y z 110 111 |/ 010 011 100 101 -x 000 001
The ___V methods simply apply a type-cast to void*s and forward to their abstract counterparts.
An Octree requires its contained items to provide positional info. But requiring the item classes to implement an OctreeItem interface would impose a direct interface change on every prospective item type, and enlarge their instances with a vptr.
Instead, this agent transfers the Octree-related interface/implementation away from the item type into a separate class. The Octree can now hold void pointers to items and call the agent to query them indirectly.
hxa7241_graphics::OctreeAgent< TYPE >::OctreeAgent | ( | ) | [inline, protected] |
standard object services ---------------------------------------------------
virtual hxa7241_graphics::OctreeAgent< TYPE >::~OctreeAgent | ( | ) | [inline, virtual] |
bool hxa7241_graphics::OctreeAgent< TYPE >::isOverlappingCellV | ( | const void * | pItem, | |
const Vector3r & | lowerCorner, | |||
const Vector3r & | upperCorner | |||
) | const [inline, virtual] |
dword hxa7241_graphics::OctreeAgent< TYPE >::getSubcellOverlapsV | ( | const void * | pItem, | |
const Vector3r & | lower, | |||
const Vector3r & | middle, | |||
const Vector3r & | upper | |||
) | const [inline, virtual] |
Implements hxa7241_graphics::OctreeAgentV.
virtual bool hxa7241_graphics::OctreeAgent< TYPE >::isOverlappingCell | ( | const TYPE & | item, | |
const Vector3r & | lowerCorner, | |||
const Vector3r & | upperCorner | |||
) | const [protected, pure virtual] |
queries --------------------------------------------------------------------
Called by Octree to get relation of item to cell.
Implemented in Octree_Agent_Face.
dword hxa7241_graphics::OctreeAgent< TYPE >::getSubcellOverlaps | ( | const TYPE & | item, | |
const Vector3r & | lowerCorner, | |||
const Vector3r & | middlePoint, | |||
const Vector3r & | upperCorner | |||
) | const [protected, virtual] |
default implementation
Called by Octree to get relation of item to subcell octants.
Override to make a more efficent calculation (boundary testing can be shared).
y z 6 7 |/ 2 3 4 5 -x 0 1in binary:
y z 110 111 |/ 010 011 100 101 -x 000 001