-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkdtree.hpp
More file actions
31 lines (23 loc) · 736 Bytes
/
kdtree.hpp
File metadata and controls
31 lines (23 loc) · 736 Bytes
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
#ifndef KDNODE_H
#define KDNODE_H
#include <vector>
#include <glm/glm.hpp>
#include <mesh/object.hpp>
class KDNode {
public:
KDNode(const std::vector<unsigned int>& triIdx, const std::vector<glm::vec3>& vtx, const std::vector<glm::vec3>& nrm);
~KDNode();
bool hit(const Ray& ray,Intersection& ix);
private:
void triMin(const glm::vec3& a, glm::vec3& min);
void triMax(const glm::vec3& a, glm::vec3& max);
bool triIx(const Ray& ray, unsigned int i,Intersection& ix);
bool boxIx(const Ray& ray);
bool sphereIx(const Ray& ray);
glm::vec3 vMin, vMax;
KDNode *left, *right;
std::vector<glm::vec3> tris;
std::vector<glm::vec3> nrms;
unsigned int nTris;
};
#endif /* KDNODE_H */