Skip to content

Commit 1a8c65b

Browse files
committed
Synchronize copies of hittable_list.h
1 parent 6381478 commit 1a8c65b

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Change Log -- Ray Tracing in One Weekend
88
- Fix: Standardized naming for ray-t and time parameters (#746)
99
- Fix: `random_unit_vector()` was incorrect (#697)
1010
- Fix: Synchronize text and copies of `hittable.h`
11+
- Fix: Synchronize copies of `hittable_list.h`
1112

1213
### In One Weekend
1314

src/TheNextWeek/hittable_list.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "hittable.h"
1717

18+
#include <memory>
1819
#include <vector>
1920

2021

src/TheRestOfYourLife/hittable_list.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "hittable.h"
1717

18+
#include <memory>
1819
#include <vector>
1920

2021

@@ -59,17 +60,12 @@ bool hittable_list::bounding_box(double time0, double time1, aabb& output_box) c
5960
if (objects.empty()) return false;
6061

6162
aabb temp_box;
62-
bool first_true = objects[0]->bounding_box(time0, time1, temp_box);
63-
64-
if (!first_true)
65-
return false;
66-
67-
output_box = temp_box;
63+
bool first_box = true;
6864

6965
for (const auto& object : objects) {
70-
if (!object->bounding_box(time0, time1, temp_box))
71-
return false;
72-
output_box = surrounding_box(output_box, temp_box);
66+
if (!object->bounding_box(time0, time1, temp_box)) return false;
67+
output_box = first_box ? temp_box : surrounding_box(output_box, temp_box);
68+
first_box = false;
7369
}
7470

7571
return true;

0 commit comments

Comments
 (0)