diff --git a/CHANGELOG.md b/CHANGELOG.md index b8640af8..d5fd12ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,15 +6,27 @@ ### Modified +- `RapierContext` has been split in multiple `Component`s: + - `RapierContextColliders` + - `RapierContextJoints` + - `RapierContextSimulation` + - `RapierRigidBodySet` +- Renamed `DefaultReadRapierContext` and `DefaultWriteRapierContext`. + - Use `ReadRapierContext` and its associated `single()` method. + +## v0.28.0 (09 December 2024) + +### Modified + - Update from rapier `0.21` to rapier `0.22`, see [rapier's changelog](https://github.com/dimforge/rapier/blob/master/CHANGELOG.md). - Update bevy to 0.15. -- `RapierContext`, `RapierConfiguration` and `RenderToSimulationTime` are now a `Component` instead of resources. +- `RapierContext`, `RapierConfiguration` and `SimulationToRenderTime` are now a `Component` instead of resources. - Rapier now supports multiple independent physics worlds, see example `multi_world3` for usage details. - Migration guide: - `ResMut` -> `WriteDefaultRapierContext` - `Res` -> `ReadDefaultRapierContext` - - Access to `RapierConfiguration` and `RenderToSimulationTime` should query for it + - Access to `RapierConfiguration` and `SimulationToRenderTime` should query for it on the responsible entity owning the `RenderContext`. - If you are building a library on top of `bevy_rapier` and would want to support multiple independent physics worlds too, you can check out the details of [#545](https://github.com/dimforge/bevy_rapier/pull/545) diff --git a/bevy_rapier2d/examples/debugdump2.rs b/bevy_rapier2d/examples/debugdump2.rs index 190a5079..4d133d91 100644 --- a/bevy_rapier2d/examples/debugdump2.rs +++ b/bevy_rapier2d/examples/debugdump2.rs @@ -1,6 +1,6 @@ //! Example using bevy_mod_debugdump to output a graph of systems execution order. //! run with: -//! `cargo run --example debugdump2 > dump.dot && dot -Tsvg dump.dot > dump.svg` +//! `cargo run --example debugdump2 > dump.dot && dot -Tsvg dump.dot > dump.svg` use bevy::prelude::*; use bevy_mod_debugdump::{schedule_graph, schedule_graph_dot}; diff --git a/bevy_rapier2d/examples/testbed2.rs b/bevy_rapier2d/examples/testbed2.rs index cbb3cf03..c1bcc9d0 100644 --- a/bevy_rapier2d/examples/testbed2.rs +++ b/bevy_rapier2d/examples/testbed2.rs @@ -205,11 +205,12 @@ fn main() { OnExit(Examples::PlayerMovement2), ( cleanup, - |mut rapier_config: Query<&mut RapierConfiguration>, - ctxt: ReadDefaultRapierContext| { + |mut rapier_config: Query<&mut RapierConfiguration>, ctxt: ReadRapierContext| { let mut rapier_config = rapier_config.single_mut(); - rapier_config.gravity = - RapierConfiguration::new(ctxt.integration_parameters.length_unit).gravity; + rapier_config.gravity = RapierConfiguration::new( + ctxt.single().simulation.integration_parameters.length_unit, + ) + .gravity; }, ), ) diff --git a/bevy_rapier3d/examples/joints3.rs b/bevy_rapier3d/examples/joints3.rs index 3edecc74..3ded4ade 100644 --- a/bevy_rapier3d/examples/joints3.rs +++ b/bevy_rapier3d/examples/joints3.rs @@ -279,7 +279,7 @@ pub fn setup_physics(mut commands: Commands) { } pub fn print_impulse_revolute_joints( - context: ReadDefaultRapierContext, + context: ReadRapierContext, joints: Query<(Entity, &ImpulseJoint)>, ) { for (entity, impulse_joint) in joints.iter() { @@ -288,7 +288,7 @@ pub fn print_impulse_revolute_joints( println!( "angle for {}: {:?}", entity, - context.impulse_revolute_joint_angle(entity), + context.single().impulse_revolute_joint_angle(entity), ); } _ => {} diff --git a/bevy_rapier3d/examples/multi_world3.rs b/bevy_rapier3d/examples/multi_contexts3.rs similarity index 80% rename from bevy_rapier3d/examples/multi_world3.rs rename to bevy_rapier3d/examples/multi_contexts3.rs index 54a0ad93..8e74acbb 100644 --- a/bevy_rapier3d/examples/multi_world3.rs +++ b/bevy_rapier3d/examples/multi_contexts3.rs @@ -1,7 +1,7 @@ use bevy::{input::common_conditions::input_just_pressed, prelude::*}; use bevy_rapier3d::prelude::*; -const N_WORLDS: usize = 2; +const N_CONTEXTS: usize = 2; fn main() { App::new() @@ -18,21 +18,21 @@ fn main() { )) .add_systems( Startup, - ((create_worlds, setup_physics).chain(), setup_graphics), + ((create_contexts, setup_physics).chain(), setup_graphics), ) .add_systems(Update, move_platforms) .add_systems( Update, - change_world.run_if(input_just_pressed(KeyCode::KeyC)), + change_context.run_if(input_just_pressed(KeyCode::KeyC)), ) .run(); } -fn create_worlds(mut commands: Commands) { - for i in 0..N_WORLDS { - let mut world = commands.spawn((RapierContext::default(), WorldId(i))); +fn create_contexts(mut commands: Commands) { + for i in 0..N_CONTEXTS { + let mut context = commands.spawn((RapierContextSimulation::default(), ContextId(i))); if i == 0 { - world.insert(DefaultRapierContext); + context.insert((DefaultRapierContext, RapierContextSimulation::default())); } } } @@ -45,7 +45,7 @@ fn setup_graphics(mut commands: Commands) { } #[derive(Component)] -pub struct WorldId(pub usize); +pub struct ContextId(pub usize); #[derive(Component)] struct Platform { @@ -58,8 +58,8 @@ fn move_platforms(time: Res