![]() |
VR-Forces 4.3.1 Class Documentation
|
The DtSpatialSubdivision class represents a uniform spatial container.
The container is divided up into a lattice of cells, with resolution specified at creation. Each cell is a container of the objects in it. Its purpose is to efficiently store and search objects spatially.
The DtSpatialSubdivision is a templated container, similar to the std::list or std::vector classes. As such, it can hold any specified item. The intended use is to store elements that have spatial properties - elements that have an actual volume, position, orientation, and so on.
The responsibility for and intelligence necessary to perform operations on the spatial subdivision, such as intersection with primitives, insertion of elements into, and so on, is in specific classes for the distinct operations. This greatly facilitates extending existing capabilities and adding new ones. As a result, the spatial subdivision functionality is spread out across an entire family of classes, as described in this section.
The DtSpatialSubdivision is the container class. It is defined in spatialSubdivision.h, in the geometry library.
The spatial subdivision intersector classes know how to intersect a primitive and a spatial subdivision, and apply a specified operation to the results of the intersection through a functor interface.
The functor interface allows for tremendous flexibility in the type and complexity of operations that are performed on the spatial subdivision. By changing the functor supplied to the intersect() member function, different operations can be performed, such as inserting elements into the spatial subdivision, gathering elements of specific characteristics from the spatial subdivision, or simply accumulating all cells in the spatial subdivision that are part of the intersection. The following are examples of intersectors:
The spatial subdivision functors are simple classes that are used by the spatial subdivision intersectors to perform different operations on the results of intersection tests. These operations include insertion of elements into spatial subdivision cells (DtSsInsertionFunctor), accumulation of spatial subdivision cells for later analysis (DtSsAccumulationFunctor), among others.
While simple, these functors differ from standard functors in the following important ways:
The following are examples of functors:
The spatial subdivision inserter classes are utility classes that combine the appropriate intersector with an insertion functor, in order to facilitate inserting of elements of the appropriate type into a spatial subdivision.
To create a spatial subdivision, do the following:
To insert an element into a spatial subdivision container, you use an inserter class. The following example show how the terrain database now creates the spatial subdivision for the terrain polygons. The terrain() function returns the root terrain polygon node (DtGdbNode*).
To intersect a chord with an spatial subdivision, create an instance of a DtSsChordIntersector (ssChordIntersector.h, and call its intersect function with the desired chord, spatial subdivision, and functor. Please see DtSsChordIntersector for more information.
To intersect an extent with an spatial subdivision, create an instance of an DtSsExtentIntersector (ssExtentIntersector.h) and call its intersect function with the desired extent, spatial subdivision, and functor. Please see DtSsExtentIntersector for more information.
Because the spatial subdivision is a templated container, creating a spatial subdivision of a new type of element is as easy as altering the declaration.
For example, the following creates a spatial subdivision of pointers to DtGdbNodes:
The following creates a spatial subdivision of pointers to DtVectorObstructions:
Derive the new functor from the DtSsFunctor class. To use this functor, pass it as a parameter to an existing spatial subdivision intersector or other utility class, or to a newly created spatial subdivision utility class.
Creating new intersector classes is probably one of the most useful extensions to the spatial subdivision classes. For instance, an intersector class for spheres or cylinders or other implicit surfaces would enable efficient selection of all elements within a specified radius of a location (or line).
To create a new intersector class, there is no need to derive from any parent class. The intersector class merely needs to know how to intersect the specified primitive with the spatial subdivision and to allow user-specified processing of the results.
So, to create a sphere intersector you could test every cell for inclusion with the specified sphere, using the properties of the spatial subdivision (cell deltas, location, and so on) to calculate the cells to test, and to pass these cells to the user-specified functor. This would be useful when selecting all cells within a blast radius. To take it a step further, a new functor could also be derived that would know how to intersect all the elements of a cell, such as DtGdbNodes, with the specified primitive. Used together, the new sphere intersector and sphere intersection functor could be used to select all polygons within the blast radius of a detonation.
[<< The Settings Manager] [Home] [Top of Page] [Symbol Strings >>]