3 #include <unordered_set> 14 friend class boost::serialization::access;
15 template <
typename Archive>
16 void serialize(Archive& ar,
const unsigned int version) {
17 boost::serialization::void_cast_register<AABB, Primitive>();
18 ar & boost::serialization::base_object<Primitive>(*this);
49 AABB(glm::dvec3 min, glm::dvec3 max);
53 ~AABB()
override =
default;
75 inline glm::dvec3
const &
getMin()
const {
return vertices[0].
pos;}
81 inline glm::dvec3
const &
getMax()
const {
return vertices[1].
pos;}
98 const glm::dvec3& rayOrigin,
99 const glm::dvec3& rayDir,
100 const glm::dvec3& intersectionPoint
106 const glm::dvec3& rayOrigin,
107 const glm::dvec3& rayDir
113 const glm::dvec3& rayOrigin,
114 const glm::dvec3& rayDir
131 std::vector<Primitive*> & primitives
139 std::vector<Vertex> & verts
147 std::unordered_set<Vertex *, VertexKeyHash, VertexKeyEqual> & verts
167 namespace serialization {
169 template<
class Archive>
170 inline void save_construct_data(
171 Archive & ar,
const AABB * t,
const unsigned int file_version)
178 template<
class Archive>
179 inline void load_construct_data(
180 Archive & ar,
AABB * t,
const unsigned int file_version)
188 ::new(t)
AABB(min, max);
size_t getNumVertices() override
Definition: AABB.h:119
glm::dvec3 const & getMin() const
Get the min value for each coordinate of the axis aligned bounding box.
Definition: AABB.h:75
~AABB() override=default
Default destructor for axis aligned bounding box.
AABB()=default
Default constructor for axis aligned bounding box.
void _clone(Primitive *p) override
Assist clone function.
Definition: AABB.cpp:23
std::vector< double > getRayIntersection(const glm::dvec3 &rayOrigin, const glm::dvec3 &rayDir) override
Definition: AABB.cpp:172
double getRayIntersectionDistance(const glm::dvec3 &rayOrigin, const glm::dvec3 &rayDir) override
Definition: AABB.cpp:198
std::string toString()
Bbuild a string representing the axis aligned bounding box.
Definition: AABB.cpp:168
glm::dvec3 bounds[2]
Cached bounds to speed-up intersection computation.
Definition: AABB.h:35
Vertex vertices[2]
Vertices defining the axis aligned bounding box.
Definition: AABB.h:31
static std::shared_ptr< AABB > getForPrimitives(std::vector< Primitive *> &primitives)
Build an axis aligned bounding box containing given primitives.
Definition: AABB.cpp:44
void update() override
Definition: AABB.h:152
AABB * getAABB() override
Obtain this axis aligned bounding box.
Definition: AABB.cpp:226
glm::dvec3 const & getMax() const
Get the max value for each coordinate of the axis aligned bounding box.
Definition: AABB.h:81
Class representing an Axis Aligned Bounding Box (AABB)
Definition: AABB.h:10
Vertex * getVertices() override
Definition: AABB.cpp:230
glm::dvec3 pos
Vertex 3D position.
Definition: Vertex.h:32
double getIncidenceAngle_rad(const glm::dvec3 &rayOrigin, const glm::dvec3 &rayDir, const glm::dvec3 &intersectionPoint) override
Definition: AABB.cpp:234
glm::dvec3 getCentroid() override
Get the centroid of the axis aligned bounding box.
Definition: AABB.cpp:35
glm::dvec3 getSize()
Obtain size along each axis for the axis aligned bounding box.
Definition: AABB.cpp:40
Abstract class defining the common behavior for all primitives.
Definition: Primitive.h:20
Primitive * clone() override
Generate a clone of the primitive.
Definition: AABB.cpp:17
static std::shared_ptr< AABB > getForVertices(std::vector< Vertex > &verts)
Build an axis aligned bounding box containing given vertices.
Class representing a vertex.
Definition: Vertex.h:14