Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Commit

Permalink
feat: let CollisionData::new accept any implementation of `IntoIter…
Browse files Browse the repository at this point in the history
…ator<Item=Vec2>` (#211)
  • Loading branch information
jcornaz committed Mar 6, 2022
1 parent 62f87b2 commit df3169a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
4 changes: 2 additions & 2 deletions core/src/events.rs
Expand Up @@ -106,13 +106,13 @@ impl CollisionData {
rigid_body_entity: Entity,
collision_shape_entity: Entity,
collision_layers: CollisionLayers,
normals: SmallVec<[Vec2; 1]>,
normals: impl IntoIterator<Item = Vec2>,
) -> Self {
Self {
rigid_body_entity,
collision_shape_entity,
collision_layers,
normals,
normals: normals.into_iter().collect(),
}
}

Expand Down
34 changes: 14 additions & 20 deletions rapier/src/pipeline.rs
Expand Up @@ -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),
Expand Down

0 comments on commit df3169a

Please sign in to comment.