Nori
|
Specializes GenericKDTree to a three-dimensional tree that can be used to intersect rays against triangles meshes. More...
#include <kdtree.h>
Public Member Functions | |
KDTree () | |
Create a new and empty kd-tree. | |
virtual | ~KDTree () |
Release all memory. | |
void | addMesh (Mesh *mesh) |
Register a triangle mesh for inclusion in the kd-tree. | |
void | build () |
Build the kd-tree. | |
bool | rayIntersect (const Ray3f &ray, Intersection &its, bool shadowRay=false) const |
Intersect a ray against all triangle meshes registered with the kd-tree. | |
SizeType | getPrimitiveCount () const |
Return the total number of internally represented triangles. | |
SizeType | getMeshCount () const |
Return the total number of meshes registered with the kd-tree. | |
Mesh * | getMesh (IndexType idx) |
Return one of the registered meshes. | |
const Mesh * | getMesh (IndexType idx) const |
Return one of the registered meshes (const version) | |
const BoundingBox3f & | getBoundingBox () const |
Return a (slightly enlarged) axis-aligned bounding box containing all primitives. | |
BoundingBox3f | getBoundingBox (IndexType index) const |
BoundingBox3f | getClippedBoundingBox (IndexType index, const BoundingBox3f &clip) const |
Returns the axis-aligned bounding box of a triangle after it has clipped to the extents of another given bounding box. | |
Protected Types | |
typedef GenericKDTree < BoundingBox3f, SurfaceAreaHeuristic3, KDTree > | Parent |
typedef Parent::SizeType | SizeType |
Size number format. | |
typedef Parent::IndexType | IndexType |
Index number format (max 2^32 prims) | |
typedef Parent::KDNode | KDNode |
Protected Member Functions | |
IndexType | findMesh (IndexType &idx) const |
Compute the mesh and triangle indices corresponding to a primitive index used by the underlying generic kd-tree implementation. |
Specializes GenericKDTree to a three-dimensional tree that can be used to intersect rays against triangles meshes.
The internal tree construction algorithm generates a surface area heuristic (SAH) kd-tree using the "perfect splits" optimization.
This class also implements an robust adapted version of the optimized ray traversal algorithm (TA^B_{rec}), which is explained in Vlastimil Havran's PhD thesis "Heuristic Ray Shooting Algorithms".
typedef Parent::IndexType KDTree::IndexType [protected] |
Index number format (max 2^32 prims)
Reimplemented from GenericKDTree< BoundingBox3f, SurfaceAreaHeuristic3, KDTree >.
typedef Parent::KDNode KDTree::KDNode [protected] |
Reimplemented from GenericKDTree< BoundingBox3f, SurfaceAreaHeuristic3, KDTree >.
typedef GenericKDTree<BoundingBox3f, SurfaceAreaHeuristic3, KDTree> KDTree::Parent [protected] |
Reimplemented from GenericKDTree< BoundingBox3f, SurfaceAreaHeuristic3, KDTree >.
typedef Parent::SizeType KDTree::SizeType [protected] |
Size number format.
Reimplemented from GenericKDTree< BoundingBox3f, SurfaceAreaHeuristic3, KDTree >.
KDTree::KDTree | ( | ) |
Create a new and empty kd-tree.
virtual KDTree::~KDTree | ( | ) | [virtual] |
Release all memory.
void KDTree::addMesh | ( | Mesh * | mesh | ) |
Register a triangle mesh for inclusion in the kd-tree.
This function can only be used before build() is called
void KDTree::build | ( | ) |
Build the kd-tree.
const BoundingBox3f& KDTree::getBoundingBox | ( | ) | const [inline] |
Return a (slightly enlarged) axis-aligned bounding box containing all primitives.
Reimplemented from KDTreeBase< BoundingBox3f >.
BoundingBox3f KDTree::getBoundingBox | ( | IndexType | index | ) | const [inline] |
BoundingBox3f KDTree::getClippedBoundingBox | ( | IndexType | index, |
const BoundingBox3f & | clip | ||
) | const [inline] |
Returns the axis-aligned bounding box of a triangle after it has clipped to the extents of another given bounding box.
See Mesh::getClippedBoundingBox() for details
SizeType KDTree::getMeshCount | ( | ) | const [inline] |
SizeType KDTree::getPrimitiveCount | ( | ) | const [inline] |
bool KDTree::rayIntersect | ( | const Ray3f & | ray, |
Intersection & | its, | ||
bool | shadowRay = false |
||
) | const |
Intersect a ray against all triangle meshes registered with the kd-tree.
Detailed information about the intersection, if any, will be stored in the provided Intersection data record.
The shadowRay
parameter specifies whether this detailed information is really needed. When set to true
, the function just checks whether or not there is occlusion, but without providing any more detail (i.e. its
will not be filled with contents). This is usually much faster.
true
If an intersection was found