Update shape size/position for calculating visibility.

This commit is contained in:
Nolan Darilek 2021-06-10 09:31:48 -05:00
parent 24db52abd9
commit a461b0907f
2 changed files with 4 additions and 9 deletions

View File

@ -50,10 +50,7 @@ impl Plugin for LogPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_startup_system(setup.system()).add_system_to_stage(
CoreStage::PostUpdate,
read_log
.system()
.chain(error_handler.system())
.after(crate::visibility::LOG_VISIBLE_LABEL),
read_log.system().chain(error_handler.system()),
);
}
}

View File

@ -108,15 +108,13 @@ fn update_viewshed<'a>(
let coord = Coord::new(start.x_i32(), start.y_i32());
viewshed.visible.clear();
let collider_set = QueryPipelineColliderComponentsSet(&collider_query);
let shape = Cuboid::new(Vec2::new(0.5, 0.5).into());
let shape = Cuboid::new(Vec2::new(0.49, 0.49).into());
let range = viewshed.range as f32;
let visibility_grid = VisibilityGrid(map, |coord: Coord| {
if start.x_i32() == coord.x && start.y_i32() == coord.y {
return 0;
} else if coord.distance(start) > range {
if coord.distance(start) > range {
return 255;
}
let shape_pos = (Vec2::new(coord.x as f32, coord.y as f32), 0.);
let shape_pos = (Vec2::new(coord.x as f32 + 0.5, coord.y as f32 + 0.5), 0.);
let mut opacity = 0;
query_pipeline.intersections_with_shape(
&collider_set,