diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-22 13:54:00 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-22 13:54:00 -0700 |
| commit | 6350e4ffca8ce1e46465284ef3d7559e0f40229b (patch) | |
| tree | 597bd17cc5c86d7271fea5abba4495fb58b4d7c2 /src/sim/lib | |
| parent | 21f6ee0be48f83db3a0052269cfc47ac73dc64f9 (diff) | |
fixes and refactors
Diffstat (limited to 'src/sim/lib')
| -rw-r--r-- | src/sim/lib/ray.rs | 10 |
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; |
