Skip to content

Commit 72ec97a

Browse files
committed
Simplify logic in hittable_list::bounding_box()
1 parent ea16faa commit 72ec97a

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

books/RayTracingTheNextWeek.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -649,14 +649,13 @@
649649

650650
if (!first_true)
651651
return false;
652-
else
653-
output_box = temp_box;
652+
653+
output_box = temp_box;
654654

655655
for (auto object : objects) {
656-
if (objects[i]->bounding_box(t0, t1, temp_box))
657-
output_box = surrounding_box(output_box, temp_box);
658-
else
656+
if (!objects[i]->bounding_box(t0, t1, temp_box))
659657
return false;
658+
output_box = surrounding_box(output_box, temp_box);
660659
}
661660

662661
return true;

src/TheNextWeek/hittable_list.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@ bool hittable_list::bounding_box(double t0, double t1, aabb& output_box) const {
5656

5757
if (!first_true)
5858
return false;
59-
else
60-
output_box = temp_box;
59+
60+
output_box = temp_box;
6161

6262
for (auto object : objects) {
63-
if (object->bounding_box(t0, t1, temp_box))
64-
output_box = surrounding_box(output_box, temp_box);
65-
else
63+
if (!object->bounding_box(t0, t1, temp_box))
6664
return false;
65+
output_box = surrounding_box(output_box, temp_box);
6766
}
6867

6968
return true;

0 commit comments

Comments
 (0)