From bcca9e7ed81e398a96d3cafbe455d95dfc40b81c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sun, 11 Feb 2024 11:27:25 +0100 Subject: [PATCH 1/2] feat: update to rapier 0.18 --- Cargo.toml | 8 ++++---- build/salva2d/Cargo.toml | 4 ++-- build/salva3d/Cargo.toml | 4 ++-- examples2d/Cargo.toml | 4 ++-- examples2d/basic2.rs | 6 +++--- examples2d/elasticity2.rs | 4 ++-- examples2d/surface_tension2.rs | 4 ++-- examples3d/Cargo.toml | 4 ++-- examples3d/elasticity3.rs | 2 +- examples3d/faucet3.rs | 2 +- examples3d/surface_tension3.rs | 2 +- src/coupling/coupling_manager.rs | 4 ++-- src/integrations/rapier/fluids_pipeline.rs | 4 ++-- src/liquid_world.rs | 2 +- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d891238..87c2e48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,10 +18,10 @@ salva3d = { path = "./build/salva3d" } #rapier_testbed2d = { git = "https://github.com/dimforge/rapier", branch = "split_geom" } #rapier_testbed3d = { git = "https://github.com/dimforge/rapier", branch = "split_geom" } -rapier2d = { git = "https://github.com/dimforge/rapier" } -rapier3d = { git = "https://github.com/dimforge/rapier" } -rapier_testbed2d = { git = "https://github.com/dimforge/rapier" } -rapier_testbed3d = { git = "https://github.com/dimforge/rapier" } +#rapier2d = { git = "https://github.com/dimforge/rapier" } +#rapier3d = { git = "https://github.com/dimforge/rapier" } +#rapier_testbed2d = { git = "https://github.com/dimforge/rapier" } +#rapier_testbed3d = { git = "https://github.com/dimforge/rapier" } # rapier2d = { git = "https://github.com/dimforge/rapier", rev = "3b0d256" } # rapier3d = { git = "https://github.com/dimforge/rapier", rev = "3b0d256" } diff --git a/build/salva2d/Cargo.toml b/build/salva2d/Cargo.toml index 6916ec2..4320f70 100644 --- a/build/salva2d/Cargo.toml +++ b/build/salva2d/Cargo.toml @@ -43,8 +43,8 @@ rayon = { version = "1.8", optional = true } nalgebra = "0.32" parry2d = { version = "0.13", optional = true } -rapier2d = { version = "0.17", optional = true } -rapier_testbed2d = { version = "0.17", optional = true } +rapier2d = { version = "0.18", optional = true } +rapier_testbed2d = { version = "0.18", optional = true } bevy_egui = { version = "0.23", features = ["immutable_ctx"], optional = true } diff --git a/build/salva3d/Cargo.toml b/build/salva3d/Cargo.toml index 4a45650..0ac24ce 100644 --- a/build/salva3d/Cargo.toml +++ b/build/salva3d/Cargo.toml @@ -39,8 +39,8 @@ rayon = { version = "1.8", optional = true } nalgebra = "0.32" parry3d = { version = "0.13", optional = true } -rapier3d = { version = "0.17", optional = true } -rapier_testbed3d = { version = "0.17", optional = true } +rapier3d = { version = "0.18", optional = true } +rapier_testbed3d = { version = "0.18", optional = true } bevy_egui = { version = "0.23", features = ["immutable_ctx"], optional = true } diff --git a/examples2d/Cargo.toml b/examples2d/Cargo.toml index 9ef9fe2..e6388fb 100644 --- a/examples2d/Cargo.toml +++ b/examples2d/Cargo.toml @@ -12,8 +12,8 @@ parallel = [ "rapier_testbed2d/parallel"] Inflector = "0.11" nalgebra = "0.32" parry2d = "0.13" -rapier2d = "0.17" -rapier_testbed2d = "0.17" +rapier2d = "0.18" +rapier_testbed2d = "0.18" parry3d = "0.13" bevy = "0.12.1" diff --git a/examples2d/basic2.rs b/examples2d/basic2.rs index 9b7fa11..863566e 100644 --- a/examples2d/basic2.rs +++ b/examples2d/basic2.rs @@ -100,7 +100,7 @@ pub fn init_world(testbed: &mut Testbed) { ); /* - * Create a dynamic box. + * Create a dynamic rigid-bodies. */ let rad = 0.4; let mut build_rigid_body_with_coupling = |x, y, collider: Collider| { @@ -109,8 +109,8 @@ pub fn init_world(testbed: &mut Testbed) { let rb = RigidBodyBuilder::dynamic() .translation(Vector2::new(x, y)) .build(); - let _rb_handle = bodies.insert(rb); - let co_handle = colliders.insert(collider); + let rb_handle = bodies.insert(rb); + let co_handle = colliders.insert_with_parent(collider, rb_handle, &mut bodies); let bo_handle = fluids_pipeline .liquid_world .add_boundary(Boundary::new(Vec::new())); diff --git a/examples2d/elasticity2.rs b/examples2d/elasticity2.rs index f8f5f8d..68bd119 100644 --- a/examples2d/elasticity2.rs +++ b/examples2d/elasticity2.rs @@ -63,9 +63,9 @@ pub fn init_world(testbed: &mut Testbed) { plugin.set_fluid_color(fluid_handle, Point3::new(0.6, 0.8, 0.5)); // Setup the ground. - bodies.insert(RigidBodyBuilder::fixed().build()); + let ground_handle = bodies.insert(RigidBodyBuilder::fixed().build()); let co = ColliderBuilder::cuboid(ground_half_width, ground_thickness).build(); - let co_handle = colliders.insert(co); + let co_handle = colliders.insert_with_parent(co, ground_handle, &mut bodies); let bo_handle = fluids_pipeline .liquid_world .add_boundary(Boundary::new(Vec::new())); diff --git a/examples2d/surface_tension2.rs b/examples2d/surface_tension2.rs index a8b259f..9c15d4d 100644 --- a/examples2d/surface_tension2.rs +++ b/examples2d/surface_tension2.rs @@ -45,9 +45,9 @@ pub fn init_world(testbed: &mut Testbed) { let ground_thickness = 0.02; let ground_half_width = 0.15; - bodies.insert(RigidBodyBuilder::fixed().build()); + let ground_handle = bodies.insert(RigidBodyBuilder::fixed().build()); let co = ColliderBuilder::cuboid(ground_half_width, ground_thickness).build(); - let co_handle = colliders.insert(co); + let co_handle = colliders.insert_with_parent(co, ground_handle, &mut bodies); let bo_handle = fluids_pipeline .liquid_world .add_boundary(Boundary::new(Vec::new())); diff --git a/examples3d/Cargo.toml b/examples3d/Cargo.toml index 58b5c88..701166f 100644 --- a/examples3d/Cargo.toml +++ b/examples3d/Cargo.toml @@ -12,8 +12,8 @@ parallel = [ "rapier_testbed3d/parallel", "salva3d/parallel"] num-traits = "0.2" Inflector = "0.11" nalgebra = "0.32" -rapier3d = "0.17" -rapier_testbed3d = "0.17" +rapier3d = "0.18" +rapier_testbed3d = "0.18" parry3d = "0.13" bevy = "0.12.1" diff --git a/examples3d/elasticity3.rs b/examples3d/elasticity3.rs index cb77b5e..1a9f77c 100644 --- a/examples3d/elasticity3.rs +++ b/examples3d/elasticity3.rs @@ -80,7 +80,7 @@ pub fn init_world(testbed: &mut Testbed) { let ground_handle = bodies.insert(RigidBodyBuilder::fixed().build()); let co = ColliderBuilder::cuboid(ground_half_width, ground_thickness, ground_half_width).build(); - let co_handle = colliders.insert(co); + let co_handle = colliders.insert_with_parent(co, ground_handle, &mut bodies); let bo_handle = fluids_pipeline .liquid_world .add_boundary(Boundary::new(Vec::new())); diff --git a/examples3d/faucet3.rs b/examples3d/faucet3.rs index 009b375..9b6a994 100644 --- a/examples3d/faucet3.rs +++ b/examples3d/faucet3.rs @@ -46,7 +46,7 @@ pub fn init_world(testbed: &mut Testbed) { let co = ColliderBuilder::ball(ground_rad).build(); let ball_samples = salva3d::sampling::shape_surface_ray_sample(co.shape(), PARTICLE_RADIUS).unwrap(); - let co_handle = colliders.insert(co); + let co_handle = colliders.insert_with_parent(co, ground_handle, &mut bodies); let bo_handle = fluids_pipeline .liquid_world .add_boundary(Boundary::new(Vec::new())); diff --git a/examples3d/surface_tension3.rs b/examples3d/surface_tension3.rs index 0895f5c..cf6b2c8 100644 --- a/examples3d/surface_tension3.rs +++ b/examples3d/surface_tension3.rs @@ -52,7 +52,7 @@ pub fn init_world(testbed: &mut Testbed) { let co = ColliderBuilder::cuboid(ground_half_width, ground_thickness, ground_half_width).build(); - let co_handle = colliders.insert(co); + let co_handle = colliders.insert_with_parent(co, ground_handle, &mut bodies); let bo_handle = fluids_pipeline .liquid_world .add_boundary(Boundary::new(Vec::new())); diff --git a/src/coupling/coupling_manager.rs b/src/coupling/coupling_manager.rs index 7d9208c..695a982 100644 --- a/src/coupling/coupling_manager.rs +++ b/src/coupling/coupling_manager.rs @@ -24,7 +24,7 @@ pub trait CouplingManager { ); /// Transmit forces from salva's boundary objects to the coupled bodies. - fn transmit_forces(&mut self, boundaries: &BoundarySet); + fn transmit_forces(&mut self, timestep: &TimestepManager, boundaries: &BoundarySet); } impl CouplingManager for () { @@ -39,5 +39,5 @@ impl CouplingManager for () { ) { } - fn transmit_forces(&mut self, _: &BoundarySet) {} + fn transmit_forces(&mut self, _: &TimestepManager, _: &BoundarySet) {} } diff --git a/src/integrations/rapier/fluids_pipeline.rs b/src/integrations/rapier/fluids_pipeline.rs index 11ab792..920570a 100644 --- a/src/integrations/rapier/fluids_pipeline.rs +++ b/src/integrations/rapier/fluids_pipeline.rs @@ -260,7 +260,7 @@ impl<'a> CouplingManager for ColliderCouplingManager<'a> { } } - fn transmit_forces(&mut self, boundaries: &BoundarySet) { + fn transmit_forces(&mut self, timestep: &TimestepManager, boundaries: &BoundarySet) { for (collider, coupling) in &self.coupling.entries { if let (Some(collider), Some(boundary)) = ( self.colliders.get(*collider), @@ -277,7 +277,7 @@ impl<'a> CouplingManager for ColliderCouplingManager<'a> { for (pos, force) in boundary.positions.iter().zip(forces.iter().cloned()) { - body.add_force_at_point(force, *pos, true) + body.apply_impulse_at_point(force * timestep.dt(), *pos, true) } } } diff --git a/src/liquid_world.rs b/src/liquid_world.rs index 29c6829..889b738 100644 --- a/src/liquid_world.rs +++ b/src/liquid_world.rs @@ -143,7 +143,7 @@ impl LiquidWorld { self.boundaries.as_slice(), ); - coupling.transmit_forces(&self.boundaries); + coupling.transmit_forces(&self.timestep_manager, &self.boundaries); self.counters.stages.solver_time.pause(); } From 5e8285e45513f0b7635c0896b8b8140915352dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sun, 11 Feb 2024 11:29:08 +0100 Subject: [PATCH 2/2] Release v0.9.0 --- build/salva2d/Cargo.toml | 2 +- build/salva3d/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/salva2d/Cargo.toml b/build/salva2d/Cargo.toml index 4320f70..e7387da 100644 --- a/build/salva2d/Cargo.toml +++ b/build/salva2d/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "salva2d" -version = "0.8.0" +version = "0.9.0" authors = [ "Sébastien Crozet " ] description = "2-dimensional particle-based fluid dynamics in Rust." documentation = "https://salva.rs/docs" diff --git a/build/salva3d/Cargo.toml b/build/salva3d/Cargo.toml index 0ac24ce..fdbce0e 100644 --- a/build/salva3d/Cargo.toml +++ b/build/salva3d/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "salva3d" -version = "0.8.0" +version = "0.9.0" authors = [ "Sébastien Crozet " ] description = "3-dimensional particle-based fluid dynamics in Rust." documentation = "https://salva.rs/rustdoc/salva3d/index.html"