diff --git a/Cargo.toml b/Cargo.toml index 6bcc504..8ba578c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,24 +21,37 @@ rapier_collisions = ["bevy_rapier3d"] thiserror = "1.0" [dependencies.bevy] -version = "0.10" +version = "0.11" default-features = false features = ["bevy_render", "bevy_asset"] [dependencies.bevy_rapier3d] -version = "0.21" +version = "0.22" optional = true default-features = false features = ["dim3", "async-collider"] [dev-dependencies] -bevy-inspector-egui = "0.18" -bevy_rapier3d = "0.21" +bevy-inspector-egui = "0.19" +bevy_rapier3d = "0.22" rand = "0.8" [dev-dependencies.bevy] -version = "0.10" -features = ["bevy_render", "bevy_pbr", "bevy_core_pipeline", "bevy_asset", "bevy_winit", "x11", "png"] +version = "0.11" +features = [ + "bevy_asset", + "bevy_winit", + "bevy_core_pipeline", + "bevy_pbr", + "bevy_render", + "bevy_sprite", + "png", + "x11", + # The following features are required because of https://github.com/bevyengine/bevy/discussions/9100 + "ktx2", + "zstd", + "tonemapping_luts", +] default-features = false [[example]] diff --git a/examples/anchors_example.rs b/examples/anchors_example.rs index de51fa4..6b151a8 100644 --- a/examples/anchors_example.rs +++ b/examples/anchors_example.rs @@ -11,12 +11,11 @@ fn main() { brightness: 1.0, }) .add_plugins(DefaultPlugins) - .add_plugin(ResourceInspectorPlugin::::new()) - .add_plugin(WorldInspectorPlugin::default()) - .add_plugin(camera_plugin::CameraPlugin) - .add_plugin(ClothPlugin) - .add_startup_system(spawn_cloth) - .add_startup_system(setup) + .add_plugins(ResourceInspectorPlugin::::new()) + .add_plugins(WorldInspectorPlugin::default()) + .add_plugins(camera_plugin::CameraPlugin) + .add_plugins(ClothPlugin) + .add_systems(Startup, (spawn_cloth, setup)) .run(); } diff --git a/examples/balloon_example.rs b/examples/balloon_example.rs index 628d8b9..9f29e3b 100644 --- a/examples/balloon_example.rs +++ b/examples/balloon_example.rs @@ -11,16 +11,15 @@ fn main() { brightness: 1.0, }) .add_plugins(DefaultPlugins) - .add_plugin(WorldInspectorPlugin::default()) - .add_plugin(ResourceInspectorPlugin::::new()) - .add_plugin(camera_plugin::CameraPlugin) - .add_plugin(ClothPlugin) + .add_plugins(WorldInspectorPlugin::default()) + .add_plugins(ResourceInspectorPlugin::::new()) + .add_plugins(camera_plugin::CameraPlugin) + .add_plugins(ClothPlugin) .insert_resource(ClothConfig { friction: 0.1, ..Default::default() }) - .add_startup_system(spawn_cloth) - .add_startup_system(setup) + .add_systems(Startup, (spawn_cloth, setup)) .run(); } diff --git a/examples/camera_plugin.rs b/examples/camera_plugin.rs index 66b3c45..8c2c0ab 100644 --- a/examples/camera_plugin.rs +++ b/examples/camera_plugin.rs @@ -9,7 +9,8 @@ pub struct CameraController; impl Plugin for CameraPlugin { fn build(&self, app: &mut App) { - app.add_startup_system(setup).add_system(handle_camera); + app.add_systems(Startup, setup) + .add_systems(PostUpdate, handle_camera); log::info!("Camera Plugin loaded"); } } diff --git a/examples/flag_example.rs b/examples/flag_example.rs index bba0956..41ac89f 100644 --- a/examples/flag_example.rs +++ b/examples/flag_example.rs @@ -11,10 +11,10 @@ fn main() { brightness: 1.0, }) .add_plugins(DefaultPlugins) - .add_plugin(WorldInspectorPlugin::default()) - .add_plugin(ResourceInspectorPlugin::::new()) - .add_plugin(ResourceInspectorPlugin::::new()) - .add_plugin(camera_plugin::CameraPlugin) + .add_plugins(WorldInspectorPlugin::default()) + .add_plugins(ResourceInspectorPlugin::::new()) + .add_plugins(ResourceInspectorPlugin::::new()) + .add_plugins(camera_plugin::CameraPlugin) .insert_resource(Winds::from(vec![ Wind::SinWave { max_velocity: Vec3::new(20.0, 15.0, 0.0), @@ -29,9 +29,8 @@ fn main() { abs: false, }, ])) - .add_plugin(ClothPlugin) - .add_startup_system(spawn_cloth) - .add_startup_system(setup) + .add_plugins(ClothPlugin) + .add_systems(Startup, (spawn_cloth, setup)) .run(); } diff --git a/examples/moving_example.rs b/examples/moving_example.rs index 08f8042..0118b9c 100644 --- a/examples/moving_example.rs +++ b/examples/moving_example.rs @@ -27,14 +27,13 @@ fn main() { brightness: 1.0, }) .add_plugins(DefaultPlugins) - .add_plugin(WorldInspectorPlugin::default()) - .add_plugin(ResourceInspectorPlugin::::new()) - .add_plugin(ResourceInspectorPlugin::::new()) - .add_plugin(camera_plugin::CameraPlugin) - .add_plugin(ClothPlugin) - .add_startup_system(spawn_cloth) - .add_startup_system(setup) - .add_system(animate_cube) + .add_plugins(WorldInspectorPlugin::default()) + .add_plugins(ResourceInspectorPlugin::::new()) + .add_plugins(ResourceInspectorPlugin::::new()) + .add_plugins(camera_plugin::CameraPlugin) + .add_plugins(ClothPlugin) + .add_systems(Startup, (spawn_cloth, setup)) + .add_systems(Update, animate_cube) .run(); } diff --git a/examples/rapier_collision_example.rs b/examples/rapier_collision_example.rs index 44e3b9a..a5adacc 100644 --- a/examples/rapier_collision_example.rs +++ b/examples/rapier_collision_example.rs @@ -21,16 +21,20 @@ fn main() { brightness: 1.0, }) .add_plugins(DefaultPlugins) - .add_plugin(RapierPhysicsPlugin::::default()) - .add_plugin(ResourceInspectorPlugin::::new()) - .add_plugin(WorldInspectorPlugin::default()) - .add_plugin(ClothPlugin) - .add_plugin(camera_plugin::CameraPlugin) + .add_plugins(RapierPhysicsPlugin::::default()) + .add_plugins(ResourceInspectorPlugin::::new()) + .add_plugins(WorldInspectorPlugin::default()) + .add_plugins(ClothPlugin) + .add_plugins(camera_plugin::CameraPlugin) .insert_resource(ClothMovement { sign: -1.0, t: 0.0 }) - .add_startup_system(spawn_cloth) - .add_startup_system(setup) - .add_system(shoot_balls.run_if(on_timer(Duration::from_secs(6)))) - .add_system(move_cloth) + .add_systems(Startup, (spawn_cloth, setup)) + .add_systems( + Update, + ( + shoot_balls.run_if(on_timer(Duration::from_secs(6))), + move_cloth, + ), + ) .run(); } diff --git a/src/components/cloth_builder.rs b/src/components/cloth_builder.rs index c2968b4..479b783 100644 --- a/src/components/cloth_builder.rs +++ b/src/components/cloth_builder.rs @@ -315,16 +315,20 @@ impl ClothBuilder { ), _ => None, }); - vertex_colors.map_or_else(|| { - log::warn!("ClothBuilder has anchored vertex colors but the associated mesh doesn't have a valid Vertex_Color attribute"); - }, |colors| { - res.extend(colors.into_iter().enumerate().filter_map(|(i, color)| { - self.anchored_vertex_colors - .iter() - .find(|(c, _)| *c == color) - .map(|(_, anchor)| (i, *anchor)) - })); - }); + #[allow(clippy::option_if_let_else)] + match vertex_colors { + Some(colors) => { + res.extend(colors.into_iter().enumerate().filter_map(|(i, color)| { + self.anchored_vertex_colors + .iter() + .find(|(c, _)| *c == color) + .map(|(_, anchor)| (i, *anchor)) + })); + } + None => { + log::warn!("ClothBuilder has anchored vertex colors but the associated mesh doesn't have a valid Vertex_Color attribute"); + } + }; } if !self.anchored_position_conditions.is_empty() { let vertex_positions: Option> = mesh @@ -335,15 +339,19 @@ impl ClothBuilder { } _ => None, }); - vertex_positions.map_or_else(|| { - log::warn!("ClothBuilder has anchored vertex positions but the associated mesh doesn't have a valid Vertex_Position attribute"); - }, |positions| { - res.extend(positions.into_iter().enumerate().flat_map(|(i, pos)| { - self.anchored_position_conditions - .iter() - .filter_map(move |(c, anchor)| c(pos).then_some((i, *anchor))) - })); - }); + #[allow(clippy::option_if_let_else)] + match vertex_positions { + Some(positions) => { + res.extend(positions.into_iter().enumerate().flat_map(|(i, pos)| { + self.anchored_position_conditions + .iter() + .filter_map(move |(c, anchor)| c(pos).then_some((i, *anchor))) + })); + } + None => { + log::warn!("ClothBuilder has anchored vertex positions but the associated mesh doesn't have a valid Vertex_Position attribute"); + } + }; } res } diff --git a/src/lib.rs b/src/lib.rs index dd150a1..c61af0b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -307,16 +307,21 @@ impl Plugin for ClothPlugin { .register_type::() .register_type::() .register_type::(); - app.add_systems(( - systems::cloth::init, - systems::cloth::update, - systems::cloth::render.after(systems::cloth::update), - )); + app.add_systems( + Update, + ( + systems::cloth::init, + (systems::cloth::update, systems::cloth::render).chain(), + ), + ); #[cfg(feature = "rapier_collisions")] - app.register_type::().add_systems(( - systems::collisions::init_cloth_collider, - systems::collisions::handle_collisions.before(systems::cloth::render), - )); + app.register_type::().add_systems( + Update, + ( + systems::collisions::init_cloth_collider, + systems::collisions::handle_collisions.before(systems::cloth::render), + ), + ); bevy::log::info!("Loaded Cloth Plugin"); } } diff --git a/src/vertex_anchor.rs b/src/vertex_anchor.rs index 2688033..2b445a8 100644 --- a/src/vertex_anchor.rs +++ b/src/vertex_anchor.rs @@ -1,12 +1,12 @@ use bevy::math::Vec3; use bevy::prelude::{Entity, GlobalTransform}; -use bevy::reflect::{FromReflect, Reflect}; +use bevy::reflect::Reflect; /// Defines a cloth vertex anchor through a `target` and `offset` /// /// The default anchor will link the cloth vertices to the cloth entity's `GlobalTransform`, /// you can anchor them to a specific entity by defining a `custom_target`. -#[derive(Debug, Copy, Clone, Default, Reflect, FromReflect)] +#[derive(Debug, Copy, Clone, Default, Reflect)] #[must_use] pub struct VertexAnchor { /// Optional custom anchor target entity. If not set, the cloth entity will be used diff --git a/src/wind.rs b/src/wind.rs index e0f8316..cc5e939 100644 --- a/src/wind.rs +++ b/src/wind.rs @@ -1,9 +1,9 @@ use bevy::ecs::prelude::Resource; use bevy::math::Vec3; -use bevy::reflect::{FromReflect, Reflect}; +use bevy::reflect::Reflect; /// Wind definition for cloth physics -#[derive(Debug, Clone, Reflect, FromReflect)] +#[derive(Debug, Clone, Reflect)] pub enum Wind { /// Constant Wind force ConstantWind {