common: bvh: rip the_tester

This commit is contained in:
Quaternions 2025-02-06 10:37:22 -08:00
parent 0c991715ab
commit 4899003766
3 changed files with 5 additions and 5 deletions
engine/physics/src
lib
common/src
snf/src

@ -1136,7 +1136,7 @@ impl PhysicsData{
//relative to moving platforms
//let relative_body=state.body.relative_to(&Body::ZERO);
let relative_body=&state.body;
data.bvh.the_tester(&aabb,&mut |&convex_mesh_id|{
data.bvh.sample_aabb(&aabb,&mut |&convex_mesh_id|{
//no checks are needed because of the time limits.
let model_mesh=data.models.mesh(convex_mesh_id);
let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,data.hitbox_mesh.transformed_mesh());
@ -1198,7 +1198,7 @@ fn recalculate_touching(
aabb.inflate(hitbox_mesh.halfsize);
//relative to moving platforms
//let relative_body=state.body.relative_to(&Body::ZERO);
bvh.the_tester(&aabb,&mut |&convex_mesh_id|{
bvh.sample_aabb(&aabb,&mut |&convex_mesh_id|{
//no checks are needed because of the time limits.
let model_mesh=models.mesh(convex_mesh_id);
let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,hitbox_mesh.transformed_mesh());

@ -30,7 +30,7 @@ impl<T> BvhNode<T>{
aabb:Aabb::default(),
}
}
pub fn the_tester<F:FnMut(&T)>(&self,aabb:&Aabb,f:&mut F){
pub fn sample_aabb<F:FnMut(&T)>(&self,aabb:&Aabb,f:&mut F){
match &self.content{
RecursiveContent::Leaf(model)=>f(model),
RecursiveContent::Branch(children)=>for child in children{
@ -39,7 +39,7 @@ impl<T> BvhNode<T>{
//you're probably not going to spend a lot of time outside the map,
//so the test is extra work for nothing
if aabb.intersects(&child.aabb){
child.the_tester(aabb,f);
child.sample_aabb(aabb,f);
}
},
}

@ -233,7 +233,7 @@ impl<R:BinReaderExt> StreamableMap<R>{
}
pub fn get_intersecting_region_block_ids(&self,aabb:&Aabb)->Vec<BlockId>{
let mut block_ids=Vec::new();
self.bvh.the_tester(aabb,&mut |&block_id|block_ids.push(block_id));
self.bvh.sample_aabb(aabb,&mut |&block_id|block_ids.push(block_id));
block_ids
}
pub fn load_region(&mut self,block_id:BlockId)->Result<Vec<(model::ModelId,model::Model)>,Error>{