Skip to content
Open
Show file tree
Hide file tree
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
34 changes: 34 additions & 0 deletions crates/parry3d/tests/geometry/trimesh_intersection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,40 @@ fn build_diamond(position: &Isometry<Real>) -> TriMesh {
TriMesh::new(points, indices).unwrap()
}

fn build_square(position: &Isometry<Real>) -> TriMesh {
// Square from two triangles
let points = vec![
position * Point3::new(-2.0, 0.0, -2.0),
position * Point3::new(0.0, -1.0, -2.0),
position * Point3::new(0.0, 0.0, -2.0),
position * Point3::new(0.0, 0.0, 0.0),
];

let indices = vec![
[0u32, 1, 2],
[1, 3, 2],
];

TriMesh::new(points, indices).unwrap()
}

#[test]
fn trimesh_plane_square_intersection() {
let mesh = build_square(&Isometry::identity());

let result = mesh.intersection_with_local_plane(&Vector3::ith_axis(2), -1.0, std::f32::EPSILON);

assert!(matches!(result, IntersectResult::Intersect(_)));

if let IntersectResult::Intersect(line) = result {
// Need to check points individually since order is not guaranteed
let vertices = line.vertices();
assert_eq!(vertices.len(), 2);
assert!(vertices.contains(&Point3::new(0.0, -0.5, -1.0)));
assert!(vertices.contains(&Point3::new(0.0, 0.0, -1.0)));
}
}

#[test]
fn trimesh_plane_edge_intersection() {
let mesh = build_diamond(&Isometry::identity());
Expand Down
2 changes: 2 additions & 0 deletions src/query/split/split_trimesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,8 @@ impl TriMesh {
continue 'traversal;
}
}

next = None;
}
}
}
Expand Down