Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntersectionCompositeShapeShapeVisitor is now able to return partId #293

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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 @@ -38,15 +38,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 @@ -69,7 +75,7 @@ where
pos12,
g1,
g2,
found_intersection: false,
found_intersection: None,
}
}
}
Expand Down Expand Up @@ -103,7 +109,7 @@ where
});

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