![]() |
VR-Forces 5.0.2 Developer's Guide
|
DtOctree class.
DtOctree implements an octree, for storing arbitary objects with extents in a way that makes it fast to enumerate objects that intersect a specified extent.
Currently there's some sloppiness in the implementation which will make it difficult to specialize this template to objects other than DtSimObjects, but it's good to keep that sloppiness to a minimum, as this class would be useful for other things (notably terrain triangles).
The outer octree class does attempt to deal with objects which are outside the octree's defined region, but it does not do so efficiently.

Public Types | |
| typedef std::map< T *, DtOctreeMember< T > * > | MemberContainer |
| typedef std::map< T *, DtOctreeMember< T > * >::iterator | MemberIterator |
| typedef std::list< T * > | OutsideAreaContainer |
| typedef std::list< T * >::iterator | OutsideAreaIterator |
| typedef DtSpatialSelectionFunctorTemplate < T > | SpatialSelectionFunctor |
Public Member Functions | |
| DtOctree (const DtExtent ®ion) | |
| virtual | ~DtOctree () |
| virtual void | visitObjects (const DtExtent &extent, DtSpatialSelectionFunctorTemplate< T > &callback) |
| virtual void | addObject (T *object, const DtExtent &extent) |
| virtual void | removeObject (T *object, bool needsLock=true) |
| virtual void | updatePositions () |
| bool | containsObject (T *object) |
| int | numObjects () |
| int | numObjectsOutside () |
Protected Member Functions | |
| bool | removeObjectOutsideArea (T *object) |
Protected Attributes | |
| tbb::spin_rw_mutex | myMutex |
| DtOctreeNode< T > * | myRootNode |
| OutsideAreaContainer | myObjectsOutsideArea |
| MemberContainer | myMemberMap |
| tbb::atomic< unsigned int > | mySearchKey |
| typedef std::map<T*, DtOctreeMember<T>*> DtOctree< T >::MemberContainer |
Container and iterator typedefs for the STL structures used.
| typedef std::map<T*, DtOctreeMember<T>*>::iterator DtOctree< T >::MemberIterator |
| typedef std::list<T*> DtOctree< T >::OutsideAreaContainer |
| typedef std::list<T*>::iterator DtOctree< T >::OutsideAreaIterator |
| typedef DtSpatialSelectionFunctorTemplate<T> DtOctree< T >::SpatialSelectionFunctor |
Constructor. The extent covered by an octree may not be changed once the octree is created.
Destructor. Deletes the octree and any members in it (though not the corresponding objects).
|
inlinevirtual |
Call the given functor for every member that shares a node with the specified extent. This does not test for exact intersection; it only iterates over any objects that might intersect the given extent (i.e. there may be extras).
|
inlinevirtual |
TODO: Add search key to outside octree list so that objects which fall completely outside the octree region can be filtered out of searches completely within.
Add a member to the octree.
|
inlinevirtual |
Remove a member from the octree.
Referenced by DtOctree< const DtSimObject >::updatePositions().
|
inlinevirtual |
Process any updates to the objects' positions that have happened since they were added to the octree. If members' extents change, they will still be returned from visitMembers() as if they held the old position until this function is called. Once this function is called, objects will intersect using the newly-specified positions (until the function is called again, obviously).
Referenced by DtOctree< const DtSimObject >::removeObject().
|
protected |
|
protected |
|
protected |
List of objects which are at least partially outside the octree's root extent.
Referenced by DtOctree< const DtSimObject >::addObject(), DtOctree< const DtSimObject >::containsObject(), DtOctree< const DtSimObject >::numObjects(), DtOctree< const DtSimObject >::numObjectsOutside(), DtOctree< const DtSimObject >::removeObjectOutsideArea(), DtOctree< const DtSimObject >::updatePositions(), and DtOctree< const DtSimObject >::visitObjects().
|
protected |
Mapping of T* pointers to DtOctreeMember objects in the tree.
Referenced by DtOctree< const DtSimObject >::addObject(), DtOctree< const DtSimObject >::containsObject(), DtOctree< const DtSimObject >::numObjects(), DtOctree< const DtSimObject >::removeObject(), DtOctree< const DtSimObject >::updatePositions(), and DtOctree< const DtSimObject >::~DtOctree().
Referenced by DtOctree< const DtSimObject >::visitObjects().