diff --git a/CHANGELOG.md b/CHANGELOG.md index edb1c46..dad997c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Added `xpbd_collisions` feature * Added `xpbd_collision` example * Split `collisions` into `rapier` and `xpbd` sub-modules +* Collisions happen on fixed update schedule (#20) * Fixed clippy warnings for rust 1.72.0 (#19) * Added rustfmt config (#19) * Added vertex colors in flag example (#19) @@ -31,7 +32,8 @@ ### Fixes -* Fixed visibility issues with cloths. Now the `Aabb` is directly handled by the cloth engine. +* Fixed visibility issues with cloths. Now the `Aabb` is directly handled by +the cloth engine. ### bevy_inspector_egui diff --git a/Cargo.toml b/Cargo.toml index da769e1..bc26f05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,6 +96,3 @@ crate-type = ["staticlib"] [profile.dev] opt-level = 1 -# Enable high optimizations for dependencies (incl. Bevy), but not for our code: -[profile.dev.package."*"] -opt-level = 3 diff --git a/README.md b/README.md index 57480b5..14806f9 100644 --- a/README.md +++ b/README.md @@ -325,27 +325,27 @@ in `ClothConfig::acceleration_smoothing`. 1. Flag example -run `cargo run --example flag` + run `cargo run --example flag` 2. Balloon example -run `cargo run --example balloon` + run `cargo run --example balloon` 3. Moving example -run `cargo run --example moving` + run `cargo run --example moving` 4. [`bevy_rapier`] collision example -run `cargo run --example rapier_collision --features rapier_collisions` + run `cargo run --example rapier_collision --features rapier_collisions` 5. [`bevy_xpbd`] collision example -run `cargo run --example xpbd_collision --features xpbd_collisions` + run `cargo run --example xpbd_collision --features xpbd_collisions` 6. Anchors example -run `cargo run --example anchors` + run `cargo run --example anchors` [`bevy_rapier`]: https://github.com/dimforge/bevy_rapier [`bevy_xpbd`]: https://github.com/Jondolf/bevy_xpbd diff --git a/src/lib.rs b/src/lib.rs index e8a69f5..b7102dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -372,22 +372,13 @@ impl Plugin for ClothPlugin { ); #[cfg(feature = "rapier_collisions")] - app.register_type::().add_systems( - Update, - ( - systems::collisions::rapier::init_cloth_collider, - systems::collisions::rapier::handle_collisions.before(systems::cloth::render), - ), - ); + app.register_type::() + .add_systems(Update, systems::collisions::rapier::init_cloth_collider) + .add_systems(FixedUpdate, systems::collisions::rapier::handle_collisions); #[cfg(feature = "xpbd_collisions")] - app.register_type::().add_systems( - Update, - ( - systems::collisions::xpbd::init_cloth_collider, - systems::collisions::xpbd::handle_collisions.before(systems::cloth::render), - ), - ); - + app.register_type::() + .add_systems(Update, systems::collisions::xpbd::init_cloth_collider) + .add_systems(FixedUpdate, systems::collisions::xpbd::handle_collisions); bevy::log::info!("Loaded Cloth Plugin"); } } diff --git a/src/systems/cloth.rs b/src/systems/cloth.rs index 92a3224..dde0d5d 100644 --- a/src/systems/cloth.rs +++ b/src/systems/cloth.rs @@ -51,6 +51,7 @@ pub fn render( if let Some(mesh) = meshes.get_mut(handle) { rendering.update_positions(cloth.compute_vertex_positions(transform)); rendering.apply(mesh); + // TODO set_if_neq *aabb = rendering.compute_aabb(); } else { log::warn!("A Cloth has a `ClothRendering` component without a loaded mesh handle");