From 06eeac6043630d6f6bb423f33705b7091ae8f039 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 26 Oct 2023 19:38:34 -0700 Subject: [PATCH] data structures --- src/face_crawler.rs | 4 ++-- src/model_physics.rs | 29 ++++++++++++----------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/face_crawler.rs b/src/face_crawler.rs index 74b32bd..a3aa836 100644 --- a/src/face_crawler.rs +++ b/src/face_crawler.rs @@ -3,13 +3,13 @@ use crate::model_physics::{VirtualMesh,FEV,FaceId}; use crate::integer::{Time,Planar64Vec3}; struct State{ - time:Time, fev:FEV, + time:Time, } enum Transition{ Miss, - NextState(State), + Next(FEV,Time), Hit(FaceId,Time), } diff --git a/src/model_physics.rs b/src/model_physics.rs index fb8791f..2b2388d 100644 --- a/src/model_physics.rs +++ b/src/model_physics.rs @@ -1,14 +1,17 @@ use crate::integer::{Planar64,Planar64Vec3}; +#[derive(Clone,Copy)] pub struct VertId(usize); +#[derive(Clone,Copy)] pub struct EdgeId(usize); +#[derive(Clone,Copy)] pub struct FaceId(usize); //Vertex <-> Edge <-> Face -> Collide pub enum FEV{ Face(FaceId), Edge(EdgeId), - Vertex(VertId), + Vert(VertId), } //use Unit32 #[repr(C)] for map files @@ -17,17 +20,15 @@ struct Face{ dot:Planar64, } struct FaceRefs{ - edges:Vec, + edges:Vec<(EdgeId,FaceId)>, verts:Vec, } struct EdgeRefs{ faces:[FaceId;2],//left, right - verts:[VertId;2],//bottom, top - vert_faces:[FaceId;2],//bottom, top + verts:[(VertId,FaceId);2],//bottom, top } struct VertRefs{ - faces:Vec, - edges:Vec, + edges:Vec<(EdgeId,FaceId)>, } pub struct PhysicsMesh{ faces:Vec, @@ -36,28 +37,22 @@ pub struct PhysicsMesh{ vert_topology:Vec, } impl PhysicsMesh{ - pub fn face_normal(&self,face_id:FaceId)->Planar64Vec3{ - self.faces[face_id.0].normal + pub fn face_nd(&self,face_id:FaceId)->(Planar64Vec3,Planar64){ + (self.faces[face_id.0].normal,self.faces[face_id.0].dot) } //ideally I never calculate the vertex position, but I have to for the graphical meshes... - pub fn face_edges(&self,face_id:FaceId)->&Vec{ + pub fn face_edges(&self,face_id:FaceId)->&Vec<(EdgeId,FaceId)>{ &self.face_topology[face_id.0].edges } pub fn edge_side_faces(&self,edge_id:EdgeId)->&[FaceId;2]{ &self.edge_topology[edge_id.0].faces } - pub fn edge_end_faces(&self,edge_id:EdgeId)->&[FaceId;2]{ - &self.edge_topology[edge_id.0].vert_faces - } - pub fn edge_verts(&self,edge_id:EdgeId)->&[VertId;2]{ + pub fn edge_ends(&self,edge_id:EdgeId)->&[(VertId,FaceId);2]{ &self.edge_topology[edge_id.0].verts } - pub fn vert_edges(&self,vert_id:VertId)->&Vec{ + pub fn vert_edges(&self,vert_id:VertId)->&Vec<(EdgeId,FaceId)>{ &self.vert_topology[vert_id.0].edges } - pub fn vert_faces(&self,vert_id:VertId)->&Vec{ - &self.vert_topology[vert_id.0].faces - } } //Note that a face on a minkowski mesh refers to a pair of fevs on the meshes it's summed from