Skip to content
Snippets Groups Projects
Commit 8678445a authored by Yoel's avatar Yoel
Browse files

Fixed the bounds-function to return the member, added check for BoundingVolume in intersect

parent 266bcb05
No related branches found
No related tags found
No related merge requests found
...@@ -20,12 +20,14 @@ std::shared_ptr<cam::Hit> Group::intersect(const cam::Ray& r) const { ...@@ -20,12 +20,14 @@ std::shared_ptr<cam::Hit> Group::intersect(const cam::Ray& r) const {
std::shared_ptr<cam::Hit> result; std::shared_ptr<cam::Hit> result;
for (std::shared_ptr<Shape> s : shapeList) { for (std::shared_ptr<Shape> s : shapeList) {
std::shared_ptr<cam::Hit> temp = s->intersect(imagR); if (s->bounds().intersects(imagR)) {
if (temp != nullptr) { std::shared_ptr<cam::Hit> temp = s->intersect(imagR);
if (result == nullptr) { if (temp != nullptr) {
result = temp; if (result == nullptr) {
} else if (result->t > temp->t) { result = temp;
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 { ...@@ -38,7 +40,7 @@ std::shared_ptr<cam::Hit> Group::intersect(const cam::Ray& r) const {
return result; return result;
} }
util::AxisAlignedBoundingBox Group::bounds() const { util::AxisAlignedBoundingBox Group::bounds() const {
return util::AxisAlignedBoundingBox(); return boundingVolume;
} }
void Group::add(const std::shared_ptr<Shape>& shape) { void Group::add(const std::shared_ptr<Shape>& shape) {
shapeList.push_back(shape); shapeList.push_back(shape);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment