diff --git a/crates/parry2d-f64/Cargo.toml b/crates/parry2d-f64/Cargo.toml index 3aa58393..21fb2c3f 100644 --- a/crates/parry2d-f64/Cargo.toml +++ b/crates/parry2d-f64/Cargo.toml @@ -22,11 +22,28 @@ workspace = true [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"] diff --git a/crates/parry2d/Cargo.toml b/crates/parry2d/Cargo.toml index 19b7e19d..76bf9277 100644 --- a/crates/parry2d/Cargo.toml +++ b/crates/parry2d/Cargo.toml @@ -22,11 +22,28 @@ workspace = true [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"] @@ -73,4 +90,97 @@ 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", "--generate-link-to-definition"] +cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] + +# The following listing is to allow for examples to be scraped, +# see https://doc.rust-lang.org/rustdoc/scraped-examples.html#scraped-examples for details. +# To help with generating this list, see the script `write_examples.sh` + +[[example]] +name = "aabb2d" +path = "examples/aabb2d.rs" +doc-scrape-examples = true + +[[example]] +name = "ball2d" +path = "examples/ball2d.rs" +doc-scrape-examples = true + +[[example]] +name = "bounding_sphere2d" +path = "examples/bounding_sphere2d.rs" +doc-scrape-examples = true + +[[example]] +name = "contact_query2d" +path = "examples/contact_query2d.rs" +doc-scrape-examples = true + +[[example]] +name = "convex2d" +path = "examples/convex2d.rs" +doc-scrape-examples = true + +[[example]] +name = "convex_hull2d" +path = "examples/convex_hull2d.rs" +doc-scrape-examples = true + +[[example]] +name = "convex_try_new2d" +path = "examples/convex_try_new2d.rs" +doc-scrape-examples = true + +[[example]] +name = "cuboid2d" +path = "examples/cuboid2d.rs" +doc-scrape-examples = true + +[[example]] +name = "distance_query2d" +path = "examples/distance_query2d.rs" +doc-scrape-examples = true + +[[example]] +name = "plane2d" +path = "examples/plane2d.rs" +doc-scrape-examples = true + +[[example]] +name = "point_in_poly2d" +path = "examples/point_in_poly2d.rs" +doc-scrape-examples = true + +[[example]] +name = "polygons_intersection2d" +path = "examples/polygons_intersection2d.rs" +doc-scrape-examples = true + +[[example]] +name = "polyline2d" +path = "examples/polyline2d.rs" +doc-scrape-examples = true + +[[example]] +name = "proximity_query2d" +path = "examples/proximity_query2d.rs" +doc-scrape-examples = true + +[[example]] +name = "solid_point_query2d" +path = "examples/solid_point_query2d.rs" +doc-scrape-examples = true + +[[example]] +name = "solid_ray_cast2d" +path = "examples/solid_ray_cast2d.rs" +doc-scrape-examples = true + +[[example]] +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 c3391dd8..f04f29f1 100644 --- a/crates/parry3d-f64/Cargo.toml +++ b/crates/parry3d-f64/Cargo.toml @@ -22,11 +22,23 @@ workspace = true [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"] diff --git a/crates/parry3d/Cargo.toml b/crates/parry3d/Cargo.toml index 62545af3..05797c45 100644 --- a/crates/parry3d/Cargo.toml +++ b/crates/parry3d/Cargo.toml @@ -22,11 +22,23 @@ workspace = true [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"] @@ -76,3 +88,111 @@ obj = { version = "0.10.2", optional = true } oorandom = "11" ptree = "0.4.0" rand = { version = "0.8" } + +[package.metadata.docs.rs] +rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"] +cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] + +# The following listing is to allow for examples to be scraped, +# see https://doc.rust-lang.org/rustdoc/scraped-examples.html#scraped-examples for details. +# To help with generating this list, see the script `write_examples.sh` + +[[example]] +name = "aabb3d" +path = "examples/aabb3d.rs" +doc-scrape-examples = true + +[[example]] +name = "ball3d" +path = "examples/ball3d.rs" +doc-scrape-examples = true + +[[example]] +name = "bounding_sphere3d" +path = "examples/bounding_sphere3d.rs" +doc-scrape-examples = true + +[[example]] +name = "capsule" +path = "examples/capsule.rs" +doc-scrape-examples = true + +[[example]] +name = "cone" +path = "examples/cone.rs" +doc-scrape-examples = true + +[[example]] +name = "contact_query3d" +path = "examples/contact_query3d.rs" +doc-scrape-examples = true + +[[example]] +name = "convex3d" +path = "examples/convex3d.rs" +doc-scrape-examples = true + +[[example]] +name = "convex_hull3d" +path = "examples/convex_hull3d.rs" +doc-scrape-examples = true + +[[example]] +name = "convex_try_new3d" +path = "examples/convex_try_new3d.rs" +doc-scrape-examples = true + +[[example]] +name = "cuboid3d" +path = "examples/cuboid3d.rs" +doc-scrape-examples = true + +[[example]] +name = "cylinder" +path = "examples/cylinder.rs" +doc-scrape-examples = true + +[[example]] +name = "distance_query3d" +path = "examples/distance_query3d.rs" +doc-scrape-examples = true + +[[example]] +name = "getting_started" +path = "examples/getting_started.rs" +doc-scrape-examples = true + +[[example]] +name = "mesh3d" +path = "examples/mesh3d.rs" +doc-scrape-examples = true + +[[example]] +name = "plane3d" +path = "examples/plane3d.rs" +doc-scrape-examples = true + +[[example]] +name = "polyline3d" +path = "examples/polyline3d.rs" +doc-scrape-examples = true + +[[example]] +name = "proximity_query3d" +path = "examples/proximity_query3d.rs" +doc-scrape-examples = true + +[[example]] +name = "solid_point_query3d" +path = "examples/solid_point_query3d.rs" +doc-scrape-examples = true + +[[example]] +name = "solid_ray_cast3d" +path = "examples/solid_ray_cast3d.rs" +doc-scrape-examples = true + +[[example]] +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 093e5a36..5380b92f 100755 --- a/publish.sh +++ b/publish.sh @@ -9,6 +9,8 @@ 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 $tmp/examples currdir=`pwd` cd $tmp && cargo publish cd $currdir @@ -21,6 +23,8 @@ 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 diff --git a/src/utils/hashmap.rs b/src/utils/hashmap.rs index a5d02a3d..aeb5b1d3 100644 --- a/src/utils/hashmap.rs +++ b/src/utils/hashmap.rs @@ -5,7 +5,6 @@ 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. diff --git a/write_examples.sh b/write_examples.sh new file mode 100644 index 00000000..2a06c89b --- /dev/null +++ b/write_examples.sh @@ -0,0 +1,21 @@ +#! /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} .rs) + 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/parry3d/examples ./crates/parry3d/Cargo.toml