Skip to content

Commit afc6705

Browse files
committed
Rework book 2 AABB incremental listings
1 parent 157d39f commit afc6705

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

books/RayTracingTheNextWeek.html

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,46 +1123,26 @@
11231123
straight-forward, but we'll add a few things to the `aabb` class in the process.
11241124

11251125
The first task is to construct an axis-aligned bounding box of the span of objects in the BVH
1126-
constructor. Basically, we'll construct the `bvh_node`s bounding box from this span by initializing
1127-
the bounding box to empty, and then augmenting it with each bounding box in the span of objects.
1126+
constructor. Basically, we'll construct the bounding box of the `bvh_node` from this span by
1127+
initializing the bounding box to empty (we'll define `aabb::empty` shortly), and then augment it
1128+
with each bounding box in the span of objects.
11281129

1129-
We don't have a way yet to express an empty bounding box, so we'll imagine one for now and
1130-
implementing it shortly.
1130+
Once we have the bounding box, set the splitting axis to the one with the longest side. We'll
1131+
imagine a function that does that for us: `aabb::longest_axis()`. Finally, since we're computing the
1132+
bounding box of the object span up front, we can delete the original line that computed it as the
1133+
union of the left and right sides.
11311134

11321135
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
11331136
class bvh_node : public hittable {
11341137
public:
11351138
...
1136-
11371139
bvh_node(std::vector<shared_ptr<hittable>>& objects, size_t start, size_t end) {
11381140
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
11391141
// Build the bounding box of the span of source objects.
11401142
bbox = aabb::empty;
11411143
for (size_t object_index=start; object_index < end; object_index++)
11421144
bbox = aabb(bbox, objects[object_index]->bounding_box());
1143-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1144-
1145-
...
1146-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1147-
[Listing [object-span-bbox]: <kbd>[bvh.h]</kbd> Building the bbox for the span of BVH objects]
1148-
1149-
Now that we have the bounding box, set the splitting axis to the one with the longest side. Again,
1150-
we'll imagine a function that does that for us: `aabb::longest_axis()`. Finally, since we're
1151-
computing the bounding box of the object span up front, we can delete the original line that
1152-
computed it as the union of the left and right sides.
11531145

1154-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1155-
class bvh_node : public hittable {
1156-
public:
1157-
...
1158-
bvh_node(std::vector<shared_ptr<hittable>>& objects, size_t start, size_t end) {
1159-
// Build the bounding box of the span of source objects.
1160-
bbox = aabb::empty;
1161-
for (size_t object_index=start; object_index < end; object_index++)
1162-
bbox = aabb(bbox, objects[object_index]->bounding_box());
1163-
1164-
1165-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
11661146
int axis = bbox.longest_axis();
11671147
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
11681148

0 commit comments

Comments
 (0)