This commit is contained in:
2025-11-20 09:49:46 -08:00
parent 749ace538d
commit e2ba15880a

View File

@@ -1,13 +1,13 @@
use strafesnet_common::integer::{Planar64,Planar64Vec3};
use crate::model::{TransformedMesh,MeshQuery};
use crate::model::{MeshQuery,SubmeshVertId,TransformedMesh};
// This algorithm is based on Lua code
// written by Trey Reynolds in 2021
struct PQ{
p:Planar64Vec3,
q:Planar64Vec3,
p:SubmeshVertId,
q:SubmeshVertId,
}
type Simplex=arrayvec::ArrayVec<PQ,4>;
@@ -51,10 +51,12 @@ pub fn minimum_difference<'p,'q>(p:&'p TransformedMesh,q:&'q TransformedMesh)->O
// local new_point_p = queryP(initialAxis)
// local new_point_q = queryQ(-initialAxis)
// local direction, a0, a1, b0, b1, c0, c1, d0, d1
let initial_axis=q.hint_point()-p.hint_point();
let new_point_p=p.farthest_vert(initial_axis);
let new_point_q=q.farthest_vert(-initial_axis);
let mut simplex=Simplex::from_iter([PQ{p:new_point_p,q:new_point_q}]);
let mut direction=q.hint_point()-p.hint_point();
let new_point=PQ{
p:p.farthest_vert(direction),
q:q.farthest_vert(-direction),
};
let mut simplex=Simplex::from_iter([new_point]);
// exitRadius = testIntersection and 0 or exitRadius or 1/0
// for _ = 1, 100 do
@@ -67,6 +69,10 @@ pub fn minimum_difference<'p,'q>(p:&'p TransformedMesh,q:&'q TransformedMesh)->O
// new_point_p = queryP(-direction)
// new_point_q = queryQ(direction)
// local newPoint = new_point_q - new_point_p
let new_point=PQ{
p:p.farthest_vert(direction),
q:q.farthest_vert(-direction),
};
// if -direction:Dot(newPoint) > (exitRadius + radiusP + radiusQ)*direction.magnitude then
// return false
@@ -92,7 +98,7 @@ pub fn minimum_difference<'p,'q>(p:&'p TransformedMesh,q:&'q TransformedMesh)->O
// end
// direction, a0, a1, b0, b1, c0, c1, d0, d1 = reduceSimplex(new_point_p, new_point_q, a0, a1, b0, b1, c0, c1)
let s:Simplex = reduce_simplex();
(direction,simplex) = reduce_simplex();
panic!("quit underlining all my code!");
}
// return nil