Compare commits

..

No commits in common. "0185b9c590b8c12d571d390a94aa39aef21edf20" and "478644491aaa6f561666aaa74b102fa4ef86ea0c" have entirely different histories.

2 changed files with 9 additions and 12 deletions

View File

@ -44,6 +44,7 @@ fn update(
));
}
} else if closest == ClosestPoints::Intersecting && sound_transform.is_some() {
println!("Clearing volumetric");
commands
.entity(sound_entity)
.remove::<Transform>()

View File

@ -61,7 +61,7 @@ impl Viewshed {
let visibility_grid = VisibilityGrid(size, *viewer_entity, opacity_map.clone());
let mut new_visible = HashSet::new();
let mut new_visible_entities = HashSet::new();
// println!("Start: {viewer_entity}");
println!("Start: {viewer_entity}");
context.for_each_visible(
Coord::new(start.x_i32(), start.y_i32()),
&visibility_grid,
@ -71,17 +71,17 @@ impl Viewshed {
|coord, _directions, _visibility| {
let coord = IVec2::new(coord.x, coord.y);
new_visible.insert(coord);
// println!("Checking {coord:?}");
println!("Checking {coord:?}");
if let Some((_, entities)) = opacity_map.get(&coord) {
for e in entities {
if entities.len() == 1 || sensors.contains(*e) {
// println!("Spotted {e:?}");
println!("Spotted {e:?}");
new_visible_entities.insert(*e);
} else {
let should_push = std::cell::RefCell::new(true);
let coord = Vec2::new(coord.x as f32 + 0.5, coord.y as f32 + 0.5);
let dir = Dir2::new_unchecked((coord - *start).normalize());
// println!("Casting from {coord} to {dir:?}");
println!("Casting from {coord} to {dir:?}");
spatial_query.cast_ray_predicate(
*start,
dir,
@ -90,7 +90,7 @@ impl Viewshed {
default(),
&|entity| {
if *e != entity && entities.contains(e) {
// println!("{entities:?} contains {e}");
println!("{entities:?} contains {e}");
*should_push.borrow_mut() = false;
}
true
@ -109,11 +109,11 @@ impl Viewshed {
}
if new_visible_entities != **visible_entities {
for lost in visible_entities.difference(&new_visible_entities) {
// println!("Lost {lost}");
println!("Lost {lost}");
commands.trigger_targets(VisibilityChanged::Lost(*lost), *viewer_entity);
}
for gained in new_visible_entities.difference(visible_entities) {
// println!("Gained {gained}");
println!("Gained {gained}");
commands.trigger_targets(VisibilityChanged::Gained(*gained), *viewer_entity);
}
**visible_entities = new_visible_entities;
@ -180,11 +180,7 @@ fn update_opacity_map(
spatial_query: SpatialQuery,
query: Query<
(Entity, &GlobalTransform, &ColliderAabb, &Visible),
Or<(
Changed<GlobalTransform>,
Changed<ColliderAabb>,
Changed<Visible>,
)>,
Or<(Changed<GlobalTransform>, Changed<Visible>)>,
>,
visible: Query<(Entity, &GlobalTransform, &Collider, &Visible)>,
) {