aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Hrusecky <robert.hrusecky@utexas.edu>2020-10-29 18:09:41 -0500
committerRobert Hrusecky <robert.hrusecky@utexas.edu>2020-10-29 18:09:41 -0500
commitbcec54ef31d987cf20b493628a20777183a95f65 (patch)
treecee40c0467c04f1f02861342e20ce8223ca6d99b
parentdd8e25bc4756b8bd01d283b5d7e7c5daa9a1af3f (diff)
parent4b8242b9c267a9412c88793575db37f79c544ca2 (diff)
downloadrapier-bcec54ef31d987cf20b493628a20777183a95f65.tar.gz
rapier-bcec54ef31d987cf20b493628a20777183a95f65.tar.bz2
rapier-bcec54ef31d987cf20b493628a20777183a95f65.zip
Merge branch 'master' into infinite_fall_memory
Fix merge conflict resulting from "axii" spelling correction
-rw-r--r--.github/workflows/rapier-ci-bench.yml4
-rw-r--r--CHANGELOG19
-rw-r--r--Cargo.toml5
-rw-r--r--benchmarks2d/Cargo.toml2
-rw-r--r--benchmarks3d/Cargo.toml2
-rw-r--r--build/rapier2d/Cargo.toml19
-rw-r--r--build/rapier3d/Cargo.toml19
-rw-r--r--build/rapier_testbed2d/Cargo.toml14
-rw-r--r--build/rapier_testbed3d/Cargo.toml18
-rw-r--r--examples2d/Cargo.toml2
-rw-r--r--examples2d/all_examples2.rs2
-rw-r--r--examples2d/collision_groups2.rs98
-rw-r--r--examples3d/Cargo.toml2
-rw-r--r--examples3d/all_examples3.rs4
-rw-r--r--examples3d/collision_groups3.rs102
-rw-r--r--examples3d/debug_boxes3.rs32
-rw-r--r--examples3d/debug_cylinder3.rs65
-rw-r--r--examples3d/heightfield3.rs18
-rw-r--r--examples3d/primitives3.rs27
-rw-r--r--examples3d/trimesh3.rs18
-rw-r--r--src/dynamics/mass_properties.rs4
-rw-r--r--src/dynamics/mass_properties_capsule.rs23
-rw-r--r--src/dynamics/mass_properties_cone.rs29
-rw-r--r--src/dynamics/mass_properties_cylinder.rs40
-rw-r--r--src/dynamics/mass_properties_polygon.rs2
-rw-r--r--src/dynamics/mod.rs3
-rw-r--r--src/dynamics/rigid_body.rs15
-rw-r--r--src/geometry/broad_phase_multi_sap.rs16
-rw-r--r--src/geometry/capsule.rs86
-rw-r--r--src/geometry/collider.rs430
-rw-r--r--src/geometry/contact.rs50
-rw-r--r--src/geometry/contact_generator/ball_convex_contact_generator.rs23
-rw-r--r--src/geometry/contact_generator/capsule_capsule_contact_generator.rs39
-rw-r--r--src/geometry/contact_generator/contact_dispatcher.rs76
-rw-r--r--src/geometry/contact_generator/contact_generator.rs22
-rw-r--r--src/geometry/contact_generator/cuboid_capsule_contact_generator.rs11
-rw-r--r--src/geometry/contact_generator/cuboid_cuboid_contact_generator.rs4
-rw-r--r--src/geometry/contact_generator/cuboid_triangle_contact_generator.rs8
-rw-r--r--src/geometry/contact_generator/heightfield_shape_contact_generator.rs50
-rw-r--r--src/geometry/contact_generator/mod.rs13
-rw-r--r--src/geometry/contact_generator/pfm_pfm_contact_generator.rs119
-rw-r--r--src/geometry/contact_generator/polygon_polygon_contact_generator.rs35
-rw-r--r--src/geometry/contact_generator/trimesh_shape_contact_generator.rs12
-rw-r--r--src/geometry/interaction_groups.rs60
-rw-r--r--src/geometry/mod.rs33
-rw-r--r--src/geometry/narrow_phase.rs220
-rw-r--r--src/geometry/polygon.rs2
-rw-r--r--src/geometry/polygonal_feature_map.rs132
-rw-r--r--src/geometry/polyhedron_feature3d.rs155
-rw-r--r--src/geometry/proximity_detector/ball_convex_proximity_detector.rs20
-rw-r--r--src/geometry/proximity_detector/cuboid_cuboid_proximity_detector.rs4
-rw-r--r--src/geometry/proximity_detector/cuboid_triangle_proximity_detector.rs8
-rw-r--r--src/geometry/proximity_detector/polygon_polygon_proximity_detector.rs29
-rw-r--r--src/geometry/proximity_detector/proximity_detector.rs8
-rw-r--r--src/geometry/proximity_detector/proximity_dispatcher.rs40
-rw-r--r--src/geometry/proximity_detector/trimesh_shape_proximity_detector.rs11
-rw-r--r--src/geometry/round_cylinder.rs107
-rw-r--r--src/geometry/sat.rs105
-rw-r--r--src/geometry/shape.rs390
-rw-r--r--src/geometry/trimesh.rs45
-rw-r--r--src/geometry/user_callbacks.rs57
-rw-r--r--src/geometry/wquadtree.rs33
-rw-r--r--src/lib.rs1
-rw-r--r--src/pipeline/collision_pipeline.rs23
-rw-r--r--src/pipeline/physics_pipeline.rs11
-rw-r--r--src/pipeline/query_pipeline.rs35
-rw-r--r--src/utils.rs6
-rw-r--r--src_testbed/box2d_backend.rs76
-rw-r--r--src_testbed/engine.rs95
-rw-r--r--src_testbed/nphysics_backend.rs51
-rw-r--r--src_testbed/objects/cone.rs74
-rw-r--r--src_testbed/objects/cylinder.rs74
-rw-r--r--src_testbed/objects/mod.rs2
-rw-r--r--src_testbed/objects/node.rs18
-rw-r--r--src_testbed/physx_backend.rs45
-rw-r--r--src_testbed/testbed.rs27
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
diff --git a/CHANGELOG b/CHANGELOG
index 70b20e5..aba1ac2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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.
diff --git a/Cargo.toml b/Cargo.toml
index 944fa40..cfb166a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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 {
+