diff --git a/Cargo.toml b/Cargo.toml index ae6dce6..ccccc63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_pathmesh" -version = "0.5.0" +version = "0.6.0" authors = ["François Mockers "] edition = "2021" license = "MIT OR Apache-2.0" @@ -13,13 +13,13 @@ documentation = "https://docs.rs/bevy_pathmesh" categories = ["game-development"] [dependencies] -itertools = "0.11" +itertools = "0.12" [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/README.md b/README.md index 6d971c8..0dfe656 100644 --- a/README.md +++ b/README.md @@ -85,5 +85,6 @@ fn get_path( |Bevy|bevy_pathmesh| |---|---| +|0.13|0.6| |0.11|0.5| |0.10|0.4| diff --git a/examples/gltf.rs b/examples/gltf.rs index 9ae38f3..9cea619 100644 --- a/examples/gltf.rs +++ b/examples/gltf.rs @@ -20,14 +20,13 @@ fn main() { DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { title: "Navmesh with Polyanya".to_string(), - fit_canvas_to_parent: true, ..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 +63,7 @@ fn setup(mut commands: Commands, asset_server: Res) { commands.insert_resource(AmbientLight { color: Color::SEA_GREEN, - brightness: 0.05, + brightness: 100.0, }); commands.spawn(Camera3dBundle { @@ -197,7 +196,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 +253,12 @@ 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 { + base_color: Color::BLUE, + emissive: Color::BLUE * 50.0, + ..default() + }), transform: Transform::from_xyz(-1.0, 0.0, -2.0), ..Default::default() }, @@ -267,7 +270,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 +312,15 @@ 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 { + base_color: Color::RED, + emissive: Color::RED * 50.0, + ..default() + }), transform: Transform::from_xyz(x, 0.0, z), ..Default::default() }, @@ -325,7 +332,7 @@ fn give_target_auto( point_light: PointLight { color: Color::RED, shadows_enabled: true, - range: 3.0, + range: 10.0, ..default() }, transform: Transform::from_xyz(0.0, 1.5, 0.0), @@ -350,7 +357,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 +367,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.into()); 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 +385,15 @@ 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 { + base_color: Color::RED, + emissive: Color::RED * 50.0, + ..default() + }), transform: Transform::from_translation(target), ..Default::default() }, @@ -394,7 +405,7 @@ fn give_target_on_click( point_light: PointLight { color: Color::RED, shadows_enabled: true, - range: 3.0, + range: 10.0, ..default() }, transform: Transform::from_xyz(0.0, 1.5, 0.0), @@ -437,7 +448,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 +471,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..2ebe2af 100644 --- a/examples/lines.rs +++ b/examples/lines.rs @@ -12,7 +12,6 @@ fn main() { DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { title: "Navmesh with Polyanya".to_string(), - fit_canvas_to_parent: true, ..default() }), ..default() @@ -224,7 +223,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 +238,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..81db7c7 100644 --- a/examples/many.rs +++ b/examples/many.rs @@ -26,7 +26,6 @@ fn main() { .set(WindowPlugin { primary_window: Some(Window { title: "Navmesh with Polyanya".to_string(), - fit_canvas_to_parent: true, present_mode: PresentMode::AutoNoVsync, ..default() }), @@ -507,7 +506,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() ); @@ -537,7 +536,7 @@ fn update_ui( } 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..8563540 100644 --- a/examples/moving.rs +++ b/examples/moving.rs @@ -20,7 +20,6 @@ fn main() { DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { title: "Navmesh with Polyanya".to_string(), - fit_canvas_to_parent: true, ..default() }), ..default() @@ -226,8 +225,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