From f900cafee417e013e20eeb5e41569344e30828ff Mon Sep 17 00:00:00 2001 From: Joona Aalto Date: Wed, 1 Jan 2025 23:40:15 +0200 Subject: [PATCH 1/8] Only store a world-space normal for `ContactManifold` --- crates/avian2d/examples/custom_collider.rs | 5 +- .../examples/kinematic_character_2d/plugin.rs | 13 ++--- .../avian2d/examples/one_way_platform_2d.rs | 20 +++++--- .../examples/kinematic_character_3d/plugin.rs | 13 ++--- src/collision/contact_query.rs | 39 +++++++-------- src/collision/mod.rs | 47 ++----------------- src/debug_render/mod.rs | 16 +++++-- src/dynamics/solver/contact/mod.rs | 20 +++----- 8 files changed, 61 insertions(+), 112 deletions(-) diff --git a/crates/avian2d/examples/custom_collider.rs b/crates/avian2d/examples/custom_collider.rs index 107d231d..aaaf580c 100644 --- a/crates/avian2d/examples/custom_collider.rs +++ b/crates/avian2d/examples/custom_collider.rs @@ -90,15 +90,12 @@ impl AnyCollider for CircleCollider { vec![ContactManifold { index: 0, - normal1, - normal2, + normal: rotation1 * normal1, contacts: vec![ContactData { feature_id1: PackedFeatureId::face(0), feature_id2: PackedFeatureId::face(0), point1, point2, - normal1, - normal2, penetration: sum_radius - distance_squared.sqrt(), // Impulses are computed by the constraint solver normal_impulse: 0.0, diff --git a/crates/avian2d/examples/kinematic_character_2d/plugin.rs b/crates/avian2d/examples/kinematic_character_2d/plugin.rs index 3e4f5c1c..eb5f8d56 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