Skip to content

Commit

Permalink
IntersectionCompositeShapeShapeVisitor is now able to return partId
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Dec 6, 2024
1 parent 0e4705c commit f3db16b
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ where
let mut visitor = IntersectionCompositeShapeShapeVisitor::new(dispatcher, pos12, g1, g2);

let _ = g1.typed_qbvh().traverse_depth_first(&mut visitor);
visitor.found_intersection
visitor.found_intersection.is_some()
}

/// Proximity between a shape and a composite (`Mesh`, `Compound`) shape.
Expand All @@ -41,15 +41,21 @@ where
}

/// A visitor for checking if a composite-shape and a shape intersect.
pub struct IntersectionCompositeShapeShapeVisitor<'a, D: ?Sized, G1: ?Sized + 'a> {
pub struct IntersectionCompositeShapeShapeVisitor<'a, D: ?Sized, G1: 'a>
where
G1: ?Sized + TypedSimdCompositeShape,
{
ls_aabb2: SimdAabb,

dispatcher: &'a D,
pos12: &'a Isometry<Real>,
g1: &'a G1,
g2: &'a dyn Shape,

found_intersection: bool,
/// Populated after the traversal.
///
/// Is [`None`] if no intersection was found.
pub found_intersection: Option<G1::PartId>,
}

impl<'a, D, G1> IntersectionCompositeShapeShapeVisitor<'a, D, G1>
Expand All @@ -72,7 +78,7 @@ where
pos12,
g1,
g2,
found_intersection: false,
found_intersection: None,
}
}
}
Expand Down Expand Up @@ -106,7 +112,7 @@ where
});

if found_intersection {
self.found_intersection = true;
self.found_intersection = Some(part_id);
return SimdVisitStatus::ExitEarly;
}
}
Expand Down

0 comments on commit f3db16b

Please sign in to comment.