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