Skip to content
Merged
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
293 changes: 85 additions & 208 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions crates/avian2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enhanced-determinism = [
"parry2d-f64?/enhanced-determinism",
]

default-collider = ["dep:nalgebra"]
default-collider = []
# We unfortunately can't reuse the f32 and f64 features for this,
# because Parry uses separate crates for f32 and f64.
parry-f32 = ["f32", "dep:parry2d", "default-collider"]
Expand Down Expand Up @@ -87,16 +87,15 @@ bevy_heavy = { version = "0.4" }
bevy_transform_interpolation = { version = "0.4" }
libm = { version = "0.2", optional = true }
approx = "0.5"
parry2d = { version = "0.25", optional = true }
parry2d-f64 = { version = "0.25", optional = true }
nalgebra = { version = "0.34", features = ["convert-glam030"], optional = true }
parry2d = { version = "0.26", optional = true }
parry2d-f64 = { version = "0.26", optional = true }
obvhs = { version = "0.3" }
serde = { version = "1", features = ["derive"], optional = true }
derive_more = "2"
thiserror = "2"
arrayvec = "0.7"
smallvec = "1.15"
itertools = "0.13"
itertools = "0.14"
bitflags = "2.5.0"
thread_local = { version = "1.1" }
disqualified = { version = "1.0" }
Expand All @@ -107,7 +106,7 @@ bevy = { version = "0.18.0", default-features = false, features = ["2d", "ui"] }
bevy_heavy = { version = "0.4", features = ["approx"] }
glam = { version = "0.30", features = ["bytemuck"] }
bytemuck = "1.19"
criterion = { version = "0.5", features = ["html_reports"] }
criterion = { version = "0.8", features = ["html_reports"] }
bevy_mod_debugdump = { version = "0.15" }

[lints]
Expand Down
11 changes: 5 additions & 6 deletions crates/avian3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ enhanced-determinism = [
"parry3d-f64?/enhanced-determinism",
]

default-collider = ["dep:nalgebra"]
default-collider = []
# We unfortunately can't reuse the f32 and f64 features for this,
# because Parry uses separate crates for f32 and f64.
parry-f32 = ["f32", "dep:parry3d", "default-collider"]
Expand Down Expand Up @@ -89,15 +89,14 @@ bevy_heavy = { version = "0.4" }
bevy_transform_interpolation = { version = "0.4" }
libm = { version = "0.2", optional = true }
approx = "0.5"
parry3d = { version = "0.25", optional = true }
parry3d-f64 = { version = "0.25", optional = true }
nalgebra = { version = "0.34", features = ["convert-glam030"], optional = true }
parry3d = { version = "0.26", optional = true }
parry3d-f64 = { version = "0.26", optional = true }
obvhs = { version = "0.3" }
serde = { version = "1", features = ["derive"], optional = true }
derive_more = "2"
thiserror = "2"
smallvec = "1.15"
itertools = "0.13"
itertools = "0.14"
bitflags = "2.5.0"
thread_local = { version = "1.1" }
disqualified = { version = "1.0" }
Expand All @@ -111,7 +110,7 @@ bevy = { version = "0.18.0", features = [
"experimental_bevy_feathers",
] }
bevy_heavy = { version = "0.4", features = ["approx"] }
criterion = { version = "0.5", features = ["html_reports"] }
criterion = { version = "0.8", features = ["html_reports"] }
bevy_mod_debugdump = { version = "0.15" }
rand = "0.9"

Expand Down
4 changes: 2 additions & 2 deletions src/collision/collider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ impl ColliderAabb {
pub fn from_shape(shape: &crate::parry::shape::SharedShape) -> Self {
let aabb = shape.compute_local_aabb();
Self {
min: aabb.mins.into(),
max: aabb.maxs.into(),
min: aabb.mins,
max: aabb.maxs,
}
}

Expand Down
58 changes: 27 additions & 31 deletions src/collision/collider/parry/contact_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ pub fn contact(
) -> Result<Option<SingleContact>, UnsupportedShape> {
let rotation1: Rotation = rotation1.into();
let rotation2: Rotation = rotation2.into();
let isometry1 = make_isometry(position1.into(), rotation1);
let isometry2 = make_isometry(position2.into(), rotation2);
let isometry1 = make_pose(position1, rotation1);
let isometry2 = make_pose(position2, rotation2);

parry::query::contact(
&isometry1,
Expand All @@ -85,10 +85,10 @@ pub fn contact(
.map(|contact| {
if let Some(contact) = contact {
// Transform contact data into local space
let point1: Vector = rotation1.inverse() * Vector::from(contact.point1);
let point2: Vector = rotation2.inverse() * Vector::from(contact.point2);
let normal1: Vector = (rotation1.inverse() * Vector::from(contact.normal1)).normalize();
let normal2: Vector = (rotation2.inverse() * Vector::from(contact.normal2)).normalize();
let point1: Vector = rotation1.inverse() * contact.point1;
let point2: Vector = rotation2.inverse() * contact.point2;
let normal1: Vector = (rotation1.inverse() * contact.normal1).normalize();
let normal2: Vector = (rotation2.inverse() * contact.normal2).normalize();

// Make sure the normals are valid
if !normal1.is_normalized() || !normal2.is_normalized() {
Expand Down Expand Up @@ -167,8 +167,8 @@ pub fn contact_manifolds(
let position2: Position = position2.into();
let rotation1: Rotation = rotation1.into();
let rotation2: Rotation = rotation2.into();
let isometry1 = make_isometry(position1, rotation1);
let isometry2 = make_isometry(position2, rotation2);
let isometry1 = make_pose(position1, rotation1);
let isometry2 = make_pose(position2, rotation2);
let isometry12 = isometry1.inv_mul(&isometry2);

// TODO: Reuse manifolds from previous frame to improve performance
Expand Down Expand Up @@ -199,14 +199,14 @@ pub fn contact_manifolds(
prediction_distance,
)
{
let normal = rotation1 * Vector::from(contact.normal1);
let normal = rotation1 * contact.normal1;

// Make sure the normal is valid
if !normal.is_normalized() {
return;
}

let local_point1: Vector = contact.point1.into();
let local_point1: Vector = contact.point1;

// The contact point is the midpoint of the two points in world space.
// The anchors are relative to the positions of the colliders.
Expand All @@ -231,11 +231,7 @@ pub fn contact_manifolds(
}

let subpos1 = manifold.subshape_pos1.unwrap_or_default();
let local_normal: Vector = subpos1
.rotation
.transform_vector(&manifold.local_n1)
.normalize()
.into();
let local_normal: Vector = (subpos1.rotation * manifold.local_n1).normalize();
let normal = rotation1 * local_normal;

// Make sure the normal is valid
Expand All @@ -246,7 +242,7 @@ pub fn contact_manifolds(
let points = manifold.contacts().iter().map(|contact| {
// The contact point is the midpoint of the two points in world space.
// The anchors are relative to the positions of the colliders.
let point1 = rotation1 * Vector::from(subpos1.transform_point(&contact.local_p1));
let point1 = rotation1 * subpos1.transform_point(contact.local_p1);
let anchor1 = point1 + normal * contact.dist * 0.5;
let anchor2 = anchor1 + (position1.0 - position2.0);
let world_point = position1.0 + anchor1;
Expand Down Expand Up @@ -355,8 +351,8 @@ pub fn closest_points(
) -> Result<ClosestPoints, UnsupportedShape> {
let rotation1: Rotation = rotation1.into();
let rotation2: Rotation = rotation2.into();
let isometry1 = make_isometry(position1.into(), rotation1);
let isometry2 = make_isometry(position2.into(), rotation2);
let isometry1 = make_pose(position1, rotation1);
let isometry2 = make_pose(position2, rotation2);

parry::query::closest_points(
&isometry1,
Expand All @@ -368,7 +364,7 @@ pub fn closest_points(
.map(|closest_points| match closest_points {
parry::query::ClosestPoints::Intersecting => ClosestPoints::Intersecting,
parry::query::ClosestPoints::WithinMargin(point1, point2) => {
ClosestPoints::WithinMargin(point1.into(), point2.into())
ClosestPoints::WithinMargin(point1, point2)
}
parry::query::ClosestPoints::Disjoint => ClosestPoints::OutsideMargin,
})
Expand Down Expand Up @@ -432,8 +428,8 @@ pub fn distance(
) -> Result<Scalar, UnsupportedShape> {
let rotation1: Rotation = rotation1.into();
let rotation2: Rotation = rotation2.into();
let isometry1 = make_isometry(position1.into(), rotation1);
let isometry2 = make_isometry(position2.into(), rotation2);
let isometry1 = make_pose(position1, rotation1);
let isometry2 = make_pose(position2, rotation2);

parry::query::distance(
&isometry1,
Expand Down Expand Up @@ -500,8 +496,8 @@ pub fn intersection_test(
) -> Result<bool, UnsupportedShape> {
let rotation1: Rotation = rotation1.into();
let rotation2: Rotation = rotation2.into();
let isometry1 = make_isometry(position1.into(), rotation1);
let isometry2 = make_isometry(position2.into(), rotation2);
let isometry1 = make_pose(position1, rotation1);
let isometry2 = make_pose(position2, rotation2);

parry::query::intersection_test(
&isometry1,
Expand Down Expand Up @@ -588,15 +584,15 @@ pub fn time_of_impact(
let velocity1: LinearVelocity = velocity1.into();
let velocity2: LinearVelocity = velocity2.into();

let isometry1 = make_isometry(position1.into(), rotation1);
let isometry2 = make_isometry(position2.into(), rotation2);
let isometry1 = make_pose(position1, rotation1);
let isometry2 = make_pose(position2, rotation2);

parry::query::cast_shapes(
&isometry1,
&velocity1.0.into(),
velocity1.0,
collider1.shape_scaled().0.as_ref(),
&isometry2,
&velocity2.0.into(),
velocity2.0,
collider2.shape_scaled().0.as_ref(),
ShapeCastOptions {
max_time_of_impact,
Expand All @@ -607,10 +603,10 @@ pub fn time_of_impact(
.map(|toi| {
toi.map(|toi| TimeOfImpact {
time_of_impact: toi.time_of_impact,
point1: toi.witness1.into(),
point2: toi.witness2.into(),
normal1: toi.normal1.into(),
normal2: toi.normal2.into(),
point1: toi.witness1,
point2: toi.witness2,
normal1: toi.normal1,
normal2: toi.normal2,
status: toi.status,
})
})
Expand Down
Loading