Skip to content

Commit

Permalink
fix compilation of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebcrozet committed May 5, 2024
1 parent e6fd532 commit 842366c
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 40 deletions.
16 changes: 10 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## unreleased

### Added

- Add `ShapeCastOptions` that includes two new options for (linear) shape-casting.
`ShapeCastOptions::target_distance` which will return a hit as soon as the moving
shapes are closer than this distance; and `compute_impact_geometry_on_penetration`
which forces the calculation of proper witness points and normals even if the shapes
are initially intersecting (`time_of_impact == 0.0`).

### Modified

This version modifies many names related to shape-casting:
Expand All @@ -17,16 +25,12 @@ This version modifies many names related to shape-casting:
- 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
`stop_at_penetration` arguments. This `ShapeCastOptions` includes two new options:
`ShapeCastOptions::target_distance` which will return a hit as soon as the moving
shapes are closer than this distance; and `compute_impact_geometry_on_penetration`
which forces the calculation of proper witness points and normals even if the shapes
are initially intersecting (`toi == 0.0`, `time_of_impact == 0.0`).
`stop_at_penetration` arguments.
- Rename `query::nonlinear_time_of_impact` to `query::cast_shapes_nonlinear`.
- Rename `QueryDispatcher::nonlinear_time_of_impact` to `QueryDispatcher::cast_sahpes_nonlinear`.
- Rename `NonlinearTOIMode` to `NonlinearShapeCastMode`, and `NonlinearTOIMode::DirectionalTOI` to
`NonlinearShapeCastMode::Directional`.
- rename `TimeOfImpactStatus::Penetrating` to `ShapeCastStatus::PenetratingOrWithinTargetDist`.
- Rename `TimeOfImpactStatus::Penetrating` to `ShapeCastStatus::PenetratingOrWithinTargetDist`.

## v0.14.0

Expand Down
11 changes: 4 additions & 7 deletions crates/parry2d/examples/time_of_impact_query2d.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extern crate nalgebra as na;

use na::{Isometry2, Vector2};
use parry2d::math::Real;
use parry2d::query;
use parry2d::query::ShapeCastOptions;
use parry2d::shape::{Ball, Cuboid};

fn main() {
Expand All @@ -27,8 +27,7 @@ fn main() {
&cuboid_pos,
&box_vel1,
&cuboid,
Real::MAX,
true,
ShapeCastOptions::default(),
)
.unwrap();
let toi_will_touch = query::cast_shapes(
Expand All @@ -38,8 +37,7 @@ fn main() {
&cuboid_pos,
&box_vel2,
&cuboid,
Real::MAX,
true,
ShapeCastOptions::default(),
)
.unwrap();
let toi_wont_touch = query::cast_shapes(
Expand All @@ -49,8 +47,7 @@ fn main() {
&cuboid_pos,
&box_vel1,
&cuboid,
Real::MAX,
true,
ShapeCastOptions::default(),
)
.unwrap();

Expand Down
12 changes: 4 additions & 8 deletions crates/parry3d/examples/time_of_impact_query3d.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
extern crate nalgebra as na;

use na::{Isometry3, Vector3};
use parry3d::math::Real;
use parry3d::query;
use parry3d::query::{self, ShapeCastOptions};
use parry3d::shape::{Ball, Cuboid};

fn main() {
Expand All @@ -27,8 +26,7 @@ fn main() {
&cuboid_pos,
&cuboid_vel1,
&cuboid,
Real::MAX,
true,
ShapeCastOptions::default(),
)
.unwrap();
let toi_will_touch = query::cast_shapes(
Expand All @@ -38,8 +36,7 @@ fn main() {
&cuboid_pos,
&cuboid_vel2,
&cuboid,
Real::MAX,
true,
ShapeCastOptions::default(),
)
.unwrap();
let toi_wont_touch = query::cast_shapes(
Expand All @@ -49,8 +46,7 @@ fn main() {
&cuboid_pos,
&cuboid_vel1,
&cuboid,
Real::MAX,
true,
ShapeCastOptions::default(),
)
.unwrap();

Expand Down
6 changes: 3 additions & 3 deletions crates/parry3d/tests/geometry/ball_ball_toi.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Issue #35

use na::{self, Isometry3, Vector3};
use parry3d::math::Real;
use parry3d::query;
use parry3d::query::{self, ShapeCastOptions};
use parry3d::shape::Ball;

#[test]
Expand All @@ -13,7 +12,8 @@ fn test_ball_ball_toi() {
let vel1 = Vector3::new(0.0, 10.0, 0.0);
let vel2 = Vector3::zeros();

let cast = query::cast_shapes(&m1, &vel1, &b, &m2, &vel2, &b, Real::MAX, true).unwrap();
let cast =
query::cast_shapes(&m1, &vel1, &b, &m2, &vel2, &b, ShapeCastOptions::default()).unwrap();

assert_eq!(cast.unwrap().time_of_impact, 0.9);
}
5 changes: 3 additions & 2 deletions crates/parry3d/tests/geometry/ball_triangle_toi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Issue #123

use na::{self, Isometry3, Point3, Vector3};
use parry3d::query;
use parry3d::query::{self, ShapeCastOptions};
use parry3d::shape::{Ball, Triangle};

#[test]
Expand All @@ -18,7 +18,8 @@ fn ball_triangle_toi_infinite_loop_issue() {
let vel1 = Vector3::new(0.0, 0.000000000000000000000000000000000000000006925, 0.0);
let vel2 = Vector3::zeros();

let cast = query::cast_shapes(&m1, &vel1, &b, &m2, &vel2, &t, std::f32::MAX, true).unwrap();
let cast =
query::cast_shapes(&m1, &vel1, &b, &m2, &vel2, &t, ShapeCastOptions::default()).unwrap();

println!("ShapeCastHit: {:?}", cast);
assert!(cast.is_none()); // The provided velocity is too small.
Expand Down
7 changes: 3 additions & 4 deletions crates/parry3d/tests/geometry/still_objects_toi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use na::{self, Isometry3, Vector3};
use parry3d::query::cast_shapes;
use parry3d::query::{cast_shapes, ShapeCastOptions};
use parry3d::shape::Cuboid;

/**
Expand All @@ -25,15 +25,14 @@ fn collide(v_y: f32) -> Option<f32> {
let vel2 = Vector3::zeros();
let cuboid = Cuboid::new(Vector3::new(0.5, 0.5, 0.5));

time_of_impact(
cast_shapes(
&pos1,
&vel1,
&cuboid,
&pos2,
&vel2,
&cuboid,
std::f32::MAX,
true,
ShapeCastOptions::default(),
)
.unwrap()
.map(|time_of_impact| time_of_impact.time_of_impact)
Expand Down
11 changes: 4 additions & 7 deletions crates/parry3d/tests/geometry/time_of_impact3.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use na::{self, Isometry3, Vector3};
use parry3d::math::Real;
use parry3d::query;
use parry3d::query::{self, ShapeCastOptions};
use parry3d::shape::{Ball, Cuboid};

#[test]
Expand All @@ -26,8 +26,7 @@ fn ball_cuboid_toi() {
&cuboid_pos,
&cuboid_vel1,
&cuboid,
Real::MAX,
true,
ShapeCastOptions::default(),
)
.unwrap()
.map(|time_of_impact| time_of_impact.time_of_impact);
Expand All @@ -38,8 +37,7 @@ fn ball_cuboid_toi() {
&cuboid_pos,
&cuboid_vel2,
&cuboid,
Real::MAX,
true,
ShapeCastOptions::default(),
)
.unwrap()
.map(|time_of_impact| time_of_impact.time_of_impact);
Expand All @@ -50,8 +48,7 @@ fn ball_cuboid_toi() {
&cuboid_pos,
&cuboid_vel1,
&cuboid,
Real::MAX,
true,
ShapeCastOptions::default(),
)
.unwrap()
.map(|time_of_impact| time_of_impact.time_of_impact);
Expand Down
5 changes: 2 additions & 3 deletions crates/parry3d/tests/geometry/trimesh_trimesh_toi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use na::{zero, Isometry3, Point3, Vector3};
use parry3d::math::Real;
use parry3d::query;
use parry3d::query::{self, ShapeCastOptions};
use parry3d::shape::TriMesh;

fn build_pyramid() -> TriMesh {
Expand Down Expand Up @@ -40,8 +40,7 @@ fn do_toi_test() -> Option<Real> {
&transform_two,
&vel_two,
&shape_two,
Real::MAX,
true,
ShapeCastOptions::default(),
)
.unwrap()
.map(|time_of_impact| time_of_impact.time_of_impact)
Expand Down

0 comments on commit 842366c

Please sign in to comment.