cow: utter brilliance

This commit is contained in:
Quaternions 2023-10-27 15:10:38 -07:00
parent 3d5ac0cd61
commit 64657e718d
2 changed files with 22 additions and 21 deletions

View File

@ -34,7 +34,7 @@ impl<F:Copy,E:Copy,V:Copy> State<FEV<F,E,V>>{
} }
} }
//test each edge collision time, ignoring roots with zero or conflicting derivative //test each edge collision time, ignoring roots with zero or conflicting derivative
for &(edge_id,test_face_id) in mesh.face_edges(face_id){ for &(edge_id,test_face_id) in mesh.face_edges(face_id).iter(){
let (n,d)=mesh.face_nd(test_face_id); let (n,d)=mesh.face_nd(test_face_id);
for t in zeroes2((n.dot(body.position)-d)*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){ for t in zeroes2((n.dot(body.position)-d)*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){
let t=body.time+Time::from(t); let t=body.time+Time::from(t);
@ -49,7 +49,7 @@ impl<F:Copy,E:Copy,V:Copy> State<FEV<F,E,V>>{
}, },
&FEV::<F,E,V>::Edge(edge_id)=>{ &FEV::<F,E,V>::Edge(edge_id)=>{
//test each face collision time, ignoring roots with zero or conflicting derivative //test each face collision time, ignoring roots with zero or conflicting derivative
for &test_face_id in mesh.edge_side_faces(edge_id){ for &test_face_id in mesh.edge_side_faces(edge_id).iter(){
let (n,d)=mesh.face_nd(test_face_id); let (n,d)=mesh.face_nd(test_face_id);
for t in zeroes2((n.dot(body.position)-d)*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){ for t in zeroes2((n.dot(body.position)-d)*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){
let t=body.time+Time::from(t); let t=body.time+Time::from(t);
@ -61,7 +61,7 @@ impl<F:Copy,E:Copy,V:Copy> State<FEV<F,E,V>>{
} }
} }
//test each vertex collision time, ignoring roots with zero or conflicting derivative //test each vertex collision time, ignoring roots with zero or conflicting derivative
for &(vert_id,test_face_id) in mesh.edge_ends(edge_id){ for &(vert_id,test_face_id) in mesh.edge_ends(edge_id).iter(){
let (n,d)=mesh.face_nd(test_face_id); let (n,d)=mesh.face_nd(test_face_id);
for t in zeroes2((n.dot(body.position)-d)*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){ for t in zeroes2((n.dot(body.position)-d)*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){
let t=body.time+Time::from(t); let t=body.time+Time::from(t);
@ -76,7 +76,7 @@ impl<F:Copy,E:Copy,V:Copy> State<FEV<F,E,V>>{
}, },
&FEV::<F,E,V>::Vert(vertex_id)=>{ &FEV::<F,E,V>::Vert(vertex_id)=>{
//test each edge collision time, ignoring roots with zero or conflicting derivative //test each edge collision time, ignoring roots with zero or conflicting derivative
for &(edge_id,test_face_id) in mesh.vert_edges(vertex_id){ for &(edge_id,test_face_id) in mesh.vert_edges(vertex_id).iter(){
let (n,d)=mesh.face_nd(test_face_id); let (n,d)=mesh.face_nd(test_face_id);
for t in zeroes2((n.dot(body.position)-d)*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){ for t in zeroes2((n.dot(body.position)-d)*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){
let t=body.time+Time::from(t); let t=body.time+Time::from(t);

View File

@ -1,4 +1,5 @@
use crate::integer::{Planar64,Planar64Vec3}; use crate::integer::{Planar64,Planar64Vec3};
use std::borrow::Cow;
#[derive(Clone,Copy)] #[derive(Clone,Copy)]
pub struct VertId(usize); pub struct VertId(usize);
@ -39,14 +40,14 @@ pub struct PhysicsMesh{
vert_topology:Vec<VertRefs>, vert_topology:Vec<VertRefs>,
} }
pub trait MeshQuery<FACE,EDGE,VERT>{ pub trait MeshQuery<FACE:Clone,EDGE:Clone,VERT:Clone>{
fn closest_fev(&self,point:Planar64Vec3)->FEV<FACE,EDGE,VERT>; fn closest_fev(&self,point:Planar64Vec3)->FEV<FACE,EDGE,VERT>;
fn face_nd(&self,face_id:FACE)->(Planar64Vec3,Planar64); fn face_nd(&self,face_id:FACE)->(Planar64Vec3,Planar64);
fn vert(&self,vert_id:VERT)->Planar64Vec3; fn vert(&self,vert_id:VERT)->Planar64Vec3;
fn face_edges(&self,face_id:FACE)->&Vec<(EDGE,FACE)>; fn face_edges(&self,face_id:FACE)->Cow<Vec<(EDGE,FACE)>>;
fn edge_side_faces(&self,edge_id:EDGE)->&[FACE;2]; fn edge_side_faces(&self,edge_id:EDGE)->Cow<[FACE;2]>;
fn edge_ends(&self,edge_id:EDGE)->&[(VERT,FACE);2]; fn edge_ends(&self,edge_id:EDGE)->Cow<[(VERT,FACE);2]>;
fn vert_edges(&self,vert_id:VERT)->&Vec<(EDGE,FACE)>; fn vert_edges(&self,vert_id:VERT)->Cow<Vec<(EDGE,FACE)>>;
} }
impl MeshQuery<FaceId,EdgeId,VertId> for PhysicsMesh{ impl MeshQuery<FaceId,EdgeId,VertId> for PhysicsMesh{
fn closest_fev(&self,point:Planar64Vec3)->FEV<FaceId,EdgeId,VertId>{ fn closest_fev(&self,point:Planar64Vec3)->FEV<FaceId,EdgeId,VertId>{
@ -60,17 +61,17 @@ impl MeshQuery<FaceId,EdgeId,VertId> for PhysicsMesh{
fn vert(&self,vert_id:VertId)->Planar64Vec3{ fn vert(&self,vert_id:VertId)->Planar64Vec3{
todo!() todo!()
} }
fn face_edges(&self,face_id:FaceId)->&Vec<(EdgeId,FaceId)>{ fn face_edges(&self,face_id:FaceId)->Cow<Vec<(EdgeId,FaceId)>>{
&self.face_topology[face_id.0].edges Cow::Borrowed(&self.face_topology[face_id.0].edges)
} }
fn edge_side_faces(&self,edge_id:EdgeId)->&[FaceId;2]{ fn edge_side_faces(&self,edge_id:EdgeId)->Cow<[FaceId;2]>{
&self.edge_topology[edge_id.0].faces Cow::Borrowed(&self.edge_topology[edge_id.0].faces)
} }
fn edge_ends(&self,edge_id:EdgeId)->&[(VertId,FaceId);2]{ fn edge_ends(&self,edge_id:EdgeId)->Cow<[(VertId,FaceId);2]>{
&self.edge_topology[edge_id.0].verts Cow::Borrowed(&self.edge_topology[edge_id.0].verts)
} }
fn vert_edges(&self,vert_id:VertId)->&Vec<(EdgeId,FaceId)>{ fn vert_edges(&self,vert_id:VertId)->Cow<Vec<(EdgeId,FaceId)>>{
&self.vert_topology[vert_id.0].edges Cow::Borrowed(&self.vert_topology[vert_id.0].edges)
} }
} }
@ -134,16 +135,16 @@ impl MeshQuery<MinkowskiFace,MinkowskiEdge,MinkowskiVert> for MinkowskiMesh<'_>{
fn vert(&self,vert_id:MinkowskiVert)->Planar64Vec3{ fn vert(&self,vert_id:MinkowskiVert)->Planar64Vec3{
todo!() todo!()
} }
fn face_edges(&self,face_id:MinkowskiFace)->&Vec<(MinkowskiEdge,MinkowskiFace)>{ fn face_edges(&self,face_id:MinkowskiFace)->Cow<Vec<(MinkowskiEdge,MinkowskiFace)>>{
todo!() todo!()
} }
fn edge_side_faces(&self,edge_id:MinkowskiEdge)->&[MinkowskiFace;2]{ fn edge_side_faces(&self,edge_id:MinkowskiEdge)->Cow<[MinkowskiFace;2]>{
todo!() todo!()
} }
fn edge_ends(&self,edge_id:MinkowskiEdge)->&[(MinkowskiVert,MinkowskiFace);2]{ fn edge_ends(&self,edge_id:MinkowskiEdge)->Cow<[(MinkowskiVert,MinkowskiFace);2]>{
todo!() todo!()
} }
fn vert_edges(&self,vert_id:MinkowskiVert)->&Vec<(MinkowskiEdge,MinkowskiFace)>{ fn vert_edges(&self,vert_id:MinkowskiVert)->Cow<Vec<(MinkowskiEdge,MinkowskiFace)>>{
todo!() todo!()
} }
} }