Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix benchmark cargo config and update API calls to match most recent … #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build/parry3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ rustc-hash = "1"

[dev-dependencies]
oorandom = "11"
rand = "0.8.0"
nalgebra = { version = "0.28", features = ["rand"]}
rand_isaac = "0.3.0"
6 changes: 3 additions & 3 deletions build/parry3d/benches/bounding_volume/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use na::Isometry3;
use parry3d::bounding_volume::BoundingVolume;
use parry3d::bounding_volume::{BoundingSphere, AABB};
use parry3d::shape::{
Ball, Capsule, Cone, ConvexHull, Cuboid, Cylinder, Segment, TriMesh, Triangle,
Ball, Capsule, Cone, ConvexPolyhedron, Cuboid, Cylinder, Segment, TriMesh, Triangle,
};
use rand::SeedableRng;
use rand_isaac::IsaacRng;
Expand Down Expand Up @@ -135,13 +135,13 @@ bench_method!(
bench_method!(
bench_convex_aabb,
aabb: AABB,
c: ConvexHull,
c: ConvexPolyhedron,
m: Isometry3<f32>
);
bench_method!(
bench_convex_bounding_sphere,
bounding_sphere: BoundingSphere,
c: ConvexHull,
c: ConvexPolyhedron,
m: Isometry3<f32>
);

Expand Down
13 changes: 8 additions & 5 deletions build/parry3d/benches/common/default_gen.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#![feature(trivial_bounds)]
use na::{
self, Isometry2, Isometry3, Matrix2, Matrix3, Matrix4, Point2, Point3, Point4, RealField,
Vector2, Vector3, Vector4,
};
use parry3d::bounding_volume::{BoundingSphere, AABB};
use parry3d::math::{Point, Real, Vector};
use parry3d::query::Ray;
use parry3d::shape::{Ball, Capsule, Cone, ConvexHull, Cuboid, Cylinder, Segment, Triangle};
use parry3d::shape::{Ball, Capsule, Cone, ConvexPolyhedron, Cuboid, Cylinder, Segment, Triangle};
use rand::distributions::{Distribution, Standard};
use rand::Rng;


pub trait DefaultGen {
fn generate<R: Rng>(rng: &mut R) -> Self;
}
Expand Down Expand Up @@ -74,9 +76,10 @@ where
impl DefaultGen for Capsule
where
Standard: Distribution<Real>,
Standard: Distribution<Point<Real>>,
{
fn generate<R: Rng>(rng: &mut R) -> Capsule {
Capsule::new(rng.gen::<Real>().abs(), rng.gen::<Real>().abs())
Capsule::new(rng.gen::<Point<Real>>(), rng.gen::<Point<Real>>(), rng.gen::<Real>().abs())
}
}

Expand Down Expand Up @@ -116,15 +119,15 @@ where
}
}

impl DefaultGen for ConvexHull
impl DefaultGen for ConvexPolyhedron
where
Standard: Distribution<Point<Real>>,
{
fn generate<R: Rng>(rng: &mut R) -> ConvexHull {
fn generate<R: Rng>(rng: &mut R) -> ConvexPolyhedron {
// It is recommended to have at most 100 points.
// Otherwise, a smarter structure like the DK hierarchy would be needed.
// let pts: Vec<_> = (0..100).map(|_| rng.gen()).collect();
// ConvexHull::try_from_points(&pts).unwrap()
// ConvexPolyhedron::try_from_points(&pts).unwrap()
unimplemented!()
}
}
Expand Down
30 changes: 25 additions & 5 deletions build/parry3d/benches/common/generators.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
use na::{Point2, Point3};
use parry3d::shape::TriMesh;
use rand::Rng;
use rand_isaac::IsaacRng;

pub fn generate_trimesh_around_origin<R: Rng>(rng: &mut R) -> TriMesh {
let pts = (0..3000).map(|_| rng.gen::<Point3<f32>>() * 3.0).collect();
let uvs = (0..3000).map(|_| rng.gen::<Point2<f32>>() * 3.0).collect();
let indices = (0..1000)
.map(|i| Point3::new(i * 3, i * 3 + 1, i * 3 + 2))
let count = 1000;
let pts = (0..3 * count).map(|_| rng.gen::<Point3<f32>>() * 3.0).collect();
let indices = (0..count)
.map(|i| [i * 3, i * 3 + 1, i * 3 + 2])
.collect();

TriMesh::new(pts, indices, Some(uvs))
TriMesh::new(pts, indices)
}
pub fn generate_trimesh_around_origin_100<R: Rng>(rng: &mut R) -> TriMesh {
let count = 100;
let pts = (0..3 * count).map(|_| rng.gen::<Point3<f32>>() * 3.0).collect();
let indices = (0..count)
.map(|i| [i * 3, i * 3 + 1, i * 3 + 2])
.collect();

TriMesh::new(pts, indices)
}

pub fn generate_trimesh_around_origin_10000<R: Rng>(rng: &mut R) -> TriMesh {
let count = 10000;
let pts = (0..3 * count).map(|_| rng.gen::<Point3<f32>>() * 3.0).collect();
let indices = (0..count)
.map(|i| [i * 3, i * 3 + 1, i * 3 + 2])
.collect();

TriMesh::new(pts, indices)
}
2 changes: 2 additions & 0 deletions build/parry3d/benches/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pub use self::default_gen::generate;
pub use self::generators::generate_trimesh_around_origin;
pub use self::generators::generate_trimesh_around_origin_10000;
pub use self::generators::generate_trimesh_around_origin_100;
pub use self::unref::unref;

mod default_gen;
Expand Down
15 changes: 10 additions & 5 deletions build/parry3d/benches/query/contacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,49 @@ mod macros;
bench_free_fn!(
bench_ball_against_ball,
query::contact,
pos12: Isometry3<f32>,
pos1: Isometry3<f32>,
b1: Ball,
pos2: Isometry3<f32>,
b2: Ball,
prediction: f32
);

bench_free_fn!(
bench_cuboid_against_cuboid,
query::contact,
pos12: Isometry3<f32>,
pos1: Isometry3<f32>,
b1: Cuboid,
pos2: Isometry3<f32>,
b2: Cuboid,
prediction: f32
);

bench_free_fn!(
bench_capsule_against_capsule,
query::contact,
pos12: Isometry3<f32>,
pos1: Isometry3<f32>,
b1: Capsule,
pos2: Isometry3<f32>,
b2: Capsule,
prediction: f32
);

bench_free_fn!(
bench_cone_against_cone,
query::contact,
pos12: Isometry3<f32>,
pos1: Isometry3<f32>,
b1: Cone,
pos2: Isometry3<f32>,
b2: Cone,
prediction: f32
);

bench_free_fn!(
bench_cylinder_against_cylinder,
query::contact,
pos12: Isometry3<f32>,
pos1: Isometry3<f32>,
b1: Cylinder,
pos2: Isometry3<f32>,
b2: Cylinder,
prediction: f32
);
62 changes: 41 additions & 21 deletions build/parry3d/benches/query/ray.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::common::{generate, generate_trimesh_around_origin, unref};
use crate::common::{generate, generate_trimesh_around_origin,generate_trimesh_around_origin_100, generate_trimesh_around_origin_10000, unref};
use na::Isometry3;
use parry3d::bounding_volume::{BoundingSphere, AABB};
use parry3d::query::{Ray, RayCast};
use parry3d::shape::{
Ball, Capsule, Cone, ConvexHull, Cuboid, Cylinder, Segment, TriMesh, Triangle,
Ball, Capsule, Cone, ConvexPolyhedron, Cuboid, Cylinder, Segment, TriMesh, Triangle,
};
use rand::SeedableRng;
use rand_isaac::IsaacRng;
Expand Down Expand Up @@ -85,8 +85,8 @@ bench_method!(
);

bench_method!(
bench_ray_against_ball_with_normal_uv,
cast_ray_and_get_normal_and_uv,
bench_ray_against_ball_with_normal,
cast_ray_and_get_normal,
b: Ball,
pos: Isometry3<f32>,
ray: Ray,
Expand All @@ -95,8 +95,8 @@ bench_method!(
);

bench_method!(
bench_ray_against_cuboid_with_normal_uv,
cast_ray_and_get_normal_and_uv,
bench_ray_against_cuboid_with_normal,
cast_ray_and_get_normal,
c: Cuboid,
pos: Isometry3<f32>,
ray: Ray,
Expand All @@ -105,8 +105,8 @@ bench_method!(
);

bench_method!(
bench_ray_against_capsule_with_normal_uv,
cast_ray_and_get_normal_and_uv,
bench_ray_against_capsule_with_normal,
cast_ray_and_get_normal,
c: Capsule,
pos: Isometry3<f32>,
ray: Ray,
Expand All @@ -115,8 +115,8 @@ bench_method!(
);

bench_method!(
bench_ray_against_cone_with_normal_uv,
cast_ray_and_get_normal_and_uv,
bench_ray_against_cone_with_normal,
cast_ray_and_get_normal,
c: Cone,
pos: Isometry3<f32>,
ray: Ray,
Expand All @@ -125,8 +125,8 @@ bench_method!(
);

bench_method!(
bench_ray_against_cylinder_with_normal_uv,
cast_ray_and_get_normal_and_uv,
bench_ray_against_cylinder_with_normal,
cast_ray_and_get_normal,
c: Cylinder,
pos: Isometry3<f32>,
ray: Ray,
Expand All @@ -135,8 +135,8 @@ bench_method!(
);

bench_method!(
bench_ray_against_segment_with_normal_uv,
cast_ray_and_get_normal_and_uv,
bench_ray_against_segment_with_normal,
cast_ray_and_get_normal,
c: Segment,
pos: Isometry3<f32>,
ray: Ray,
Expand All @@ -145,8 +145,8 @@ bench_method!(
);

bench_method!(
bench_ray_against_triangle_with_normal_uv,
cast_ray_and_get_normal_and_uv,
bench_ray_against_triangle_with_normal,
cast_ray_and_get_normal,
c: Triangle,
pos: Isometry3<f32>,
ray: Ray,
Expand All @@ -155,21 +155,41 @@ bench_method!(
);

bench_method!(
bench_ray_against_convex_with_normal_uv,
cast_ray_and_get_normal_and_uv,
c: ConvexHull,
bench_ray_against_convex_with_normal,
cast_ray_and_get_normal,
c: ConvexPolyhedron,
pos: Isometry3<f32>,
ray: Ray,
max_toi: f32,
solid: bool
);

bench_method_gen!(
bench_ray_against_trimesh_with_normal_uv,
cast_ray_and_get_normal_and_uv,
bench_ray_against_trimesh_with_normal,
cast_ray_and_get_normal,
m: TriMesh = generate_trimesh_around_origin,
pos: Isometry3<f32> = generate,
ray: Ray = generate,
max_toi: f32 = generate,
solid: bool = generate
);

bench_method_gen!(
bench_ray_against_trimesh_with_normal_100,
cast_ray_and_get_normal,
m: TriMesh = generate_trimesh_around_origin_100,
pos: Isometry3<f32> = generate,
ray: Ray = generate,
max_toi: f32 = generate,
solid: bool = generate
);

bench_method_gen!(
bench_ray_against_trimesh_with_normal_10000,
cast_ray_and_get_normal,
m: TriMesh = generate_trimesh_around_origin_10000,
pos: Isometry3<f32> = generate,
ray: Ray = generate,
max_toi: f32 = generate,
solid: bool = generate
);
4 changes: 2 additions & 2 deletions build/parry3d/benches/support_map/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::common::{generate, unref};
use na::{Isometry3, Vector3};
use parry3d::shape::SupportMap;
use parry3d::shape::{Ball, Capsule, Cone, ConvexHull, Cuboid, Cylinder, Segment, Triangle};
use parry3d::shape::{Ball, Capsule, Cone, ConvexPolyhedron, Cuboid, Cylinder, Segment, Triangle};
use rand::SeedableRng;
use rand_isaac::IsaacRng;
use test::Bencher;
Expand Down Expand Up @@ -62,7 +62,7 @@ bench_method!(
bench_method!(
bench_convex_support_map,
support_point,
c: ConvexHull,
c: ConvexPolyhedron,
m: Isometry3<f32>,
dir: Vector3<f32>
);