From 1b57c18d2dbe0230676496dd6f4cec2871f61691 Mon Sep 17 00:00:00 2001
From: Thierry Berger
Date: Mon, 9 Sep 2024 11:35:08 +0200
Subject: [PATCH] Fix compilation and remove nphysics mentions (#60)
* fix compilation ; remove mentions to nphysics/ncollide ; update community links
* removed asmjs mentions
* translate Fluid::compute_aabb for parry
---
Cargo.toml | 7 +----
README.md | 8 ++---
build/salva2d/Cargo.toml | 54 +++++++++++++++++++++-----------
build/salva3d/Cargo.toml | 46 +++++++++++++++++----------
examples2d/all_examples2.rs | 4 +--
examples3d/all_examples3.rs | 4 +--
src/counters/mod.rs | 4 +--
src/coupling/coupling_manager.rs | 2 +-
src/lib.rs | 10 ++----
src/object/fluid.rs | 8 ++---
src/sampling/mod.rs | 2 +-
11 files changed, 85 insertions(+), 64 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 0d1c81f..dc9065a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
[workspace]
-members = [ "build/salva2d", "build/salva3d", "examples2d", "examples3d" ]
+members = ["build/salva2d", "build/salva3d", "examples2d", "examples3d"]
resolver = "2"
[profile.release]
@@ -36,8 +36,3 @@ salva3d = { path = "./build/salva3d" }
# rapier3d = { path = "../rapier/build/rapier3d" }
# rapier_testbed2d = { path = "../rapier/build/rapier_testbed2d" }
# rapier_testbed3d = { path = "../rapier/build/rapier_testbed3d" }
-
-#nphysics2d = { path = "../nphysics/build/nphysics2d" }
-#nphysics3d = { path = "../nphysics/build/nphysics3d" }
-#ncollide2d = { path = "../ncollide/build/ncollide2d" }
-#ncollide3d = { path = "../ncollide/build/ncollide3d" }
diff --git a/README.md b/README.md
index cf68242..99343ab 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@
- Users guide | 2D Documentation | 3D Documentation | Forum
+ Users guide | 2D Documentation | 3D Documentation | Discord
@@ -25,13 +25,13 @@
**Salva** is a 2 and 3-dimensional particle-based fluid simulation engine for games and animations.
It uses [nalgebra](https://nalgebra.org) for vector/matrix math and can optionally interface with
-[nphysics](https://nphysics.org) for two-way coupling with rigid bodies, multibodies, and deformable bodies.
+[rapier](https://rapier.rs) for two-way coupling with rigid bodies, multibodies, and deformable bodies.
2D and 3D implementations both share (mostly) the same code!
Examples are available in the `examples2d` and `examples3d` directories. Because those demos are based on
WASM and WebGl 1.0 they should work on most modern browsers. Feel free to ask for help
-and discuss features on the official [user forum](https://discourse.nphysics.org).
+and discuss features on the official [discord](https://discord.gg/vt9DJSW).
## Why the name Salva?
@@ -44,5 +44,5 @@ is inspired from its renown painting [The Persistence of Memory](https://en.wiki
- **Surface tension:** WCSPH surface tension, and methods from He et al. 2014 and Akinci et al. 2013
- **Elasticity:** method from Becker et al. 2009
- **Multiphase fluids**: mix several fluids with different characteristics (densities, viscosities, etc.)
-- Optional **two-way coupling** with bodies from **nphysics**.
+- Optional **two-way coupling** with bodies from **rapier**.
- **WASM** support
diff --git a/build/salva2d/Cargo.toml b/build/salva2d/Cargo.toml
index b093b98..7abc7ed 100644
--- a/build/salva2d/Cargo.toml
+++ b/build/salva2d/Cargo.toml
@@ -1,14 +1,20 @@
[package]
-name = "salva2d"
+name = "salva2d"
version = "0.9.0"
-authors = [ "Sébastien Crozet " ]
+authors = ["Sébastien Crozet "]
description = "2-dimensional particle-based fluid dynamics in Rust."
documentation = "https://salva.rs/docs"
homepage = "https://salva.rs"
repository = "https://github.com/dimforge/salva"
readme = "README.md"
-categories = [ "science", "game-development", "mathematics", "simulation", "wasm"]
-keywords = [ "physics", "dynamics", "particles", "fluids", "SPH" ]
+categories = [
+ "science",
+ "game-development",
+ "mathematics",
+ "simulation",
+ "wasm",
+]
+keywords = ["physics", "dynamics", "particles", "fluids", "SPH"]
license = "Apache-2.0"
edition = "2021"
@@ -16,21 +22,26 @@ edition = "2021"
maintenance = { status = "actively-developed" }
[features]
-default = [ "dim2" ]
-dim2 = [ ]
-parallel = [ "rayon" ]
-sampling = [ "rapier" ]
-rapier = [ "parry", "rapier2d" ]
-rapier-testbed = [ "rapier", "rapier_testbed2d", "graphics" ]
-rapier-harness = [ "rapier-testbed" ]
-parry = [ "parry2d" ]
-wasm-bindgen = [ "rapier2d/wasm-bindgen" ]
-graphics = [ "bevy", "bevy_egui" ]
+default = ["dim2"]
+dim2 = []
+parallel = ["rayon"]
+sampling = ["rapier"]
+rapier = ["parry", "rapier2d"]
+rapier-testbed = ["rapier", "rapier_testbed2d", "graphics"]
+rapier-harness = ["rapier-testbed"]
+parry = ["parry2d"]
+wasm-bindgen = ["rapier2d/wasm-bindgen"]
+graphics = ["bevy", "bevy_egui"]
+
+[lints]
+rust.unexpected_cfgs = { level = "warn", check-cfg = [
+ 'cfg(feature, values("dim3"))',
+] }
[lib]
name = "salva2d"
path = "../../src/lib.rs"
-required-features = [ "dim2" ]
+required-features = ["dim2"]
[dependencies]
approx = "0.5"
@@ -38,7 +49,7 @@ num-traits = "0.2"
fnv = "1.0"
itertools = "0.13"
generational-arena = "0.2"
-instant = { version = "0.1", features = [ "now" ] }
+instant = { version = "0.1", features = ["now"] }
rayon = { version = "1.8", optional = true }
nalgebra = "0.33"
@@ -49,8 +60,15 @@ rapier_testbed2d = { version = "0.21", optional = true }
bevy_egui = { version = "0.26", features = ["immutable_ctx"], optional = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-bevy = { version = "0.13.2", default-features = false, features = ["bevy_winit", "bevy_render", "x11"], optional = true }
+bevy = { version = "0.13.2", default-features = false, features = [
+ "bevy_winit",
+ "bevy_render",
+ "x11",
+], optional = true }
# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
-bevy = { version = "0.13", default-features = false, features = ["bevy_winit", "bevy_render"], optional = true }
+bevy = { version = "0.13", default-features = false, features = [
+ "bevy_winit",
+ "bevy_render",
+], optional = true }
diff --git a/build/salva3d/Cargo.toml b/build/salva3d/Cargo.toml
index 02ab3f1..1cef4b1 100644
--- a/build/salva3d/Cargo.toml
+++ b/build/salva3d/Cargo.toml
@@ -1,32 +1,37 @@
[package]
-name = "salva3d"
+name = "salva3d"
version = "0.9.0"
-authors = [ "Sébastien Crozet " ]
+authors = ["Sébastien Crozet "]
description = "3-dimensional particle-based fluid dynamics in Rust."
documentation = "https://salva.rs/rustdoc/salva3d/index.html"
homepage = "https://salva.rs"
repository = "https://github.com/dimforge/salva"
readme = "README.md"
-keywords = [ "physics", "dynamics", "particles", "fluids", "SPH" ]
+keywords = ["physics", "dynamics", "particles", "fluids", "SPH"]
license = "Apache-2.0"
edition = "2021"
+[lints]
+rust.unexpected_cfgs = { level = "warn", check-cfg = [
+ 'cfg(feature, values("dim2"))',
+] }
+
[features]
-default = [ "dim3" ]
-dim3 = [ ]
-parallel = [ "rayon" ]
-rapier = [ "parry", "rapier3d" ]
-sampling = [ "rapier" ]
-rapier-testbed = [ "rapier", "rapier_testbed3d", "graphics" ]
-rapier-harness = [ "rapier-testbed" ]
-parry = [ "parry3d" ]
-wasm-bindgen = [ "rapier3d/wasm-bindgen" ]
-graphics = [ "bevy", "bevy_egui" ]
+default = ["dim3"]
+dim3 = []
+parallel = ["rayon"]
+rapier = ["parry", "rapier3d"]
+sampling = ["rapier"]
+rapier-testbed = ["rapier", "rapier_testbed3d", "graphics"]
+rapier-harness = ["rapier-testbed"]
+parry = ["parry3d"]
+wasm-bindgen = ["rapier3d/wasm-bindgen"]
+graphics = ["bevy", "bevy_egui"]
[lib]
name = "salva3d"
path = "../../src/lib.rs"
-required-features = [ "dim3" ]
+required-features = ["dim3"]
[dependencies]
approx = "0.5"
@@ -34,7 +39,7 @@ num-traits = "0.2"
fnv = "1.0"
itertools = "0.13"
generational-arena = "0.2"
-instant = { version = "0.1", features = [ "now" ] }
+instant = { version = "0.1", features = ["now"] }
rayon = { version = "1.8", optional = true }
nalgebra = "0.33"
@@ -45,8 +50,15 @@ rapier_testbed3d = { version = "0.21", optional = true }
bevy_egui = { version = "0.26", features = ["immutable_ctx"], optional = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-bevy = { version = "0.13", default-features = false, features = ["bevy_winit", "bevy_render", "x11"], optional = true }
+bevy = { version = "0.13", default-features = false, features = [
+ "bevy_winit",
+ "bevy_render",
+ "x11",
+], optional = true }
# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
-bevy = { version = "0.13", default-features = false, features = ["bevy_winit", "bevy_render"], optional = true }
+bevy = { version = "0.13", default-features = false, features = [
+ "bevy_winit",
+ "bevy_render",
+], optional = true }
diff --git a/examples2d/all_examples2.rs b/examples2d/all_examples2.rs
index 30be6a8..b0d3390 100644
--- a/examples2d/all_examples2.rs
+++ b/examples2d/all_examples2.rs
@@ -23,7 +23,7 @@ fn demo_name_from_command_line() -> Option {
None
}
-#[cfg(any(target_arch = "wasm32", target_arch = "asmjs"))]
+#[cfg(target_arch = "wasm32")]
fn demo_name_from_url() -> Option {
let window = stdweb::web::window();
let hash = window.location()?.search().ok()?;
@@ -34,7 +34,7 @@ fn demo_name_from_url() -> Option {
}
}
-#[cfg(not(any(target_arch = "wasm32", target_arch = "asmjs")))]
+#[cfg(not(target_arch = "wasm32"))]
fn demo_name_from_url() -> Option {
None
}
diff --git a/examples3d/all_examples3.rs b/examples3d/all_examples3.rs
index 85bb0c0..15afac7 100644
--- a/examples3d/all_examples3.rs
+++ b/examples3d/all_examples3.rs
@@ -27,7 +27,7 @@ fn demo_name_from_command_line() -> Option {
None
}
-#[cfg(any(target_arch = "wasm32", target_arch = "asmjs"))]
+#[cfg(target_arch = "wasm32")]
fn demo_name_from_url() -> Option {
None
// let window = stdweb::web::window();
@@ -39,7 +39,7 @@ fn demo_name_from_url() -> Option {
// }
}
-#[cfg(not(any(target_arch = "wasm32", target_arch = "asmjs")))]
+#[cfg(not(target_arch = "wasm32"))]
fn demo_name_from_url() -> Option {
None
}
diff --git a/src/counters/mod.rs b/src/counters/mod.rs
index 8b16125..1d91ba5 100644
--- a/src/counters/mod.rs
+++ b/src/counters/mod.rs
@@ -12,7 +12,7 @@ mod solver_counters;
mod stages_counters;
mod timer;
-/// Aggregation of all the performances counters tracked by nphysics.
+/// Aggregation of all the performances counters tracked by salva.
#[derive(Clone, Copy)]
pub struct Counters {
/// Total number of substeps performed.
@@ -30,7 +30,7 @@ pub struct Counters {
}
impl Counters {
- /// Create a new set of counters initialized to wero.
+ /// Create a new set of counters initialized to zero.
pub fn new() -> Self {
Counters {
nsubsteps: 0,
diff --git a/src/coupling/coupling_manager.rs b/src/coupling/coupling_manager.rs
index 695a982..3eeea2c 100644
--- a/src/coupling/coupling_manager.rs
+++ b/src/coupling/coupling_manager.rs
@@ -4,7 +4,7 @@ use crate::object::{BoundarySet, Fluid};
use crate::TimestepManager;
/// Trait that needs to be implemented by middlewares responsible for
-/// coupling bodies from a rigid-body physic framework (nphysics, bullet, PhysX, etc.)
+/// coupling bodies from a rigid-body physic framework (rapier, bullet, PhysX, etc.)
/// with boundary objects of salva.
pub trait CouplingManager {
/// Updates the boundary objects from the coupled bodies.
diff --git a/src/lib.rs b/src/lib.rs
index a969b6c..650ee92 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,13 +1,13 @@
/*!
**Salva** is a 2 and 3-dimensional particle-based fluid simulation engine for games and animations.
It uses [nalgebra](https://nalgebra.org) for vector/matrix math and can optionally interface with
-[nphysics](https://nphysics.org) for two-way coupling with rigid bodies, multibodies, and deformable bodies.
+[rapier](https://rapier.rs) for two-way coupling with rigid bodies, multibodies, and deformable bodies.
2D and 3D implementations both share (mostly) the same code!
Examples are available in the `examples2d` and `examples3d` directories. Because those demos are based on
WASM and WebGl 1.0 they should work on most modern browsers. Feel free to ask for help
-and discuss features on the official [user forum](https://discourse.nphysics.org).
+and discuss features on the official [discord](https://discord.gg/vt9DJSW).
## Why the name Salva?
@@ -20,7 +20,7 @@ The name of this library is inspired from the famous surrealist artist `Salvador
- **Surface tension:** WCSPH surface tension, and methods from He et al. 2014 and Akinci et al. 2013
- **Elasticity:** method from Becker et al. 2009
- **Multiphase fluids**: mix several fluids with different characteristics (densities, viscosities, etc.)
-- Optional **two-way coupling** with bodies from **nphysics**.
+- Optional **two-way coupling** with bodies from **rapier**.
- **WASM** support
*/
#![deny(non_camel_case_types)]
@@ -36,10 +36,6 @@ The name of this library is inspired from the famous surrealist artist `Salvador
#![doc(html_logo_url = "https://salva.rs/img/logo_salva_rustdoc.svg")]
extern crate nalgebra as na;
-#[cfg(all(feature = "dim2", feature = "ncollide"))]
-extern crate ncollide2d as ncollide;
-#[cfg(all(feature = "dim3", feature = "ncollide"))]
-extern crate ncollide3d as ncollide;
extern crate num_traits as num;
#[cfg(all(feature = "dim2", feature = "parry"))]
pub extern crate parry2d as parry;
diff --git a/src/object/fluid.rs b/src/object/fluid.rs
index 2c79f5e..755a967 100644
--- a/src/object/fluid.rs
+++ b/src/object/fluid.rs
@@ -166,10 +166,10 @@ impl Fluid {
}
/// Computes the AABB of this fluid.
- #[cfg(feature = "nphysics")]
- pub fn compute_aabb(&self, particle_radius: Real) -> ncollide::bounding_volume::AABB {
- use ncollide::bounding_volume::{self, BoundingVolume};
- bounding_volume::local_point_cloud_aabb(&self.positions).loosened(particle_radius)
+ #[cfg(feature = "parry")]
+ pub fn compute_aabb(&self, particle_radius: Real) -> parry::bounding_volume::Aabb {
+ use parry::bounding_volume::{details::local_point_cloud_aabb, BoundingVolume};
+ local_point_cloud_aabb(&self.positions).loosened(particle_radius)
}
/// The mass of the `i`-th particle of this fluid.
diff --git a/src/sampling/mod.rs b/src/sampling/mod.rs
index 78e79e8..d44e9dd 100644
--- a/src/sampling/mod.rs
+++ b/src/sampling/mod.rs
@@ -1,4 +1,4 @@
-//! Methods for converting shapes from ncollide to sets of points.
+//! Methods for converting shapes from parry to sets of points.
pub use self::ray_sampling::{
shape_surface_ray_sample, shape_volume_ray_sample, surface_ray_sample, volume_ray_sample,