Skip to content

Commit ed326b8

Browse files
committed
Remove unnecessary cast to size_t
1 parent 72ec97a commit ed326b8

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

books/RayTracingTheRestOfYourLife.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,8 +2174,7 @@
21742174

21752175
vec3 hittable_list::random(const vec3& o) const {
21762176
auto int_size = static_cast<int>(objects.size());
2177-
auto index = static_cast<size_t>(random_int(0, int_size-1));
2178-
return objects[index]->random(o);
2177+
return objects[random_int(0, int_size-1)]->random(o);
21792178
}
21802179
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21812180
[Listing [density-mixture]: <kbd>[hittable_list.h]</kbd> Creating a mixture of densities]

src/TheRestOfYourLife/hittable_list.h

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

5959
if (!first_true)
6060
return false;
61-
else
62-
output_box = temp_box;
61+
62+
output_box = temp_box;
6363

6464
for (auto object : objects) {
65-
if (object->bounding_box(t0, t1, temp_box))
66-
output_box = surrounding_box(output_box, temp_box);
67-
else
65+
if (!object->bounding_box(t0, t1, temp_box))
6866
return false;
67+
output_box = surrounding_box(output_box, temp_box);
6968
}
7069

7170
return true;
@@ -85,8 +84,7 @@ double hittable_list::pdf_value(const vec3& o, const vec3& v) const {
8584

8685
vec3 hittable_list::random(const vec3 &o) const {
8786
auto int_size = static_cast<int>(objects.size());
88-
auto index = static_cast<size_t>(random_int(0, int_size-1));
89-
return objects[index]->random(o);
87+
return objects[random_int(0, int_size-1)]->random(o);
9088
}
9189

9290

0 commit comments

Comments
 (0)