Wrapper for a Handle; used to create a memberTable that acts like Table<Handle, Node*> but stores only Handle* internally to avoid memory copies.
template<class T>
Constructor & Destructor Documentation
template<class T>
To construct a balanced tree, insert the elements and then call AABSPTree::balance().
template<class T>
template<class T>
Member Function Documentation
template<class T>
Rebalances the tree (slow). Call when objects have moved substantially from their original positions (which unbalances the tree and causes the spatial queries to be slow).
template<class T>
C++ STL style iterator method. Returns the first member. Use preincrement (++entry) to get to the next element (iteration order is arbitrary). Do not modify the set while iterating.
template<class T>
Iterates through the members that intersect the box.
template<class T>
Throws out all elements of the set.
template<class T>
Recursively clone the passed in node tree, setting pointers for members in the memberTable as appropriate. called by the assignment operator.
template<class T>
Returns the bounds of the sub array. Used by makeNode.
template<class T>
Returns true if this object is in the set, otherwise returns false. O(1) time.
template<class T>
Clears the member table.
template<class T>
C++ STL style iterator method. Returns one after the last iterator element.
template<class T>
template<class T>
template<class T>
Appends all members whose bounds intersect the box. See also AABSPTree::beginBoxIntersection.
template<class T>
Typically used to find all visible objects inside the view frustum (see also GCamera::getClipPlanes). .. i.e. all objects not culled by frustum.
Example:
template<class T>
Returns all members inside the set of planes.
template<class T>
template<class T>
Returns an array of all members of the set. See also AABSPTree::begin.
template<class T>
Inserts each elements in the array in turn. If the tree begins empty (no structure and no elements), this is faster than inserting each element in turn. You still need to balance the tree at the end.
template<class T>
Inserts an object into the set if it is not already present. O(log n) time. Does not cause the tree to be balanced.
template<class T>
template<typename RayCallback>
Invoke a callback for every member along a ray until the closest intersection is found.
void callback(const Ray& ray, const T& object, float& distance). If the ray hits the object before travelling distance distance, updates distance with the new distance to the intersection, otherwise leaves it unmodified. A common example is:
class Entity {
public:
void intersect(const Ray& ray, float& maxDist, Vector3& outLocation, Vector3& outNormal) {
float d = maxDist;
... search for intersection distance d
if ((d > 0) && (d < maxDist)) {
Intersection occured
maxDist = d;
outLocation = ...;
outNormal = ...;
}
}
};
Finds the surface normal and location of the first intersection with the scene
class Intersection {
public:
Entity* closestEntity;
Vector3 hitLocation;
Vector3 hitNormal;
void operator()(const Ray& ray, const Entity* entity, float& distance) {
entity->intersect(ray, distance, hitLocation, hitNormal);
}
};
AABSPTree<Entity*> scene;
Intersection intersection;
float distance = inf();
scene.intersectRay(camera.worldRay(x, y), intersection, distance);
template<class T>
Recursively subdivides the subarray. Clears the source array as soon as it is no longer needed. Call assignSplitBounds() on the root node after making a tree.
template<class T>
template<class T>
Removes an object from the set in O(1) time. It is an error to remove members that are not already present. May unbalance the tree. Removing an element never causes a node (split plane) to be removed... nodes are only changed when the tree is rebalanced. This behavior is desirable because it allows the split planes to be serialized, and then deserialized into an empty tree which can be repopulated.
template<class T>
Stores the locations of the splitting planes (the structure but not the content) so that the tree can be quickly rebuilt from a previous configuration without calling balance.
template<class T>
template<class T>
If the element is in the set, it is removed. The element is then inserted. This is useful when the == and hashCode methods on T are independent of the bounds. In that case, you may call update(v) to insert an element for the first time and call update(v) again every time it moves to keep the tree up to date.
Member Data Documentation
template<class T>
Maps members to the node containing them.
template<class T>
The documentation for this class was generated from the following file: Generated on Thu Aug 2 11:40:44 2007 for G3D by | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||