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

Cargo doc ci #1

Closed
wants to merge 14 commits into from
Closed
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
16 changes: 14 additions & 2 deletions .github/workflows/parry-ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: parry CI build

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

env:
CARGO_TERM_COLOR: always
Expand All @@ -22,6 +22,18 @@ jobs:
- uses: actions/checkout@v4
- name: Clippy
run: cargo clippy
doc:
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -D warnings
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ env.RUST_CACHE_KEY }}
- name: Cargo doc
run: cargo doc
build-native:
runs-on: ubuntu-latest
env:
Expand Down
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Change Log

## Unreleased

### Modified

- `TypedShape::Custom(u32)` is now `TypedShape::Custom(&dyn Shape)`.

## v0.16.1

### Fix

- Fix occasional crash in mesh/mesh intersection if some of the vertex coordinates are very small.

## v0.16.0

### Fix

- Fix edge case where some of the principal angular inertia are clamped to zero
for decimeter-sized objects.
- Have ball-ball shape casting take into account the `stop_on_penetration` flags.
- Don’t panic in EPA for a corner case that needs some additional debugging. Show a debug log instead.

### Added

- Implement concave polygons intersections: `polygons_intersection_points`, `polygon_intersection`.

### Modified

- Update `bitflags` to version ^2.3
- Update `nalgebra` to 0.33.
- Update `indexmap` to 2.

## v0.15.1

### Fix
Expand Down
22 changes: 12 additions & 10 deletions crates/parry2d-f64/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "parry2d-f64"
version = "0.15.1"
version = "0.16.1"
authors = ["Sébastien Crozet <[email protected]>"]

description = "2 dimensional collision detection library in Rust. 64-bit precision version."
Expand All @@ -19,14 +19,14 @@ maintenance = { status = "actively-developed" }
[features]
default = ["required-features", "std"]
required-features = ["dim2", "f64"]
std = ["nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec/std", "spade"]
std = ["nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec/std", "spade", "thiserror"]
dim2 = []
f64 = []
serde-serialize = ["serde", "nalgebra/serde-serialize", "arrayvec/serde"]
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/packed_simd", "simd-is-enabled"]
simd-nightly = ["simba/portable_simd", "simd-is-enabled"]
enhanced-determinism = ["simba/libm_force", "indexmap"]
parallel = ["rayon"]

Expand All @@ -41,28 +41,30 @@ required-features = ["required-features"]

[dependencies]
either = { version = "1", default-features = false }
bitflags = "1"
bitflags = "2.3"
downcast-rs = { version = "1", default-features = false }
num-traits = { version = "0.2", default-features = false }
smallvec = "1"
slab = { version = "0.4", optional = true }
arrayvec = { version = "0.7", default-features = false }
simba = { version = "0.8", default-features = false }
nalgebra = { version = "0.32", default-features = false, features = ["libm"] }
simba = { version = "0.9", default-features = false }
nalgebra = { version = "0.33", default-features = false, features = ["libm"] }
approx = { version = "0.5", default-features = false }
serde = { version = "1.0", optional = true, features = ["derive"] }
rkyv = { version = "0.7.41", optional = true }
num-derive = "0.4"
indexmap = { version = "1", features = ["serde-1"], optional = true }
rustc-hash = { version = "1", optional = true }
indexmap = { version = "2", features = ["serde"], optional = true }
rustc-hash = { version = "2", optional = true }
cust_core = { version = "0.1", optional = true }
spade = { version = "2", optional = true } # Make this optional?
rayon = { version = "1", optional = true }
bytemuck = { version = "1", features = ["derive"], optional = true }
log = "0.4"
ordered-float = { version = "4", default-features = false }
thiserror = { version = "1", optional = true }

[dev-dependencies]
simba = { version = "0.8", default-features = false, features = ["partial_fixed_point_support"] }
simba = { version = "0.9", default-features = false }
oorandom = "11"
ptree = "0.4.0"
rand = { version = "0.8" }
23 changes: 13 additions & 10 deletions crates/parry2d/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "parry2d"
version = "0.15.1"
version = "0.16.1"
authors = ["Sébastien Crozet <[email protected]>"]

description = "2 dimensional collision detection library in Rust."
Expand All @@ -19,14 +19,14 @@ maintenance = { status = "actively-developed" }
[features]
default = ["required-features", "std"]
required-features = ["dim2", "f32"]
std = ["nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec/std", "spade"]
std = ["nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec/std", "spade", "thiserror"]
dim2 = []
f32 = []
serde-serialize = ["serde", "nalgebra/serde-serialize", "arrayvec/serde"]
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/packed_simd", "simd-is-enabled"]
simd-nightly = ["simba/portable_simd", "simd-is-enabled"]
enhanced-determinism = ["simba/libm_force", "indexmap"]
parallel = ["rayon"]

Expand All @@ -41,28 +41,31 @@ required-features = ["required-features"]

[dependencies]
either = { version = "1", default-features = false }
bitflags = "1"
bitflags = "2.3"
downcast-rs = { version = "1", default-features = false }
num-traits = { version = "0.2", default-features = false }
smallvec = "1"
slab = { version = "0.4", optional = true }
arrayvec = { version = "0.7", default-features = false }
simba = { version = "0.8", default-features = false }
nalgebra = { version = "0.32", default-features = false, features = ["libm"] }
simba = { version = "0.9", default-features = false }
nalgebra = { version = "0.33", default-features = false, features = ["libm"] }
approx = { version = "0.5", default-features = false }
serde = { version = "1.0", optional = true, features = ["derive"] }
rkyv = { version = "0.7.41", optional = true }
num-derive = "0.4"
indexmap = { version = "1", features = ["serde-1"], optional = true }
rustc-hash = { version = "1", optional = true }
indexmap = { version = "2", features = ["serde"], optional = true }
rustc-hash = { version = "2", optional = true }
cust_core = { version = "0.1", optional = true }
spade = { version = "2", optional = true }
rayon = { version = "1", optional = true }
bytemuck = { version = "1", features = ["derive"], optional = true }
ordered-float = { version = "4", default-features = false }
log = "0.4"
thiserror = { version = "1", optional = true }

[dev-dependencies]
simba = { version = "0.8", default-features = false, features = ["partial_fixed_point_support"] }
simba = { version = "0.9", default-features = false }
oorandom = "11"
ptree = "0.4.0"
rand = { version = "0.8" }
macroquad = "0.4"
108 changes: 108 additions & 0 deletions crates/parry2d/examples/point_in_poly2d.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
use macroquad::prelude::*;
use nalgebra::{Point2, UnitComplex, Vector2};
use parry2d::utils::point_in_poly2d;

const RENDER_SCALE: f32 = 30.0;

#[macroquad::main("parry2d::utils::point_in_poly2d")]
async fn main() {
let mut spikes = spikes_polygon();
let test_points = grid_points();

let animation_rotation = UnitComplex::new(0.02);
let spikes_render_pos = Point2::new(screen_width() / 2.0, screen_height() / 2.0);

loop {
clear_background(BLACK);

/*
* Compute polygon intersections.
*/
spikes
.iter_mut()
.for_each(|pt| *pt = animation_rotation * *pt);
draw_polygon(&spikes, RENDER_SCALE, spikes_render_pos, BLUE);

for point in &test_points {
if point_in_poly2d(point, &spikes) {
draw_point(*point, RENDER_SCALE, spikes_render_pos, RED);
} else {
draw_point(*point, RENDER_SCALE, spikes_render_pos, GREEN);
}
}

next_frame().await
}
}

fn spikes_polygon() -> Vec<Point2<f32>> {
let teeths = 3;
let width = 15.0;
let height = 7.5;
let tooth_width = width / (teeths as f32);
let center = Vector2::new(width / 2.0, height / 2.0);

let mut polygon = vec![
Point2::new(width, 0.0) - center,
Point2::new(width, height) - center,
Point2::new(0.0, height) - center,
];

for i in 0..teeths {
let x = i as f32 * tooth_width;
polygon.push(Point2::new(x, 0.0) - center);
polygon.push(Point2::new(x + tooth_width / 2.0, height * 1.5) - center);
}

polygon
}

fn grid_points() -> Vec<Point2<f32>> {
let count = 40;
let spacing = 0.6;
let mut pts = vec![];
for i in 0..count {
for j in 0..count {
pts.push(Point2::new(
(i as f32 - count as f32 / 2.0) * spacing,
(j as f32 - count as f32 / 2.0) * spacing,
));
}
}
pts
}

fn draw_polygon(polygon: &[Point2<f32>], scale: f32, shift: Point2<f32>, color: Color) {
for i in 0..polygon.len() {
let a = polygon[i];
let b = polygon[(i + 1) % polygon.len()];
draw_line(
a.x * scale + shift.x,
a.y * scale + shift.y,
b.x * scale + shift.x,
b.y * scale + shift.y,
2.0,
color,
);
}
}

fn draw_point(point: Point2<f32>, scale: f32, shift: Point2<f32>, color: Color) {
let edge_len = 0.15;
draw_line(
(point.x - edge_len) * scale + shift.x,
point.y * scale + shift.y,
(point.x + edge_len) * scale + shift.x,
point.y * scale + shift.y,
2.0,
color,
);
draw_line(
point.x * scale + shift.x,
(point.y - edge_len) * scale + shift.y,
point.x * scale + shift.x,
(point.y + edge_len) * scale + shift.y,
2.0,
color,
);
}
Loading