Skip to content

Commit baa664f

Browse files
committed
fix benchmarks
1 parent 914232e commit baa664f

34 files changed

+278
-268
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use parry2d::math::{Pose, Vector, Vector};
1+
use parry2d::math::{Pose, Vector};
22
use parry2d::query::PointQuery;
33
use parry2d::shape::Cuboid;
44

@@ -9,23 +9,23 @@ fn main() {
99

1010
// Solid projection.
1111
assert_eq!(
12-
cuboid.distance_to_point(&Pose::identity(), &pt_inside, true),
12+
cuboid.distance_to_point(&Pose::identity(), pt_inside, true),
1313
0.0
1414
);
1515

1616
// Non-solid projection.
1717
assert_eq!(
18-
cuboid.distance_to_point(&Pose::identity(), &pt_inside, false),
18+
cuboid.distance_to_point(&Pose::identity(), pt_inside, false),
1919
-1.0
2020
);
2121

2222
// The other point is outside of the cuboid so the `solid` flag has no effect.
2323
assert_eq!(
24-
cuboid.distance_to_point(&Pose::identity(), &pt_outside, false),
24+
cuboid.distance_to_point(&Pose::identity(), pt_outside, false),
2525
1.0
2626
);
2727
assert_eq!(
28-
cuboid.distance_to_point(&Pose::identity(), &pt_outside, true),
28+
cuboid.distance_to_point(&Pose::identity(), pt_outside, true),
2929
1.0
3030
);
3131
}

crates/parry2d/examples/solid_ray_cast2d.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use parry2d::math::{Pose, Vector, Vector};
1+
use parry2d::math::{Pose, Vector};
22
use parry2d::query::{Ray, RayCast};
33
use parry2d::shape::Cuboid;
44

crates/parry2d/examples/time_of_impact_query2d.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,30 @@ fn main() {
2020

2121
let toi_intersecting = query::cast_shapes(
2222
&ball_pos_intersecting,
23-
&ball_vel1,
23+
ball_vel1,
2424
&ball,
2525
&cuboid_pos,
26-
&box_vel1,
26+
box_vel1,
2727
&cuboid,
2828
ShapeCastOptions::default(),
2929
)
3030
.unwrap();
3131
let toi_will_touch = query::cast_shapes(
3232
&ball_pos_will_touch,
33-
&ball_vel2,
33+
ball_vel2,
3434
&ball,
3535
&cuboid_pos,
36-
&box_vel2,
36+
box_vel2,
3737
&cuboid,
3838
ShapeCastOptions::default(),
3939
)
4040
.unwrap();
4141
let toi_wont_touch = query::cast_shapes(
4242
&ball_pos_wont_touch,
43-
&ball_vel1,
43+
ball_vel1,
4444
&ball,
4545
&cuboid_pos,
46-
&box_vel1,
46+
box_vel1,
4747
&cuboid,
4848
ShapeCastOptions::default(),
4949
)

crates/parry2d/tests/geometry/aabb_scale.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use parry2d::bounding_volume::Aabb;
2-
use parry2d::math::{Vector, Vector};
2+
use parry2d::math::Vector;
33

44
#[test]
55
fn test_aabb_scale_wrt_center() {
66
let aabb = Aabb::from_half_extents(Vector::new(1.0, 2.0), Vector::new(4.0, 5.0));
77
let scale = Vector::new(10.0, -20.0);
8-
let scaled_aabb = aabb.scaled_wrt_center(&scale);
9-
let scaled_aabb_neg = aabb.scaled_wrt_center(&-scale);
10-
let scaled_aabb_abs = aabb.scaled_wrt_center(&scale.abs());
8+
let scaled_aabb = aabb.scaled_wrt_center(scale);
9+
let scaled_aabb_neg = aabb.scaled_wrt_center(-scale);
10+
let scaled_aabb_abs = aabb.scaled_wrt_center(scale.abs());
1111

1212
assert_eq!(&scaled_aabb, &scaled_aabb_neg);
1313
assert_eq!(&scaled_aabb, &scaled_aabb_abs);

crates/parry2d/tests/geometry/ball_ball_toi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn test_ball_ball_toi() {
1313
let v1 = Vector::new(0.0, 10.0);
1414
let v2 = Vector::ZERO;
1515

16-
let cast = query::cast_shapes(&m1, &v1, &b, &m2, &v2, &b, ShapeCastOptions::default()).unwrap();
16+
let cast = query::cast_shapes(&m1, v1, &b, &m2, v2, &b, ShapeCastOptions::default()).unwrap();
1717

1818
assert_eq!(cast.unwrap().time_of_impact, 0.9);
1919
}

crates/parry2d/tests/geometry/epa_convergence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use parry2d::{
2-
math::{Pose, Real, Vector, Vector},
2+
math::{Pose, Vector},
33
query,
44
shape::{Capsule, ConvexPolygon, SharedShape},
55
};

crates/parry2d/tests/geometry/ray_cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use parry2d::math::{Pose, Real, Vector, Vector};
1+
use parry2d::math::{Pose, Real, Vector};
22
use parry2d::query::{Ray, RayCast};
33
use parry2d::shape::{ConvexPolygon, Segment, Triangle};
44

crates/parry2d/tests/geometry/time_of_impact2.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use parry2d::math::{Pose, Real, Vector, Vector};
1+
use parry2d::math::{Pose, Real, Vector};
22
use parry2d::query;
33
use parry2d::query::details::ShapeCastOptions;
44
use parry2d::shape::{Ball, Cuboid, Polyline, Segment};
@@ -17,21 +17,21 @@ fn ball_ball_intersecting_toi() {
1717

1818
let toi_separating = query::cast_shapes(
1919
&ball1_pos_intersecting,
20-
&ball1_vel_separating,
20+
ball1_vel_separating,
2121
&ball1,
2222
&ball2_pos,
23-
&ball2_vel,
23+
ball2_vel,
2424
&ball2,
2525
ShapeCastOptions::default(),
2626
)
2727
.unwrap();
2828

2929
let toi_penetrating_ignore_pen = query::cast_shapes(
3030
&ball1_pos_intersecting,
31-
&ball1_vel_penetrating,
31+
ball1_vel_penetrating,
3232
&ball1,
3333
&ball2_pos,
34-
&ball2_vel,
34+
ball2_vel,
3535
&ball2,
3636
ShapeCastOptions {
3737
stop_at_penetration: false,
@@ -42,10 +42,10 @@ fn ball_ball_intersecting_toi() {
4242

4343
let toi_separating_ignore_pen = query::cast_shapes(
4444
&ball1_pos_intersecting,
45-
&ball1_vel_separating,
45+
ball1_vel_separating,
4646
&ball1,
4747
&ball2_pos,
48-
&ball2_vel,
48+
ball2_vel,
4949
&ball2,
5050
ShapeCastOptions {
5151
stop_at_penetration: false,
@@ -85,30 +85,30 @@ fn ball_cuboid_toi() {
8585

8686
let toi_intersecting = query::cast_shapes(
8787
&ball_pos_intersecting,
88-
&ball_vel1,
88+
ball_vel1,
8989
&ball,
9090
&cuboid_pos,
91-
&cuboid_vel1,
91+
cuboid_vel1,
9292
&cuboid,
9393
ShapeCastOptions::default(),
9494
)
9595
.unwrap();
9696
let toi_will_touch = query::cast_shapes(
9797
&ball_pos_will_touch,
98-
&ball_vel2,
98+
ball_vel2,
9999
&ball,
100100
&cuboid_pos,
101-
&cuboid_vel2,
101+
cuboid_vel2,
102102
&cuboid,
103103
ShapeCastOptions::default(),
104104
)
105105
.unwrap();
106106
let toi_wont_touch = query::cast_shapes(
107107
&ball_pos_wont_touch,
108-
&ball_vel2,
108+
ball_vel2,
109109
&ball,
110110
&cuboid_pos,
111-
&cuboid_vel1,
111+
cuboid_vel1,
112112
&cuboid,
113113
ShapeCastOptions::default(),
114114
)
@@ -135,10 +135,10 @@ fn cuboid_cuboid_toi_issue_214() {
135135

136136
let hit = query::cast_shapes(
137137
&pos1,
138-
&vel1,
138+
vel1,
139139
&shape1,
140140
&pos2,
141-
&vel2,
141+
vel2,
142142
&shape2,
143143
ShapeCastOptions::default(),
144144
)
@@ -166,10 +166,10 @@ fn cast_shapes_should_return_toi_for_ball_and_rotated_polyline() {
166166

167167
let hit = query::cast_shapes(
168168
&ball_isometry,
169-
&ball_velocity,
169+
ball_velocity,
170170
&ball,
171171
&polyline_isometry,
172-
&polyline_velocity,
172+
polyline_velocity,
173173
&polyline,
174174
ShapeCastOptions::with_max_time_of_impact(1.0),
175175
)
@@ -198,10 +198,10 @@ fn cast_shapes_should_return_toi_for_ball_and_rotated_segment() {
198198

199199
let hit = query::cast_shapes(
200200
&ball_isometry,
201-
&ball_velocity,
201+
ball_velocity,
202202
&ball,
203203
&segment_isometry,
204-
&segment_velocity,
204+
segment_velocity,
205205
&segment,
206206
ShapeCastOptions::with_max_time_of_impact(1.0),
207207
)
@@ -230,10 +230,10 @@ fn cast_shapes_should_return_toi_for_rotated_segment_and_ball() {
230230

231231
let hit = query::cast_shapes(
232232
&segment_isometry,
233-
&segment_velocity,
233+
segment_velocity,
234234
&segment,
235235
&ball_isometry,
236-
&ball_velocity,
236+
ball_velocity,
237237
&ball,
238238
ShapeCastOptions::with_max_time_of_impact(1.0),
239239
)

crates/parry2d/tests/query/point_composite_shape.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ fn project_local_point_and_get_feature_gets_the_enclosing_triangle() {
1313
let mesh = TriMesh::new(vertices, vec![[0, 1, 2], [3, 0, 2]]).unwrap();
1414
let query_pt = Vector::new(0.6, 0.6); // Inside the top-right triangle (index 1)
1515

16-
let (proj, feat) = mesh.project_local_point_and_get_feature(&query_pt);
16+
let (proj, feat) = mesh.project_local_point_and_get_feature(query_pt);
1717

1818
let correct_tri_idx = 1;
1919
let correct_tri = mesh.triangle(correct_tri_idx);
2020

21-
let is_inside_correct = correct_tri.contains_local_point(&query_pt);
21+
let is_inside_correct = correct_tri.contains_local_point(query_pt);
2222

2323
assert!(is_inside_correct);
2424
assert_eq!(proj.is_inside, is_inside_correct);
@@ -39,12 +39,12 @@ fn project_local_point_and_get_feature_projects_correctly_from_outside() {
3939
{
4040
let query_pt = Vector::new(-1.0, 0.0); // Left from the bottom-left triangle (index 0)
4141

42-
let (proj, feat) = mesh.project_local_point_and_get_feature(&query_pt);
42+
let (proj, feat) = mesh.project_local_point_and_get_feature(query_pt);
4343

4444
let correct_tri_idx = 0;
4545
let correct_tri = mesh.triangle(correct_tri_idx);
4646

47-
let is_inside_correct = correct_tri.contains_local_point(&query_pt);
47+
let is_inside_correct = correct_tri.contains_local_point(query_pt);
4848

4949
assert_eq!(is_inside_correct, false);
5050
assert_eq!(proj.is_inside, is_inside_correct);
@@ -54,12 +54,12 @@ fn project_local_point_and_get_feature_projects_correctly_from_outside() {
5454
{
5555
let query_pt = Vector::new(0.5, 2.0); // Above the top-right triangle (index 1)
5656

57-
let (proj, feat) = mesh.project_local_point_and_get_feature(&query_pt);
57+
let (proj, feat) = mesh.project_local_point_and_get_feature(query_pt);
5858

5959
let correct_tri_idx = 1;
6060
let correct_tri = mesh.triangle(correct_tri_idx);
6161

62-
let is_inside_correct = correct_tri.contains_local_point(&query_pt);
62+
let is_inside_correct = correct_tri.contains_local_point(query_pt);
6363

6464
assert_eq!(is_inside_correct, false);
6565
assert_eq!(proj.is_inside, is_inside_correct);

crates/parry2d/tests/query/point_triangle.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ fn project_local_point_point_on_ab() {
1212

1313
let query_pt = Vector::new(1.4, 1.0);
1414

15-
let proj1 = tri1.project_local_point(&query_pt, false); // Used to fail on 0.14 and earlier
16-
let proj2 = tri2.project_local_point(&query_pt, false);
15+
let proj1 = tri1.project_local_point(query_pt, false); // Used to fail on 0.14 and earlier
16+
let proj2 = tri2.project_local_point(query_pt, false);
1717

1818
assert_eq!(proj1.point, proj2.point);
1919
assert_eq!(proj1.point, query_pt);

0 commit comments

Comments
 (0)