Simplify types.
This commit is contained in:
parent
8eb050d10a
commit
a75068f6a9
|
@ -52,7 +52,7 @@ impl Viewshed {
|
||||||
&mut self,
|
&mut self,
|
||||||
viewer_entity: &Entity,
|
viewer_entity: &Entity,
|
||||||
visible_entities: &mut VisibleEntities,
|
visible_entities: &mut VisibleEntities,
|
||||||
start: &GlobalTransform,
|
start: &Vec2,
|
||||||
rapier_context: &RapierContext,
|
rapier_context: &RapierContext,
|
||||||
visible_query: &Query<(&Visible, &Collider, &GlobalTransform)>,
|
visible_query: &Query<(&Visible, &Collider, &GlobalTransform)>,
|
||||||
events: &mut EventWriter<VisibilityChanged>,
|
events: &mut EventWriter<VisibilityChanged>,
|
||||||
|
@ -62,7 +62,7 @@ impl Viewshed {
|
||||||
let mut boxes = vec![];
|
let mut boxes = vec![];
|
||||||
let shape = Collider::cuboid(self.range as f32, self.range as f32);
|
let shape = Collider::cuboid(self.range as f32, self.range as f32);
|
||||||
rapier_context.intersections_with_shape(
|
rapier_context.intersections_with_shape(
|
||||||
start.translation().truncate(),
|
*start,
|
||||||
0.,
|
0.,
|
||||||
&shape,
|
&shape,
|
||||||
QueryFilter::new()
|
QueryFilter::new()
|
||||||
|
@ -89,8 +89,8 @@ impl Viewshed {
|
||||||
let shape = Collider::cuboid(0.49, 0.49);
|
let shape = Collider::cuboid(0.49, 0.49);
|
||||||
let mut new_visible_entities = HashSet::new();
|
let mut new_visible_entities = HashSet::new();
|
||||||
let size = (
|
let size = (
|
||||||
(start.translation().x.abs() + self.range as f32) as u32,
|
(start.x.abs() + self.range as f32) as u32,
|
||||||
(start.translation().y.abs() + self.range as f32) as u32,
|
(start.y.abs() + self.range as f32) as u32,
|
||||||
);
|
);
|
||||||
let visibility_grid = VisibilityGrid(
|
let visibility_grid = VisibilityGrid(
|
||||||
size,
|
size,
|
||||||
|
@ -148,11 +148,10 @@ impl Viewshed {
|
||||||
for e in &coord_entities {
|
for e in &coord_entities {
|
||||||
let mut should_insert = true;
|
let mut should_insert = true;
|
||||||
if coord_entities.len() > 1 {
|
if coord_entities.len() > 1 {
|
||||||
let start = start.translation().truncate();
|
|
||||||
let dest = Vec2::new(coord.x as f32, coord.y as f32);
|
let dest = Vec2::new(coord.x as f32, coord.y as f32);
|
||||||
let dir = dest - start;
|
let dir = dest - *start;
|
||||||
rapier_context.intersections_with_ray(
|
rapier_context.intersections_with_ray(
|
||||||
start,
|
*start,
|
||||||
dir,
|
dir,
|
||||||
1.,
|
1.,
|
||||||
true,
|
true,
|
||||||
|
@ -333,7 +332,7 @@ fn update_viewshed(
|
||||||
viewshed.update(
|
viewshed.update(
|
||||||
&viewer_entity,
|
&viewer_entity,
|
||||||
&mut visible_entities,
|
&mut visible_entities,
|
||||||
viewer_transform,
|
&viewer_transform.translation().truncate(),
|
||||||
&rapier_context,
|
&rapier_context,
|
||||||
&visible,
|
&visible,
|
||||||
&mut changed,
|
&mut changed,
|
||||||
|
@ -365,7 +364,7 @@ fn remove_visible(
|
||||||
viewshed.update(
|
viewshed.update(
|
||||||
&viewer_entity,
|
&viewer_entity,
|
||||||
&mut visible_entities,
|
&mut visible_entities,
|
||||||
start,
|
&start.translation().truncate(),
|
||||||
&rapier_context,
|
&rapier_context,
|
||||||
&visible,
|
&visible,
|
||||||
&mut changed,
|
&mut changed,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user