Skip to content

Commit

Permalink
Merge pull request #437 from RayTracing/fix-435
Browse files Browse the repository at this point in the history
Fix & simplify hittable_list::bounding_box()
  • Loading branch information
hollasch committed Apr 3, 2020
2 parents 8050a26 + 5119b05 commit f2ff2d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change Log -- Ray Tracing in One Weekend
====================================================================================================

----------------------------------------------------------------------------------------------------
# v3.0.2 (in progress)

### _The Next Week_
- Fix `shared_ptr` dereference and simplify code in `hittable_list::bounding_box()` (#435)


----------------------------------------------------------------------------------------------------
# v3.0.1 (2020-03-31)

Expand Down
13 changes: 4 additions & 9 deletions books/RayTracingTheNextWeek.html
Original file line number Diff line number Diff line change
Expand Up @@ -663,17 +663,12 @@
if (objects.empty()) return false;

aabb temp_box;
bool first_true = objects[0]->bounding_box(t0, t1, temp_box);

if (!first_true)
return false;

output_box = temp_box;
bool first_box = true;

for (const auto& object : objects) {
if (!objects[i]->bounding_box(t0, t1, temp_box))
return false;
output_box = surrounding_box(output_box, temp_box);
if (!object->bounding_box(t0, t1, temp_box)) return false;
output_box = first_box ? temp_box : surrounding_box(output_box, temp_box);
first_box = false;
}

return true;
Expand Down
13 changes: 4 additions & 9 deletions src/TheNextWeek/hittable_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,12 @@ bool hittable_list::bounding_box(double t0, double t1, aabb& output_box) const {
if (objects.empty()) return false;

aabb temp_box;
bool first_true = objects[0]->bounding_box(t0, t1, temp_box);

if (!first_true)
return false;

output_box = temp_box;
bool first_box = true;

for (const auto& object : objects) {
if (!object->bounding_box(t0, t1, temp_box))
return false;
output_box = surrounding_box(output_box, temp_box);
if (!object->bounding_box(t0, t1, temp_box)) return false;
output_box = first_box ? temp_box : surrounding_box(output_box, temp_box);
first_box = false;
}

return true;
Expand Down

0 comments on commit f2ff2d1

Please sign in to comment.