summaryrefslogtreecommitdiff
path: root/src/sim/lib/ray.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim/lib/ray.rs')
-rw-r--r--src/sim/lib/ray.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/sim/lib/ray.rs b/src/sim/lib/ray.rs
index 52d5ba9..ec90d00 100644
--- a/src/sim/lib/ray.rs
+++ b/src/sim/lib/ray.rs
@@ -1,11 +1,12 @@
use glam::{IVec2, Vec2};
-// Amanatides and Woo's fast Voxel Traversal
+// Amanatide's and Woo's fast Voxel Traversal
pub struct AwDda {
next: IVec2,
step_sign: IVec2,
step_delta: Vec2,
t_max: Vec2,
+ done: bool,
}
impl AwDda {
@@ -37,6 +38,7 @@ impl AwDda {
step_sign,
step_delta,
t_max,
+ done: false,
}
}
}
@@ -44,9 +46,13 @@ impl AwDda {
impl Iterator for AwDda {
type Item = IVec2;
fn next(&mut self) -> Option<Self::Item> {
- if self.t_max.min_element() >= 1.0 {
+ if self.done {
return None;
}
+ if self.t_max.min_element() >= 1.0 {
+ self.done = true;
+ return Some(self.next);
+ }
let cur = self.next;