diff --git a/Cargo.toml b/Cargo.toml index ba3b0680daf71..9f8f78e5d994d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,5 +5,7 @@ members = ["bevy_rapier2d", "bevy_rapier3d"] codegen-units = 1 [patch.crates-io] +#parry2d = { path = "../parry/build/parry2d" } +#parry3d = { path = "../parry/build/parry3d" } #rapier2d = { path = "../rapier/build/rapier2d" } #rapier3d = { path = "../rapier/build/rapier3d" } \ No newline at end of file diff --git a/bevy_rapier2d/Cargo.toml b/bevy_rapier2d/Cargo.toml index 7eb93643941e1..b40e085d1adfe 100644 --- a/bevy_rapier2d/Cargo.toml +++ b/bevy_rapier2d/Cargo.toml @@ -30,8 +30,8 @@ enhanced-determinism = [ "rapier2d/enhanced-determinism" ] [dependencies] bevy = { version = "0.4", default-features = false } -nalgebra = "0.23" -rapier2d = "0.4" +nalgebra = "0.24" +rapier2d = "0.5" concurrent-queue = "1" [dev-dependencies] diff --git a/bevy_rapier2d/examples/events2.rs b/bevy_rapier2d/examples/events2.rs index fbeeb36f5c38d..6851a3e1efa3f 100644 --- a/bevy_rapier2d/examples/events2.rs +++ b/bevy_rapier2d/examples/events2.rs @@ -52,8 +52,8 @@ fn setup_graphics(commands: &mut Commands, mut configuration: ResMut) { - while let Ok(proximity_event) = events.proximity_events.pop() { - println!("Received proximity event: {:?}", proximity_event); + while let Ok(intersection_event) = events.intersection_events.pop() { + println!("Received intersection event: {:?}", intersection_event); } while let Ok(contact_event) = events.contact_events.pop() { diff --git a/bevy_rapier3d/Cargo.toml b/bevy_rapier3d/Cargo.toml index ad3d67513afca..e4c78b4b9fdaf 100644 --- a/bevy_rapier3d/Cargo.toml +++ b/bevy_rapier3d/Cargo.toml @@ -30,8 +30,8 @@ enhanced-determinism = [ "rapier3d/enhanced-determinism" ] [dependencies] bevy = { version = "0.4", default-features = false } -nalgebra = "0.23" -rapier3d = "0.4" +nalgebra = "0.24" +rapier3d = "0.5" concurrent-queue = "1" [dev-dependencies] diff --git a/bevy_rapier3d/examples/events3.rs b/bevy_rapier3d/examples/events3.rs index 51cc4fb3c7c3a..93f3149fa6565 100644 --- a/bevy_rapier3d/examples/events3.rs +++ b/bevy_rapier3d/examples/events3.rs @@ -54,8 +54,8 @@ fn setup_graphics(commands: &mut Commands) { } fn display_events(events: Res) { - while let Ok(proximity_event) = events.proximity_events.pop() { - println!("Received proximity event: {:?}", proximity_event); + while let Ok(intersection_event) = events.intersection_events.pop() { + println!("Received intersection event: {:?}", intersection_event); } while let Ok(contact_event) = events.contact_events.pop() { diff --git a/bevy_rapier3d/examples/locked_rotations3.rs b/bevy_rapier3d/examples/locked_rotations3.rs index 92547a42671f8..054320ddb4f50 100644 --- a/bevy_rapier3d/examples/locked_rotations3.rs +++ b/bevy_rapier3d/examples/locked_rotations3.rs @@ -70,7 +70,7 @@ pub fn setup_physics(commands: &mut Commands) { let rigid_body = RigidBodyBuilder::new_dynamic() .translation(0.0, 3.0, 0.0) .lock_translations() - .principal_angular_inertia(Vector3::zeros(), Vector3::new(true, false, false)); + .restrict_rotations(true, false, false); let collider = ColliderBuilder::cuboid(0.2, 0.6, 2.0); commands.spawn((rigid_body, collider)); diff --git a/bevy_rapier3d/examples/static_trimesh3.rs b/bevy_rapier3d/examples/static_trimesh3.rs index 4f1d6aa64295d..230981f95f072 100644 --- a/bevy_rapier3d/examples/static_trimesh3.rs +++ b/bevy_rapier3d/examples/static_trimesh3.rs @@ -65,7 +65,7 @@ pub fn setup_physics(commands: &mut Commands) { // Create the ramp. let mut vertices: Vec> = Vec::new(); - let mut indices: Vec> = Vec::new(); + let mut indices: Vec<[u32; 3]> = Vec::new(); let segments = 32; let ramp_size = ramp_size(); for i in 0..=segments { @@ -77,8 +77,8 @@ pub fn setup_physics(commands: &mut Commands) { } for i in 0..segments { // Two triangles making up a flat quad for each segment of the ramp. - indices.push(Point3::new(2 * i + 0, 2 * i + 1, 2 * i + 2)); - indices.push(Point3::new(2 * i + 2, 2 * i + 1, 2 * i + 3)); + indices.push([2 * i + 0, 2 * i + 1, 2 * i + 2]); + indices.push([2 * i + 2, 2 * i + 1, 2 * i + 3]); } let rigid_body = RigidBodyBuilder::new_static().translation(0.0, 0.0, 0.0); let collider = ColliderBuilder::trimesh(vertices, indices); @@ -88,7 +88,7 @@ pub fn setup_physics(commands: &mut Commands) { // so that we can join the end of the ramp smoothly // to the lip of the bowl. let mut vertices: Vec> = Vec::new(); - let mut indices: Vec> = Vec::new(); + let mut indices: Vec<[u32; 3]> = Vec::new(); let segments = 32; let bowl_size = Vec3::new(10.0, 3.0, 10.0); for ix in 0..=segments { @@ -110,8 +110,8 @@ pub fn setup_physics(commands: &mut Commands) { let row0 = ix * (segments + 1); let row1 = (ix + 1) * (segments + 1); // Two triangles making up a not-very-flat quad for each segment of the bowl. - indices.push(Point3::new(row0 + iz + 0, row0 + iz + 1, row1 + iz + 0)); - indices.push(Point3::new(row1 + iz + 0, row0 + iz + 1, row1 + iz + 1)); + indices.push([row0 + iz + 0, row0 + iz + 1, row1 + iz + 0]); + indices.push([row1 + iz + 0, row0 + iz + 1, row1 + iz + 1]); } } // Position so ramp connects smoothly @@ -154,7 +154,7 @@ fn ball_spawner( // NOTE: The timing here only works properly with `time_dependent_number_of_timesteps` // disabled, as it is for examples. - ball_state.seconds_until_next_spawn -= integration_parameters.dt(); + ball_state.seconds_until_next_spawn -= integration_parameters.dt; if ball_state.seconds_until_next_spawn > 0.0 { return; } diff --git a/src/physics/resources.rs b/src/physics/resources.rs index 21190fb16b38d..a2b9f67eb8404 100644 --- a/src/physics/resources.rs +++ b/src/physics/resources.rs @@ -1,7 +1,7 @@ use crate::rapier::{ dynamics::{JointHandle, RigidBodyHandle}, geometry::{ - ColliderHandle, ContactEvent, ContactPairFilter, ProximityEvent, ProximityPairFilter, + ColliderHandle, ContactEvent, ContactPairFilter, IntersectionEvent, IntersectionPairFilter, }, pipeline::EventHandler, }; @@ -47,8 +47,8 @@ impl Default for RapierConfiguration { pub struct EventQueue { /// The unbounded contact event queue. pub contact_events: ConcurrentQueue, - /// The unbounded proximity event queue. - pub proximity_events: ConcurrentQueue, + /// The unbounded intersection event queue. + pub intersection_events: ConcurrentQueue, /// Are these queues automatically cleared before each simulation timestep? pub auto_clear: bool, } @@ -58,7 +58,7 @@ impl EventQueue { pub fn new(auto_clear: bool) -> Self { Self { contact_events: ConcurrentQueue::unbounded(), - proximity_events: ConcurrentQueue::unbounded(), + intersection_events: ConcurrentQueue::unbounded(), auto_clear, } } @@ -66,13 +66,13 @@ impl EventQueue { /// Removes all events contained by this queue. pub fn clear(&self) { while let Ok(_) = self.contact_events.pop() {} - while let Ok(_) = self.proximity_events.pop() {} + while let Ok(_) = self.intersection_events.pop() {} } } impl EventHandler for EventQueue { - fn handle_proximity_event(&self, event: ProximityEvent) { - let _ = self.proximity_events.push(event); + fn handle_intersection_event(&self, event: IntersectionEvent) { + let _ = self.intersection_events.push(event); } fn handle_contact_event(&self, event: ContactEvent) { @@ -87,19 +87,19 @@ pub struct SimulationToRenderTime { pub diff: f32, } -/// Custom filters for proximity and contact pairs. +/// Custom filters for intersection and contact pairs. pub struct InteractionPairFilters { - /// Custom proximity pair filter. - pub proximity_filter: Option>, + /// Custom intersection pair filter. + pub intersection_filter: Option>, /// Custom contact pair filter. pub contact_filter: Option>, } impl InteractionPairFilters { - /// A new interaction pair filter with no custom proximity and contact pair filters. + /// A new interaction pair filter with no custom intersection and contact pair filters. pub fn new() -> Self { Self { - proximity_filter: None, + intersection_filter: None, contact_filter: None, } } @@ -110,9 +110,9 @@ impl InteractionPairFilters { self } - /// Sets the custom proximity pair filter. - pub fn proximity_filter(mut self, filter: impl ProximityPairFilter + 'static) -> Self { - self.proximity_filter = Some(Box::new(filter) as Box); + /// Sets the custom intersection pair filter. + pub fn intersection_filter(mut self, filter: impl IntersectionPairFilter + 'static) -> Self { + self.intersection_filter = Some(Box::new(filter) as Box); self } } diff --git a/src/physics/systems.rs b/src/physics/systems.rs index ee62c7227f0a8..c573417eeca55 100644 --- a/src/physics/systems.rs +++ b/src/physics/systems.rs @@ -193,7 +193,7 @@ pub fn step_world_system( if configuration.time_dependent_number_of_timesteps { sim_to_render_time.diff += time.delta_seconds(); - let sim_dt = integration_parameters.dt(); + let sim_dt = integration_parameters.dt; while sim_to_render_time.diff >= sim_dt { if configuration.physics_pipeline_active { // NOTE: in this comparison we do the same computations we @@ -217,7 +217,7 @@ pub fn step_world_system( &mut colliders, &mut joints, filter.contact_filter.as_deref(), - filter.proximity_filter.as_deref(), + filter.intersection_filter.as_deref(), &*events, ); } @@ -233,7 +233,7 @@ pub fn step_world_system( &mut colliders, &mut joints, filter.contact_filter.as_deref(), - filter.proximity_filter.as_deref(), + filter.intersection_filter.as_deref(), &*events, ); } @@ -285,7 +285,7 @@ pub fn sync_transform_system( >, ) { let dt = sim_to_render_time.diff; - let sim_dt = integration_parameters.dt(); + let sim_dt = integration_parameters.dt; let alpha = dt / sim_dt; for (rigid_body, previous_pos, mut transform) in interpolation_query.iter_mut() { if let Some(rb) = bodies.get(rigid_body.handle()) { diff --git a/src/render/systems.rs b/src/render/systems.rs index 1aea1e12377ca..0052287c99972 100644 --- a/src/render/systems.rs +++ b/src/render/systems.rs @@ -77,7 +77,7 @@ pub fn create_collider_renders_system( radius: 1.0, }), #[cfg(feature = "dim2")] - ShapeType::Trimesh => { + ShapeType::TriMesh => { let mut mesh = Mesh::new(bevy::render::pipeline::PrimitiveTopology::TriangleList); let trimesh = shape.as_trimesh().unwrap(); @@ -102,7 +102,7 @@ pub fn create_collider_renders_system( mesh } #[cfg(feature = "dim3")] - ShapeType::Trimesh => { + ShapeType::TriMesh => { let mut mesh = Mesh::new(bevy::render::pipeline::PrimitiveTopology::TriangleList); let trimesh = shape.as_trimesh().unwrap(); @@ -182,7 +182,7 @@ pub fn create_collider_renders_system( let b = shape.as_ball().unwrap(); Vec3::new(b.radius, b.radius, b.radius) } - ShapeType::Trimesh => Vec3::one(), + ShapeType::TriMesh => Vec3::one(), _ => unimplemented!(), } * configuration.scale;