Skip to content

Commit

Permalink
update bevy, rapier, parry, nalgebra
Browse files Browse the repository at this point in the history
  • Loading branch information
Ray Redondo authored and sebcrozet committed Jan 19, 2024
1 parent 3964163 commit d4415d0
Show file tree
Hide file tree
Showing 21 changed files with 212 additions and 139 deletions.
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = [ "build/salva2d", "build/salva3d", "examples2d", "examples3d" ]
resolver = "2"

[profile.release]
#lto = true
Expand All @@ -17,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" }
Expand Down
25 changes: 12 additions & 13 deletions build/salva2d/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "salva2d"
version = "0.7.0"
version = "0.8.0"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
description = "2-dimensional particle-based fluid dynamics in Rust."
documentation = "https://salva.rs/docs"
Expand All @@ -10,7 +10,7 @@ readme = "README.md"
categories = [ "science", "game-development", "mathematics", "simulation", "wasm"]
keywords = [ "physics", "dynamics", "particles", "fluids", "SPH" ]
license = "Apache-2.0"
edition = "2018"
edition = "2021"

[badges]
maintenance = { status = "actively-developed" }
Expand All @@ -33,25 +33,24 @@ path = "../../src/lib.rs"
required-features = [ "dim2" ]

[dependencies]
approx = "0.4"
approx = "0.5"
num-traits = "0.2"
fnv = "1.0"
itertools = "0.10"
itertools = "0.12"
generational-arena = "0.2"
instant = { version = "0.1", features = [ "now" ] }
rayon = { version = "1.5", optional = true }
rayon = { version = "1.8", optional = true }

nalgebra = "0.29"
parry2d = { version = "0.7", optional = true }
rapier2d = { version = "0.11", optional = true }
rapier_testbed2d = { version = "0.11", optional = true }
nalgebra = "0.32"
parry2d = { version = "0.13", optional = true }
rapier2d = { version = "0.17", optional = true }
rapier_testbed2d = { version = "0.17", optional = true }

bevy_egui = { version = "0.5", optional = true }
bevy_egui = { version = "0.23", features = ["immutable_ctx"], optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = { version = "0.5", default-features = false, features = ["bevy_wgpu", "bevy_winit", "render", "x11"], optional = true }
bevy = { version = "0.12.1", default-features = false, features = ["bevy_winit", "bevy_render", "x11"], optional = true }

# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = { version = "0.5", default-features = false, features = ["bevy_winit", "render"], optional = true }
bevy_webgl2 = { version = "0.5", optional = true }
bevy = { version = "0.12", default-features = false, features = ["bevy_winit", "bevy_render"], optional = true }
26 changes: 12 additions & 14 deletions build/salva3d/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "salva3d"
version = "0.7.0"
version = "0.8.0"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
description = "3-dimensional particle-based fluid dynamics in Rust."
documentation = "https://salva.rs/rustdoc/salva3d/index.html"
Expand All @@ -9,7 +9,7 @@ repository = "https://github.com/dimforge/salva"
readme = "README.md"
keywords = [ "physics", "dynamics", "particles", "fluids", "SPH" ]
license = "Apache-2.0"
edition = "2018"
edition = "2021"

[features]
default = [ "dim3" ]
Expand All @@ -29,26 +29,24 @@ path = "../../src/lib.rs"
required-features = [ "dim3" ]

[dependencies]
approx = "0.4"
approx = "0.5"
num-traits = "0.2"
fnv = "1.0"
itertools = "0.10"
itertools = "0.12"
generational-arena = "0.2"
instant = { version = "0.1", features = [ "now" ] }
rayon = { version = "1.5", optional = true }
rayon = { version = "1.8", optional = true }

nalgebra = "0.29"
parry3d = { version = "0.7", optional = true }
rapier3d = { version = "0.11", optional = true }
rapier_testbed3d = { version = "0.11", optional = true }
nalgebra = "0.32"
parry3d = { version = "0.13", optional = true }
rapier3d = { version = "0.17", optional = true }
rapier_testbed3d = { version = "0.17", optional = true }

bevy_egui = { version = "0.5", optional = true }
bevy_egui = { version = "0.23", features = ["immutable_ctx"], optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy = { version = "0.5", default-features = false, features = ["bevy_wgpu", "bevy_winit", "render", "x11"], optional = true }
bevy = { version = "0.12", default-features = false, features = ["bevy_winit", "bevy_render", "x11"], optional = true }

# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
bevy = { version = "0.5", default-features = false, features = ["bevy_winit", "render"], optional = true }
bevy_webgl2 = { version = "0.5", optional = true }

bevy = { version = "0.12", default-features = false, features = ["bevy_winit", "bevy_render"], optional = true }
12 changes: 6 additions & 6 deletions examples2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ parallel = [ "rapier_testbed2d/parallel"]

[dependencies]
Inflector = "0.11"
nalgebra = "0.29"
parry2d = "0.6"
rapier2d = "0.11"
rapier_testbed2d = "0.11"
parry3d = { version = "0.7" }
bevy = "0.5"
nalgebra = "0.32"
parry2d = "0.13"
rapier2d = "0.17"
rapier_testbed2d = "0.17"
parry3d = "0.13"
bevy = "0.12.1"

[dependencies.salva2d]
path = "../build/salva2d"
Expand Down
18 changes: 13 additions & 5 deletions examples2d/basic2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate nalgebra as na;

use na::{DVector, Point2, Point3, Vector2};
use rapier2d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
use rapier2d::dynamics::{ImpulseJointSet, MultibodyJointSet, RigidBodyBuilder, RigidBodySet};
use rapier2d::geometry::{Collider, ColliderBuilder, ColliderSet};
use rapier_testbed2d::Testbed;
use salva2d::integrations::rapier::{ColliderSampling, FluidsPipeline, FluidsTestbedPlugin};
Expand All @@ -20,7 +20,8 @@ pub fn init_world(testbed: &mut Testbed) {
let mut plugin = FluidsTestbedPlugin::new();
let mut bodies = RigidBodySet::new();
let mut colliders = ColliderSet::new();
let joints = JointSet::new();
let impulse_joints = ImpulseJointSet::new();
let multibody_joints = MultibodyJointSet::new();
let mut fluids_pipeline = FluidsPipeline::new(PARTICLE_RADIUS, SMOOTHING_FACTOR);

// Liquid.
Expand Down Expand Up @@ -85,7 +86,7 @@ pub fn init_world(testbed: &mut Testbed) {
}
});

let rigid_body = RigidBodyBuilder::new_static().build();
let rigid_body = RigidBodyBuilder::fixed().build();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::heightfield(heights, ground_size).build();
let co_handle = colliders.insert_with_parent(collider, handle, &mut bodies);
Expand All @@ -105,7 +106,7 @@ pub fn init_world(testbed: &mut Testbed) {
let mut build_rigid_body_with_coupling = |x, y, collider: Collider| {
let samples =
salva2d::sampling::shape_surface_ray_sample(collider.shape(), PARTICLE_RADIUS).unwrap();
let rb = RigidBodyBuilder::new_dynamic()
let rb = RigidBodyBuilder::dynamic()
.translation(Vector2::new(x, y))
.build();
let _rb_handle = bodies.insert(rb);
Expand All @@ -132,7 +133,14 @@ pub fn init_world(testbed: &mut Testbed) {
*/
plugin.set_pipeline(fluids_pipeline);
testbed.add_plugin(plugin);
testbed.set_world_with_params(bodies, colliders, joints, gravity, ());
testbed.set_world_with_params(
bodies,
colliders,
impulse_joints,
multibody_joints,
gravity,
(),
);
testbed.integration_parameters_mut().dt = 1.0 / 200.0;
// testbed.enable_boundary_particles_rendering(true);
}
14 changes: 11 additions & 3 deletions examples2d/custom_forces2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate nalgebra as na;

use na::{Point2, Point3, Unit, Vector2};
use rapier2d::dynamics::{JointSet, RigidBodySet};
use rapier2d::dynamics::{ImpulseJointSet, MultibodyJointSet, RigidBodySet};
use rapier2d::geometry::ColliderSet;
use rapier_testbed2d::Testbed;
use salva2d::integrations::rapier::{FluidsPipeline, FluidsRenderingMode, FluidsTestbedPlugin};
Expand All @@ -23,7 +23,8 @@ pub fn init_world(testbed: &mut Testbed) {
let mut plugin = FluidsTestbedPlugin::new();
let bodies = RigidBodySet::new();
let colliders = ColliderSet::new();
let joints = JointSet::new();
let impulse_joints = ImpulseJointSet::new();
let multibody_joints = MultibodyJointSet::new();
let mut fluids_pipeline = FluidsPipeline::new(PARTICLE_RADIUS, SMOOTHING_FACTOR);

// Liquid.
Expand All @@ -46,7 +47,14 @@ pub fn init_world(testbed: &mut Testbed) {
plugin.set_pipeline(fluids_pipeline);
plugin.set_fluid_rendering_mode(FluidsRenderingMode::VelocityColor { min: 0.0, max: 5.0 });
testbed.add_plugin(plugin);
testbed.set_world_with_params(bodies, colliders, joints, gravity, ());
testbed.set_world_with_params(
bodies,
colliders,
impulse_joints,
multibody_joints,
gravity,
(),
);
testbed.integration_parameters_mut().dt = 1.0 / 200.0;
testbed.look_at(Point2::origin(), 300.0);
}
Expand Down
16 changes: 12 additions & 4 deletions examples2d/elasticity2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate nalgebra as na;

use na::{Isometry2, Point2, Point3, Vector2};
use rapier2d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
use rapier2d::dynamics::{ImpulseJointSet, MultibodyJointSet, RigidBodyBuilder, RigidBodySet};
use rapier2d::geometry::{ColliderBuilder, ColliderSet};
use rapier_testbed2d::Testbed;
use salva2d::integrations::rapier::{
Expand All @@ -25,7 +25,8 @@ pub fn init_world(testbed: &mut Testbed) {
let mut plugin = FluidsTestbedPlugin::new();
let mut bodies = RigidBodySet::new();
let mut colliders = ColliderSet::new();
let joints = JointSet::new();
let impulse_joints = ImpulseJointSet::new();
let multibody_joints = MultibodyJointSet::new();
let mut fluids_pipeline = FluidsPipeline::new(PARTICLE_RADIUS, SMOOTHING_FACTOR);

let ground_thickness = 0.2;
Expand Down Expand Up @@ -62,7 +63,7 @@ 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::new_static().build());
bodies.insert(RigidBodyBuilder::fixed().build());
let co = ColliderBuilder::cuboid(ground_half_width, ground_thickness).build();
let co_handle = colliders.insert(co);
let bo_handle = fluids_pipeline
Expand All @@ -80,7 +81,14 @@ pub fn init_world(testbed: &mut Testbed) {
plugin.set_pipeline(fluids_pipeline);
plugin.set_fluid_rendering_mode(FluidsRenderingMode::VelocityColor { min: 0.0, max: 5.0 });
testbed.add_plugin(plugin);
testbed.set_world_with_params(bodies, colliders, joints, gravity, ());
testbed.set_world_with_params(
bodies,
colliders,
impulse_joints,
multibody_joints,
gravity,
(),
);
testbed.integration_parameters_mut().dt = 1.0 / 200.0;
testbed.look_at(Point2::new(0.0, 1.0), 100.0);
}
16 changes: 12 additions & 4 deletions examples2d/surface_tension2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate nalgebra as na;

use na::{Isometry2, Point2, Point3, Vector2};
use rapier2d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
use rapier2d::dynamics::{ImpulseJointSet, MultibodyJointSet, RigidBodyBuilder, RigidBodySet};
use rapier2d::geometry::{ColliderBuilder, ColliderSet};
use rapier_testbed2d::{Testbed, TestbedApp};
use salva2d::integrations::rapier::{
Expand All @@ -27,7 +27,8 @@ pub fn init_world(testbed: &mut Testbed) {
let mut plugin = FluidsTestbedPlugin::new();
let mut bodies = RigidBodySet::new();
let mut colliders = ColliderSet::new();
let joints = JointSet::new();
let impulse_joints = ImpulseJointSet::new();
let multibody_joints = MultibodyJointSet::new();
let mut fluids_pipeline = FluidsPipeline::new(PARTICLE_RADIUS, SMOOTHING_FACTOR);

// Initialize the fluid and give it some surface tension. This will make the fluid take a spherical shape.
Expand All @@ -44,7 +45,7 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_thickness = 0.02;
let ground_half_width = 0.15;

bodies.insert(RigidBodyBuilder::new_static().build());
bodies.insert(RigidBodyBuilder::fixed().build());
let co = ColliderBuilder::cuboid(ground_half_width, ground_thickness).build();
let co_handle = colliders.insert(co);
let bo_handle = fluids_pipeline
Expand All @@ -62,7 +63,14 @@ pub fn init_world(testbed: &mut Testbed) {
plugin.set_pipeline(fluids_pipeline);
plugin.set_fluid_rendering_mode(FluidsRenderingMode::VelocityColor { min: 0.0, max: 5.0 });
testbed.add_plugin(plugin);
testbed.set_world_with_params(bodies, colliders, joints, gravity, ());
testbed.set_world_with_params(
bodies,
colliders,
impulse_joints,
multibody_joints,
gravity,
(),
);
testbed.integration_parameters_mut().dt = 1.0 / 200.0;
testbed.look_at(Point2::origin(), 1500.0);
// testbed.enable_boundary_particles_rendering(true);
Expand Down
10 changes: 5 additions & 5 deletions examples3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ parallel = [ "rapier_testbed3d/parallel", "salva3d/parallel"]
[dependencies]
num-traits = "0.2"
Inflector = "0.11"
nalgebra = "0.29"
rapier3d = "0.11"
rapier_testbed3d = "0.11"
parry3d = { version = "0.7" }
bevy = "0.5"
nalgebra = "0.32"
rapier3d = "0.17"
rapier_testbed3d = "0.17"
parry3d = "0.13"
bevy = "0.12.1"

[dependencies.salva3d]
path = "../build/salva3d"
Expand Down
16 changes: 12 additions & 4 deletions examples3d/basic3.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate nalgebra as na;

use na::{Isometry3, Point3, Vector3};
use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
use rapier3d::dynamics::{ImpulseJointSet, MultibodyJointSet, RigidBodyBuilder, RigidBodySet};
use rapier3d::geometry::{ColliderBuilder, ColliderSet, SharedShape};
use rapier_testbed3d::{Testbed, TestbedApp};
use salva3d::integrations::rapier::{ColliderSampling, FluidsPipeline, FluidsTestbedPlugin};
Expand All @@ -22,7 +22,8 @@ pub fn init_world(testbed: &mut Testbed) {
let gravity = Vector3::y() * -9.81;
let mut bodies = RigidBodySet::new();
let mut colliders = ColliderSet::new();
let joints = JointSet::new();
let impulse_joints = ImpulseJointSet::new();
let multibody_joints = MultibodyJointSet::new();
let mut fluids_pipeline = FluidsPipeline::new(PARTICLE_RADIUS, SMOOTHING_FACTOR);

// Parameters of the ground.
Expand All @@ -48,7 +49,7 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_shape = SharedShape::cuboid(ground_half_width, ground_thickness, ground_half_width);
let wall_shape = SharedShape::cuboid(ground_thickness, ground_half_height, ground_half_width);

let ground_body = RigidBodyBuilder::new_static().build();
let ground_body = RigidBodyBuilder::fixed().build();
let ground_handle = bodies.insert(ground_body);

let wall_poses = [
Expand Down Expand Up @@ -105,7 +106,14 @@ pub fn init_world(testbed: &mut Testbed) {
plugin.render_boundary_particles = true;
testbed.add_plugin(plugin);
// testbed.set_body_wireframe(ground_handle, true);
testbed.set_world_with_params(bodies, colliders, joints, gravity, ());
testbed.set_world_with_params(
bodies,
colliders,
impulse_joints,
multibody_joints,
gravity,
(),
);
testbed.integration_parameters_mut().dt = 1.0 / 200.0;
testbed.look_at(Point3::new(3.0, 3.0, 3.0), Point3::origin());
}
Expand Down

0 comments on commit d4415d0

Please sign in to comment.