make aabb_list with silly iterator to avoid pub-ing Vert

This commit is contained in:
Quaternions 2023-11-01 16:40:05 -07:00
parent e92eaed2d3
commit 49931a40fc
2 changed files with 15 additions and 1 deletions

View File

@ -167,6 +167,11 @@ pub trait MeshQuery<FACE:Clone,EDGE:Clone,VERT:Clone>{
fn edge_verts(&self,edge_id:EDGE)->Cow<[VERT;2]>;
fn vert_edges(&self,vert_id:VERT)->Cow<Vec<EDGE>>;
}
impl PhysicsMesh{
pub fn verts<'a>(&'a self)->impl Iterator<Item=Planar64Vec3>+'a{
self.verts.iter().map(|Vert(pos)|*pos)
}
}
impl MeshQuery<FaceId,EdgeId,VertId> for PhysicsMesh{
fn closest_fev(&self,point:Planar64Vec3)->FEV<FaceId,EdgeId,VertId>{
//TODO: put some genius code right here

View File

@ -168,6 +168,15 @@ impl PhysicsModels{
self.attributes.clear();
self.model_id_from_wormhole_id.clear();
}
fn aabb_list(&self)->Vec<crate::aabb::Aabb>{
self.models.iter().map(|model|{
let mut aabb=crate::aabb::Aabb::default();
for pos in self.meshes[model.mesh_id].verts(){
aabb.grow(model.transform.transform_point3(pos));
}
aabb
}).collect()
}
//TODO: "statically" verify the maps don't refer to any nonexistant data, if they do delete the references.
//then I can make these getter functions unchecked.
fn mesh(&self,model_id:usize)->TransformedMesh{
@ -853,7 +862,7 @@ impl PhysicsState {
self.meshes.push(PhysicsMesh::from(model));
}
}
self.bvh=crate::bvh::generate_bvh(self.models.aabb_list(&self.meshes));
self.bvh=crate::bvh::generate_bvh(self.models.aabb_list());
//I don't wanna write structs for temporary structures
//this code builds ModeDescriptions from the unsorted lists at the top of the function
starts.sort_by_key(|tup|tup.1.mode_id);