forked from StrafesNET/strafe-client
face crawler work
This commit is contained in:
parent
b215578c8d
commit
19c7a8924e
@ -1,5 +1,5 @@
|
||||
use crate::physics::Body;
|
||||
use crate::integer::Time;
|
||||
use crate::integer::{Time,Planar64Vec3};
|
||||
|
||||
struct VertexId(usize);
|
||||
struct EdgeId(usize);
|
||||
@ -24,24 +24,31 @@ enum Transition{
|
||||
}
|
||||
|
||||
impl State{
|
||||
fn next_transition(&self,mesh:&VirtualMesh,time_limit:Time)->Transition{
|
||||
fn next_transition(&self,mesh:&VirtualMesh,body:&Body,time_limit:Time)->Transition{
|
||||
//conflicting derivative means it crosses in the wrong direction.
|
||||
match self.fev{
|
||||
//if the transition time is equal to an already tested transition, do not replace the current best.
|
||||
match &self.fev{
|
||||
FEV::Face(face_id)=>{
|
||||
//test own face collision time
|
||||
//test own face collision time, ignoring edges with zero or conflicting derivative
|
||||
//test each edge collision time, ignoring edges with zero or conflicting derivative
|
||||
//if face: return (Face,Time)
|
||||
//if edge: goto edge
|
||||
//if face: Transition::Hit(Face,Time)
|
||||
//if edge: Transition::NextState(State{time,fev:FEV::Edge(edge_id)})
|
||||
//if none:
|
||||
Transition::Miss
|
||||
},
|
||||
FEV::Edge(edge_id)=>{
|
||||
//test each face collision time, ignoring faces with zero or conflicting derivative
|
||||
//test each vertex collision time, ignoring vertices with zero or conflicting derivative
|
||||
//if face: goto face
|
||||
//if vertex: goto vertex
|
||||
//if face: Transition::NextState(State{time,fev:FEV::Face(face_id)})
|
||||
//if vert: Transition::NextState(State{time,fev:FEV::Vertex(vertex_id)})
|
||||
//if none:
|
||||
Transition::Miss
|
||||
},
|
||||
FEV::Vertex(vertex_id)=>{
|
||||
//test each edge collision time, ignoring edges with zero or conflicting derivative
|
||||
//goto edge
|
||||
//if some: Transition::NextState(State{time,fev:FEV::Edge(edge_id)})
|
||||
//if none:
|
||||
Transition::Miss
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -52,24 +59,30 @@ impl State{
|
||||
//(edge,edge)
|
||||
//(vertex,face)
|
||||
|
||||
struct VirtualMesh{
|
||||
//???
|
||||
struct VirtualMesh<'a>{
|
||||
mesh0:&'a PhysicsMesh,
|
||||
mesh1:&'a PhysicsMesh,
|
||||
}
|
||||
|
||||
impl VirtualMesh{
|
||||
pub fn minkowski_sum(mesh0:&PhysicsMesh,mesh1:&PhysicsMesh)->Self{
|
||||
//?????
|
||||
impl VirtualMesh<'_>{
|
||||
pub fn minkowski_sum<'a>(mesh0:&PhysicsMesh,mesh1:&PhysicsMesh)->VirtualMesh<'a>{
|
||||
Self{
|
||||
mesh0,
|
||||
mesh1,
|
||||
}
|
||||
}
|
||||
pub fn predict_collision(&self,body:&Body,time:Time,time_limit:Time)->Option<(FaceId,Time)>{
|
||||
//mesh.closest_point returns if the point is on a face, edge or vertex
|
||||
let (point,fev)=self.closest_point(body.extrapolated_position(time));
|
||||
fn closest_fev(&self,point:Planar64Vec3)->FEV{
|
||||
//put some genius code right here
|
||||
todo!()
|
||||
}
|
||||
pub fn predict_collision(&self,relative_body:&Body,time_limit:Time)->Option<(FaceId,Time)>{
|
||||
let mut state=State{
|
||||
time,
|
||||
fev,
|
||||
time:relative_body.time,
|
||||
fev:self.closest_fev(relative_body.position),
|
||||
};
|
||||
//it would be possible to write down the point of closest approach...
|
||||
loop{
|
||||
match state.next_transition(self,time_limit){
|
||||
match state.next_transition(self,relative_body,time_limit){
|
||||
Transition::Miss=>return None,
|
||||
Transition::NextState(next_state)=>state=next_state,
|
||||
Transition::Hit(hit_face,hit_time)=>return Some((hit_face,hit_time)),
|
||||
|
Loading…
Reference in New Issue
Block a user