-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaabb.h
More file actions
78 lines (72 loc) · 2.24 KB
/
aabb.h
File metadata and controls
78 lines (72 loc) · 2.24 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once
#include <def.h>
/// @brief Closest pair between a point and triangle.
enum class DistanceType {
P_T0, ///< The point is closest to triangle vertex zero.
P_T1, ///< The point is closest to triangle vertex one.
P_T2, ///< The point is closest to triangle vertex two.
P_E0, ///< The point is closest to triangle edge zero (vertex zero to one).
P_E1, ///< The point is closest to triangle edge one (vertex one to two).
P_E2, ///< The point is closest to triangle edge two (vertex two to zero).
P_T, ///< The point is closest to the interior of the triangle.
/// The edges are closest at vertex 0 of edge A and 0 of edge B.
EA0_EB0,
/// The edges are closest at vertex 0 of edge A and 1 of edge B.
EA0_EB1,
/// The edges are closest at vertex 1 of edge A and 0 of edge B.
EA1_EB0,
/// The edges are closest at vertex 1 of edge A and 1 of edge B.
EA1_EB1,
/// The edges are closest at the interior of edge A and vertex 0 of edge B.
EA_EB0,
/// The edges are closest at the interior of edge A and vertex 1 of edge B.
EA_EB1,
/// The edges are closest at vertex 0 of edge A and the interior of edge B.
EA0_EB,
/// The edges are closest at vertex 1 of edge A and the interior of edge B.
EA1_EB,
/// The edges are closest at an interior point of edge A and B.
EA_EB,
AUTO ///< Automatically determine the closest pair.
};
extern const char* distanceTypeString[];
template<typename Scalar>
class AABB {
public:
glm::tvec3<Scalar> min = glm::tvec3<Scalar>{ FLT_MAX };
glm::tvec3<Scalar> max = glm::tvec3<Scalar>{ -FLT_MAX };
AABB<Scalar> expand(const AABB<Scalar>& aabb)const;
};
template<typename Scalar>
class BVHNode {
public:
AABB<Scalar> bbox;
int isLeaf;
int leftIndex;
int rightIndex;
int parent;
int TriangleIndex;
};
enum class QueryType {
UNKNOWN,
VF,
EE
};
struct Vec3d {
double x, y, z;
Vec3d operator-() const {
return Vec3d{-x, -y, -z};
}
};
class Query {
public:
QueryType type = QueryType::UNKNOWN;
DistanceType dType = DistanceType::AUTO;
indexType v0;
indexType v1;
indexType v2;
indexType v3;
double d;
double toi = 0.f;
Vec3d normal = Vec3d{0.0, 0.0, 0.0};
};