make aabb_list with silly iterator to avoid pub-ing Vert
This commit is contained in:
parent
e92eaed2d3
commit
49931a40fc
@ -167,6 +167,11 @@ pub trait MeshQuery<FACE:Clone,EDGE:Clone,VERT:Clone>{
|
|||||||
fn edge_verts(&self,edge_id:EDGE)->Cow<[VERT;2]>;
|
fn edge_verts(&self,edge_id:EDGE)->Cow<[VERT;2]>;
|
||||||
fn vert_edges(&self,vert_id:VERT)->Cow<Vec<EDGE>>;
|
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{
|
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>{
|
||||||
//TODO: put some genius code right here
|
//TODO: put some genius code right here
|
||||||
|
@ -168,6 +168,15 @@ impl PhysicsModels{
|
|||||||
self.attributes.clear();
|
self.attributes.clear();
|
||||||
self.model_id_from_wormhole_id.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.
|
//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.
|
//then I can make these getter functions unchecked.
|
||||||
fn mesh(&self,model_id:usize)->TransformedMesh{
|
fn mesh(&self,model_id:usize)->TransformedMesh{
|
||||||
@ -853,7 +862,7 @@ impl PhysicsState {
|
|||||||
self.meshes.push(PhysicsMesh::from(model));
|
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
|
//I don't wanna write structs for temporary structures
|
||||||
//this code builds ModeDescriptions from the unsorted lists at the top of the function
|
//this code builds ModeDescriptions from the unsorted lists at the top of the function
|
||||||
starts.sort_by_key(|tup|tup.1.mode_id);
|
starts.sort_by_key(|tup|tup.1.mode_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user