From a461b0907fb70f24c22ffcee983901949e393c8d Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 10 Jun 2021 09:31:48 -0500 Subject: [PATCH] Update shape size/position for calculating visibility. --- src/log.rs | 5 +---- src/visibility.rs | 8 +++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/log.rs b/src/log.rs index 877dd6d..4c70b68 100644 --- a/src/log.rs +++ b/src/log.rs @@ -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()), ); } } diff --git a/src/visibility.rs b/src/visibility.rs index 3bb81ae..e1e5926 100644 --- a/src/visibility.rs +++ b/src/visibility.rs @@ -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,