Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ STYLE.md
Cargo.lock
.idea
.vscode
.DS_Store
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = ["build/salva2d", "build/salva3d", "examples2d", "examples3d"]
members = ["build/salva2d", "build/salva2d-f64", "build/salva3d", "build/salva3d-f64", "examples2d", "examples3d"]
default-members = ["build/salva2d", "build/salva2d-f64", "build/salva3d", "build/salva3d-f64"]
resolver = "2"

[workspace.lints]
Expand All @@ -17,7 +18,9 @@ opt-level = 1

[patch.crates-io]
salva2d = { path = "./build/salva2d" }
salva2d-f64 = { path = "./build/salva2d-f64" }
salva3d = { path = "./build/salva3d" }
salva3d-f64 = { path = "./build/salva3d-f64" }

#parry2d = { git = "https://github.com/sebcrozet/parry" }
#parry3d = { git = "https://github.com/sebcrozet/parry" }
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,10 @@ is inspired from its renown painting [The Persistence of Memory](https://en.wiki
- **Multiphase fluids**: mix several fluids with different characteristics (densities, viscosities, etc.)
- Optional **two-way coupling** with bodies from **rapier**.
- **WASM** support

## Running examples

```bash
cargo run --release -p examples2d --bin all_examples2
cargo run --release -p examples3d --bin all_examples3
```
64 changes: 64 additions & 0 deletions build/salva2d-f64/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[package]
name = "salva2d-f64"
version = "0.9.0"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
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" ]
license = "Apache-2.0"
edition = "2021"

[badges]
maintenance = { status = "actively-developed" }

[features]
default = [ "dim2", "f64" ]
dim2 = [ ]
f64 = [ ]
parallel = [ "rayon" ]
sampling = [ "rapier" ]
rapier = [ "parry", "rapier2d-f64" ]
rapier-testbed = [ "rapier", "rapier_testbed2d", "graphics" ]
rapier-harness = [ "rapier-testbed" ]
parry = [ "parry2d-f64" ]
wasm-bindgen = [ ]
graphics = [ "bevy", "bevy_egui" ]

[lints]
rust.unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(feature, values("dim3", "f32"))',
] }

[lib]
name = "salva2d_f64"
path = "../../src/lib.rs"
required-features = [ "dim2", "f64" ]

[dependencies]
approx = "0.5"
num-traits = "0.2"
fnv = "1.0"
itertools = "0.13"
generational-arena = "0.2"
rayon = { version = "1.8", optional = true }

nalgebra = { version = "0.35", features = ["convert-glam033"] }
glamx = "0.3"
parry2d-f64 = { version = "0.28", optional = true }
rapier2d-f64 = { version = "0.33", optional = true }
# TODO update it to f64
rapier_testbed2d = { version = "0.33", optional = true }

bevy_egui = { version = "0.26", features = ["immutable_ctx"], optional = true }
bitflags = "2"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
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 }
36 changes: 20 additions & 16 deletions build/salva2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,41 @@ 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"]
graphics = ["bevy", "bevy_egui"]
default = [ "dim2", "f32" ]
dim2 = [ ]
f32 = [ ]
parallel = [ "rayon" ]
sampling = [ "rapier" ]
rapier = [ "parry", "rapier2d" ]
rapier-testbed = [ "rapier", "rapier_testbed2d", "graphics", "kiss3d" ]
rapier-harness = [ "rapier-testbed" ]
parry = [ "parry2d" ]
graphics = [ "bevy", "bevy_egui" ]

[lints]
workspace = true
rust.unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(feature, values("dim3", "f64"))',
] }

[lib]
name = "salva2d"
path = "../../src/lib.rs"
required-features = ["dim2"]
required-features = [ "dim2", "f32" ]

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

nalgebra = "0.33"
parry2d = { version = "0.18", optional = true }
rapier2d = { version = "0.23", optional = true }
rapier_testbed2d = { version = "0.23", optional = true }
nalgebra = { version = "0.35", features = ["convert-glam033"] }
glamx = "0.3"
parry2d = { version = "0.28", optional = true }
rapier2d = { version = "0.33", optional = true }
rapier_testbed2d = { version = "0.33", optional = true }
kiss3d = { version = "0.43", optional = true }

bevy_egui = { version = "0.31", features = ["immutable_ctx"], optional = true }
bitflags = "2"
Expand Down
60 changes: 60 additions & 0 deletions build/salva3d-f64/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[package]
name = "salva3d-f64"
version = "0.9.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"
homepage = "https://salva.rs"
repository = "https://github.com/dimforge/salva"
readme = "README.md"
keywords = [ "physics", "dynamics", "particles", "fluids", "SPH" ]
license = "Apache-2.0"
edition = "2021"

[features]
default = [ "dim3", "f64" ]
dim3 = [ ]
f64 = [ ]
parallel = [ "rayon" ]
rapier = [ "parry", "rapier3d-f64" ]
sampling = [ "rapier" ]
rapier-testbed = [ "rapier", "rapier_testbed3d", "graphics" ]
rapier-harness = [ "rapier-testbed" ]
parry = [ "parry3d-f64" ]
wasm-bindgen = [ ]
graphics = [ "bevy", "bevy_egui" ]

[lints]
rust.unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(feature, values("dim2", "f32"))',
] }

[lib]
name = "salva3d_f64"
path = "../../src/lib.rs"
required-features = [ "dim3", "f64" ]

[dependencies]
approx = "0.5"
num-traits = "0.2"
fnv = "1.0"
itertools = "0.13"
generational-arena = "0.2"
rayon = { version = "1.8", optional = true }

nalgebra = { version = "0.35", features = ["convert-glam033"] }
glamx = "0.3"
parry3d-f64 = { version = "0.28", optional = true }
rapier3d-f64 = { version = "0.33", optional = true }
# TODO update it to f64
rapier_testbed3d = { version = "0.33", optional = true }

bevy_egui = { version = "0.26", features = ["immutable_ctx"], optional = true }
bitflags = "2"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
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 }
36 changes: 20 additions & 16 deletions build/salva3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,41 @@ license = "Apache-2.0"
edition = "2021"

[lints]
workspace = true
rust.unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(feature, values("dim2", "f64"))',
] }

[features]
default = ["dim3"]
dim3 = []
parallel = ["rayon"]
rapier = ["parry", "rapier3d"]
sampling = ["rapier"]
rapier-testbed = ["rapier", "rapier_testbed3d", "graphics"]
rapier-harness = ["rapier-testbed"]
parry = ["parry3d"]
graphics = ["bevy", "bevy_egui"]
default = [ "dim3", "f32" ]
dim3 = [ ]
f32 = [ ]
parallel = [ "rayon" ]
rapier = [ "parry", "rapier3d" ]
sampling = [ "rapier" ]
rapier-testbed = [ "rapier", "rapier_testbed3d", "graphics", "kiss3d" ]
rapier-harness = [ "rapier-testbed" ]
parry = [ "parry3d" ]
graphics = [ "bevy", "bevy_egui" ]

[lib]
name = "salva3d"
path = "../../src/lib.rs"
required-features = ["dim3"]
required-features = [ "dim3", "f32" ]

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

nalgebra = "0.33"
parry3d = { version = "0.18", optional = true }
rapier3d = { version = "0.23", optional = true }
rapier_testbed3d = { version = "0.23.1", optional = true }
nalgebra = { version = "0.35", features = ["convert-glam033"] }
glamx = "0.3"
parry3d = { version = "0.28", optional = true }
rapier3d = { version = "0.33", optional = true }
rapier_testbed3d = { version = "0.33", optional = true }
kiss3d = { version = "0.43", optional = true }

bevy_egui = { version = "0.31", features = ["immutable_ctx"], optional = true }
bitflags = "2.6.0"
Expand Down
17 changes: 9 additions & 8 deletions examples2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ authors = ["Sébastien Crozet <developer@crozet.re>"]
edition = "2018"

[features]
default = []
parallel = ["rapier_testbed2d/parallel"]
default = ["parallel"]
parallel = [ "rapier_testbed2d/parallel", "salva2d/parallel" ]

[dependencies]
Inflector = "0.11"
nalgebra = "0.33"
parry2d = "0.18"
rapier2d = "0.23"
rapier_testbed2d = "0.23"
parry3d = "0.18"
Inflector = "0.11"
nalgebra = "0"
parry2d = "0.28"
rapier2d = "0.33"
rapier_testbed2d = "0.33"
parry3d = "0.28"
bevy = "0.15"
pollster = "0.4"

[dependencies.salva2d]
path = "../build/salva2d"
Expand Down
23 changes: 12 additions & 11 deletions examples2d/all_examples2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extern crate nalgebra as na;

use inflector::Inflector;

use rapier_testbed2d::{Testbed, TestbedApp};
use rapier_testbed2d::{Example, TestbedApp};

mod basic2;
mod custom_forces2;
Expand Down Expand Up @@ -46,20 +46,21 @@ fn main() {
.unwrap_or(String::new())
.to_camel_case();

let mut builders: Vec<(_, fn(&mut Testbed))> = vec![
("Basic", basic2::init_world),
("Layers", layers2::init_world),
("Custom forces", custom_forces2::init_world),
("Elasticity", elasticity2::init_world),
("Surface tension", surface_tension2::init_world),
let mut builders = vec![
Example::demo("Basic", basic2::init_world),
Example::demo("Layers", layers2::init_world),
Example::demo("Custom forces", custom_forces2::init_world),
Example::demo("Elasticity", elasticity2::init_world),
Example::demo("Surface tension", surface_tension2::init_world),
];
builders.sort_by_key(|builder| builder.0);
builders.sort_by_key(|builder| builder.name);

let i = builders
.iter()
.position(|builder| builder.0.to_camel_case().as_str() == demo.as_str())
.position(|builder| builder.name.to_camel_case().as_str() == demo.as_str())
.unwrap_or(0);
let testbed = TestbedApp::from_builders(i, builders);
builders.rotate_left(i);
let testbed = TestbedApp::from_builders(builders);

testbed.run()
pollster::block_on(testbed.run());
}
Loading