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() { } else if closest == ClosestPoints::Intersecting && sound_transform.is_some() {
println!("Clearing volumetric");
commands commands
.entity(sound_entity) .entity(sound_entity)
.remove::<Transform>() .remove::<Transform>()

View File

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