Raytracer
Loading...
Searching...
No Matches
BVHNode.hpp
1#include "core/Scene.hpp"
2#include "interfaces/IHittable.hpp"
3
4#ifndef __BVH_NODE_HPP__
5 #define __BVH_NODE_HPP__
6
7namespace Raytracer::Utils
8{
10 private:
11 std::shared_ptr<Interfaces::IHittable> _left;
12 std::shared_ptr<Interfaces::IHittable> _right;
13 AxisAlignedBBox _bbox;
14
15 public:
16 BVHNode() = default;
17 BVHNode(Core::Scene list);
18 BVHNode(std::vector<std::shared_ptr<Interfaces::IHittable>> &objects,
19 size_t start, size_t end);
20 bool hit(const Core::Ray &ray, Interval interval,
21 Core::Payload &payload) const override;
22 AxisAlignedBBox boundingBox() const override;
23 static bool boxCompare(const std::shared_ptr<Interfaces::IHittable> &a,
24 const std::shared_ptr<Interfaces::IHittable> &b, int axis);
25 static bool boxXCompare(
26 const std::shared_ptr<Interfaces::IHittable> &a,
27 const std::shared_ptr<Interfaces::IHittable> &b);
28 static bool boxYCompare(
29 const std::shared_ptr<Interfaces::IHittable> &a,
30 const std::shared_ptr<Interfaces::IHittable> &b);
31 static bool boxZCompare(
32 const std::shared_ptr<Interfaces::IHittable> &a,
33 const std::shared_ptr<Interfaces::IHittable> &b);
34 GET_SET(std::shared_ptr<Interfaces::IHittable>, left)
35 GET_SET(std::shared_ptr<Interfaces::IHittable>, right)
36 };
37} // namespace Raytracer::Utils
38
39#endif /* __BVH_NODE_HPP__ */
Definition Payload.hpp:11
Definition Ray.hpp:9
Definition Scene.hpp:10
Definition IHittable.hpp:11
Definition AxisAlignedBBox.hpp:10
Definition BVHNode.hpp:9
AxisAlignedBBox boundingBox() const override
Get the bounding box of the BVHNode.
Definition BVHNode.cpp:105
static bool boxYCompare(const std::shared_ptr< Interfaces::IHittable > &a, const std::shared_ptr< Interfaces::IHittable > &b)
Compare two objects based on the y-axis.
Definition BVHNode.cpp:167
static bool boxXCompare(const std::shared_ptr< Interfaces::IHittable > &a, const std::shared_ptr< Interfaces::IHittable > &b)
Compare two objects based on the x-axis.
Definition BVHNode.cpp:147
static bool boxCompare(const std::shared_ptr< Interfaces::IHittable > &a, const std::shared_ptr< Interfaces::IHittable > &b, int axis)
Compare two objects based on the given axis.
Definition BVHNode.cpp:124
bool hit(const Core::Ray &ray, Interval interval, Core::Payload &payload) const override
Check if the ray hits the BVHNode.
Definition BVHNode.cpp:81
static bool boxZCompare(const std::shared_ptr< Interfaces::IHittable > &a, const std::shared_ptr< Interfaces::IHittable > &b)
Compare two objects based on the z-axis.
Definition BVHNode.cpp:187
Definition Interval.hpp:9