From 1b3bd80e886f64b5c7920e5a45a18196ab67191e Mon Sep 17 00:00:00 2001 From: Yoel <s73017@beuth-hochschule.de> Date: Sun, 6 Sep 2020 14:03:06 +0200 Subject: [PATCH] Implemented AABB for Spheres --- RayTracer/shape/Sphere.cpp | 4 ++++ RayTracer/shape/Sphere.h | 1 + 2 files changed, 5 insertions(+) diff --git a/RayTracer/shape/Sphere.cpp b/RayTracer/shape/Sphere.cpp index b969f00..e644595 100644 --- a/RayTracer/shape/Sphere.cpp +++ b/RayTracer/shape/Sphere.cpp @@ -42,4 +42,8 @@ std::shared_ptr<cam::Hit> Sphere::intersect(const cam::Ray& r) const { return nullptr; } } +util::AxisAlignedBoundingBox Sphere::bounds() const { + return util::AxisAlignedBoundingBox(util::Vec3(-radius), + util::Vec3(radius)); +} } // namespace shapes diff --git a/RayTracer/shape/Sphere.h b/RayTracer/shape/Sphere.h index 6aac273..67b8ebc 100644 --- a/RayTracer/shape/Sphere.h +++ b/RayTracer/shape/Sphere.h @@ -7,6 +7,7 @@ class Sphere : public Shape { public: Sphere(float radius, const std::shared_ptr<material::Material>& material); std::shared_ptr<cam::Hit> intersect(const cam::Ray& r) const override; + util::AxisAlignedBoundingBox bounds() const override; private: std::shared_ptr<material::Material> material; -- GitLab