Skip to content

Commit

Permalink
more clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Aug 4, 2024
1 parent 7514de4 commit 36d7c5f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 31 deletions.
6 changes: 3 additions & 3 deletions examples/auto_navmesh_avian2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ fn puck_back_to_start(
commands.entity(entity).insert((
RigidBody::Static,
Path {
current: first.clone(),
current: *first,
next: remaining,
},
));
Expand Down Expand Up @@ -215,10 +215,10 @@ pub fn move_puck(
pub fn display_puck_path(navigator: Query<(&Transform, &Path)>, mut gizmos: Gizmos) {
for (transform, path) in &navigator {
let mut to_display = path.next.iter().map(|v| v.xy()).collect::<Vec<_>>();
to_display.push(path.current.clone().xy());
to_display.push(path.current.xy());
to_display.push(transform.translation.xy());
to_display.reverse();
if to_display.len() >= 1 {
if !to_display.is_empty() {
gizmos.linestrip_2d(to_display, palettes::tailwind::YELLOW_400);
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ fn setup(mut commands: Commands, mut materials: ResMut<Assets<StandardMaterial>>
commands.spawn(PointLightBundle {
point_light: PointLight {
shadows_enabled: true,
intensity: MESH_WIDTH.min(MESH_HEIGHT) as f32 * 3_000_00.0,
intensity: MESH_WIDTH.min(MESH_HEIGHT) as f32 * 300_000.0,
range: MESH_WIDTH.min(MESH_HEIGHT) as f32 * 10.0,
..default()
},
Expand Down
13 changes: 5 additions & 8 deletions examples/gltf_avian3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,7 @@ fn give_target_auto(
let target_id = commands
.spawn((
PbrBundle {
mesh: meshes.add(Mesh::from(Sphere {
radius: 0.5,
..default()
})),
mesh: meshes.add(Mesh::from(Sphere { radius: 0.5 })),
material: materials.add(StandardMaterial {
base_color: palettes::css::RED.into(),
emissive: (palettes::css::RED * 5.0).into(),
Expand All @@ -319,7 +316,7 @@ fn give_target_auto(
})
.id();
commands.entity(entity).insert(Path {
current: first.clone(),
current: *first,
next: remaining,
});
object.0 = Some(target_id);
Expand All @@ -343,7 +340,7 @@ fn refresh_path(
let mut remaining = remaining.to_vec();
remaining.reverse();
*path = Path {
current: first.clone(),
current: *first,
next: remaining,
};
}
Expand Down Expand Up @@ -430,10 +427,10 @@ fn spawn_obstacles(
fn display_navigator_path(navigator: Query<(&Transform, &Path)>, mut gizmos: Gizmos) {
for (transform, path) in &navigator {
let mut to_display = path.next.clone();
to_display.push(path.current.clone());
to_display.push(path.current);
to_display.push(transform.translation.xz().extend(0.2).xzy());
to_display.reverse();
if to_display.len() >= 1 {
if !to_display.is_empty() {
gizmos.linestrip(
to_display.iter().map(|xz| Vec3::new(xz.x, 0.2, xz.z)),
palettes::tailwind::TEAL_400,
Expand Down
6 changes: 3 additions & 3 deletions examples/helpers/agent3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub fn give_target_to_navigator<const SIZE: u32, const X: u32, const Y: u32>(
let mut target;
let delta = if !navmesh.transformed_is_in_mesh(transform.translation) {
let delta = deltas.entry(entity).or_insert(0.0);
*delta = *delta + 0.1;
*delta += 0.1;
*delta
} else {
0.0
Expand Down Expand Up @@ -105,7 +105,7 @@ pub fn give_target_to_navigator<const SIZE: u32, const X: u32, const Y: u32>(
continue;
};
if let Some((first, remaining)) = path.path.split_first() {
let mut remaining = remaining.iter().cloned().collect::<Vec<_>>();
let mut remaining = remaining.to_vec();
remaining.reverse();
let id = commands
.spawn(PbrBundle {
Expand Down Expand Up @@ -167,7 +167,7 @@ pub fn refresh_path<const SIZE: u32, const X: u32, const Y: u32>(
continue;
};
if let Some((first, remaining)) = new_path.path.split_first() {
let mut remaining = remaining.iter().cloned().collect::<Vec<_>>();
let mut remaining = remaining.to_vec();
remaining.reverse();
path.current = *first;
path.next = remaining;
Expand Down
4 changes: 2 additions & 2 deletions examples/many.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn main() {
..default()
},
}),
FrameTimeDiagnosticsPlugin::default(),
FrameTimeDiagnosticsPlugin,
LogDiagnosticsPlugin::default(),
VleueNavigatorPlugin,
))
Expand Down Expand Up @@ -438,7 +438,7 @@ fn go_somewhere(
rng.gen_range(0.0..MESH_SIZE.x),
rng.gen_range(0.0..MESH_SIZE.y),
);
commands.entity(navigator).insert(Target { target: target });
commands.entity(navigator).insert(Target { target });
}
}

Expand Down
9 changes: 2 additions & 7 deletions examples/primitive_3d.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
use std::f32::consts::{FRAC_PI_2, PI};

use bevy::{
color::palettes,
math::{vec2, vec3},
prelude::*,
window::PrimaryWindow,
};
use bevy::{color::palettes, math::vec2, prelude::*, window::PrimaryWindow};
use polyanya::Triangulation;
use rand::Rng;
use vleue_navigator::prelude::*;
Expand Down Expand Up @@ -89,7 +84,7 @@ fn setup(
commands.spawn(PointLightBundle {
point_light: PointLight {
shadows_enabled: true,
intensity: MESH_WIDTH.min(MESH_HEIGHT) as f32 * 3_000_00.0,
intensity: MESH_WIDTH.min(MESH_HEIGHT) as f32 * 300_000.0,
range: MESH_WIDTH.min(MESH_HEIGHT) as f32 * 10.0,
..default()
},
Expand Down
11 changes: 4 additions & 7 deletions src/obstacles/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,11 @@ impl ObstacleSource for PrimitiveObstacle {
let transform = obstacle_transform.compute_transform();
let to_vec2 = |v: Vec3| v.xy();

let to_navmesh_vec3 = |v: Vec3| {
let v = navmesh_transform.rotation.mul_vec3(v);
v
};

let to_navmesh = |v: Vec2| {
let v = v.extend(0.0);
let v = navmesh_transform.rotation.inverse().mul_vec3(v);
let v = transform.transform_point(v);
to_navmesh_vec3(v)
navmesh_transform.rotation.mul_vec3(v)
};

match self {
Expand Down Expand Up @@ -128,7 +123,9 @@ impl ObstacleSource for PrimitiveObstacle {
)
.map(|v| to_vec2(to_navmesh(v)))
.collect::<Vec<_>>();
arc.push(to_vec2(to_navmesh_vec3(transform.translation)));
arc.push(to_vec2(
navmesh_transform.rotation.mul_vec3(transform.translation),
));
arc
}
PrimitiveObstacle::CircularSegment(primitive) => copypasta::arc_2d_inner(
Expand Down

0 comments on commit 36d7c5f

Please sign in to comment.