From 8678445a0ab444453e9fb49a845d56498ce7745d Mon Sep 17 00:00:00 2001 From: Yoel <s73017@beuth-hochschule.de> Date: Sun, 6 Sep 2020 15:23:06 +0200 Subject: [PATCH] Fixed the bounds-function to return the member, added check for BoundingVolume in intersect --- RayTracer/shape/Group.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/RayTracer/shape/Group.cpp b/RayTracer/shape/Group.cpp index b9f6ca6..2ce3282 100644 --- a/RayTracer/shape/Group.cpp +++ b/RayTracer/shape/Group.cpp @@ -20,12 +20,14 @@ std::shared_ptr<cam::Hit> Group::intersect(const cam::Ray& r) const { std::shared_ptr<cam::Hit> result; for (std::shared_ptr<Shape> s : shapeList) { - std::shared_ptr<cam::Hit> temp = s->intersect(imagR); - if (temp != nullptr) { - if (result == nullptr) { - result = temp; - } else if (result->t > temp->t) { - result = temp; + if (s->bounds().intersects(imagR)) { + std::shared_ptr<cam::Hit> temp = s->intersect(imagR); + if (temp != nullptr) { + if (result == nullptr) { + result = temp; + } else if (result->t > temp->t) { + result = temp; + } } } } @@ -38,7 +40,7 @@ std::shared_ptr<cam::Hit> Group::intersect(const cam::Ray& r) const { return result; } util::AxisAlignedBoundingBox Group::bounds() const { - return util::AxisAlignedBoundingBox(); + return boundingVolume; } void Group::add(const std::shared_ptr<Shape>& shape) { shapeList.push_back(shape); -- GitLab