diff --git a/src/physics.rs b/src/physics.rs index ffe8f1b..940db81 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1259,11 +1259,13 @@ fn recalculate_touching( data:&PhysicsData, models:&PhysicsModels, ){ - //drain all existing contacts - for contact in state.touching.contacts.drain(){ + //collision_end all existing contacts + //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); } - 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); } //find all models in the teleport region @@ -1272,12 +1274,11 @@ fn recalculate_touching( aabb.inflate(data.hitbox_mesh.halfsize); //relative to moving platforms //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|{ //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()); - if minkowski.is_point_in_mesh(relative_body.position){ + if minkowski.is_point_in_mesh(state.body.position){ match convex_mesh_id.model_id{ //being inside of contact objects is an invalid physics state //but the physics isn't advanced enough to do anything about it yet