Skip to content

Commit

Permalink
Fix compilation and remove nphysics mentions (#60)
Browse files Browse the repository at this point in the history
* fix compilation ; remove mentions to nphysics/ncollide ; update community links

* removed asmjs mentions

* translate Fluid::compute_aabb for parry
  • Loading branch information
Vrixyz authored Sep 9, 2024
1 parent 8ac39a3 commit 1b57c18
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 64 deletions.
7 changes: 1 addition & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = [ "build/salva2d", "build/salva3d", "examples2d", "examples3d" ]
members = ["build/salva2d", "build/salva3d", "examples2d", "examples3d"]
resolver = "2"

[profile.release]
Expand Down Expand Up @@ -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" }
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
</p>
<p align = "center">
<strong>
<a href="https://salva.rs">Users guide</a> | <a href="https://docs.rs/salva2d/latest/salva2d">2D Documentation</a> | <a href="https://docs.rs/salva3d/latest/salva3d">3D Documentation</a> | <a href="https://discourse.nphysics.org">Forum</a>
<a href="https://salva.rs">Users guide</a> | <a href="https://docs.rs/salva2d/latest/salva2d">2D Documentation</a> | <a href="https://docs.rs/salva3d/latest/salva3d">3D Documentation</a> | <a href="https://discord.gg/vt9DJSW">Discord</a>
</strong>
</p>

-----

**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?

Expand All @@ -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
54 changes: 36 additions & 18 deletions build/salva2d/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,44 +1,55 @@
[package]
name = "salva2d"
name = "salva2d"
version = "0.9.0"
authors = [ "Sébastien Crozet <[email protected]>" ]
authors = ["Sébastien Crozet <[email protected]>"]
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"

[badges]
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"
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"
Expand All @@ -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 }
46 changes: 29 additions & 17 deletions build/salva3d/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
[package]
name = "salva3d"
name = "salva3d"
version = "0.9.0"
authors = [ "Sébastien Crozet <[email protected]>" ]
authors = ["Sébastien Crozet <[email protected]>"]
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"
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"
Expand All @@ -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 }
4 changes: 2 additions & 2 deletions examples2d/all_examples2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn demo_name_from_command_line() -> Option<String> {
None
}

#[cfg(any(target_arch = "wasm32", target_arch = "asmjs"))]
#[cfg(target_arch = "wasm32")]
fn demo_name_from_url() -> Option<String> {
let window = stdweb::web::window();
let hash = window.location()?.search().ok()?;
Expand All @@ -34,7 +34,7 @@ fn demo_name_from_url() -> Option<String> {
}
}

#[cfg(not(any(target_arch = "wasm32", target_arch = "asmjs")))]
#[cfg(not(target_arch = "wasm32"))]
fn demo_name_from_url() -> Option<String> {
None
}
Expand Down
4 changes: 2 additions & 2 deletions examples3d/all_examples3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn demo_name_from_command_line() -> Option<String> {
None
}

#[cfg(any(target_arch = "wasm32", target_arch = "asmjs"))]
#[cfg(target_arch = "wasm32")]
fn demo_name_from_url() -> Option<String> {
None
// let window = stdweb::web::window();
Expand All @@ -39,7 +39,7 @@ fn demo_name_from_url() -> Option<String> {
// }
}

#[cfg(not(any(target_arch = "wasm32", target_arch = "asmjs")))]
#[cfg(not(target_arch = "wasm32"))]
fn demo_name_from_url() -> Option<String> {
None
}
Expand Down
4 changes: 2 additions & 2 deletions src/counters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/coupling/coupling_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 3 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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?
Expand All @@ -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)]
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/object/fluid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Real> {
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.
Expand Down
2 changes: 1 addition & 1 deletion src/sampling/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 1b57c18

Please sign in to comment.