-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBVHNode.h
More file actions
47 lines (37 loc) · 1.11 KB
/
BVHNode.h
File metadata and controls
47 lines (37 loc) · 1.11 KB
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
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include "Vector3.h"
#include "DataTypes.h"
namespace dae
{
struct Ray;
struct BVHNode
{
Vector3 aabbMin;
Vector3 aabbMax;
int leftChild;
int rightChild;
int firstPrim;
int triangleCount;
bool isLeaf() {return triangleCount > 0;}
void Setup();
};
struct BVH
{
void IntersectBVH(const Ray& ray, const int nodeIdx, HitRecord& hitRecord);
bool IntersectBVH(const Ray& ray, const int nodeIdx);
void BuildBVH(const std::vector<TriangleMesh>& triangleMeshes);
void UpdateNodeBounds( int nodeIdx );
static bool IntersectAABB(const Ray& ray, const Vector3 bmin, const Vector3 bmax, const HitRecord& hitRecord);
void Subdivide( int nodeIdx );
// triangle count
std::vector<TriangleMesh> Meshes;
//TriangleMesh m_Mesh;
int amountOfTriangles;
std::vector<BVHNode> bvhNode;
std::vector<int> triangleIndex;
int rootNodeIdx = 0;
int nodesUsed = 1;
bool isBuild = false;
Triangle GetTriangleByIndex(int index) const;
};
}