From d155517587b5f26db8360e996759d94062f969d8 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 31 Oct 2023 20:55:15 -0700 Subject: [PATCH] delete aabb physics --- src/physics.rs | 282 +------------------------------------------------ 1 file changed, 1 insertion(+), 281 deletions(-) diff --git a/src/physics.rs b/src/physics.rs index 70fec1d..447e6c1 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1,7 +1,6 @@ -use crate::zeroes::zeroes2; use crate::instruction::{InstructionEmitter,InstructionConsumer,TimedInstruction}; use crate::integer::{Time,Planar64,Planar64Vec3,Planar64Mat3,Angle32,Ratio64,Ratio64Vec2}; -use crate::model_physics::{PhysicsMesh,TransformedMesh,MinkowskiMesh}; +use crate::model_physics::{PhysicsMesh,TransformedMesh}; #[derive(Debug)] pub enum PhysicsInstruction { @@ -970,285 +969,6 @@ impl PhysicsState { MoveState::Water=>None,//TODO } } - fn mesh(&self) -> TreyMesh { - let mut aabb=TreyMesh::default(); - for vertex in TreyMesh::unit_vertices(){ - aabb.grow(self.body.position+self.style.hitbox_halfsize*vertex); - } - aabb - } - fn predict_collision_end(&self,time:Time,time_limit:Time,collision_data:&ContactCollision) -> Option> { - //must treat cancollide false objects differently: you may not exit through the same face you entered. - //RelativeCollsion must reference the full model instead of a particular face - //this is Ctrl+C Ctrl+V of predict_collision_start but with v=-v before the calc and t=-t after the calc - //find best t - let mut best_time=time_limit; - let mut exit_face:Option=None; - let mesh0=self.mesh(); - let mesh1=self.models.get(collision_data.model as usize).unwrap().mesh(); - let (v,a)=(-self.body.velocity,self.body.acceleration); - //collect x - match collision_data.face { - TreyMeshFace::Top|TreyMeshFace::Back|TreyMeshFace::Bottom|TreyMeshFace::Front=>{ - for t in zeroes2(mesh0.max.x()-mesh1.min.x(),v.x(),a.x()/2) { - //negative t = back in time - //must be moving towards surface to collide - //must beat the current soonest collision time - //must be moving towards surface - let t_time=self.body.time-Time::from(t); - if time<=t_time&&t_time{ - //generate event if v.x<0||a.x<0 - if -v.x(){ - //generate event if 0{ - for t in zeroes2(mesh0.max.y()-mesh1.min.y(),v.y(),a.y()/2) { - //negative t = back in time - //must be moving towards surface to collide - //must beat the current soonest collision time - //must be moving towards surface - let t_time=self.body.time-Time::from(t); - if time<=t_time&&t_time{ - //generate event if v.y<0||a.y<0 - if -v.y(){ - //generate event if 0{ - for t in zeroes2(mesh0.max.z()-mesh1.min.z(),v.z(),a.z()/2) { - //negative t = back in time - //must be moving towards surface to collide - //must beat the current soonest collision time - //must be moving towards surface - let t_time=self.body.time-Time::from(t); - if time<=t_time&&t_time{ - //generate event if v.z<0||a.z<0 - if -v.z(){ - //generate event if 0 Option> { - let mesh0=self.mesh(); - let mesh1=self.models.get(model_id).unwrap().mesh(); - let (p,v,a,body_time)=(self.body.position,self.body.velocity,self.body.acceleration,self.body.time); - //find best t - let mut best_time=time_limit; - let mut best_face:Option=None; - //collect x - for t in zeroes2(mesh0.max.x()-mesh1.min.x(),v.x(),a.x()/2) { - //must collide now or in the future - //must beat the current soonest collision time - //must be moving towards surface - let t_time=body_time+Time::from(t); - if time<=t_time&&t_time for PhysicsState {