-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat TriMesh as solid in project_local_point_and_get_feature with = …
…dim2
- Loading branch information
Showing
3 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
mod point_composite_shape; | ||
mod point_triangle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use na::Point2; | ||
use parry2d::{query::PointQuery, shape::TriMesh}; | ||
|
||
#[test] | ||
fn project_local_point_and_get_feature_gets_the_enclosing_triangle() { | ||
let vertices = vec![ | ||
Point2::new(0.0, 1.0), | ||
Point2::new(0.0, 0.0), | ||
Point2::new(1.0, 0.0), | ||
Point2::new(1.0, 1.0), | ||
]; | ||
|
||
let mesh = TriMesh::new(vertices, vec![[0, 1, 2], [3, 0, 2]]); | ||
let query_pt = Point2::new(0.6, 0.6); // Inside the top-right triangle (index 1) | ||
|
||
let (proj, feat) = mesh.project_local_point_and_get_feature(&query_pt); | ||
|
||
let correct_tri_idx = 1; | ||
let correct_tri = mesh.triangle(correct_tri_idx); | ||
|
||
let is_inside_correct = correct_tri.contains_local_point(&query_pt); | ||
|
||
assert!(is_inside_correct); | ||
assert_eq!(proj.is_inside, is_inside_correct); | ||
assert_eq!(feat.unwrap_face(), correct_tri_idx); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters