functions

This commit is contained in:
Quaternions 2023-10-26 19:38:37 -07:00
parent 06eeac6043
commit bb46801610

View File

@ -1,6 +1,7 @@
use crate::physics::Body; use crate::physics::Body;
use crate::model_physics::{VirtualMesh,FEV,FaceId}; use crate::model_physics::{VirtualMesh,FEV,FaceId};
use crate::integer::{Time,Planar64Vec3}; use crate::integer::{Time,Planar64,Planar64Vec3};
use crate::zeroes::zeroes2;
struct State{ struct State{
fev:FEV, fev:FEV,
@ -46,15 +47,15 @@ impl State{
pub fn predict_collision(mesh:&VirtualMesh,relative_body:&Body,time_limit:Time)->Option<(FaceId,Time)>{ pub fn predict_collision(mesh:&VirtualMesh,relative_body:&Body,time_limit:Time)->Option<(FaceId,Time)>{
let mut state=State{ let mut state=State{
time:relative_body.time,
fev:mesh.closest_fev(relative_body.position), fev:mesh.closest_fev(relative_body.position),
time:relative_body.time,
}; };
//it would be possible to write down the point of closest approach... //it would be possible to write down the point of closest approach...
loop{ loop{
match state.next_transition(mesh,relative_body,time_limit){ match state.next_transition(mesh,relative_body,time_limit){
Transition::Miss=>return None, Transition::Miss=>return None,
Transition::NextState(next_state)=>state=next_state, Transition::Next(fev,time)=>(state.fev,state.time)=(fev,time),
Transition::Hit(hit_face,hit_time)=>return Some((hit_face,hit_time)), Transition::Hit(face,time)=>return Some((face,time)),
} }
} }
} }