Skip to content

Commit 65f15f8

Browse files
committed
Revert "Migrate codebase to glam + release v0.26.0 (dimforge#401)"
This reverts commit 72f842d.
1 parent 72f842d commit 65f15f8

File tree

375 files changed

+13759
-13378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

375 files changed

+13759
-13378
lines changed

.github/workflows/parry-ci-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- name: Build parry3d SIMD
4141
run: cd crates/parry3d; cargo build --verbose --features simd-stable;
4242
- name: Check serialization
43-
run: cargo check --features bytemuck-serialize,serde-serialize,rkyv;
43+
run: cargo check --features bytemuck-serialize,serde-serialize,rkyv-serialize;
4444
- name: Check enhanced-determinism
4545
run: cargo check --features enhanced-determinism
4646
tests:
@@ -91,7 +91,7 @@ jobs:
9191
with:
9292
toolchain: stable
9393
- name: cargo doc
94-
run: cargo doc --workspace --features bytemuck-serialize,serde-serialize,parallel --no-deps --document-private-items # TODO: rkyv
94+
run: cargo doc --workspace --features bytemuck-serialize,serde-serialize,rkyv-serialize,parallel --no-deps --document-private-items
9595
check-benchmarks:
9696
runs-on: ubuntu-latest
9797
steps:

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ private
88
Cargo.lock
99
Makefile
1010
.vscode
11-
.idea
12-
.DS_store
11+
.idea

CHANGELOG.md

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,3 @@
1-
## 0.26.0
2-
3-
### Breaking changes
4-
5-
This release migrates parry from `nalgebra` to `glam` (via the `glamx` crate) for future compatibility with
6-
`rust-gpu`. This is a major breaking change affecting almost all public APIs.
7-
8-
#### Type renames
9-
10-
- `Isometry``Pose` (using `glamx::Pose2`/`Pose3`)
11-
- `Rotation``Rot2`/`Rot3` (using `glamx::Rot2`/`Rot3`)
12-
- `IsometryOps``PoseOps`
13-
- `IsometryOpt``PoseOpt`
14-
15-
#### Removed types
16-
17-
- `Point<Real>` - use `Vector` instead. Points and vectors are now unified.
18-
- `UnitVector<Real>` - use `Vector` instead. Normalization is no longer encoded in the type.
19-
- `Translation<Real>` - use `Vector` for translations.
20-
21-
#### Math type changes
22-
23-
- `Vector` is now `glam::Vec2`/`Vec3`/`DVec2`/`DVec3` depending on dimension and precision features
24-
- `Matrix` is now `glam::Mat2`/`Mat3`/`DMat2`/`DMat3`
25-
- The `math` module now re-exports glam types and provides dimension-agnostic aliases
26-
27-
#### API signature changes
28-
29-
- Many functions that previously took `&Point<Real>` or `&Vector<Real>` now take `Vector` by value
30-
- Functions taking `&Isometry<Real>` now take `&Pose` or `Pose` by value
31-
- `HalfSpace::new` now takes `Vector` instead of `Unit<Vector<Real>>`
32-
- Shape constructors like `Segment::new`, `Triangle::new`, `Capsule::new` now take `Vector` instead of `Point`
33-
- `Aabb::mins` and `Aabb::maxs` are now `Vector` instead of `Point<Real>`
34-
35-
#### Migration guide
36-
37-
If your codebase currently relies on `nalgebra`, note that `nalgebra` and `glamx` provide type conversion. Enable the
38-
corresponding features:
39-
- `nalgebra = { version = "0.34", features = [ "convert-glam030" ] }`
40-
- `glamx = { version = "0.1", features = ["nalgebra"] }`
41-
then you can convert between `glam` and `nalgebra` types using `.into()`.
42-
43-
```rust
44-
// Before (nalgebra)
45-
use parry3d::na::{Point3, Vector3, Isometry3, Unit};
46-
let point = Point3::new(1.0, 2.0, 3.0);
47-
let vector = Vector3::new(1.0, 0.0, 0.0);
48-
let normal = Unit::new_normalize(vector);
49-
let pos = Isometry3::translation(1.0, 2.0, 3.0);
50-
51-
// After (glam)
52-
use parry3d::math::{Vector, Pose};
53-
let point = Vector::new(1.0, 2.0, 3.0); // Points are now Vector
54-
let vector = Vector::X;
55-
let normal = vector.normalize(); // No Unit wrapper
56-
let pos = Pose::translation(1.0, 2.0, 3.0);
57-
```
58-
59-
Common patterns:
60-
- `Point3::origin()``Vector::ZERO`
61-
- `Vector3::x()``Vector::X`
62-
- `point.coords` → just use the vector directly
63-
- `Unit::new_normalize(v)``v.normalize()`
64-
- `Isometry3::identity()``Pose::IDENTITY`
65-
- `isometry.translation.vector``pose.translation`
66-
67-
### Modified
68-
69-
- Re-export `glamx` instead of `nalgebra` as the public linear algebra dependency
70-
- Migrate visual examples from `macroquad` to `kiss3d`
71-
- Renamed `rkyv-serialize` feature to just `rkyv`
72-
731
## 0.25.3
742

753
- Significantly improve performances of `Voxels::combine_voxel_states`.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ parry3d = { path = "crates/parry3d" }
2727
parry2d-f64 = { path = "crates/parry2d-f64" }
2828
parry3d-f64 = { path = "crates/parry3d-f64" }
2929

30-
#glamx = { path = "../glamx" }
3130
#simba = { path = "../simba" }
3231
#simba = { git = "https://github.com/dimforge/simba", rev = "45a5266eb36ed9d25907e9bf9130cd4ac846a748" }
3332
#nalgebra = { git = "https://github.com/dimforge/nalgebra", rev = "0cf79aef0e6155befc3279a3145f1940822b8377" }

Claude.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cargo build -p parry2d
3535
cd crates/parry3d && cargo build --features simd-stable
3636

3737
# Build with all serialization features
38-
cargo build --features bytemuck-serialize,serde-serialize,rkyv
38+
cargo build --features bytemuck-serialize,serde-serialize,rkyv-serialize
3939

4040
# Build with enhanced determinism (incompatible with SIMD)
4141
cargo build --features enhanced-determinism

crates/parry2d-f64/Cargo.toml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "parry2d-f64"
3-
version = "0.26.0"
3+
version = "0.25.3"
44
authors = ["Sébastien Crozet <developer@crozet.re>"]
55

66
description = "2 dimensional collision detection library in Rust. 64-bit precision version."
@@ -23,7 +23,7 @@ workspace = true
2323
default = ["required-features", "std", "spade"]
2424
required-features = ["dim2", "f64"]
2525
std = [
26-
"glamx/std",
26+
"nalgebra/std",
2727
"slab",
2828
"simba/std",
2929
"arrayvec/std",
@@ -37,19 +37,23 @@ f64 = []
3737
serde-serialize = [
3838
"serde",
3939
"serde_arrays",
40-
"glamx/serde",
40+
"nalgebra/serde-serialize",
4141
"arrayvec/serde",
4242
"bitflags/serde",
4343
"hashbrown?/serde",
4444
"spade?/serde",
4545
]
46-
rkyv = ["dep:rkyv", "glamx/rkyv"]
47-
bytemuck-serialize = ["bytemuck", "glamx/bytemuck"]
46+
rkyv-serialize = [
47+
"rkyv/validation",
48+
"nalgebra/rkyv-serialize",
49+
"simba/rkyv-serialize",
50+
]
51+
bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"]
4852
simd-stable = ["simba/wide", "simd-is-enabled"]
4953
simd-nightly = ["simba/portable_simd", "simd-is-enabled"]
50-
enhanced-determinism = ["simba/libm_force", "indexmap", "glamx/libm"]
54+
enhanced-determinism = ["simba/libm_force", "indexmap"]
5155
parallel = ["rayon"]
52-
alloc = ["hashbrown"]
56+
alloc = ["nalgebra/alloc", "hashbrown"]
5357
spade = ["dep:spade", "alloc"]
5458
improved_fixed_point_support = []
5559

@@ -70,11 +74,11 @@ num-traits = { version = "0.2", default-features = false }
7074
slab = { version = "0.4", optional = true }
7175
arrayvec = { version = "0.7", default-features = false }
7276
simba = { version = "0.9", default-features = false }
73-
glamx = { version = "0.1.2", default-features = false, features = ["nostd-libm", "approx"] }
77+
nalgebra = { version = "0.34", default-features = false, features = ["libm", "macros"] }
7478
approx = { version = "0.5", default-features = false }
7579
serde = { version = "1.0", optional = true, features = ["derive"] }
7680
serde_arrays = { version = "0.2", optional = true }
77-
rkyv = { version = "0.8", optional = true, default-features = false, features = ["bytecheck", "alloc"] }
81+
rkyv = { version = "0.7.41", optional = true }
7882
num-derive = "0.4"
7983
indexmap = { version = "2", features = ["serde"], optional = true }
8084
hashbrown = { version = "0.16", optional = true, default-features = false, features = [

crates/parry2d/Cargo.toml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "parry2d"
3-
version = "0.26.0"
3+
version = "0.25.3"
44
authors = ["Sébastien Crozet <developer@crozet.re>"]
55

66
description = "2 dimensional collision detection library in Rust."
@@ -24,7 +24,7 @@ default = ["required-features", "std", "spade"]
2424
required-features = ["dim2", "f32"]
2525
std = [
2626
"alloc",
27-
"glamx/std",
27+
"nalgebra/std",
2828
"slab",
2929
"simba/std",
3030
"arrayvec/std",
@@ -37,22 +37,26 @@ f32 = []
3737
serde-serialize = [
3838
"serde",
3939
"serde_arrays",
40-
"glamx/serde",
40+
"nalgebra/serde-serialize",
4141
"arrayvec/serde",
4242
"bitflags/serde",
4343
"hashbrown?/serde",
4444
"spade?/serde",
4545
]
46-
rkyv = ["dep:rkyv", "glamx/rkyv"]
47-
bytemuck-serialize = ["bytemuck", "glamx/bytemuck"]
46+
rkyv-serialize = [
47+
"rkyv/validation",
48+
"nalgebra/rkyv-serialize",
49+
"simba/rkyv-serialize",
50+
]
51+
bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"]
4852
simd-stable = ["simba/wide", "simd-is-enabled"]
4953
simd-nightly = ["simba/portable_simd", "simd-is-enabled"]
50-
enhanced-determinism = ["simba/libm_force", "indexmap", "glamx/libm"]
54+
enhanced-determinism = ["simba/libm_force", "indexmap"]
5155
parallel = ["rayon"]
52-
alloc = ["hashbrown"]
56+
alloc = ["nalgebra/alloc", "hashbrown"]
5357
spade = ["dep:spade", "alloc"]
5458
improved_fixed_point_support = []
55-
encase = [ "dep:encase", "glamx/encase" ]
59+
encase = [ "dep:encase", "nalgebra/encase" ]
5660

5761
# Do not enable this feature directly. It is automatically
5862
# enabled with the "simd-stable" or "simd-nightly" feature.
@@ -71,11 +75,11 @@ num-traits = { version = "0.2", default-features = false }
7175
slab = { version = "0.4", optional = true }
7276
arrayvec = { version = "0.7", default-features = false }
7377
simba = { version = "0.9", default-features = false }
74-
glamx = { version = "0.1.2", default-features = false, features = ["nostd-libm", "approx"] }
78+
nalgebra = { version = "0.34", default-features = false, features = ["libm", "macros"] }
7579
approx = { version = "0.5", default-features = false }
7680
serde = { version = "1.0", optional = true, features = ["derive"] }
7781
serde_arrays = { version = "0.2", optional = true }
78-
rkyv = { version = "0.8", optional = true, default-features = false, features = ["bytecheck", "alloc"] }
82+
rkyv = { version = "0.7.41", optional = true }
7983
num-derive = "0.4"
8084
indexmap = { version = "2", features = ["serde"], optional = true }
8185
hashbrown = { version = "0.16", optional = true, default-features = false, features = [
@@ -97,8 +101,7 @@ simba = { version = "0.9", default-features = false }
97101
oorandom = "11"
98102
ptree = "0.4.0"
99103
rand = { version = "0.9" }
100-
kiss3d = "0.39"
101-
web-time = "1"
104+
macroquad = "0.4.12"
102105

103106
[package.metadata.docs.rs]
104107
rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]

crates/parry2d/examples/aabb2d.rs

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
1-
mod utils2d;
1+
mod common_macroquad2d;
22

3-
use kiss3d::prelude::*;
4-
use parry2d::bounding_volume::BoundingVolume;
5-
use parry2d::math::Pose;
3+
extern crate nalgebra as na;
4+
5+
use common_macroquad2d::{draw_polyline, lissajous_2d, mquad_from_na, na_from_mquad};
6+
use macroquad::prelude::*;
7+
use na::Isometry2;
8+
use parry2d::bounding_volume::{Aabb, BoundingVolume};
69
use parry2d::shape::Ball;
7-
use utils2d::{draw_aabb2, draw_circle, lissajous_2d};
810

911
const RENDER_SCALE: f32 = 30.0;
1012

11-
#[kiss3d::main]
13+
#[macroquad::main("aabb2d")]
1214
async fn main() {
13-
let mut window = Window::new("aabb2d").await;
14-
let mut camera = PanZoomCamera2d::new(Vec2::ZERO, 4.0);
15-
let mut scene = SceneNode2d::empty();
16-
17-
let start_time = web_time::Instant::now();
15+
let render_pos = Vec2::new(300.0, 300.0);
1816

19-
while window.render_2d(&mut scene, &mut camera).await {
20-
let elapsed_time = start_time.elapsed().as_secs_f32() * 0.7;
17+
loop {
18+
let elapsed_time = get_time() as f32 * 0.7;
19+
clear_background(BLACK);
2120

2221
/*
2322
* Initialize the shapes.
2423
*/
2524
let ball1 = Ball::new(0.5);
2625
let ball2 = Ball::new(1.0);
2726

28-
let ball1_pos = lissajous_2d(elapsed_time) * 5f32;
29-
let ball1_pose = Pose::from_translation(ball1_pos);
30-
let ball2_pose = Pose::identity();
27+
let ball1_pos = na_from_mquad(lissajous_2d(elapsed_time)) * 5f32;
28+
let ball2_pos = Isometry2::identity();
3129

3230
/*
3331
* Compute their axis-aligned bounding boxes.
3432
*/
35-
let aabb_ball1 = ball1.aabb(&ball1_pose);
36-
let aabb_ball2 = ball2.aabb(&ball2_pose);
33+
let aabb_ball1 = ball1.aabb(&ball1_pos.into());
34+
let aabb_ball2 = ball2.aabb(&ball2_pos);
3735

3836
// Merge the two boxes.
3937
let bounding_aabb = aabb_ball1.merged(&aabb_ball2);
@@ -52,49 +50,52 @@ async fn main() {
5250
assert!(bounding_aabb.contains(&aabb_ball2));
5351
assert!(loose_aabb_ball2.contains(&aabb_ball2));
5452

53+
let ball1_translation = mquad_from_na(ball1_pos.coords.into()) * RENDER_SCALE + render_pos;
5554
draw_circle(
56-
&mut window,
57-
ball1_pos * RENDER_SCALE,
55+
ball1_translation.x,
56+
ball1_translation.y,
5857
ball1.radius * RENDER_SCALE,
5958
color,
6059
);
60+
let ball2_translation =
61+
mquad_from_na(ball2_pos.translation.vector.into()) * RENDER_SCALE + render_pos;
6162
draw_circle(
62-
&mut window,
63-
ball2_pose.translation * RENDER_SCALE,
63+
ball2_translation.x,
64+
ball2_translation.y,
6465
ball2.radius * RENDER_SCALE,
6566
color,
6667
);
6768

68-
draw_aabb2(
69-
&mut window,
70-
aabb_ball1.mins * RENDER_SCALE,
71-
aabb_ball1.maxs * RENDER_SCALE,
72-
color,
73-
);
74-
draw_aabb2(
75-
&mut window,
76-
aabb_ball2.mins * RENDER_SCALE,
77-
aabb_ball2.maxs * RENDER_SCALE,
78-
color,
79-
);
80-
draw_aabb2(
81-
&mut window,
82-
bounding_aabb.mins * RENDER_SCALE,
83-
bounding_aabb.maxs * RENDER_SCALE,
84-
YELLOW,
85-
);
69+
draw_aabb(aabb_ball1, render_pos, color);
70+
draw_aabb(aabb_ball2, render_pos, color);
71+
draw_aabb(bounding_aabb, render_pos, YELLOW);
8672

8773
// Inclusion test
8874
let color_included: Color = if loose_aabb_ball2.contains(&aabb_ball1) {
8975
BLUE
9076
} else {
9177
MAGENTA
9278
};
93-
draw_aabb2(
94-
&mut window,
95-
loose_aabb_ball2.mins * RENDER_SCALE,
96-
loose_aabb_ball2.maxs * RENDER_SCALE,
97-
color_included,
98-
);
79+
draw_aabb(loose_aabb_ball2, render_pos, color_included);
80+
next_frame().await
9981
}
10082
}
83+
84+
fn draw_aabb(aabb: Aabb, offset: Vec2, color: Color) {
85+
let mins = mquad_from_na(aabb.mins) * RENDER_SCALE + offset;
86+
let maxs = mquad_from_na(aabb.maxs) * RENDER_SCALE + offset;
87+
88+
let line = vec![
89+
Vec2::new(mins.x, mins.y),
90+
Vec2::new(mins.x, maxs.y),
91+
Vec2::new(maxs.x, maxs.y),
92+
Vec2::new(maxs.x, mins.y),
93+
Vec2::new(mins.x, mins.y),
94+
];
95+
let drawable_line = line
96+
.iter()
97+
.zip(line.iter().cycle().skip(1).take(line.len()))
98+
.map(|item| (item.0.clone(), item.1.clone()))
99+
.collect();
100+
draw_polyline(drawable_line, color);
101+
}

0 commit comments

Comments
 (0)