Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 20ce541

Browse files
committed
Update documentation.
1 parent 98a06cc commit 20ce541

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

Grid3D.h

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
// Represents a 3 dimensional grid sub-divided with voxels. Provides necessary information to perform
88
// traversal over the grid system.
9+
//
10+
// Requires:
11+
// min_bound < max_bound
12+
// num_x_voxels > 0
13+
// num_y_voxels > 0
14+
// num_z_voxels > 0
915
struct Grid3D {
1016
public:
1117
[[nodiscard]] constexpr Grid3D(const BoundVec3& min_bound, const BoundVec3& max_bound, size_t num_x_voxels,

amanatidesWooAlgorithm.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// the grid between tMin and tMax. This version causes an additional efficiency penalty,
99
// but takes into account the negative zero case.
1010
// tMin and tMax are then updated to incorporate the new intersection values.
11+
// Returns true if the ray intersects the grid, and false otherwise.
1112
// See: http://www.cs.utah.edu/~awilliam/box/box.pdf
1213
[[no discard]] bool rayBoxIntersection(const Ray& ray, const Grid3D& grid, value_type& tMin, value_type& tMax,
1314
value_type t0, value_type t1) noexcept {
@@ -50,10 +51,10 @@
5051
}
5152

5253
void amanatidesWooAlgorithm(const Ray& ray, const Grid3D& grid, value_type t0, value_type t1) noexcept {
53-
value_type tMin; // Modified in rayBoxIntersection.
54-
value_type tMax; // Modified in rayBoxIntersection.
55-
const bool ray_has_intersected = rayBoxIntersection(ray, grid, tMin, tMax, t0, t1);
56-
if (!ray_has_intersected) return;
54+
value_type tMin;
55+
value_type tMax;
56+
const bool ray_intersects_grid = rayBoxIntersection(ray, grid, tMin, tMax, t0, t1);
57+
if (!ray_intersects_grid) return;
5758

5859
tMin = MAX(tMin, t0);
5960
tMax = MAX(tMax, t1);

amanatidesWooAlgorithm.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44
#include "Ray.h"
55
#include "Grid3D.h"
66

7-
// Provides a basis for Amanatides & Woo's "A Fast Voxel Traversal Algorithm for Ray Tracing."
7+
// Implements the algorithm presented in Amanatides & Woo's "A Fast Voxel Traversal Algorithm for Ray Tracing."
88
// See: https://www.researchgate.net/publication/2611491_A_Fast_Voxel_Traversal_Algorithm_for_Ray_Tracing
99
// If the ray origin is outside the voxel grid, uses a safer version of Smit's ray box intersection algorithm
1010
// to determine intersection. The bounds [t0, t1] determine the begin and end time for which the ray travels.
11-
//
11+
// The algorithm occurs in two phases, initialization and traversal.
12+
// Requires:
13+
// t0 > t1
14+
// 0.0 <= t0 <= 1.0
15+
// 0.0 <= t1 <= 1.0
16+
// To encapsulate entire ray traversal, set t0 = 0.0, t1 = 1.0
17+
// 'grid' encapsulates a valid voxel grid system.
1218
// Notes: Assumes that indices for voxel coordinates begin at 1.
1319
void amanatidesWooAlgorithm(const Ray& ray, const Grid3D& grid, value_type t0, value_type t1) noexcept;
1420

0 commit comments

Comments
 (0)