Theoretically restore old cache hit.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Nolan Darilek 2022-03-25 12:27:09 -05:00
parent 38564fbebe
commit 43137cfb36

View File

@ -280,7 +280,13 @@ fn update_viewshed<D: 'static + Clone + Default + Send + Sync>(
)>,
>,
visible: Query<&Visible>,
mut viewers: Query<(Entity, &mut Viewshed, &mut VisibleEntities, &Coordinates)>,
mut viewers: Query<(
Entity,
&mut Viewshed,
&mut VisibleEntities,
&Coordinates,
Option<&LastCoordinates>,
)>,
map: Query<&Map<D>>,
query_pipeline: Res<QueryPipeline>,
collider_query: QueryPipelineColliderComponentsQuery,
@ -322,7 +328,23 @@ fn update_viewshed<D: 'static + Clone + Default + Send + Sync>(
if visible.get(entity).is_err() {
continue;
}
for (viewer_entity, viewshed, visible_entities, viewer_coordinates) in viewers.iter_mut() {
for (
viewer_entity,
viewshed,
visible_entities,
viewer_coordinates,
viewer_last_coordinates,
) in viewers.iter_mut()
{
if let (Some(last_coordinates), Some(viewer_last_coordinates)) =
(last_coordinates, viewer_last_coordinates)
{
if viewer_coordinates.i32() == **viewer_last_coordinates
&& coordinates.i32() == **last_coordinates
{
continue;
}
}
if viewer_entity != entity
&& (viewer_coordinates.distance(&coordinates) <= viewshed.range as f32
|| visible_entities.contains(&entity))
@ -333,7 +355,7 @@ fn update_viewshed<D: 'static + Clone + Default + Send + Sync>(
}
let mut cache = HashMap::new();
for entity in to_update.iter() {
if let Ok((viewer_entity, mut viewshed, mut visible_entities, viewer_coordinates)) =
if let Ok((viewer_entity, mut viewshed, mut visible_entities, viewer_coordinates, _)) =
viewers.get_mut(*entity)
{
if let Ok(map) = map.get_single() {