Skip to content

Commit

Permalink
ray changes DDA-> Amanadites and woo algorithim
Browse files Browse the repository at this point in the history
  • Loading branch information
Tebarem committed Dec 21, 2024
1 parent 5903cc4 commit 877962b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/geometry/src/ray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ impl Ray {
self.origin + self.direction * t
}

/// Efficiently traverse through grid cells that the ray intersects using an optimized DDA algorithm.
/// Efficiently traverse through grid cells that the ray intersects using the Amanatides and Woo algorithm.
/// Returns an iterator over the grid cells ([`IVec3`]) that the ray passes through.
pub fn voxel_traversal(&self, bounds_min: IVec3, bounds_max: IVec3) -> VoxelTraversal {
let current_pos = self.origin.as_ivec3();

// Determine stepping direction for each axis
let step = IVec3::new(
self.direction.x.signum() as i32,
self.direction.y.signum() as i32,
self.direction.z.signum() as i32,
if self.direction.x > 0.0 { 1 } else { -1 },
if self.direction.y > 0.0 { 1 } else { -1 },
if self.direction.z > 0.0 { 1 } else { -1 },
);

// Calculate distance to next voxel boundary for each axis
Expand Down

0 comments on commit 877962b

Please sign in to comment.