|
|
|
|
@@ -191,7 +191,7 @@ fn reduce2<M:MeshQuery<Position=Planar64Vec3>>(
|
|
|
|
|
let p_u=p.dot(u);
|
|
|
|
|
|
|
|
|
|
// if p_u >= 0 then
|
|
|
|
|
if !p_u.is_negative(){
|
|
|
|
|
if p_u.is_positive(){
|
|
|
|
|
// local direction = u:Cross(p):Cross(u)
|
|
|
|
|
let direction=u.cross(p).cross(u);
|
|
|
|
|
|
|
|
|
|
@@ -263,7 +263,7 @@ fn reduce3<M:MeshQuery<Position=Planar64Vec3>>(
|
|
|
|
|
let uv_pv=uv.dot(pv);
|
|
|
|
|
|
|
|
|
|
// if uv_up >= 0 and uv_pv >= 0 then
|
|
|
|
|
if !uv_up.is_negative()&&!uv_pv.is_negative(){
|
|
|
|
|
if uv_up.is_positive()&&uv_pv.is_positive(){
|
|
|
|
|
// local uvp = uv:Dot(p)
|
|
|
|
|
let uvp=uv.dot(p);
|
|
|
|
|
|
|
|
|
|
@@ -303,7 +303,7 @@ fn reduce3<M:MeshQuery<Position=Planar64Vec3>>(
|
|
|
|
|
let p_u=p.dot(u);
|
|
|
|
|
|
|
|
|
|
// if p_u >= 0 then
|
|
|
|
|
if !p_u.is_negative(){
|
|
|
|
|
if p_u.is_positive(){
|
|
|
|
|
// local direction = up:Cross(u)
|
|
|
|
|
let direction=up.cross(u);
|
|
|
|
|
// if direction.magnitude == 0 then
|
|
|
|
|
@@ -384,9 +384,9 @@ fn reduce4<M:MeshQuery<Position=Planar64Vec3>>(
|
|
|
|
|
let uv_p=uv.dot(p);
|
|
|
|
|
|
|
|
|
|
// if pvw/uvw >= 0 and upw/uvw >= 0 and uvp/uvw >= 0 then
|
|
|
|
|
if !pv_w.div_sign(uv_w).is_negative()
|
|
|
|
|
&&!up_w.div_sign(uv_w).is_negative()
|
|
|
|
|
&&!uv_p.div_sign(uv_w).is_negative(){
|
|
|
|
|
if pv_w.div_sign(uv_w).is_positive()
|
|
|
|
|
&&up_w.div_sign(uv_w).is_positive()
|
|
|
|
|
&&uv_p.div_sign(uv_w).is_positive(){
|
|
|
|
|
// origin is contained, this is a positive detection
|
|
|
|
|
// local direction = Vector3.new(0, 0, 0)
|
|
|
|
|
// return direction, a0, a1, b0, b1, c0, c1, d0, d1
|
|
|
|
|
@@ -439,7 +439,7 @@ fn reduce4<M:MeshQuery<Position=Planar64Vec3>>(
|
|
|
|
|
let uv_pv=uv.dot(pv);
|
|
|
|
|
|
|
|
|
|
// if uv_up >= 0 and uv_pv >= 0 then
|
|
|
|
|
if !uv_up.is_negative()&&!uv_pv.is_negative(){
|
|
|
|
|
if uv_up.is_positive()&&uv_pv.is_positive(){
|
|
|
|
|
// local direction = uvw < 0 and uv or -uv
|
|
|
|
|
// return direction, a0, a1, b0, b1, c0, c1
|
|
|
|
|
let dir=if uv_w.is_negative(){
|
|
|
|
|
@@ -475,7 +475,7 @@ fn reduce4<M:MeshQuery<Position=Planar64Vec3>>(
|
|
|
|
|
let p_u=p.dot(u);
|
|
|
|
|
|
|
|
|
|
// if p_u >= 0 then
|
|
|
|
|
if !p_u.is_negative(){
|
|
|
|
|
if p_u.is_positive(){
|
|
|
|
|
// local direction = up:Cross(u)
|
|
|
|
|
let direction=up.cross(u);
|
|
|
|
|
// if direction.magnitude == 0 then
|
|
|
|
|
@@ -760,11 +760,11 @@ fn crawl_to_closest_fev<'a>(mesh:&MinkowskiMesh<'a>,simplex:Simplex<3,MinkowskiV
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn closest_fev_not_inside<'a>(mesh:&MinkowskiMesh<'a>,point:Planar64Vec3)->Option<FEV<MinkowskiMesh<'a>>>{
|
|
|
|
|
println!("=== LUA ===");
|
|
|
|
|
let (hits,_details)=crate::minimum_difference_lua::minimum_difference_details(mesh,point).unwrap();
|
|
|
|
|
println!("=== RUST ===");
|
|
|
|
|
// println!("=== LUA ===");
|
|
|
|
|
// let (hits,_details)=crate::minimum_difference_lua::minimum_difference_details(mesh,point).unwrap();
|
|
|
|
|
// println!("=== RUST ===");
|
|
|
|
|
let closest_fev_not_inside=closest_fev_not_inside_inner(mesh,point);
|
|
|
|
|
assert_eq!(hits,closest_fev_not_inside.is_none(),"algorithms disagree");
|
|
|
|
|
// assert_eq!(hits,closest_fev_not_inside.is_none(),"algorithms disagree");
|
|
|
|
|
closest_fev_not_inside
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -893,7 +893,7 @@ fn minimum_difference<const ENABLE_FAST_FAIL:bool,T,M:MeshQuery<Position=Planar6
|
|
|
|
|
let d1=direction.dot(next_pos-last_pos);
|
|
|
|
|
let cond2=simplex_big.det_is_zero(mesh);
|
|
|
|
|
println!("d1={d1:?} cond2={cond2}");
|
|
|
|
|
if !d1.is_positive()||cond2{
|
|
|
|
|
if d1.is_negative()||cond2{
|
|
|
|
|
println!("on_exact");
|
|
|
|
|
// Found enough information to compute the exact closest point.
|
|
|
|
|
// local norm = direction.unit
|
|
|
|
|
|