diff --git a/RayTracer/shape/Sphere.cpp b/RayTracer/shape/Sphere.cpp index b969f00c060268b61a11ff57e97120e70807ba8c..e644595c26e41a3b026e00ab39e6c4ed345a0f83 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 6aac27331c1d64ade364513023f9b8b845d3052f..67b8ebcfbc8fdda9eb28002ab923883e476eabb4 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;