From 657c6ee5d0ad4afd35b3948c8104070b9ed9b661 Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Mon, 15 Jul 2024 11:32:35 +0200 Subject: [PATCH 1/4] replace type alias with a 'use'. --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0c7da13e..38351293 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,11 +77,11 @@ pub mod utils; mod real { /// The scalar type used throughout this crate. #[cfg(feature = "f64")] - pub type Real = f64; + pub use f64 as Real; /// The scalar type used throughout this crate. #[cfg(feature = "f32")] - pub type Real = f32; + pub use f32 as Real; } /// Compilation flags dependent aliases for mathematical types. From 5b17c9830d65453e3a9b3c8a0efa719b303130c7 Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Wed, 17 Jul 2024 17:35:01 +0200 Subject: [PATCH 2/4] more 'use' instead of 'type' --- src/lib.rs | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 38351293..2ba7cf70 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,10 +89,8 @@ mod real { pub mod math { pub use super::real::*; pub use super::simd::*; - use na::{ - Isometry3, Matrix3, Point3, Translation3, UnitQuaternion, UnitVector3, Vector3, Vector6, - U3, U6, - }; + pub use na::{Isometry3, Matrix3, Point3, Translation3, UnitVector3, Vector3}; + use na::{UnitQuaternion, Vector6, U3, U6}; /// The default tolerance used for geometric operations. pub const DEFAULT_EPSILON: Real = Real::EPSILON; @@ -113,19 +111,19 @@ pub mod math { pub type AngDim = U3; /// The point type. - pub type Point = Point3; + pub use Point3 as Point; /// The angular vector type. pub type AngVector = Vector3; /// The vector type. - pub type Vector = Vector3; + pub use Vector3 as Vector; /// The unit vector type. - pub type UnitVector = UnitVector3; + pub use UnitVector3 as UnitVector; /// The matrix type. - pub type Matrix = Matrix3; + pub use Matrix3 as Matrix; /// The vector type with dimension `SpatialDim × 1`. pub type SpatialVector = Vector6; @@ -134,13 +132,13 @@ pub mod math { pub type Orientation = Vector3; /// The transformation matrix type. - pub type Isometry = Isometry3; + pub use Isometry3 as Isometry; /// The rotation matrix type. pub type Rotation = UnitQuaternion; /// The translation type. - pub type Translation = Translation3; + pub use Translation3 as Translation; /// The angular inertia of a rigid body. pub type AngularInertia = crate::utils::SdpMatrix3; @@ -155,7 +153,7 @@ pub mod math { pub type SpacialVector = Vector6; /// A 3D symmetric-definite-positive matrix. - pub type SdpMatrix = crate::utils::SdpMatrix3; + pub use crate::utils::SdpMatrix3 as SdpMatrix; } /// Compilation flags dependent aliases for mathematical types. @@ -163,10 +161,8 @@ pub mod math { pub mod math { pub use super::real::*; pub use super::simd::*; - use na::{ - Isometry2, Matrix2, Point2, Translation2, UnitComplex, UnitVector2, Vector1, Vector2, - Vector3, U1, U2, - }; + pub use na::{Isometry2, Matrix2, Point2, Translation2, UnitVector2, Vector2}; + use na::{UnitComplex, Vector1, Vector3, U1, U2}; /// The default tolerance used for geometric operations. pub const DEFAULT_EPSILON: Real = Real::EPSILON; @@ -184,31 +180,31 @@ pub mod math { pub type AngDim = U1; /// The point type. - pub type Point = Point2; + pub use Point2 as Point; /// The angular vector type. pub type AngVector = N; /// The vector type. - pub type Vector = Vector2; + pub use Vector2 as Vector; /// The unit vector type. - pub type UnitVector = UnitVector2; + pub use UnitVector2 as UnitVector; /// The matrix type. - pub type Matrix = Matrix2; + pub use Matrix2 as Matrix; /// The orientation type. pub type Orientation = Vector1; /// The transformation matrix type. - pub type Isometry = Isometry2; + pub use Isometry2 as Isometry; /// The rotation matrix type. pub type Rotation = UnitComplex; /// The translation type. - pub type Translation = Translation2; + pub use Translation2 as Translation; /// The angular inertia of a rigid body. pub type AngularInertia = N; @@ -223,7 +219,7 @@ pub mod math { pub type SpacialVector = Vector3; /// A 2D symmetric-definite-positive matrix. - pub type SdpMatrix = crate::utils::SdpMatrix2; + pub use crate::utils::SdpMatrix2 as SdpMatrix; } #[cfg(not(feature = "simd-is-enabled"))] From 31123c07bfabb2264ceb271c315fcd037a78ac45 Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Tue, 23 Jul 2024 14:51:10 +0200 Subject: [PATCH 3/4] explicit examples --- crates/parry2d-f64/Cargo.toml | 113 ++++++++++++++++++++++++++++++- crates/parry2d/Cargo.toml | 115 ++++++++++++++++++++++++++++++-- crates/parry3d-f64/Cargo.toml | 121 ++++++++++++++++++++++++++++++++- crates/parry3d/Cargo.toml | 122 +++++++++++++++++++++++++++++++++- publish.sh | 8 +++ write_examples.sh | 23 +++++++ 6 files changed, 491 insertions(+), 11 deletions(-) create mode 100644 write_examples.sh diff --git a/crates/parry2d-f64/Cargo.toml b/crates/parry2d-f64/Cargo.toml index 8821dbb5..9c019c7e 100644 --- a/crates/parry2d-f64/Cargo.toml +++ b/crates/parry2d-f64/Cargo.toml @@ -19,11 +19,28 @@ maintenance = { status = "actively-developed" } [features] default = ["required-features", "std"] required-features = ["dim2", "f64"] -std = ["nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec/std", "spade", "thiserror"] +std = [ + "nalgebra/std", + "slab", + "rustc-hash", + "simba/std", + "arrayvec/std", + "spade", + "thiserror", +] dim2 = [] f64 = [] -serde-serialize = ["serde", "nalgebra/serde-serialize", "arrayvec/serde", "bitflags/serde"] -rkyv-serialize = ["rkyv/validation", "nalgebra/rkyv-serialize", "simba/rkyv-serialize"] +serde-serialize = [ + "serde", + "nalgebra/serde-serialize", + "arrayvec/serde", + "bitflags/serde", +] +rkyv-serialize = [ + "rkyv/validation", + "nalgebra/rkyv-serialize", + "simba/rkyv-serialize", +] bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"] simd-stable = ["simba/wide", "simd-is-enabled"] simd-nightly = ["simba/portable_simd", "simd-is-enabled"] @@ -68,3 +85,93 @@ simba = { version = "0.9", default-features = false } oorandom = "11" ptree = "0.4.0" rand = { version = "0.8" } + +[package.metadata.docs.rs] +rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"] +all-features = true +cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] + +[[example]] +name = "aabb2d.rs" +path = "examples/aabb2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "ball2d.rs" +path = "examples/ball2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "bounding_sphere2d.rs" +path = "examples/bounding_sphere2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "contact_query2d.rs" +path = "examples/contact_query2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "convex2d.rs" +path = "examples/convex2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "convex_hull2d.rs" +path = "examples/convex_hull2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "convex_try_new2d.rs" +path = "examples/convex_try_new2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "cuboid2d.rs" +path = "examples/cuboid2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "distance_query2d.rs" +path = "examples/distance_query2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "plane2d.rs" +path = "examples/plane2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "point_in_poly2d.rs" +path = "examples/point_in_poly2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "polygons_intersection2d.rs" +path = "examples/polygons_intersection2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "polyline2d.rs" +path = "examples/polyline2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "proximity_query2d.rs" +path = "examples/proximity_query2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "solid_point_query2d.rs" +path = "examples/solid_point_query2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "solid_ray_cast2d.rs" +path = "examples/solid_ray_cast2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "time_of_impact_query2d.rs" +path = "examples/time_of_impact_query2d.rs.rs" +doc-scrape-examples = true diff --git a/crates/parry2d/Cargo.toml b/crates/parry2d/Cargo.toml index 61beba47..c72c9402 100644 --- a/crates/parry2d/Cargo.toml +++ b/crates/parry2d/Cargo.toml @@ -19,11 +19,28 @@ maintenance = { status = "actively-developed" } [features] default = ["required-features", "std"] required-features = ["dim2", "f32"] -std = ["nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec/std", "spade", "thiserror"] +std = [ + "nalgebra/std", + "slab", + "rustc-hash", + "simba/std", + "arrayvec/std", + "spade", + "thiserror", +] dim2 = [] f32 = [] -serde-serialize = ["serde", "nalgebra/serde-serialize", "arrayvec/serde", "bitflags/serde"] -rkyv-serialize = ["rkyv/validation", "nalgebra/rkyv-serialize", "simba/rkyv-serialize"] +serde-serialize = [ + "serde", + "nalgebra/serde-serialize", + "arrayvec/serde", + "bitflags/serde", +] +rkyv-serialize = [ + "rkyv/validation", + "nalgebra/rkyv-serialize", + "simba/rkyv-serialize", +] bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"] simd-stable = ["simba/wide", "simd-is-enabled"] simd-nightly = ["simba/portable_simd", "simd-is-enabled"] @@ -68,4 +85,94 @@ simba = { version = "0.9", default-features = false } oorandom = "11" ptree = "0.4.0" rand = { version = "0.8" } -macroquad = "0.4" \ No newline at end of file +macroquad = "0.4" + +[package.metadata.docs.rs] +rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"] +all-features = true +cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] + +[[example]] +name = "aabb2d.rs" +path = "examples/aabb2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "ball2d.rs" +path = "examples/ball2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "bounding_sphere2d.rs" +path = "examples/bounding_sphere2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "contact_query2d.rs" +path = "examples/contact_query2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "convex2d.rs" +path = "examples/convex2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "convex_hull2d.rs" +path = "examples/convex_hull2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "convex_try_new2d.rs" +path = "examples/convex_try_new2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "cuboid2d.rs" +path = "examples/cuboid2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "distance_query2d.rs" +path = "examples/distance_query2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "plane2d.rs" +path = "examples/plane2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "point_in_poly2d.rs" +path = "examples/point_in_poly2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "polygons_intersection2d.rs" +path = "examples/polygons_intersection2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "polyline2d.rs" +path = "examples/polyline2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "proximity_query2d.rs" +path = "examples/proximity_query2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "solid_point_query2d.rs" +path = "examples/solid_point_query2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "solid_ray_cast2d.rs" +path = "examples/solid_ray_cast2d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "time_of_impact_query2d.rs" +path = "examples/time_of_impact_query2d.rs.rs" +doc-scrape-examples = true diff --git a/crates/parry3d-f64/Cargo.toml b/crates/parry3d-f64/Cargo.toml index 4ef42957..4252dc14 100644 --- a/crates/parry3d-f64/Cargo.toml +++ b/crates/parry3d-f64/Cargo.toml @@ -19,11 +19,23 @@ maintenance = { status = "actively-developed" } [features] default = ["required-features", "std"] required-features = ["dim3", "f64"] -std = ["nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec/std", "spade", "thiserror"] +std = [ + "nalgebra/std", + "slab", + "rustc-hash", + "simba/std", + "arrayvec/std", + "spade", + "thiserror", +] dim3 = [] f64 = [] serde-serialize = ["serde", "nalgebra/serde-serialize", "bitflags/serde"] -rkyv-serialize = ["rkyv/validation", "nalgebra/rkyv-serialize", "simba/rkyv-serialize"] +rkyv-serialize = [ + "rkyv/validation", + "nalgebra/rkyv-serialize", + "simba/rkyv-serialize", +] bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"] simd-stable = ["simba/wide", "simd-is-enabled"] simd-nightly = ["simba/portable_simd", "simd-is-enabled"] @@ -67,3 +79,108 @@ thiserror = { version = "1", optional = true } oorandom = "11" ptree = "0.4.0" rand = { version = "0.8" } + +[package.metadata.docs.rs] +rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"] +all-features = true +cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] + +[[example]] +name = "aabb3d.rs" +path = "examples/aabb3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "ball3d.rs" +path = "examples/ball3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "bounding_sphere3d.rs" +path = "examples/bounding_sphere3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "capsule.rs" +path = "examples/capsule.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "cone.rs" +path = "examples/cone.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "contact_query3d.rs" +path = "examples/contact_query3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "convex3d.rs" +path = "examples/convex3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "convex_hull3d.rs" +path = "examples/convex_hull3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "convex_try_new3d.rs" +path = "examples/convex_try_new3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "cuboid3d.rs" +path = "examples/cuboid3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "cylinder.rs" +path = "examples/cylinder.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "distance_query3d.rs" +path = "examples/distance_query3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "getting_started.rs" +path = "examples/getting_started.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "mesh3d.rs" +path = "examples/mesh3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "plane3d.rs" +path = "examples/plane3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "polyline3d.rs" +path = "examples/polyline3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "proximity_query3d.rs" +path = "examples/proximity_query3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "solid_point_query3d.rs" +path = "examples/solid_point_query3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "solid_ray_cast3d.rs" +path = "examples/solid_ray_cast3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "time_of_impact_query3d.rs" +path = "examples/time_of_impact_query3d.rs.rs" +doc-scrape-examples = true diff --git a/crates/parry3d/Cargo.toml b/crates/parry3d/Cargo.toml index 54402e1e..689fe2b1 100644 --- a/crates/parry3d/Cargo.toml +++ b/crates/parry3d/Cargo.toml @@ -19,11 +19,23 @@ maintenance = { status = "actively-developed" } [features] default = ["required-features", "std"] required-features = ["dim3", "f32"] -std = ["nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec/std", "spade", "thiserror"] +std = [ + "nalgebra/std", + "slab", + "rustc-hash", + "simba/std", + "arrayvec/std", + "spade", + "thiserror", +] dim3 = [] f32 = [] serde-serialize = ["serde", "nalgebra/serde-serialize", "bitflags/serde"] -rkyv-serialize = ["rkyv/validation", "nalgebra/rkyv-serialize", "simba/rkyv-serialize"] +rkyv-serialize = [ + "rkyv/validation", + "nalgebra/rkyv-serialize", + "simba/rkyv-serialize", +] bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"] simd-stable = ["simba/wide", "simd-is-enabled"] @@ -68,3 +80,109 @@ thiserror = { version = "1", optional = true } oorandom = "11" ptree = "0.4.0" rand = { version = "0.8" } + +[package.metadata.docs.rs] +rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"] +all-features = true +cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] + +[[example]] +name = "aabb3d.rs" +path = "examples/aabb3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "ball3d.rs" +path = "examples/ball3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "bounding_sphere3d.rs" +path = "examples/bounding_sphere3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "capsule.rs" +path = "examples/capsule.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "cone.rs" +path = "examples/cone.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "contact_query3d.rs" +path = "examples/contact_query3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "convex3d.rs" +path = "examples/convex3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "convex_hull3d.rs" +path = "examples/convex_hull3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "convex_try_new3d.rs" +path = "examples/convex_try_new3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "cuboid3d.rs" +path = "examples/cuboid3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "cylinder.rs" +path = "examples/cylinder.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "distance_query3d.rs" +path = "examples/distance_query3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "getting_started.rs" +path = "examples/getting_started.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "mesh3d.rs" +path = "examples/mesh3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "plane3d.rs" +path = "examples/plane3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "polyline3d.rs" +path = "examples/polyline3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "proximity_query3d.rs" +path = "examples/proximity_query3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "solid_point_query3d.rs" +path = "examples/solid_point_query3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "solid_ray_cast3d.rs" +path = "examples/solid_ray_cast3d.rs.rs" +doc-scrape-examples = true + +[[example]] +name = "time_of_impact_query3d.rs" +path = "examples/time_of_impact_query3d.rs.rs" +doc-scrape-examples = true + diff --git a/publish.sh b/publish.sh index 093e5a36..0dff43d8 100755 --- a/publish.sh +++ b/publish.sh @@ -9,24 +9,32 @@ cp -r LICENSE README.md $tmp/. ### Publish the 2D version. sed 's#\.\./\.\./src#src#g' crates/parry2d/Cargo.toml > $tmp/Cargo.toml +rm -rf $tmp/examples +cp -r crates/parry2d/examples examples currdir=`pwd` cd $tmp && cargo publish cd $currdir ### Publish the 2D f64 version. sed 's#\.\./\.\./src#src#g' crates/parry2d-f64/Cargo.toml > $tmp/Cargo.toml +rm -rf $tmp/examples +cp -r crates/parry2d/examples examples cd $tmp && cargo publish cd $currdir ### Publish the 3D version. sed 's#\.\./\.\./src#src#g' crates/parry3d/Cargo.toml > $tmp/Cargo.toml +rm -rf $tmp/examples +cp -r crates/parry3d/examples $tmp/examples cp -r LICENSE README.md $tmp/. cd $tmp && cargo publish cd $currdir ### Publish the 3D f64 version. sed 's#\.\./\.\./src#src#g' crates/parry3d-f64/Cargo.toml > $tmp/Cargo.toml +rm -rf $tmp/examples +cp -r crates/parry3d/examples $tmp/examples cp -r LICENSE README.md $tmp/. cd $tmp && cargo publish diff --git a/write_examples.sh b/write_examples.sh new file mode 100644 index 00000000..922cd312 --- /dev/null +++ b/write_examples.sh @@ -0,0 +1,23 @@ +#! /bin/bash + +write_examples() { + examples_path=$1 + output_path=$2 + + echo >> $output_path + + find $examples_path -type f -iname '*.rs' -print0 | + while IFS= read -r -d '' line; do + example=$(basename ${line}) + echo "[[example]]" >> $output_path + echo "name = \"$example\"" >> $output_path + echo "path = \"examples/$example.rs\"" >> $output_path + echo "doc-scrape-examples = true" >> $output_path + echo >> $output_path + done +} + +write_examples ./crates/parry2d/examples ./crates/parry2d/Cargo.toml +write_examples ./crates/parry2d/examples ./crates/parry2d-f64/Cargo.toml +write_examples ./crates/parry3d/examples ./crates/parry3d/Cargo.toml +write_examples ./crates/parry3d/examples ./crates/parry3d-f64/Cargo.toml From 9ddf494561cc8a9976aaf278fe1ea765dad971e5 Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Tue, 23 Jul 2024 15:33:30 +0200 Subject: [PATCH 4/4] fix example filenames + removed examples from f64 variants f64 examples require more work to support, using parry::math::Real is a controversial solution --- crates/parry2d-f64/Cargo.toml | 90 ----------------- crates/parry2d/Cargo.toml | 69 ++++++------- crates/parry2d/examples/ball2d.rs | 2 +- crates/parry2d/examples/convex2d.rs | 2 +- crates/parry2d/examples/convex_try_new2d.rs | 2 +- crates/parry2d/examples/cuboid2d.rs | 2 +- crates/parry3d-f64/Cargo.toml | 105 -------------------- crates/parry3d/Cargo.toml | 80 +++++++-------- publish.sh | 5 +- src/utils/hashmap.rs | 13 +-- write_examples.sh | 4 +- 11 files changed, 90 insertions(+), 284 deletions(-) diff --git a/crates/parry2d-f64/Cargo.toml b/crates/parry2d-f64/Cargo.toml index 9c019c7e..e741d2ab 100644 --- a/crates/parry2d-f64/Cargo.toml +++ b/crates/parry2d-f64/Cargo.toml @@ -85,93 +85,3 @@ simba = { version = "0.9", default-features = false } oorandom = "11" ptree = "0.4.0" rand = { version = "0.8" } - -[package.metadata.docs.rs] -rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"] -all-features = true -cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] - -[[example]] -name = "aabb2d.rs" -path = "examples/aabb2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "ball2d.rs" -path = "examples/ball2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "bounding_sphere2d.rs" -path = "examples/bounding_sphere2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "contact_query2d.rs" -path = "examples/contact_query2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "convex2d.rs" -path = "examples/convex2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "convex_hull2d.rs" -path = "examples/convex_hull2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "convex_try_new2d.rs" -path = "examples/convex_try_new2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "cuboid2d.rs" -path = "examples/cuboid2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "distance_query2d.rs" -path = "examples/distance_query2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "plane2d.rs" -path = "examples/plane2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "point_in_poly2d.rs" -path = "examples/point_in_poly2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "polygons_intersection2d.rs" -path = "examples/polygons_intersection2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "polyline2d.rs" -path = "examples/polyline2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "proximity_query2d.rs" -path = "examples/proximity_query2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "solid_point_query2d.rs" -path = "examples/solid_point_query2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "solid_ray_cast2d.rs" -path = "examples/solid_ray_cast2d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "time_of_impact_query2d.rs" -path = "examples/time_of_impact_query2d.rs.rs" -doc-scrape-examples = true diff --git a/crates/parry2d/Cargo.toml b/crates/parry2d/Cargo.toml index c72c9402..1daa49eb 100644 --- a/crates/parry2d/Cargo.toml +++ b/crates/parry2d/Cargo.toml @@ -93,86 +93,87 @@ all-features = true cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] [[example]] -name = "aabb2d.rs" -path = "examples/aabb2d.rs.rs" +name = "aabb2d" +path = "examples/aabb2d.rs" doc-scrape-examples = true [[example]] -name = "ball2d.rs" -path = "examples/ball2d.rs.rs" +name = "ball2d" +path = "examples/ball2d.rs" doc-scrape-examples = true [[example]] -name = "bounding_sphere2d.rs" -path = "examples/bounding_sphere2d.rs.rs" +name = "bounding_sphere2d" +path = "examples/bounding_sphere2d.rs" doc-scrape-examples = true [[example]] -name = "contact_query2d.rs" -path = "examples/contact_query2d.rs.rs" +name = "contact_query2d" +path = "examples/contact_query2d.rs" doc-scrape-examples = true [[example]] -name = "convex2d.rs" -path = "examples/convex2d.rs.rs" +name = "convex2d" +path = "examples/convex2d.rs" doc-scrape-examples = true [[example]] -name = "convex_hull2d.rs" -path = "examples/convex_hull2d.rs.rs" +name = "convex_hull2d" +path = "examples/convex_hull2d.rs" doc-scrape-examples = true [[example]] -name = "convex_try_new2d.rs" -path = "examples/convex_try_new2d.rs.rs" +name = "convex_try_new2d" +path = "examples/convex_try_new2d.rs" doc-scrape-examples = true [[example]] -name = "cuboid2d.rs" -path = "examples/cuboid2d.rs.rs" +name = "cuboid2d" +path = "examples/cuboid2d.rs" doc-scrape-examples = true [[example]] -name = "distance_query2d.rs" -path = "examples/distance_query2d.rs.rs" +name = "distance_query2d" +path = "examples/distance_query2d.rs" doc-scrape-examples = true [[example]] -name = "plane2d.rs" -path = "examples/plane2d.rs.rs" +name = "plane2d" +path = "examples/plane2d.rs" doc-scrape-examples = true [[example]] -name = "point_in_poly2d.rs" -path = "examples/point_in_poly2d.rs.rs" +name = "point_in_poly2d" +path = "examples/point_in_poly2d.rs" doc-scrape-examples = true [[example]] -name = "polygons_intersection2d.rs" -path = "examples/polygons_intersection2d.rs.rs" +name = "polygons_intersection2d" +path = "examples/polygons_intersection2d.rs" doc-scrape-examples = true [[example]] -name = "polyline2d.rs" -path = "examples/polyline2d.rs.rs" +name = "polyline2d" +path = "examples/polyline2d.rs" doc-scrape-examples = true [[example]] -name = "proximity_query2d.rs" -path = "examples/proximity_query2d.rs.rs" +name = "proximity_query2d" +path = "examples/proximity_query2d.rs" doc-scrape-examples = true [[example]] -name = "solid_point_query2d.rs" -path = "examples/solid_point_query2d.rs.rs" +name = "solid_point_query2d" +path = "examples/solid_point_query2d.rs" doc-scrape-examples = true [[example]] -name = "solid_ray_cast2d.rs" -path = "examples/solid_ray_cast2d.rs.rs" +name = "solid_ray_cast2d" +path = "examples/solid_ray_cast2d.rs" doc-scrape-examples = true [[example]] -name = "time_of_impact_query2d.rs" -path = "examples/time_of_impact_query2d.rs.rs" +name = "time_of_impact_query2d" +path = "examples/time_of_impact_query2d.rs" doc-scrape-examples = true + diff --git a/crates/parry2d/examples/ball2d.rs b/crates/parry2d/examples/ball2d.rs index 31577edf..05dbc9fd 100644 --- a/crates/parry2d/examples/ball2d.rs +++ b/crates/parry2d/examples/ball2d.rs @@ -1,6 +1,6 @@ use parry2d::shape::Ball; fn main() { - let ball = Ball::new(1.0f32); + let ball = Ball::new(1.0); assert!(ball.radius == 1.0); } diff --git a/crates/parry2d/examples/convex2d.rs b/crates/parry2d/examples/convex2d.rs index 541bc5a6..9bfeb8bb 100644 --- a/crates/parry2d/examples/convex2d.rs +++ b/crates/parry2d/examples/convex2d.rs @@ -6,7 +6,7 @@ use parry2d::shape::ConvexPolygon; fn main() { let points = [ - Point2::new(-1.0f32, 1.0), + Point2::new(-1.0, 1.0), Point2::new(-0.5, -0.5), Point2::new(0.0, 0.5), Point2::new(0.5, -0.5), diff --git a/crates/parry2d/examples/convex_try_new2d.rs b/crates/parry2d/examples/convex_try_new2d.rs index 45288785..31eb0625 100644 --- a/crates/parry2d/examples/convex_try_new2d.rs +++ b/crates/parry2d/examples/convex_try_new2d.rs @@ -5,7 +5,7 @@ use parry2d::shape::ConvexPolygon; fn main() { let points = vec![ - Point2::new(-1.0f32, 1.0), + Point2::new(-1.0, 1.0), Point2::new(-0.5, -0.5), Point2::new(0.5, -0.5), Point2::new(1.0, 1.0), diff --git a/crates/parry2d/examples/cuboid2d.rs b/crates/parry2d/examples/cuboid2d.rs index 57611fe7..cc392b7a 100644 --- a/crates/parry2d/examples/cuboid2d.rs +++ b/crates/parry2d/examples/cuboid2d.rs @@ -4,7 +4,7 @@ use na::Vector2; use parry2d::shape::Cuboid; fn main() { - let cuboid = Cuboid::new(Vector2::new(2.0f32, 1.0)); + let cuboid = Cuboid::new(Vector2::new(2.0, 1.0)); assert!(cuboid.half_extents.x == 2.0); assert!(cuboid.half_extents.y == 1.0); diff --git a/crates/parry3d-f64/Cargo.toml b/crates/parry3d-f64/Cargo.toml index 4252dc14..a24bb96a 100644 --- a/crates/parry3d-f64/Cargo.toml +++ b/crates/parry3d-f64/Cargo.toml @@ -79,108 +79,3 @@ thiserror = { version = "1", optional = true } oorandom = "11" ptree = "0.4.0" rand = { version = "0.8" } - -[package.metadata.docs.rs] -rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"] -all-features = true -cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] - -[[example]] -name = "aabb3d.rs" -path = "examples/aabb3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "ball3d.rs" -path = "examples/ball3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "bounding_sphere3d.rs" -path = "examples/bounding_sphere3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "capsule.rs" -path = "examples/capsule.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "cone.rs" -path = "examples/cone.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "contact_query3d.rs" -path = "examples/contact_query3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "convex3d.rs" -path = "examples/convex3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "convex_hull3d.rs" -path = "examples/convex_hull3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "convex_try_new3d.rs" -path = "examples/convex_try_new3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "cuboid3d.rs" -path = "examples/cuboid3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "cylinder.rs" -path = "examples/cylinder.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "distance_query3d.rs" -path = "examples/distance_query3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "getting_started.rs" -path = "examples/getting_started.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "mesh3d.rs" -path = "examples/mesh3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "plane3d.rs" -path = "examples/plane3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "polyline3d.rs" -path = "examples/polyline3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "proximity_query3d.rs" -path = "examples/proximity_query3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "solid_point_query3d.rs" -path = "examples/solid_point_query3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "solid_ray_cast3d.rs" -path = "examples/solid_ray_cast3d.rs.rs" -doc-scrape-examples = true - -[[example]] -name = "time_of_impact_query3d.rs" -path = "examples/time_of_impact_query3d.rs.rs" -doc-scrape-examples = true diff --git a/crates/parry3d/Cargo.toml b/crates/parry3d/Cargo.toml index 689fe2b1..0179fafb 100644 --- a/crates/parry3d/Cargo.toml +++ b/crates/parry3d/Cargo.toml @@ -87,102 +87,102 @@ all-features = true cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] [[example]] -name = "aabb3d.rs" -path = "examples/aabb3d.rs.rs" +name = "aabb3d" +path = "examples/aabb3d.rs" doc-scrape-examples = true [[example]] -name = "ball3d.rs" -path = "examples/ball3d.rs.rs" +name = "ball3d" +path = "examples/ball3d.rs" doc-scrape-examples = true [[example]] -name = "bounding_sphere3d.rs" -path = "examples/bounding_sphere3d.rs.rs" +name = "bounding_sphere3d" +path = "examples/bounding_sphere3d.rs" doc-scrape-examples = true [[example]] -name = "capsule.rs" -path = "examples/capsule.rs.rs" +name = "capsule" +path = "examples/capsule.rs" doc-scrape-examples = true [[example]] -name = "cone.rs" -path = "examples/cone.rs.rs" +name = "cone" +path = "examples/cone.rs" doc-scrape-examples = true [[example]] -name = "contact_query3d.rs" -path = "examples/contact_query3d.rs.rs" +name = "contact_query3d" +path = "examples/contact_query3d.rs" doc-scrape-examples = true [[example]] -name = "convex3d.rs" -path = "examples/convex3d.rs.rs" +name = "convex3d" +path = "examples/convex3d.rs" doc-scrape-examples = true [[example]] -name = "convex_hull3d.rs" -path = "examples/convex_hull3d.rs.rs" +name = "convex_hull3d" +path = "examples/convex_hull3d.rs" doc-scrape-examples = true [[example]] -name = "convex_try_new3d.rs" -path = "examples/convex_try_new3d.rs.rs" +name = "convex_try_new3d" +path = "examples/convex_try_new3d.rs" doc-scrape-examples = true [[example]] -name = "cuboid3d.rs" -path = "examples/cuboid3d.rs.rs" +name = "cuboid3d" +path = "examples/cuboid3d.rs" doc-scrape-examples = true [[example]] -name = "cylinder.rs" -path = "examples/cylinder.rs.rs" +name = "cylinder" +path = "examples/cylinder.rs" doc-scrape-examples = true [[example]] -name = "distance_query3d.rs" -path = "examples/distance_query3d.rs.rs" +name = "distance_query3d" +path = "examples/distance_query3d.rs" doc-scrape-examples = true [[example]] -name = "getting_started.rs" -path = "examples/getting_started.rs.rs" +name = "getting_started" +path = "examples/getting_started.rs" doc-scrape-examples = true [[example]] -name = "mesh3d.rs" -path = "examples/mesh3d.rs.rs" +name = "mesh3d" +path = "examples/mesh3d.rs" doc-scrape-examples = true [[example]] -name = "plane3d.rs" -path = "examples/plane3d.rs.rs" +name = "plane3d" +path = "examples/plane3d.rs" doc-scrape-examples = true [[example]] -name = "polyline3d.rs" -path = "examples/polyline3d.rs.rs" +name = "polyline3d" +path = "examples/polyline3d.rs" doc-scrape-examples = true [[example]] -name = "proximity_query3d.rs" -path = "examples/proximity_query3d.rs.rs" +name = "proximity_query3d" +path = "examples/proximity_query3d.rs" doc-scrape-examples = true [[example]] -name = "solid_point_query3d.rs" -path = "examples/solid_point_query3d.rs.rs" +name = "solid_point_query3d" +path = "examples/solid_point_query3d.rs" doc-scrape-examples = true [[example]] -name = "solid_ray_cast3d.rs" -path = "examples/solid_ray_cast3d.rs.rs" +name = "solid_ray_cast3d" +path = "examples/solid_ray_cast3d.rs" doc-scrape-examples = true [[example]] -name = "time_of_impact_query3d.rs" -path = "examples/time_of_impact_query3d.rs.rs" +name = "time_of_impact_query3d" +path = "examples/time_of_impact_query3d.rs" doc-scrape-examples = true diff --git a/publish.sh b/publish.sh index 0dff43d8..eed651d1 100755 --- a/publish.sh +++ b/publish.sh @@ -10,7 +10,7 @@ cp -r LICENSE README.md $tmp/. ### Publish the 2D version. sed 's#\.\./\.\./src#src#g' crates/parry2d/Cargo.toml > $tmp/Cargo.toml rm -rf $tmp/examples -cp -r crates/parry2d/examples examples +cp -r crates/parry2d/examples $tmp/examples currdir=`pwd` cd $tmp && cargo publish cd $currdir @@ -18,7 +18,8 @@ cd $currdir ### Publish the 2D f64 version. sed 's#\.\./\.\./src#src#g' crates/parry2d-f64/Cargo.toml > $tmp/Cargo.toml rm -rf $tmp/examples -cp -r crates/parry2d/examples examples +cp -r crates/parry2d/examples $tmp/examples +find $tmp/examples | xargs sed 's/parry2d:/parry2d_f64:/g cd $tmp && cargo publish cd $currdir diff --git a/src/utils/hashmap.rs b/src/utils/hashmap.rs index 364ae380..aeb5b1d3 100644 --- a/src/utils/hashmap.rs +++ b/src/utils/hashmap.rs @@ -5,6 +5,7 @@ use indexmap::IndexMap as StdHashMap; #[cfg(all(not(feature = "enhanced-determinism"), feature = "serde-serialize"))] use std::collections::HashMap as StdHashMap; +use std::mem::size_of; /// Serializes only the capacity of a hash-map instead of its actual content. #[cfg(feature = "serde-serialize")] @@ -84,20 +85,20 @@ impl std::hash::Hasher for FxHasher32 { fn write(&mut self, mut bytes: &[u8]) { let read_u32 = |bytes: &[u8]| u32::from_ne_bytes(bytes[..4].try_into().unwrap()); let mut hash = FxHasher32 { hash: self.hash }; - assert!(std::mem::size_of::() <= 8); - while bytes.len() >= std::mem::size_of::() { + assert!(size_of::() <= 8); + while bytes.len() >= size_of::() { hash.add_to_hash(read_u32(bytes)); - bytes = &bytes[std::mem::size_of::()..]; + bytes = &bytes[size_of::()..]; } - if (std::mem::size_of::() > 4) && (bytes.len() >= 4) { + if (size_of::() > 4) && (bytes.len() >= 4) { hash.add_to_hash(u32::from_ne_bytes(bytes[..4].try_into().unwrap())); bytes = &bytes[4..]; } - if (std::mem::size_of::() > 2) && bytes.len() >= 2 { + if (size_of::() > 2) && bytes.len() >= 2 { hash.add_to_hash(u16::from_ne_bytes(bytes[..2].try_into().unwrap()) as u32); bytes = &bytes[2..]; } - if (std::mem::size_of::() > 1) && !bytes.is_empty() { + if (size_of::() > 1) && !bytes.is_empty() { hash.add_to_hash(bytes[0] as u32); } self.hash = hash.hash; diff --git a/write_examples.sh b/write_examples.sh index 922cd312..2a06c89b 100644 --- a/write_examples.sh +++ b/write_examples.sh @@ -8,7 +8,7 @@ write_examples() { find $examples_path -type f -iname '*.rs' -print0 | while IFS= read -r -d '' line; do - example=$(basename ${line}) + example=$(basename ${line} .rs) echo "[[example]]" >> $output_path echo "name = \"$example\"" >> $output_path echo "path = \"examples/$example.rs\"" >> $output_path @@ -18,6 +18,4 @@ write_examples() { } write_examples ./crates/parry2d/examples ./crates/parry2d/Cargo.toml -write_examples ./crates/parry2d/examples ./crates/parry2d-f64/Cargo.toml write_examples ./crates/parry3d/examples ./crates/parry3d/Cargo.toml -write_examples ./crates/parry3d/examples ./crates/parry3d-f64/Cargo.toml