Tweak shape extents and position, and viewshed range, to correctly flag tiles as visible or blocked.

This commit is contained in:
Nolan Darilek 2022-08-29 12:24:32 -05:00
parent 124cd74cb1
commit 8148aa4092

View File

@ -85,7 +85,7 @@ impl Viewshed {
);
let mut context: Context<u8> = 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;
}