borrow check fixups

This commit is contained in:
Quaternions 2024-08-09 15:12:51 -07:00
parent fb14e023df
commit ce47f01375

View File

@ -1259,11 +1259,13 @@ fn recalculate_touching(
data:&PhysicsData, data:&PhysicsData,
models:&PhysicsModels, models:&PhysicsModels,
){ ){
//drain all existing contacts //collision_end all existing contacts
for contact in state.touching.contacts.drain(){ //I would have preferred while let Some(contact)=contacts.pop()
//but there is no such method
for contact in state.touching.contacts.clone().drain(){
collision_end_contact(state,data,models.contact_attr(contact.model_id),contact); collision_end_contact(state,data,models.contact_attr(contact.model_id),contact);
} }
for intersect in state.touching.intersects.drain(){ for intersect in state.touching.intersects.clone().drain(){
collision_end_intersect(state,data,models.intersect_attr(intersect.model_id),intersect); collision_end_intersect(state,data,models.intersect_attr(intersect.model_id),intersect);
} }
//find all models in the teleport region //find all models in the teleport region
@ -1272,12 +1274,11 @@ fn recalculate_touching(
aabb.inflate(data.hitbox_mesh.halfsize); aabb.inflate(data.hitbox_mesh.halfsize);
//relative to moving platforms //relative to moving platforms
//let relative_body=&VirtualBody::relative(&Body::default(),&state.body).body(state.time); //let relative_body=&VirtualBody::relative(&Body::default(),&state.body).body(state.time);
let relative_body=&state.body;
data.bvh.the_tester(&aabb,&mut |&convex_mesh_id|{ data.bvh.the_tester(&aabb,&mut |&convex_mesh_id|{
//no checks are needed because of the time limits. //no checks are needed because of the time limits.
let model_mesh=data.models.mesh(convex_mesh_id); let model_mesh=data.models.mesh(convex_mesh_id);
let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,data.hitbox_mesh.transformed_mesh()); let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,data.hitbox_mesh.transformed_mesh());
if minkowski.is_point_in_mesh(relative_body.position){ if minkowski.is_point_in_mesh(state.body.position){
match convex_mesh_id.model_id{ match convex_mesh_id.model_id{
//being inside of contact objects is an invalid physics state //being inside of contact objects is an invalid physics state
//but the physics isn't advanced enough to do anything about it yet //but the physics isn't advanced enough to do anything about it yet