#include <qbvhaccel.h>
Public Member Functions | |
| QBVHAccel (const Context *context, u_int mp, u_int fst, u_int sf) | |
| ~QBVHAccel () | |
| BBox | WorldBound () const |
| AcceleratorType | GetType () const |
| void | Init (const std::deque< Mesh * > &meshes, const unsigned int totalVertexCount, const unsigned int totalTriangleCount) |
| const TriangleMeshID | GetMeshID (const unsigned int index) const |
| const TriangleMeshID * | GetMeshIDTable () const |
| const TriangleID | GetMeshTriangleID (const unsigned int index) const |
| const TriangleID * | GetMeshTriangleIDTable () const |
| bool | Intersect (const Ray *ray, RayHit *hit) const |
| const TriangleMesh * | GetPreprocessedMesh () const |
Private Member Functions | |
| void | Init (const Mesh *m) |
| void | BuildTree (u_int start, u_int end, u_int *primsIndexes, BBox *primsBboxes, Point *primsCentroids, const BBox &nodeBbox, const BBox ¢roidsBbox, int32_t parentIndex, int32_t childIndex, int depth) |
| void | CreateTempLeaf (int32_t parentIndex, int32_t childIndex, u_int start, u_int end, const BBox &nodeBbox) |
| int32_t | CreateIntermediateNode (int32_t parentIndex, int32_t childIndex, const BBox &nodeBbox) |
| void | PreSwizzle (int32_t nodeIndex, u_int *primsIndexes) |
| void | CreateSwizzledLeaf (int32_t parentIndex, int32_t childIndex, u_int *primsIndexes) |
Private Attributes | |
| u_int | nQuads |
| QuadTriangle * | prims |
| QBVHNode * | nodes |
| u_int | nNodes |
| u_int | maxNodes |
| BBox | worldBound |
| u_int | fullSweepThreshold |
| u_int | skipFactor |
| u_int | maxPrimsPerLeaf |
| const Context * | ctx |
| TriangleMesh * | preprocessedMesh |
| const Mesh * | mesh |
| TriangleMeshID * | meshIDs |
| TriangleID * | meshTriangleIDs |
| bool | initialized |
Friends | |
| class | MQBVHAccel |
| class | OpenCLIntersectionDevice |
Definition at line 379 of file qbvhaccel.h.
| QBVHAccel::QBVHAccel | ( | const Context * | context, | |
| u_int | mp, | |||
| u_int | fst, | |||
| u_int | sf | |||
| ) |
Normal constructor.
Definition at line 30 of file qbvhaccel.cpp.
References initialized, mesh, meshIDs, meshTriangleIDs, and preprocessedMesh.
| QBVHAccel::~QBVHAccel | ( | ) |
to free the memory.
Definition at line 40 of file qbvhaccel.cpp.
References luxrays::TriangleMesh::Delete(), luxrays::FreeAligned(), initialized, meshIDs, meshTriangleIDs, nodes, preprocessedMesh, and prims.
| void QBVHAccel::BuildTree | ( | u_int | start, | |
| u_int | end, | |||
| u_int * | primsIndexes, | |||
| BBox * | primsBboxes, | |||
| Point * | primsCentroids, | |||
| const BBox & | nodeBbox, | |||
| const BBox & | centroidsBbox, | |||
| int32_t | parentIndex, | |||
| int32_t | childIndex, | |||
| int | depth | |||
| ) | [private] |
Build the tree that will contain the primitives indexed from start to end in the primsIndexes array.
Definition at line 147 of file qbvhaccel.cpp.
References CreateIntermediateNode(), CreateTempLeaf(), ctx, luxrays::Floor2Int(), fullSweepThreshold, INFINITY, LR_LOG, luxrays::BBox::MaximumExtent(), maxPrimsPerLeaf, luxrays::Min(), NB_BINS, luxrays::BBox::pMax, luxrays::BBox::pMin, skipFactor, luxrays::BBox::SurfaceArea(), and luxrays::Union().
Referenced by Init().
| int32_t luxrays::QBVHAccel::CreateIntermediateNode | ( | int32_t | parentIndex, | |
| int32_t | childIndex, | |||
| const BBox & | nodeBbox | |||
| ) | [inline, private] |
Create an intermediate node
Definition at line 440 of file qbvhaccel.h.
References luxrays::QBVHNode::children, luxrays::FreeAligned(), maxNodes, nNodes, nodes, and luxrays::QBVHNode::SetBBox().
Referenced by BuildTree().
| void QBVHAccel::CreateSwizzledLeaf | ( | int32_t | parentIndex, | |
| int32_t | childIndex, | |||
| u_int * | primsIndexes | |||
| ) | [private] |
Create a leaf using the pre-swizzled layout, using the informations stored in the node that are organized following the traditional layout
Definition at line 357 of file qbvhaccel.cpp.
References luxrays::QBVHNode::FirstQuadIndexForLeaf(), luxrays::Mesh::GetTriangles(), luxrays::Mesh::GetVertices(), luxrays::QBVHNode::InitializeLeaf(), luxrays::QBVHNode::LeafIsEmpty(), mesh, luxrays::QBVHNode::NbQuadsInLeaf(), nodes, nQuads, and prims.
Referenced by PreSwizzle().
| void QBVHAccel::CreateTempLeaf | ( | int32_t | parentIndex, | |
| int32_t | childIndex, | |||
| u_int | start, | |||
| u_int | end, | |||
| const BBox & | nodeBbox | |||
| ) | [private] |
Create a leaf using the traditional QBVH layout
Definition at line 320 of file qbvhaccel.cpp.
References luxrays::QBVHNode::InitializeLeaf(), nNodes, nodes, nQuads, and luxrays::QBVHNode::SetBBox().
Referenced by BuildTree().
| const TriangleMeshID luxrays::QBVHAccel::GetMeshID | ( | const unsigned int | index | ) | const [inline, virtual] |
| const TriangleMeshID* luxrays::QBVHAccel::GetMeshIDTable | ( | ) | const [inline, virtual] |
| const TriangleID luxrays::QBVHAccel::GetMeshTriangleID | ( | const unsigned int | index | ) | const [inline, virtual] |
Implements luxrays::Accelerator.
Definition at line 403 of file qbvhaccel.h.
References meshTriangleIDs.
| const TriangleID* luxrays::QBVHAccel::GetMeshTriangleIDTable | ( | ) | const [inline, virtual] |
Implements luxrays::Accelerator.
Definition at line 404 of file qbvhaccel.h.
References meshTriangleIDs.
| const TriangleMesh* luxrays::QBVHAccel::GetPreprocessedMesh | ( | ) | const [inline] |
Definition at line 413 of file qbvhaccel.h.
References preprocessedMesh.
| AcceleratorType luxrays::QBVHAccel::GetType | ( | ) | const [inline, virtual] |
Implements luxrays::Accelerator.
Definition at line 397 of file qbvhaccel.h.
References luxrays::ACCEL_QBVH.
| void QBVHAccel::Init | ( | const Mesh * | m | ) | [private] |
Definition at line 70 of file qbvhaccel.cpp.
References BuildTree(), ctx, luxrays::BBox::Expand(), luxrays::Mesh::GetTotalTriangleCount(), luxrays::Mesh::GetTriangles(), luxrays::Mesh::GetVertices(), initialized, LR_LOG, maxNodes, maxPrimsPerLeaf, mesh, nNodes, nodes, nQuads, luxrays::BBox::pMax, luxrays::BBox::pMin, PreSwizzle(), prims, luxrays::RAY_EPSILON, luxrays::Union(), worldBound, and luxrays::Triangle::WorldBound().
| void QBVHAccel::Init | ( | const std::deque< Mesh * > & | meshes, | |
| const unsigned int | totalVertexCount, | |||
| const unsigned int | totalTriangleCount | |||
| ) | [virtual] |
Implements luxrays::Accelerator.
Definition at line 55 of file qbvhaccel.cpp.
References ctx, luxrays::Mesh::GetTotalTriangleCount(), luxrays::Mesh::GetTotalVertexCount(), initialized, LR_LOG, luxrays::TriangleMesh::Merge(), mesh, meshIDs, meshTriangleIDs, and preprocessedMesh.
Referenced by luxrays::MQBVHAccel::Init().
Intersect a ray in world space against the primitive and fills in an Intersection object.
Implements luxrays::Accelerator.
Definition at line 384 of file qbvhaccel.cpp.
References luxrays::QBVHNode::BBoxIntersect(), luxrays::QBVHNode::children, luxrays::Ray::d, luxrays::QBVHNode::FirstQuadIndex(), luxrays::Ray::GetDirectionSigns(), luxrays::QBVHNode::IsEmpty(), luxrays::QBVHNode::IsLeaf(), luxrays::RayHit::Miss(), luxrays::QBVHNode::NbQuadPrimitives(), nodes, prims, luxrays::Vector::x, luxrays::Vector::y, and luxrays::Vector::z.
Referenced by luxrays::MQBVHAccel::Intersect().
| void QBVHAccel::PreSwizzle | ( | int32_t | nodeIndex, | |
| u_int * | primsIndexes | |||
| ) | [private] |
switch a node and its subnodes from the traditional form of QBVH to the pre-swizzled one.
Definition at line 348 of file qbvhaccel.cpp.
References CreateSwizzledLeaf(), and nodes.
Referenced by Init().
| BBox luxrays::QBVHAccel::WorldBound | ( | ) | const [inline] |
friend class MQBVHAccel [friend] |
Definition at line 415 of file qbvhaccel.h.
friend class OpenCLIntersectionDevice [friend] |
Definition at line 416 of file qbvhaccel.h.
const Context* luxrays::QBVHAccel::ctx [private] |
Definition at line 519 of file qbvhaccel.h.
Referenced by BuildTree(), and Init().
u_int luxrays::QBVHAccel::fullSweepThreshold [private] |
The number of primitives in the node that makes switch to full sweep for binning
Definition at line 507 of file qbvhaccel.h.
Referenced by BuildTree().
bool luxrays::QBVHAccel::initialized [private] |
Definition at line 525 of file qbvhaccel.h.
Referenced by Init(), QBVHAccel(), and ~QBVHAccel().
u_int luxrays::QBVHAccel::maxNodes [private] |
Definition at line 496 of file qbvhaccel.h.
Referenced by CreateIntermediateNode(), and Init().
u_int luxrays::QBVHAccel::maxPrimsPerLeaf [private] |
The maximum number of primitives per leaf
Definition at line 517 of file qbvhaccel.h.
Referenced by BuildTree(), and Init().
const Mesh* luxrays::QBVHAccel::mesh [private] |
Definition at line 521 of file qbvhaccel.h.
Referenced by CreateSwizzledLeaf(), Init(), and QBVHAccel().
TriangleMeshID* luxrays::QBVHAccel::meshIDs [private] |
Definition at line 522 of file qbvhaccel.h.
Referenced by GetMeshID(), GetMeshIDTable(), Init(), QBVHAccel(), and ~QBVHAccel().
TriangleID* luxrays::QBVHAccel::meshTriangleIDs [private] |
Definition at line 523 of file qbvhaccel.h.
Referenced by GetMeshTriangleID(), GetMeshTriangleIDTable(), Init(), QBVHAccel(), and ~QBVHAccel().
u_int luxrays::QBVHAccel::nNodes [private] |
The number of nodes really used.
Definition at line 496 of file qbvhaccel.h.
Referenced by CreateIntermediateNode(), CreateTempLeaf(), Init(), and luxrays::OpenCLIntersectionDevice::SetDataSet().
QBVHNode* luxrays::QBVHAccel::nodes [private] |
The nodes of the QBVH.
Definition at line 491 of file qbvhaccel.h.
Referenced by CreateIntermediateNode(), CreateSwizzledLeaf(), CreateTempLeaf(), Init(), Intersect(), PreSwizzle(), luxrays::OpenCLIntersectionDevice::SetDataSet(), and ~QBVHAccel().
u_int luxrays::QBVHAccel::nQuads [private] |
the actual number of quads
Definition at line 477 of file qbvhaccel.h.
Referenced by CreateSwizzledLeaf(), CreateTempLeaf(), Init(), and luxrays::OpenCLIntersectionDevice::SetDataSet().
TriangleMesh* luxrays::QBVHAccel::preprocessedMesh [private] |
Definition at line 520 of file qbvhaccel.h.
Referenced by GetPreprocessedMesh(), Init(), QBVHAccel(), and ~QBVHAccel().
QuadTriangle* luxrays::QBVHAccel::prims [private] |
The primitive associated with each triangle. indexed by the number of quad and the number of triangle in the quad (thus, there might be holes). no need to be a tesselated primitive, the intersection test will be redone for the nearest triangle found, to fill the Intersection structure.
Definition at line 486 of file qbvhaccel.h.
Referenced by CreateSwizzledLeaf(), Init(), Intersect(), luxrays::OpenCLIntersectionDevice::SetDataSet(), and ~QBVHAccel().
u_int luxrays::QBVHAccel::skipFactor [private] |
BBox luxrays::QBVHAccel::worldBound [private] |
The world bounding box of the QBVH.
Definition at line 501 of file qbvhaccel.h.
Referenced by Init(), and WorldBound().
1.6.3