forked from brandonpelfrey/Fast-BVH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BVH.h
36 lines (28 loc) · 766 Bytes
/
BVH.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef BVH_h
#define BVH_h
#include "BBox.h"
#include <vector>
#include <stdint.h>
#include "Object.h"
#include "IntersectionInfo.h"
#include "Ray.h"
//! Node descriptor for the flattened tree
struct BVHFlatNode {
BBox bbox;
uint32_t start, nPrims, rightOffset;
};
//! \author Brandon Pelfrey
//! A Bounding Volume Hierarchy system for fast Ray-Object intersection tests
class BVH {
uint32_t nNodes, nLeafs, leafSize;
std::vector<Object*>* build_prims;
//! Build the BVH tree out of build_prims
void build();
// Fast Traversal System
BVHFlatNode *flatTree;
public:
BVH(std::vector<Object*>* objects, uint32_t leafSize=4);
bool getIntersection(const Ray& ray, IntersectionInfo *intersection, bool occlusion) const ;
~BVH();
};
#endif