diff --git a/core/src/events.rs b/core/src/events.rs index a644be65..c4f59320 100644 --- a/core/src/events.rs +++ b/core/src/events.rs @@ -106,13 +106,13 @@ impl CollisionData { rigid_body_entity: Entity, collision_shape_entity: Entity, collision_layers: CollisionLayers, - normals: SmallVec<[Vec2; 1]>, + normals: impl IntoIterator, ) -> Self { Self { rigid_body_entity, collision_shape_entity, collision_layers, - normals, + normals: normals.into_iter().collect(), } } diff --git a/rapier/src/pipeline.rs b/rapier/src/pipeline.rs index 2f281cc3..d35a3f67 100644 --- a/rapier/src/pipeline.rs +++ b/rapier/src/pipeline.rs @@ -476,30 +476,24 @@ impl EventManager { collider1.parent().and_then(|parent| bodies.get(parent)), collider2.parent().and_then(|parent| bodies.get(parent)), ) { - let normals1 = narrow_phase - .contact_pair(h1, h2) - .map(|contact_pair| { - contact_pair - .manifolds - .iter() - .map(|manifold| { + let normals1 = + narrow_phase + .contact_pair(h1, h2) + .into_iter() + .flat_map(|contact_pair| { + contact_pair.manifolds.iter().map(|manifold| { Vec2::new(manifold.data.normal.x, manifold.data.normal.y) }) - .collect() - }) - .unwrap_or_default(); - let normals2 = narrow_phase - .contact_pair(h2, h1) - .map(|contact_pair| { - contact_pair - .manifolds - .iter() - .map(|manifold| { + }); + let normals2 = + narrow_phase + .contact_pair(h2, h1) + .into_iter() + .flat_map(|contact_pair| { + contact_pair.manifolds.iter().map(|manifold| { Vec2::new(manifold.data.normal.x, manifold.data.normal.y) }) - .collect() - }) - .unwrap_or_default(); + }); let d1 = CollisionData::new( Entity::from_bits(rb1.user_data as u64),