diff options
76 files changed, 2758 insertions, 821 deletions
diff --git a/.github/workflows/rapier-ci-bench.yml b/.github/workflows/rapier-ci-bench.yml index 9cce1b2..6c4f007 100644 --- a/.github/workflows/rapier-ci-bench.yml +++ b/.github/workflows/rapier-ci-bench.yml @@ -18,15 +18,17 @@ jobs: BENCHBOT_TARGET_COMMIT: ${{ github.event.pull_request.head.sha }} BENCHBOT_SHA: ${{ github.sha }} BENCHBOT_HEAD_REF: ${{github.head_ref}} + BENCHBOT_OTHER_BACKENDS: false runs-on: ubuntu-latest steps: - name: Find commit SHA if: github.ref == 'refs/heads/master' run: | echo "::set-env name=BENCHBOT_TARGET_COMMIT::$BENCHBOT_SHA" + echo "::set-env name=BENCHBOT_OTHER_BACKENDS::true" - name: Send 3D bench message shell: bash run: curl -u $BENCHBOT_AMQP_USER:$BENCHBOT_AMQP_PASS -i -H "content-type:application/json" -X POST https://$BENCHBOT_AMQP_HOST/api/exchanges/$BENCHBOT_AMQP_VHOST//publish - -d'{"properties":{},"routing_key":"benchmark","payload":"{ \"repository\":\"https://github.com/'$BENCHBOT_TARGET_REPO'\", \"branch\":\"'$GITHUB_REF'\", \"commit\":\"'$BENCHBOT_TARGET_COMMIT'\" }","payload_encoding":"string"}'
\ No newline at end of file + -d'{"properties":{},"routing_key":"benchmark","payload":"{ \"repository\":\"https://github.com/'$BENCHBOT_TARGET_REPO'\", \"branch\":\"'$GITHUB_REF'\", \"commit\":\"'$BENCHBOT_TARGET_COMMIT'\", \"other_backends\":'$BENCHBOT_OTHER_BACKENDS' }","payload_encoding":"string"}'
\ No newline at end of file @@ -1,4 +1,21 @@ -## v0.2.0 - WIP +## v0.3.0 +- Collider shapes are now trait-objects instead of a `Shape` enum. +- Add a user-defined `u128` to each colliders and rigid-bodies for storing user data. +- Add the support for `Cylinder`, `RoundCylinder`, and `Cone` shapes. +- Added the support for collision filtering based on bit masks (often known as collision groups, collision masks, or + collision layers in other physics engines). Each collider has two groups. Their `collision_groups` is used for filtering + what pair of colliders should have their contacts computed by the narrow-phase. Their `solver_groups` is used for filtering + what pair of colliders should have their contact forces computed by the constraints solver. +- Collision groups can also be used to filter what collider should be hit by a ray-cast performed by the `QueryPipeline`. +- Added collision filters based on user-defined trait-objects. This adds two traits `ContactPairFilter` and + `ProximityPairFilter` that allows user-defined logic for determining if two colliders/sensors are allowed to interact. +- The `PhysicsPipeline::step` method now takes two additional arguments: the optional `&ContactPairFilter` and `&ProximityPairFilter` +for filtering contact and proximity pairs. + +## v0.2.1 +- Fix panic in TriMesh construction and QueryPipeline update caused by a stack overflow or a subtraction underflow. + +## v0.2.0 The most significant change on this version is the addition of the `QueryPipeline` responsible for performing scene-wide queries. So far only ray-casting has been implemented. @@ -5,6 +5,11 @@ members = [ "build/rapier2d", "build/rapier_testbed2d", "examples2d", "benchmark [patch.crates-io] #wrapped2d = { git = "https://github.com/Bastacyclop/rust_box2d.git" } #simba = { path = "../simba" } +#ncollide2d = { path = "../ncollide/build/ncollide2d" } +#ncollide3d = { path = "../ncollide/build/ncollide3d" } +#nphysics2d = { path = "../nphysics/build/nphysics2d" } +#nphysics3d = { path = "../nphysics/build/nphysics3d" } +#kiss3d = { path = "../kiss3d" } [profile.release] #debug = true diff --git a/benchmarks2d/Cargo.toml b/benchmarks2d/Cargo.toml index b1ee8db..90a6326 100644 --- a/benchmarks2d/Cargo.toml +++ b/benchmarks2d/Cargo.toml @@ -14,7 +14,7 @@ enhanced-determinism = [ "rapier2d/enhanced-determinism" ] [dependencies] rand = "0.7" Inflector = "0.11" -nalgebra = "0.22" +nalgebra = "0.23" [dependencies.rapier_testbed2d] path = "../build/rapier_testbed2d" diff --git a/benchmarks3d/Cargo.toml b/benchmarks3d/Cargo.toml index 81c843a..03194df 100644 --- a/benchmarks3d/Cargo.toml +++ b/benchmarks3d/Cargo.toml @@ -14,7 +14,7 @@ enhanced-determinism = [ "rapier3d/enhanced-determinism" ] [dependencies] rand = "0.7" Inflector = "0.11" -nalgebra = "0.22" +nalgebra = "0.23" [dependencies.rapier_testbed3d] path = "../build/rapier_testbed3d" diff --git a/build/rapier2d/Cargo.toml b/build/rapier2d/Cargo.toml index ff5253b..d963079 100644 --- a/build/rapier2d/Cargo.toml +++ b/build/rapier2d/Cargo.toml @@ -1,7 +1,6 @@ -# Name idea: bident for 2D and trident for 3D [package] name = "rapier2d" -version = "0.2.0" +version = "0.3.0" authors = [ "Sébastien Crozet <developer@crozet.re>" ] description = "2-dimensional physics engine in Rust." documentation = "http://docs.rs/rapier2d" @@ -22,7 +21,7 @@ simd-nightly = [ "simba/packed_simd", "simd-is-enabled" ] # enabled with the "simd-stable" or "simd-nightly" feature. simd-is-enabled = [ ] wasm-bindgen = [ "instant/wasm-bindgen" ] -serde-serialize = [ "nalgebra/serde-serialize", "ncollide2d/serde-serialize", "serde", "generational-arena/serde", "bit-vec/serde", "arrayvec/serde" ] +serde-serialize = [ "erased-serde", "nalgebra/serde-serialize", "ncollide2d/serde-serialize", "serde", "generational-arena/serde", "bit-vec/serde", "arrayvec/serde" ] enhanced-determinism = [ "simba/libm_force", "indexmap" ] [lib] @@ -35,18 +34,22 @@ required-features = [ "dim2" ] vec_map = "0.8" instant = { version = "0.1", features = [ "now" ]} num-traits = "0.2" -nalgebra = "0.22" -ncollide2d = "0.24" -simba = "^0.2.1" -approx = "0.3" +nalgebra = "0.23" +ncollide2d = "0.26" +simba = "0.3" +approx = "0.4" rayon = { version = "1", optional = true } -crossbeam = "0.7" +crossbeam = "0.8" generational-arena = "0.2" arrayvec = "0.5" bit-vec = "0.6" rustc-hash = "1" serde = { version = "1", features = [ "derive" ], optional = true } +erased-serde = { version = "0.3", optional = true } indexmap = { version = "1", features = [ "serde-1" ], optional = true } +downcast-rs = "1.2" +num-derive = "0.3" +bitflags = "1" [dev-dependencies] bincode = "1" diff --git a/build/rapier3d/Cargo.toml b/build/rapier3d/Cargo.toml index 130e5dd..f5c2fe4 100644 --- a/build/rapier3d/Cargo.toml +++ b/build/rapier3d/Cargo.toml @@ -1,7 +1,6 @@ -# Name idea: bident for 2D and trident for 3D [package] name = "rapier3d" -version = "0.2.0" +version = "0.3.0" authors = [ "Sébastien Crozet <developer@crozet.re>" ] description = "3-dimensional physics engine in Rust." documentation = "http://docs.rs/rapier3d" @@ -22,7 +21,7 @@ simd-nightly = [ "simba/packed_simd", "simd-is-enabled" ] # enabled with the "simd-stable" or "simd-nightly" feature. simd-is-enabled = [ ] wasm-bindgen = [ "instant/wasm-bindgen" ] -serde-serialize = [ "nalgebra/serde-serialize", "ncollide3d/serde-serialize", "serde", "generational-arena/serde", "bit-vec/serde" ] +serde-serialize = [ "erased-serde", "nalgebra/serde-serialize", "ncollide3d/serde-serialize", "serde", "generational-arena/serde", "bit-vec/serde" ] enhanced-determinism = [ "simba/libm_force", "indexmap" ] [lib] @@ -35,18 +34,22 @@ required-features = [ "dim3" ] vec_map = "0.8" instant = { version = "0.1", features = [ "now" ]} num-traits = "0.2" -nalgebra = "0.22" -ncollide3d = "0.24" -simba = "^0.2.1" -approx = "0.3" +nalgebra = "0.23" +ncollide3d = "0.26" +simba = "0.3" +approx = "0.4" rayon = { version = "1", optional = true } -crossbeam = "0.7" +crossbeam = "0.8" generational-arena = "0.2" arrayvec = "0.5" bit-vec = "0.6" rustc-hash = "1" serde = { version = "1", features = [ "derive" ], optional = true } +erased-serde = { version = "0.3", optional = true } indexmap = { version = "1", features = [ "serde-1" ], optional = true } +downcast-rs = "1.2" +num-derive = "0.3" +bitflags = "1" [dev-dependencies] bincode = "1" diff --git a/build/rapier_testbed2d/Cargo.toml b/build/rapier_testbed2d/Cargo.toml index eeecb2a..08c0893 100644 --- a/build/rapier_testbed2d/Cargo.toml +++ b/build/rapier_testbed2d/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rapier_testbed2d" -version = "0.2.0" +version = "0.3.0" authors = [ "Sébastien Crozet <developer@crozet.re>" ] description = "Testbed for the 2-dimensional physics engine in Rust." homepage = "http://rapier.org" @@ -23,17 +23,17 @@ other-backends = [ "wrapped2d", "nphysics2d" ] [dependencies] -nalgebra = "0.22" -kiss3d = { version = "0.25", features = [ "conrod" ] } +nalgebra = "0.23" +kiss3d = { version = "0.27", features = [ "conrod" ] } rand = "0.7" rand_pcg = "0.2" instant = { version = "0.1", features = [ "web-sys", "now" ]} bitflags = "1" num_cpus = { version = "1", optional = true } wrapped2d = { version = "0.4", optional = true } -ncollide2d = "0.24" -nphysics2d = { version = "0.17", optional = true } -crossbeam = "0.7" +ncollide2d = "0.26" +nphysics2d = { version = "0.18", optional = true } +crossbeam = "0.8" bincode = "1" flexbuffers = "0.1" Inflector = "0.11" @@ -42,5 +42,5 @@ md5 = "0.7" [dependencies.rapier2d] path = "../rapier2d" -version = "0.2" +version = "0.3" features = [ "serde-serialize" ] diff --git a/build/rapier_testbed3d/Cargo.toml b/build/rapier_testbed3d/Cargo.toml index 7675701..7fa01d7 100644 --- a/build/rapier_testbed3d/Cargo.toml +++ b/build/rapier_testbed3d/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rapier_testbed3d" -version = "0.2.0" +version = "0.3.0" authors = [ "Sébastien Crozet <developer@crozet.re>" ] description = "Testbed for the 3-dimensional physics engine in Rust." homepage = "http://rapier.org" @@ -22,19 +22,19 @@ parallel = [ "rapier3d/parallel", "num_cpus" ] other-backends = [ "physx", "physx-sys", "glam", "nphysics3d" ] [dependencies] -nalgebra = "0.22" -kiss3d = { version = "0.25", features = [ "conrod" ] } +nalgebra = "0.23" +kiss3d = { version = "0.27", features = [ "conrod" ] } rand = "0.7" rand_pcg = "0.2" instant = { version = "0.1", features = [ "web-sys", "now" ]} bitflags = "1" -glam = { version = "0.8", optional = true } +glam = { version = "0.9", optional = true } num_cpus = { version = "1", optional = true } -ncollide3d = "0.24" -nphysics3d = { version = "0.17", optional = true } -physx = { version = "0.6", optional = true } +ncollide3d = "0.26" +nphysics3d = { version = "0.18", optional = true } +physx = { version = "0.7", optional = true } physx-sys = { version = "0.4", optional = true } -crossbeam = "0.7" +crossbeam = "0.8" bincode = "1" flexbuffers = "0.1" serde_cbor = "0.11" @@ -44,5 +44,5 @@ serde = { version = "1", features = [ "derive" ] } [dependencies.rapier3d] path = "../rapier3d" -version = "0.2" +version = "0.3" features = [ "serde-serialize" ] diff --git a/examples2d/Cargo.toml b/examples2d/Cargo.toml index ad63958..f1ed728 100644 --- a/examples2d/Cargo.toml +++ b/examples2d/Cargo.toml @@ -14,7 +14,7 @@ enhanced-determinism = [ "rapier2d/enhanced-determinism" ] [dependencies] rand = "0.7" Inflector = "0.11" -nalgebra = "0.22" +nalgebra = "0.23" [dependencies.rapier_testbed2d] path = "../build/rapier_testbed2d" diff --git a/examples2d/all_examples2.rs b/examples2d/all_examples2.rs index 7ee924e..a7ddc75 100644 --- a/examples2d/all_examples2.rs +++ b/examples2d/all_examples2.rs @@ -11,6 +11,7 @@ use rapier_testbed2d::Testbed; use std::cmp::Ordering; mod add_remove2; +mod collision_groups2; mod debug_box_ball2; mod debug_infinite_fall; mod heightfield2; @@ -53,6 +54,7 @@ pub fn main() { let mut builders: Vec<(_, fn(&mut Testbed))> = vec![ ("Add remove", add_remove2::init_world), + ("Collision groups", collision_groups2::init_world), ("Heightfield", heightfield2::init_world), ("Joints", joints2::init_world), ("Platform", platform2::init_world), diff --git a/examples2d/collision_groups2.rs b/examples2d/collision_groups2.rs new file mode 100644 index 0000000..9fd9f0b --- /dev/null +++ b/examples2d/collision_groups2.rs @@ -0,0 +1,98 @@ +use na::{Point2, Point3}; +use rapier2d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet}; +use rapier2d::geometry::{ColliderBuilder, ColliderSet, InteractionGroups}; +use rapier_testbed2d::Testbed; + +pub fn init_world(testbed: &mut Testbed) { + /* + * World + */ + let mut bodies = RigidBodySet::new(); + let mut colliders = ColliderSet::new(); + let joints = JointSet::new(); + + /* + * Ground + */ + let ground_size = 5.0; + let ground_height = 0.1; + + let rigid_body = RigidBodyBuilder::new_static() + .translation(0.0, -ground_height) + .build(); + let floor_handle = bodies.insert(rigid_body); + let collider = ColliderBuilder::cuboid(ground_size, ground_height).build(); + colliders.insert(collider, floor_handle, &mut bodies); + + /* + * Setup groups + */ + const GREEN_GROUP: InteractionGroups = InteractionGroups::new(0b01, 0b01); + const BLUE_GROUP: InteractionGroups = InteractionGroups::new(0b10, 0b10); + + /* + * A green floor that will collide with the GREEN group only. + */ + let green_floor = ColliderBuilder::cuboid(1.0, 0.1) + .translation(0.0, 1.0) + .collision_groups(GREEN_GROUP) + .build(); + let green_collider_handle = colliders.insert(green_floor, floor_handle, &mut bodies); + + testbed.set_collider_initial_color(green_collider_handle, Point3::new(0.0, 1.0, 0.0)); + + /* + * A blue floor that will collide with the BLUE group only. + */ + let blue_floor = ColliderBuilder::cuboid(1.0, 0.1) + .translation(0.0, 2.0) + .collision_groups(BLUE_GROUP) + .build(); + let blue_collider_handle = colliders.insert(blue_floor, floor_handle, &mut bodies); + + testbed.set_collider_initial_color(blue_collider_handle, Point3::new(0.0, 0.0, 1.0)); + + /* + * Create the cubes + */ + let num = 8; + let rad = 0.1; + + let shift = rad * 2.0; + let centerx = shift * (num / 2) as f32; + let centery = 2.5; + + for j in 0usize..4 { + for i in 0..num { + let x = i as f32 * shift - centerx; + let y = j as f32 * shift + centery; + + // Alternate between the green and blue groups. + let (group, color) = if i % 2 == 0 { + (GREEN_GROUP, Point3::new(0.0, 1.0, 0.0)) + } else { + (BLUE_GROUP, Point3::new(0.0, 0.0, 1.0)) + }; + + let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y).build(); + let handle = bodies.insert(rigid_body); + let collider = ColliderBuilder::cuboid(rad, rad) + .collision_groups(group) + .build(); + colliders.insert(collider, handle, &mut bodies); + + testbed.set_body_color(handle, color); + } + } + + /* + * Set up the testbed. + */ + testbed.set_world(bodies, colliders, joints); + testbed.look_at(Point2::new(0.0, 1.0), 100.0); +} + +fn main() { + let testbed = Testbed::from_builders(0, vec![("Boxes", init_world)]); + testbed.run() +} diff --git a/examples3d/Cargo.toml b/examples3d/Cargo.toml index efc3cce..5362554 100644 --- a/examples3d/Cargo.toml +++ b/examples3d/Cargo.toml @@ -14,7 +14,7 @@ enhanced-determinism = [ "rapier3d/enhanced-determinism" ] [dependencies] rand = "0.7" Inflector = "0.11" -nalgebra = "0.22" +nalgebra = "0.23" |
