From 8148aa40923384f2a64daa37a9e72d5dd2271d4c Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Mon, 29 Aug 2022 12:24:32 -0500 Subject: [PATCH] Tweak shape extents and position, and viewshed range, to correctly flag tiles as visible or blocked. --- src/visibility.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/visibility.rs b/src/visibility.rs index 36a3c57..45d8ed6 100644 --- a/src/visibility.rs +++ b/src/visibility.rs @@ -85,7 +85,7 @@ impl Viewshed { ); let mut context: Context = Context::default(); let vision_distance = vision_distance::Circle::new(self.range); - let shape = Collider::cuboid(0.5 - f32::EPSILON, 0.5 - f32::EPSILON); + let shape = Collider::cuboid(0.49, 0.49); let mut new_visible_entities = HashSet::new(); let size = ( (start.translation().x.abs() + self.range as f32) as u32, @@ -96,7 +96,7 @@ impl Viewshed { RefCell::new(Box::new(|coord: Coord| { let shape_pos = Vec2::new(coord.x as f32 + 0.5, coord.y as f32 + 0.5); // println!("Checking {:?}", shape_pos); - if start.distance(&shape_pos) > self.range as f32 + 1. { + if start.distance(&shape_pos) > self.range as f32 { // println!("Out of range"); return u8::MAX; }