Skip to content
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@

### Added

- derive `Copy` for `VHACDParameters`.
- Derive `Copy` for `VHACDParameters`.
- Add `spade` default feature for algorithms using Delaunay triangulation from `spade`.

### Modified

- Improve `no_std` compatibility.
- Everything is now compatible, except `mesh_intersections`, `split_trimesh`,
convex hull validation, and computation of connected components for `TriMesh`.
- Add the `alloc_instead_of_core`, `std_instead_of_alloc`, and `std_instead_of_core` Clippy lints to the workspace.
- Use `core` and `alloc` directly rather than using an `std` alias.
- Use `hashbrown` instead of `rustc-hash` when `enhanced-determinism` is not enabled.
- Make `spade` optional.

## v0.18.0

Expand Down Expand Up @@ -158,7 +169,7 @@ This version modifies many names related to shape-casting:
now prefixed with `cast_shapes_` (e.g. `cast_shapes_ball_ball`).
- Rename `QueryDispatcher::time_of_impact` to `QueryDispatcher::cast_shapes`.
- The (linear) shape-casting functions like `query::cast_shapes` (previously named
`query::time_of_impact) now take a `ShapeCastOptions` instead of the `max_toi` and
`query::time_of_impact`) now take a `ShapeCastOptions` instead of the `max_toi` and
`stop_at_penetration` arguments.
- Rename `query::nonlinear_time_of_impact` to `query::cast_shapes_nonlinear`.
- Rename `QueryDispatcher::nonlinear_time_of_impact` to `QueryDispatcher::cast_shapes_nonlinear`.
Expand Down
14 changes: 12 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[workspace]
members = ["crates/parry2d", "crates/parry3d", "crates/parry2d-f64", "crates/parry3d-f64"]
members = [
"crates/parry2d",
"crates/parry3d",
"crates/parry2d-f64",
"crates/parry3d-f64",
]
resolver = "2"

[workspace.lints]
Expand All @@ -9,6 +14,11 @@ rust.unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(feature, values("wavefront"))',
] }

[workspace.lints.clippy]
alloc_instead_of_core = "warn"
std_instead_of_alloc = "warn"
std_instead_of_core = "warn"

[patch.crates-io]
parry2d = { path = "crates/parry2d" }
parry3d = { path = "crates/parry3d" }
Expand All @@ -17,4 +27,4 @@ parry3d-f64 = { path = "crates/parry3d-f64" }

#simba = { path = "../simba" }
#simba = { git = "https://github.com/dimforge/simba", rev = "45a5266eb36ed9d25907e9bf9130cd4ac846a748" }
#nalgebra = { git = "https://github.com/dimforge/nalgebra", rev = "0cf79aef0e6155befc3279a3145f1940822b8377" }
#nalgebra = { git = "https://github.com/dimforge/nalgebra", rev = "0cf79aef0e6155befc3279a3145f1940822b8377" }
19 changes: 12 additions & 7 deletions crates/parry2d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ maintenance = { status = "actively-developed" }
workspace = true

[features]
default = ["required-features", "std"]
default = ["required-features", "std", "spade"]
required-features = ["dim2", "f64"]
std = [
"nalgebra/std",
"slab",
"rustc-hash",
"simba/std",
"arrayvec/std",
"spade",
"thiserror/std",
"ena"
"ena",
"spade?/std",
]
dim2 = []
f64 = []
Expand All @@ -39,6 +39,8 @@ serde-serialize = [
"nalgebra/serde-serialize",
"arrayvec/serde",
"bitflags/serde",
"hashbrown?/serde",
"spade?/serde",
]
rkyv-serialize = [
"rkyv/validation",
Expand All @@ -50,7 +52,8 @@ simd-stable = ["simba/wide", "simd-is-enabled"]
simd-nightly = ["simba/portable_simd", "simd-is-enabled"]
enhanced-determinism = ["simba/libm_force", "indexmap"]
parallel = ["rayon"]
alloc = []
alloc = ["nalgebra/alloc", "hashbrown"]
spade = ["dep:spade", "alloc"]
improved_fixed_point_support = []

# Do not enable this feature directly. It is automatically
Expand All @@ -76,15 +79,17 @@ serde = { version = "1.0", optional = true, features = ["derive"] }
rkyv = { version = "0.7.41", optional = true }
num-derive = "0.4"
indexmap = { version = "2", features = ["serde"], optional = true }
rustc-hash = { version = "2", optional = true }
hashbrown = { version = "0.15", optional = true, default-features = false, features = [
"default-hasher",
] }
cust_core = { version = "0.1", optional = true }
spade = { version = "2", optional = true } # Make this optional?
spade = { version = "2", optional = true, default-features = false }
rayon = { version = "1", optional = true }
bytemuck = { version = "1", features = ["derive"], optional = true }
log = "0.4"
ordered-float = { version = "5", default-features = false }
thiserror = { version = "2", default-features = false }
ena = { version = "0.14.3", optional = true }
ena = { version = "0.14.3", optional = true, default-features = false }

[dev-dependencies]
simba = { version = "0.9", default-features = false }
Expand Down
21 changes: 13 additions & 8 deletions crates/parry2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ maintenance = { status = "actively-developed" }
workspace = true

[features]
default = ["required-features", "std"]
default = ["required-features", "std", "spade"]
required-features = ["dim2", "f32"]
std = [
"alloc",
"nalgebra/std",
"slab",
"rustc-hash",
"simba/std",
"arrayvec/std",
"spade",
"spade?/std",
"thiserror/std",
"ena"
"ena",
]
dim2 = []
f32 = []
Expand All @@ -39,6 +39,8 @@ serde-serialize = [
"nalgebra/serde-serialize",
"arrayvec/serde",
"bitflags/serde",
"hashbrown?/serde",
"spade?/serde",
]
rkyv-serialize = [
"rkyv/validation",
Expand All @@ -50,7 +52,8 @@ simd-stable = ["simba/wide", "simd-is-enabled"]
simd-nightly = ["simba/portable_simd", "simd-is-enabled"]
enhanced-determinism = ["simba/libm_force", "indexmap"]
parallel = ["rayon"]
alloc = []
alloc = ["nalgebra/alloc", "hashbrown"]
spade = ["dep:spade", "alloc"]
improved_fixed_point_support = []

# Do not enable this feature directly. It is automatically
Expand All @@ -76,15 +79,17 @@ serde = { version = "1.0", optional = true, features = ["derive"] }
rkyv = { version = "0.7.41", optional = true }
num-derive = "0.4"
indexmap = { version = "2", features = ["serde"], optional = true }
rustc-hash = { version = "2", optional = true }
hashbrown = { version = "0.15", optional = true, default-features = false, features = [
"default-hasher",
] }
cust_core = { version = "0.1", optional = true }
spade = { version = "2", optional = true }
spade = { version = "2", optional = true, default-features = false }
rayon = { version = "1", optional = true }
bytemuck = { version = "1", features = ["derive"], optional = true }
ordered-float = { version = "5", default-features = false }
log = "0.4"
thiserror = { version = "2", default-features = false }
ena = { version = "0.14.3", optional = true }
ena = { version = "0.14.3", optional = true, default-features = false }

[dev-dependencies]
simba = { version = "0.9", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/parry2d/examples/common_macroquad2d.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::f32::consts::{FRAC_PI_2, FRAC_PI_4};
use core::f32::consts::{FRAC_PI_2, FRAC_PI_4};

use macroquad::prelude::*;
use macroquad::{
Expand Down
2 changes: 1 addition & 1 deletion crates/parry2d/examples/convex_hull2d.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod common_macroquad2d;

use std::f32::consts::{FRAC_PI_2, FRAC_PI_4};
use core::f32::consts::{FRAC_PI_2, FRAC_PI_4};

use common_macroquad2d::{draw_point, draw_polygon, lissajous_2d_with_params, na_from_mquad};
use macroquad::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/parry2d/examples/raycasts_animated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async fn main() {
Point2::new(2.0, 2.0),
UnitComplex::new(animation_rotation * i as f32) * -Vector2::x(),
);
let toi = cube.cast_ray(&cube_pose, &ray, std::f32::MAX, true);
let toi = cube.cast_ray(&cube_pose, &ray, f32::MAX, true);

/*
*
Expand Down
8 changes: 4 additions & 4 deletions crates/parry2d/examples/solid_ray_cast2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ fn main() {
// Solid cast.
assert_eq!(
cuboid
.cast_ray(&Isometry2::identity(), &ray_inside, std::f32::MAX, true)
.cast_ray(&Isometry2::identity(), &ray_inside, f32::MAX, true)
.unwrap(),
0.0
);

// Non-solid cast.
assert_eq!(
cuboid
.cast_ray(&Isometry2::identity(), &ray_inside, std::f32::MAX, false)
.cast_ray(&Isometry2::identity(), &ray_inside, f32::MAX, false)
.unwrap(),
2.0
);

// The other ray does not intersect this shape.
assert!(cuboid
.cast_ray(&Isometry2::identity(), &ray_miss, std::f32::MAX, false)
.cast_ray(&Isometry2::identity(), &ray_miss, f32::MAX, false)
.is_none());
assert!(cuboid
.cast_ray(&Isometry2::identity(), &ray_miss, std::f32::MAX, true)
.cast_ray(&Isometry2::identity(), &ray_miss, f32::MAX, true)
.is_none());
}
26 changes: 13 additions & 13 deletions crates/parry2d/tests/geometry/ray_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn issue_178_parallel_raycast() {
let ray = Ray::new(Point2::new(0.0, 0.0), Vector2::new(0.0, 1.0));
let seg = Segment::new(Point2::new(2.0, 1.0), Point2::new(2.0, 0.0));

let cast = seg.cast_ray(&m1, &ray, std::f32::MAX, true);
let cast = seg.cast_ray(&m1, &ray, f32::MAX, true);
assert!(cast.is_none());
}

Expand All @@ -19,7 +19,7 @@ fn parallel_raycast() {
let ray = Ray::new(Point2::new(0.0, 0.0), Vector2::new(0.0, 1.0));
let seg = Segment::new(Point2::new(2.0, 1.0), Point2::new(2.0, -1.0));

let cast = seg.cast_ray(&m1, &ray, std::f32::MAX, true);
let cast = seg.cast_ray(&m1, &ray, f32::MAX, true);
assert!(cast.is_none());
}

Expand All @@ -29,7 +29,7 @@ fn collinear_raycast_starting_on_segment() {
let ray = Ray::new(Point2::new(0.0, 0.0), Vector2::new(0.0, 1.0));
let seg = Segment::new(Point2::new(0.0, 1.0), Point2::new(0.0, -1.0));

let cast = seg.cast_ray(&m1, &ray, std::f32::MAX, true);
let cast = seg.cast_ray(&m1, &ray, f32::MAX, true);
assert_eq!(cast, Some(0.0));
}

Expand All @@ -39,7 +39,7 @@ fn collinear_raycast_starting_below_segment() {
let ray = Ray::new(Point2::new(0.0, -2.0), Vector2::new(0.0, 1.0));
let seg = Segment::new(Point2::new(0.0, 1.0), Point2::new(0.0, -1.0));

let cast = seg.cast_ray(&m1, &ray, std::f32::MAX, true);
let cast = seg.cast_ray(&m1, &ray, f32::MAX, true);
assert_eq!(cast, Some(1.0));
}

Expand All @@ -49,45 +49,45 @@ fn collinear_raycast_starting_above_segment() {
let ray = Ray::new(Point2::new(0.0, 2.0), Vector2::new(0.0, 1.0));
let seg = Segment::new(Point2::new(0.0, 1.0), Point2::new(0.0, -1.0));

let cast = seg.cast_ray(&m1, &ray, std::f32::MAX, true);
let cast = seg.cast_ray(&m1, &ray, f32::MAX, true);
assert_eq!(cast, None);
}

#[test]
fn perpendicular_raycast_starting_behind_segment() {
let segment = Segment::new(Point2::new(0.0f32, -10.0), Point2::new(0.0, 10.0));
let ray = Ray::new(Point2::new(-1.0, 0.0), Vector2::new(1.0, 0.0));
assert!(segment.intersects_local_ray(&ray, std::f32::MAX));
assert!(segment.intersects_local_ray(&ray, f32::MAX));
}

#[test]
fn perpendicular_raycast_starting_in_front_of_segment() {
let segment = Segment::new(Point2::new(0.0f32, -10.0), Point2::new(0.0, 10.0));
let ray = Ray::new(Point2::new(1.0, 0.0), Vector2::new(1.0, 0.0));
assert!(!segment.intersects_local_ray(&ray, std::f32::MAX));
assert!(!segment.intersects_local_ray(&ray, f32::MAX));
}

#[test]
fn perpendicular_raycast_starting_on_segment() {
let segment = Segment::new(Point2::new(0.0f32, -10.0), Point2::new(0.0, 10.0));
let ray = Ray::new(Point2::new(0.0, 3.0), Vector2::new(1.0, 0.0));

let cast = segment.cast_local_ray(&ray, std::f32::MAX, true);
let cast = segment.cast_local_ray(&ray, f32::MAX, true);
assert_eq!(cast, Some(0.0));
}

#[test]
fn perpendicular_raycast_starting_above_segment() {
let segment = Segment::new(Point2::new(0.0f32, -10.0), Point2::new(0.0, 10.0));
let ray = Ray::new(Point2::new(0.0, 11.0), Vector2::new(1.0, 0.0));
assert!(!segment.intersects_local_ray(&ray, std::f32::MAX));
assert!(!segment.intersects_local_ray(&ray, f32::MAX));
}

#[test]
fn perpendicular_raycast_starting_below_segment() {
let segment = Segment::new(Point2::new(0.0f32, -10.0), Point2::new(0.0, 10.0));
let ray = Ray::new(Point2::new(0.0, -11.0), Vector2::new(1.0, 0.0));
assert!(!segment.intersects_local_ray(&ray, std::f32::MAX));
assert!(!segment.intersects_local_ray(&ray, f32::MAX));
}

#[test]
Expand All @@ -99,7 +99,7 @@ fn raycast_starting_outside_of_triangle() {
);
let ray = Ray::new(Point2::new(-10.0, 0.0), Vector2::new(1.0, 0.0));
let intersect = triangle
.cast_local_ray_and_get_normal(&ray, std::f32::MAX, true)
.cast_local_ray_and_get_normal(&ray, f32::MAX, true)
.expect("No intersection");

assert_ne!(intersect.time_of_impact, 0.0);
Expand All @@ -114,7 +114,7 @@ fn raycast_starting_inside_of_triangle() {
);
let ray = Ray::new(Point2::new(2.0, 0.0), Vector2::new(1.0, 0.0));
let intersect = triangle
.cast_local_ray_and_get_normal(&ray, std::f32::MAX, true)
.cast_local_ray_and_get_normal(&ray, f32::MAX, true)
.expect("No intersection");

assert_eq!(intersect.time_of_impact, 0.0);
Expand All @@ -129,7 +129,7 @@ fn raycast_starting_on_edge_of_triangle() {
);
let ray = Ray::new(Point2::new(0.0, 0.0), Vector2::new(1.0, 0.0));
let intersect = triangle
.cast_local_ray_and_get_normal(&ray, std::f32::MAX, true)
.cast_local_ray_and_get_normal(&ray, f32::MAX, true)
.expect("No intersection");

assert_eq!(intersect.time_of_impact, 0.0);
Expand Down
6 changes: 3 additions & 3 deletions crates/parry2d/tests/geometry/time_of_impact2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn cast_shapes_should_return_toi_for_ball_and_rotated_polyline() {
let ball_isometry = Isometry2::identity();
let ball_velocity = Vector2::new(1.0, 0.0);
let ball = Ball::new(0.5);
let polyline_isometry = Isometry2::rotation(-std::f32::consts::FRAC_PI_2);
let polyline_isometry = Isometry2::rotation(-core::f32::consts::FRAC_PI_2);
let polyline_velocity = Vector2::zeros();
let polyline = Polyline::new(vec![Point2::new(1.0, 1.0), Point2::new(-1.0, 1.0)], None);

Expand Down Expand Up @@ -184,7 +184,7 @@ fn cast_shapes_should_return_toi_for_ball_and_rotated_segment() {
let ball_isometry = Isometry2::identity();
let ball_velocity = Vector2::new(1.0, 0.0);
let ball = Ball::new(0.5);
let segment_isometry = Isometry2::rotation(-std::f32::consts::FRAC_PI_2);
let segment_isometry = Isometry2::rotation(-core::f32::consts::FRAC_PI_2);
let segment_velocity = Vector2::zeros();
let segment = Segment::new(Point2::new(1.0, 1.0), Point2::new(-1.0, 1.0));

Expand Down Expand Up @@ -216,7 +216,7 @@ fn cast_shapes_should_return_toi_for_rotated_segment_and_ball() {
let ball_isometry = Isometry2::identity();
let ball_velocity = Vector2::new(1.0, 0.0);
let ball = Ball::new(0.5);
let segment_isometry = Isometry2::rotation(-std::f32::consts::FRAC_PI_2);
let segment_isometry = Isometry2::rotation(-core::f32::consts::FRAC_PI_2);
let segment_velocity = Vector2::zeros();
let segment = Segment::new(Point2::new(1.0, 1.0), Point2::new(-1.0, 1.0));

Expand Down
Loading