diff --git a/build/parry3d/Cargo.toml b/build/parry3d/Cargo.toml index 7dbcd8ac..13000711 100644 --- a/build/parry3d/Cargo.toml +++ b/build/parry3d/Cargo.toml @@ -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" diff --git a/build/parry3d/benches/bounding_volume/mod.rs b/build/parry3d/benches/bounding_volume/mod.rs index 085f28d2..582a980e 100644 --- a/build/parry3d/benches/bounding_volume/mod.rs +++ b/build/parry3d/benches/bounding_volume/mod.rs @@ -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; @@ -135,13 +135,13 @@ bench_method!( bench_method!( bench_convex_aabb, aabb: AABB, - c: ConvexHull, + c: ConvexPolyhedron, m: Isometry3 ); bench_method!( bench_convex_bounding_sphere, bounding_sphere: BoundingSphere, - c: ConvexHull, + c: ConvexPolyhedron, m: Isometry3 ); diff --git a/build/parry3d/benches/common/default_gen.rs b/build/parry3d/benches/common/default_gen.rs index 14a475da..baac4817 100644 --- a/build/parry3d/benches/common/default_gen.rs +++ b/build/parry3d/benches/common/default_gen.rs @@ -1,3 +1,4 @@ +#![feature(trivial_bounds)] use na::{ self, Isometry2, Isometry3, Matrix2, Matrix3, Matrix4, Point2, Point3, Point4, RealField, Vector2, Vector3, Vector4, @@ -5,10 +6,11 @@ use na::{ 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(rng: &mut R) -> Self; } @@ -74,9 +76,10 @@ where impl DefaultGen for Capsule where Standard: Distribution, + Standard: Distribution>, { fn generate(rng: &mut R) -> Capsule { - Capsule::new(rng.gen::().abs(), rng.gen::().abs()) + Capsule::new(rng.gen::>(), rng.gen::>(), rng.gen::().abs()) } } @@ -116,15 +119,15 @@ where } } -impl DefaultGen for ConvexHull +impl DefaultGen for ConvexPolyhedron where Standard: Distribution>, { - fn generate(rng: &mut R) -> ConvexHull { + fn generate(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!() } } diff --git a/build/parry3d/benches/common/generators.rs b/build/parry3d/benches/common/generators.rs index a1a5f61c..b70d1dec 100644 --- a/build/parry3d/benches/common/generators.rs +++ b/build/parry3d/benches/common/generators.rs @@ -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(rng: &mut R) -> TriMesh { - let pts = (0..3000).map(|_| rng.gen::>() * 3.0).collect(); - let uvs = (0..3000).map(|_| rng.gen::>() * 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::>() * 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(rng: &mut R) -> TriMesh { + let count = 100; + let pts = (0..3 * count).map(|_| rng.gen::>() * 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(rng: &mut R) -> TriMesh { + let count = 10000; + let pts = (0..3 * count).map(|_| rng.gen::>() * 3.0).collect(); + let indices = (0..count) + .map(|i| [i * 3, i * 3 + 1, i * 3 + 2]) + .collect(); + + TriMesh::new(pts, indices) } diff --git a/build/parry3d/benches/common/mod.rs b/build/parry3d/benches/common/mod.rs index 746805fc..b5a8ea1a 100644 --- a/build/parry3d/benches/common/mod.rs +++ b/build/parry3d/benches/common/mod.rs @@ -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; diff --git a/build/parry3d/benches/query/contacts.rs b/build/parry3d/benches/query/contacts.rs index 8b394b13..886049ce 100644 --- a/build/parry3d/benches/query/contacts.rs +++ b/build/parry3d/benches/query/contacts.rs @@ -13,8 +13,9 @@ mod macros; bench_free_fn!( bench_ball_against_ball, query::contact, - pos12: Isometry3, + pos1: Isometry3, b1: Ball, + pos2: Isometry3, b2: Ball, prediction: f32 ); @@ -22,8 +23,9 @@ bench_free_fn!( bench_free_fn!( bench_cuboid_against_cuboid, query::contact, - pos12: Isometry3, + pos1: Isometry3, b1: Cuboid, + pos2: Isometry3, b2: Cuboid, prediction: f32 ); @@ -31,8 +33,9 @@ bench_free_fn!( bench_free_fn!( bench_capsule_against_capsule, query::contact, - pos12: Isometry3, + pos1: Isometry3, b1: Capsule, + pos2: Isometry3, b2: Capsule, prediction: f32 ); @@ -40,8 +43,9 @@ bench_free_fn!( bench_free_fn!( bench_cone_against_cone, query::contact, - pos12: Isometry3, + pos1: Isometry3, b1: Cone, + pos2: Isometry3, b2: Cone, prediction: f32 ); @@ -49,8 +53,9 @@ bench_free_fn!( bench_free_fn!( bench_cylinder_against_cylinder, query::contact, - pos12: Isometry3, + pos1: Isometry3, b1: Cylinder, + pos2: Isometry3, b2: Cylinder, prediction: f32 ); diff --git a/build/parry3d/benches/query/ray.rs b/build/parry3d/benches/query/ray.rs index 0f6f43c2..75f1c4ec 100644 --- a/build/parry3d/benches/query/ray.rs +++ b/build/parry3d/benches/query/ray.rs @@ -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; @@ -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, ray: Ray, @@ -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, ray: Ray, @@ -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, ray: Ray, @@ -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, ray: Ray, @@ -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, ray: Ray, @@ -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, ray: Ray, @@ -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, ray: Ray, @@ -155,9 +155,9 @@ 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, ray: Ray, max_toi: f32, @@ -165,11 +165,31 @@ bench_method!( ); 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 = 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 = 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 = generate, + ray: Ray = generate, + max_toi: f32 = generate, + solid: bool = generate +); diff --git a/build/parry3d/benches/support_map/mod.rs b/build/parry3d/benches/support_map/mod.rs index 7a6259b8..994ceb0c 100644 --- a/build/parry3d/benches/support_map/mod.rs +++ b/build/parry3d/benches/support_map/mod.rs @@ -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; @@ -62,7 +62,7 @@ bench_method!( bench_method!( bench_convex_support_map, support_point, - c: ConvexHull, + c: ConvexPolyhedron, m: Isometry3, dir: Vector3 );