Compare commits
4 Commits
md-generic
...
test-fail
| Author | SHA1 | Date | |
|---|---|---|---|
|
ddfeca41e9
|
|||
|
8f580ad6ba
|
|||
|
68e81b31ba
|
|||
|
cbd6e1a608
|
@@ -3,6 +3,8 @@ use strafesnet_common::integer::vec3::Vector3;
|
||||
use strafesnet_common::integer::{Fixed,Planar64,Planar64Vec3};
|
||||
|
||||
use crate::model::{DirectedEdge,FEV,MeshQuery};
|
||||
// TODO: remove mesh invert
|
||||
use crate::model::{MinkowskiMesh,MinkowskiVert};
|
||||
|
||||
// This algorithm is based on Lua code
|
||||
// written by Trey Reynolds in 2021
|
||||
@@ -502,10 +504,10 @@ impl<Vert> Simplex2_4<Vert>{
|
||||
}
|
||||
}
|
||||
|
||||
pub fn contains_point<M:MeshQuery>(mesh:&M,point:Planar64Vec3)->bool{
|
||||
pub fn contains_point(mesh:&MinkowskiMesh<'_>,point:Planar64Vec3)->bool{
|
||||
const ENABLE_FAST_FAIL:bool=true;
|
||||
// TODO: remove mesh negation
|
||||
minimum_difference::<ENABLE_FAST_FAIL,_,M>(&-mesh,point,
|
||||
minimum_difference::<ENABLE_FAST_FAIL,_,_>(&-mesh,point,
|
||||
// on_exact
|
||||
|is_intersecting,_simplex|{
|
||||
is_intersecting
|
||||
@@ -672,7 +674,7 @@ fn crawl_to_closest_ev<M:MeshQuery>(mesh:&M,simplex:Simplex<2,M::Vert>,point:Pla
|
||||
}
|
||||
|
||||
/// This function drops a vertex down to an edge or a face if the path from infinity did not cross any vertex-edge boundaries but the point is supposed to have already crossed a boundary down from a vertex
|
||||
fn crawl_to_closest_fev<M:MeshQuery>(mesh:&M,simplex:Simplex<3,M::Vert>,point:Planar64Vec3)->FEV::<M>{
|
||||
fn crawl_to_closest_fev<'a>(mesh:&MinkowskiMesh<'a>,simplex:Simplex<3,MinkowskiVert>,point:Planar64Vec3)->FEV::<MinkowskiMesh<'a>>{
|
||||
// naively start at the closest vertex
|
||||
// the closest vertex is not necessarily the one with the fewest boundary hops
|
||||
// but it doesn't matter, we will get there regardless.
|
||||
@@ -719,10 +721,10 @@ fn crawl_to_closest_fev<M:MeshQuery>(mesh:&M,simplex:Simplex<3,M::Vert>,point:Pl
|
||||
}
|
||||
}
|
||||
|
||||
pub fn closest_fev_not_inside<M:MeshQuery>(mesh:&M,point:Planar64Vec3)->Option<FEV<M>>{
|
||||
pub fn closest_fev_not_inside<'a>(mesh:&MinkowskiMesh<'a>,point:Planar64Vec3)->Option<FEV<MinkowskiMesh<'a>>>{
|
||||
const ENABLE_FAST_FAIL:bool=false;
|
||||
// TODO: remove mesh negation
|
||||
minimum_difference::<ENABLE_FAST_FAIL,_,M>(&-mesh,point,
|
||||
minimum_difference::<ENABLE_FAST_FAIL,_,_>(&-mesh,point,
|
||||
// on_exact
|
||||
|is_intersecting,simplex|{
|
||||
if is_intersecting{
|
||||
@@ -841,4 +843,33 @@ fn minimum_difference<const ENABLE_FAST_FAIL:bool,T,M:MeshQuery>(
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: unit tests
|
||||
#[cfg(test)]
|
||||
mod test{
|
||||
use super::*;
|
||||
use crate::model::{PhysicsMesh,PhysicsMeshView};
|
||||
|
||||
fn mesh_contains_point(mesh:PhysicsMeshView<'_>,point:Planar64Vec3)->bool{
|
||||
const ENABLE_FAST_FAIL:bool=true;
|
||||
// TODO: remove mesh negation
|
||||
minimum_difference::<ENABLE_FAST_FAIL,_,_>(&mesh,point,
|
||||
// on_exact
|
||||
|is_intersecting,_simplex|{
|
||||
is_intersecting
|
||||
},
|
||||
// on_escape
|
||||
|_simplex|{
|
||||
// intersection is guaranteed at this point
|
||||
true
|
||||
},
|
||||
// fast_fail value
|
||||
||false
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cube_points(){
|
||||
let mesh=PhysicsMesh::unit_cube();
|
||||
let mesh_view=mesh.complete_mesh_view();
|
||||
assert!(mesh_contains_point(mesh_view,vec3::NEG_Z));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user