diff --git a/Cargo.toml b/Cargo.toml index ae6dce6..6e5006d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,10 +16,10 @@ categories = ["game-development"] itertools = "0.11" [dependencies.polyanya] -version = "0.4" +version = "0.5" [dependencies.bevy] -version = "0.12" +version = "0.13" features = ["bevy_render", "bevy_asset"] default-features = false @@ -27,7 +27,7 @@ default-features = false rand = "0.8" [dev-dependencies.bevy] -version = "0.12" +version = "0.13" features = [ "bevy_ui", "bevy_text", diff --git a/examples/gltf.rs b/examples/gltf.rs index 9ae38f3..a89ec57 100644 --- a/examples/gltf.rs +++ b/examples/gltf.rs @@ -1,7 +1,7 @@ use bevy::{ asset::LoadState, gltf::{Gltf, GltfMesh}, - math::Vec3Swizzles, + math::{primitives::Sphere, Vec3Swizzles}, pbr::NotShadowCaster, prelude::*, window::PrimaryWindow, @@ -20,14 +20,14 @@ fn main() { DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { title: "Navmesh with Polyanya".to_string(), - fit_canvas_to_parent: true, + canvas: Some("canvas { width: 100%; height: 100%; }".to_string()), ..default() }), ..default() }), PathMeshPlugin, )) - .add_state::() + .init_state::() .add_systems(OnEnter(AppState::Setup), setup) .add_systems(Update, check_textures.run_if(in_state(AppState::Setup))) .add_systems(OnExit(AppState::Setup), setup_scene) @@ -64,7 +64,7 @@ fn setup(mut commands: Commands, asset_server: Res) { commands.insert_resource(AmbientLight { color: Color::SEA_GREEN, - brightness: 0.05, + brightness: 400.0, }); commands.spawn(Camera3dBundle { @@ -197,7 +197,7 @@ fn setup_scene( commands.spawn(( SpotLightBundle { spot_light: SpotLight { - intensity: 800.0, + intensity: 1000000.0, color: Color::SEA_GREEN, shadows_enabled: true, inner_angle: 0.5, @@ -254,8 +254,8 @@ fn setup_scene( commands .spawn(( PbrBundle { - mesh: meshes.add(Mesh::from(shape::Capsule { ..default() })), - material: materials.add(Color::BLUE.into()), + mesh: meshes.add(Mesh::from(Capsule3d { ..default() })), + material: materials.add(StandardMaterial::from(Color::BLUE)), transform: Transform::from_xyz(-1.0, 0.0, -2.0), ..Default::default() }, @@ -267,7 +267,7 @@ fn setup_scene( point_light: PointLight { color: Color::BLUE, range: 500.0, - intensity: 2000.0, + intensity: 100000.0, shadows_enabled: true, ..default() }, @@ -309,11 +309,10 @@ fn give_target_auto( let target_id = commands .spawn(( PbrBundle { - mesh: meshes.add(Mesh::from(shape::UVSphere { + mesh: meshes.add(Mesh::from(Sphere { radius: 0.5, - ..default() })), - material: materials.add(Color::RED.into()), + material: materials.add(StandardMaterial::from(Color::RED)), transform: Transform::from_xyz(x, 0.0, z), ..Default::default() }, @@ -334,7 +333,7 @@ fn give_target_auto( }) .id(); commands.entity(entity).insert(Path { - current: first.clone(), + current: *first, next: remaining, }); object.0 = Some(target_id); @@ -342,6 +341,7 @@ fn give_target_auto( } } +#[allow(clippy::too_many_arguments)] fn give_target_on_click( mut commands: Commands, mut object_query: Query<(Entity, &Transform, &mut Object)>, @@ -350,7 +350,7 @@ fn give_target_on_click( mut meshes: ResMut>, mut materials: ResMut>, current_mesh: Res, - mouse_buttons: Res>, + mouse_buttons: Res>, primary_window: Query<&Window, With>, camera: Query<(&Camera, &GlobalTransform)>, ) { @@ -360,7 +360,7 @@ fn give_target_on_click( let position = primary_window.single().cursor_position()?; let (camera, transform) = camera.get_single().ok()?; let ray = camera.viewport_to_world(transform, position)?; - let denom = Vec3::Y.dot(ray.direction); + let denom = Vec3::Y.dot(*ray.direction); let t = (Vec3::ZERO - ray.origin).dot(Vec3::Y) / denom; let target = ray.origin + ray.direction * t; navmesh.transformed_is_in_mesh(target).then_some(target) @@ -378,11 +378,10 @@ fn give_target_on_click( let target_id = commands .spawn(( PbrBundle { - mesh: meshes.add(Mesh::from(shape::UVSphere { + mesh: meshes.add(Mesh::from(Sphere { radius: 0.5, - ..default() })), - material: materials.add(Color::RED.into()), + material: materials.add(StandardMaterial::from(Color::RED)), transform: Transform::from_translation(target), ..Default::default() }, @@ -403,7 +402,7 @@ fn give_target_on_click( }) .id(); commands.entity(entity).insert(Path { - current: first.clone(), + current: *first, next: remaining, }); object.0 = Some(target_id); @@ -437,7 +436,7 @@ fn move_object( fn trigger_navmesh_visibility( mut query: Query<(&mut Visibility, &NavMeshDisp)>, - keyboard_input: ResMut>, + keyboard_input: ResMut>, current_mesh: Res, ) { if keyboard_input.just_pressed(KeyCode::Space) { @@ -460,7 +459,7 @@ fn target_activity( ) { for children in &target { point_light.get_mut(children[0]).unwrap().intensity = - (time.elapsed_seconds() * 10.0).sin().abs() * 100.0; + (time.elapsed_seconds() * 10.0).sin().abs() * 100000.0; } } diff --git a/examples/lines.rs b/examples/lines.rs index da14ff1..c96cea0 100644 --- a/examples/lines.rs +++ b/examples/lines.rs @@ -12,7 +12,7 @@ fn main() { DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { title: "Navmesh with Polyanya".to_string(), - fit_canvas_to_parent: true, + canvas: Some("canvas { width: 100%; height: 100%; }".to_string()), ..default() }), ..default() @@ -123,6 +123,7 @@ struct PathToDisplay { steps: Vec, } +#[allow(clippy::too_many_arguments)] fn on_mesh_change( mut path_to_display: ResMut, mesh: Res, @@ -224,7 +225,7 @@ fn on_mesh_change( }); } -fn mesh_change(mut mesh: ResMut, keyboard_input: Res>) { +fn mesh_change(mut mesh: ResMut, keyboard_input: Res>) { if keyboard_input.just_pressed(KeyCode::Space) { match mesh.mesh { CurrentMesh::Simple => *mesh = ARENA, @@ -239,7 +240,7 @@ struct NewPathStepEvent(Vec2); fn on_click( mut path_step_event: EventWriter, - mouse_button_input: Res>, + mouse_button_input: Res>, primary_window: Query<&Window, With>, camera_q: Query<(&Camera, &GlobalTransform)>, mesh: Res, diff --git a/examples/many.rs b/examples/many.rs index 5198529..1d29567 100644 --- a/examples/many.rs +++ b/examples/many.rs @@ -26,7 +26,7 @@ fn main() { .set(WindowPlugin { primary_window: Some(Window { title: "Navmesh with Polyanya".to_string(), - fit_canvas_to_parent: true, + canvas: Some("canvas { width: 100%; height: 100%; }".to_string()), present_mode: PresentMode::AutoNoVsync, ..default() }), @@ -43,7 +43,7 @@ fn main() { ..default() }, }), - FrameTimeDiagnosticsPlugin::default(), + FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin::default(), PathMeshPlugin, )) @@ -205,6 +205,7 @@ fn setup(mut commands: Commands, asset_server: Res) { }); } +#[allow(clippy::too_many_arguments)] fn on_mesh_change( mut commands: Commands, mut meshes: ResMut>, @@ -470,6 +471,7 @@ fn display_path( } } +#[allow(clippy::type_complexity)] fn go_somewhere( query: Query< Entity, @@ -488,7 +490,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 }); } } @@ -507,7 +509,7 @@ fn update_ui( text.sections[3].value = format!( "{:.2}\n", diagnostics - .get(FrameTimeDiagnosticsPlugin::FPS) + .get(&FrameTimeDiagnosticsPlugin::FPS) .and_then(|d| d.average()) .unwrap_or_default() ); @@ -526,18 +528,15 @@ fn update_ui( ) ); text.sections[9].value = format!("{:?}\n", *task_mode); - text.sections[11].value = format!( - "{}", - match *display_mode { - DisplayMode::Line => "hide lines", - DisplayMode::Nothing => "display lines", - } - ); + text.sections[11].value = match *display_mode { + DisplayMode::Line => "hide lines", + DisplayMode::Nothing => "display lines", + }.to_string(); *count = new_count; } fn mode_change( - keyboard_input: Res>, + keyboard_input: Res>, mut task_mode: ResMut, mut display_mode: ResMut, ) { @@ -547,7 +546,7 @@ fn mode_change( TaskMode::Blocking => *task_mode = TaskMode::Async, } } - if keyboard_input.just_pressed(KeyCode::L) { + if keyboard_input.just_pressed(KeyCode::KeyL) { match *display_mode { DisplayMode::Line => *display_mode = DisplayMode::Nothing, DisplayMode::Nothing => *display_mode = DisplayMode::Line, diff --git a/examples/moving.rs b/examples/moving.rs index d9f41dc..90348ad 100644 --- a/examples/moving.rs +++ b/examples/moving.rs @@ -20,7 +20,7 @@ fn main() { DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { title: "Navmesh with Polyanya".to_string(), - fit_canvas_to_parent: true, + canvas: Some("canvas { width: 100%; height: 100%; }".to_string()), ..default() }), ..default() @@ -126,6 +126,7 @@ fn setup( commands.insert_resource(AURORA); } +#[allow(clippy::too_many_arguments)] fn on_mesh_change( mesh: Res, mut commands: Commands, @@ -226,8 +227,8 @@ fn on_mesh_change( fn mesh_change( mut mesh: ResMut, - keyboard_input: Res>, - mouse_input: Res>, + keyboard_input: Res>, + mouse_input: Res>, time: Res