diff --git a/crates/avian2d/Cargo.toml b/crates/avian2d/Cargo.toml index e82e0803..7cefeb41 100644 --- a/crates/avian2d/Cargo.toml +++ b/crates/avian2d/Cargo.toml @@ -73,6 +73,7 @@ nalgebra = { version = "0.33", features = ["convert-glam029"], optional = true } serde = { version = "1", features = ["derive"], optional = true } derive_more = "1" indexmap = "2.0.0" +arrayvec = "0.7" fxhash = "0.2.1" itertools = "0.13" bitflags = "2.5.0" diff --git a/crates/avian2d/examples/custom_collider.rs b/crates/avian2d/examples/custom_collider.rs index 107d231d..f3b51385 100644 --- a/crates/avian2d/examples/custom_collider.rs +++ b/crates/avian2d/examples/custom_collider.rs @@ -79,31 +79,28 @@ impl AnyCollider for CircleCollider { let sum_radius = self.radius + other.radius; if distance_squared < (sum_radius + prediction_distance).powi(2) { - let normal1 = if distance_squared != 0.0 { + let local_normal1 = if distance_squared != 0.0 { delta_pos.normalize_or_zero() } else { Vector::X }; - let normal2 = delta_rot.inverse() * (-normal1); - let point1 = normal1 * self.radius; - let point2 = normal2 * other.radius; + let local_normal2 = delta_rot.inverse() * (-local_normal1); + let local_point1 = local_normal1 * self.radius; + let local_point2 = local_normal2 * other.radius; vec![ContactManifold { index: 0, - normal1, - normal2, - contacts: vec![ContactData { - feature_id1: PackedFeatureId::face(0), - feature_id2: PackedFeatureId::face(0), - point1, - point2, - normal1, - normal2, + normal: rotation1 * local_normal1, + points: avian2d::data_structures::ArrayVec::from_iter([ContactPoint { + local_point1, + local_point2, penetration: sum_radius - distance_squared.sqrt(), - // Impulses are computed by the constraint solver + // Impulses are computed by the constraint solver. normal_impulse: 0.0, tangent_impulse: 0.0, - }], + feature_id1: PackedFeatureId::face(0), + feature_id2: PackedFeatureId::face(0), + }]), }] } else { vec![] diff --git a/crates/avian2d/examples/kinematic_character_2d/plugin.rs b/crates/avian2d/examples/kinematic_character_2d/plugin.rs index 3e4f5c1c..3c981327 100644 --- a/crates/avian2d/examples/kinematic_character_2d/plugin.rs +++ b/crates/avian2d/examples/kinematic_character_2d/plugin.rs @@ -269,12 +269,7 @@ fn kinematic_controller_collisions( bodies: Query<&RigidBody>, collider_parents: Query<&ColliderParent, Without>, mut character_controllers: Query< - ( - &mut Position, - &Rotation, - &mut LinearVelocity, - Option<&MaxSlopeAngle>, - ), + (&mut Position, &mut LinearVelocity, Option<&MaxSlopeAngle>), (With, With), >, time: Res