Tweak shape extents and position, and viewshed range, to correctly flag tiles as visible or blocked.
This commit is contained in:
parent
124cd74cb1
commit
8148aa4092
|
@ -85,7 +85,7 @@ impl Viewshed {
|
||||||
);
|
);
|
||||||
let mut context: Context<u8> = Context::default();
|
let mut context: Context<u8> = Context::default();
|
||||||
let vision_distance = vision_distance::Circle::new(self.range);
|
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 mut new_visible_entities = HashSet::new();
|
||||||
let size = (
|
let size = (
|
||||||
(start.translation().x.abs() + self.range as f32) as u32,
|
(start.translation().x.abs() + self.range as f32) as u32,
|
||||||
|
@ -96,7 +96,7 @@ impl Viewshed {
|
||||||
RefCell::new(Box::new(|coord: Coord| {
|
RefCell::new(Box::new(|coord: Coord| {
|
||||||
let shape_pos = Vec2::new(coord.x as f32 + 0.5, coord.y as f32 + 0.5);
|
let shape_pos = Vec2::new(coord.x as f32 + 0.5, coord.y as f32 + 0.5);
|
||||||
// println!("Checking {:?}", shape_pos);
|
// 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");
|
// println!("Out of range");
|
||||||
return u8::MAX;
|
return u8::MAX;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user