DHART
|
Bounding Volume Hierarchy acceleration. More...
#include <nanort.h>
Public Member Functions | |
BVHAccel () | |
~BVHAccel () | |
template<class Prim , class Pred > | |
bool | Build (const unsigned int num_primitives, const Prim &p, const Pred &pred, const BVHBuildOptions< T > &options=BVHBuildOptions< T >()) |
Build BVH for input primitives. More... | |
BVHBuildStatistics | GetStatistics () const |
Get statistics of built BVH tree. Valid after Build() More... | |
void | Debug () |
template<class I , class H > | |
bool | Traverse (const Ray< T > &ray, const I &intersector, H *isect, const BVHTraceOptions &options=BVHTraceOptions()) const |
Traverse into BVH along ray and find closest hit point & primitive if found. More... | |
template<class I > | |
bool | ListNodeIntersections (const Ray< T > &ray, int max_intersections, const I &intersector, StackVector< NodeHit< T >, 128 > *hits) const |
List up nodes which intersects along the ray. This function is useful for two-level BVH traversal. See examples/nanosg for example. More... | |
const std::vector< BVHNode< T > > & | GetNodes () const |
const std::vector< unsigned int > & | GetIndices () const |
void | BoundingBox (T bmin[3], T bmax[3]) const |
Returns bounding box of built BVH. More... | |
bool | IsValid () const |
Private Member Functions | |
template<class P , class Pred > | |
unsigned int | BuildTree (BVHBuildStatistics *out_stat, std::vector< BVHNode< T > > *out_nodes, unsigned int left_idx, unsigned int right_idx, unsigned int depth, const P &p, const Pred &pred) |
Builds BVH tree recursively. More... | |
template<class I > | |
bool | TestLeafNode (const BVHNode< T > &node, const Ray< T > &ray, const I &intersector) const |
template<class I > | |
bool | TestLeafNodeIntersections (const BVHNode< T > &node, const Ray< T > &ray, const int max_intersections, const I &intersector, std::priority_queue< NodeHit< T >, std::vector< NodeHit< T > >, NodeHitComparator< T > > *isect_pq) const |
Private Attributes | |
std::vector< BVHNode< T > > | nodes_ |
std::vector< unsigned int > | indices_ |
std::vector< BBox< T > > | bboxes_ |
BVHBuildOptions< T > | options_ |
BVHBuildStatistics | stats_ |
unsigned int | pad0_ |
Bounding Volume Hierarchy acceleration.
BVHAccel is central part of ray tracing(ray traversal). BVHAccel takes an input geometry(primitive) information and build a data structure for efficient ray tracing(O(log2 N)
in theory, where N is the number of primitive in the scene).
T | real value type(float or double). |
|
inline |
Definition at line 707 of file nanort.h.
References nanort::BVHAccel< T >::pad0_.
|
inline |
|
inline |
Returns bounding box of built BVH.
Definition at line 798 of file nanort.h.
References nanort::BVHAccel< T >::nodes_.
bool nanort::BVHAccel< T >::Build | ( | const unsigned int | num_primitives, |
const Prim & | p, | ||
const Pred & | pred, | ||
const BVHBuildOptions< T > & | options = BVHBuildOptions<T>() |
||
) |
Build BVH for input primitives.
Prim | Primitive(e.g. Triangle) accessor class. |
Pred | Predicator(comparator class object for Prim class to find nearest hit point) |
[in] | num_primitives | The number of primitive. |
[in] | p | Primitive accessor class object. |
[in] | pred | Predicator object. |
Definition at line 1907 of file nanort.h.
References nanort::BBox< T >::bmax, nanort::BBox< T >::bmin, nanort::BVHBuildOptions< T >::cache_bbox, nanort::ComputeBoundingBox(), nanort::BVHBuildOptions< T >::min_primitives_for_parallel_build, and nanort::BVHBuildOptions< T >::shallow_depth.
Referenced by HF::nanoGeom::nanoRT_BVH().
|
private |
Builds BVH tree recursively.
Definition at line 1771 of file nanort.h.
References nanort::BVHNode< T >::axis, nanort::BVHNode< T >::bmax, nanort::BVHNode< T >::bmin, nanort::ComputeBoundingBox(), nanort::ContributeBinBuffer(), nanort::BVHNode< T >::data, nanort::FindCutFromBinBuffer(), nanort::BVHNode< T >::flag, nanort::GetBoundingBox(), nanort::BVHBuildStatistics::max_tree_depth, nanort::BVHBuildStatistics::num_branch_nodes, and nanort::BVHBuildStatistics::num_leaf_nodes.
void nanort::BVHAccel< T >::Debug |
|
inline |
Definition at line 793 of file nanort.h.
References nanort::BVHAccel< T >::indices_.
|
inline |
Definition at line 792 of file nanort.h.
References nanort::BVHAccel< T >::nodes_.
|
inline |
Get statistics of built BVH tree. Valid after Build()
Definition at line 731 of file nanort.h.
References nanort::BVHAccel< T >::stats_.
|
inline |
Definition at line 813 of file nanort.h.
References nanort::BVHAccel< T >::nodes_.
bool nanort::BVHAccel< T >::ListNodeIntersections | ( | const Ray< T > & | ray, |
int | max_intersections, | ||
const I & | intersector, | ||
StackVector< NodeHit< T >, 128 > * | hits | ||
) | const |
List up nodes which intersects along the ray. This function is useful for two-level BVH traversal. See examples/nanosg
for example.
I | Intersection class |
Definition at line 2628 of file nanort.h.
References nanort::BVHNode< T >::axis, nanort::BVHNode< T >::bmax, nanort::BVHNode< T >::bmin, nanort::BVHNode< T >::data, nanort::Ray< T >::dir, nanort::BVHNode< T >::flag, nanort::IntersectRayAABB(), nanort::Ray< T >::max_t, nanort::Ray< T >::min_t, nanort::Ray< T >::org, and nanort::vsafe_inverse().
|
inlineprivate |
Definition at line 2390 of file nanort.h.
References nanort::BVHNode< T >::data, nanort::Ray< T >::dir, and nanort::Ray< T >::org.
|
inlineprivate |
Definition at line 2577 of file nanort.h.
References nanort::BVHNode< T >::data, nanort::Ray< T >::dir, nanort::NodeHit< T >::node_id, nanort::Ray< T >::org, nanort::NodeHit< T >::t_max, and nanort::NodeHit< T >::t_min.
bool nanort::BVHAccel< T >::Traverse | ( | const Ray< T > & | ray, |
const I & | intersector, | ||
H * | isect, | ||
const BVHTraceOptions & | options = BVHTraceOptions() |
||
) | const |
Traverse into BVH along ray and find closest hit point & primitive if found.
I | Intersector class |
H | Hit class |
[in] | ray | Input ray |
[in] | intersector | Intersector object. This object is called for each possible intersection of ray and BVH during traversal. |
[out] | isect | Intersection point information(filled when any hit point was found) |
[in] | options | Traversal options. |
Definition at line 2505 of file nanort.h.
References nanort::BVHNode< T >::axis, nanort::BVHNode< T >::bmax, nanort::BVHNode< T >::bmin, nanort::BVHNode< T >::data, nanort::Ray< T >::dir, nanort::BVHNode< T >::flag, nanort::IntersectRayAABB(), kNANORT_MAX_STACK_DEPTH, nanort::Ray< T >::max_t, nanort::Ray< T >::min_t, nanort::Ray< T >::org, and nanort::vsafe_inverse().
Referenced by HF::RayTracer::NanoRTRayTracer::Intersect(), HF::nanoGeom::nanoRT_Intersect(), and HF::nanoGeom::nanoRT_RayCast().
|
private |
|
private |
Definition at line 862 of file nanort.h.
Referenced by nanort::BVHAccel< T >::GetIndices().
|
private |
Definition at line 861 of file nanort.h.
Referenced by nanort::BVHAccel< T >::BoundingBox(), nanort::BVHAccel< T >::GetNodes(), and nanort::BVHAccel< T >::IsValid().
|
private |
|
private |
Definition at line 866 of file nanort.h.
Referenced by nanort::BVHAccel< T >::BVHAccel().
|
private |
Definition at line 865 of file nanort.h.
Referenced by nanort::BVHAccel< T >::GetStatistics().