remove intermediate allocation
This commit is contained in:
@@ -991,8 +991,6 @@ impl PhysicsData{
|
||||
|
||||
let mut contact_models=HashMap::new();
|
||||
let mut intersect_models=HashMap::new();
|
||||
let mut contacts_in_order=Vec::new();
|
||||
let mut intersects_in_order=Vec::new();
|
||||
|
||||
let mut physics_attr_id_from_model_attr_id=HashMap::<CollisionAttributesId,PhysicsAttributesId>::new();
|
||||
let mut used_meshes=Vec::new();
|
||||
@@ -1054,7 +1052,6 @@ impl PhysicsData{
|
||||
attr_id,
|
||||
transform,
|
||||
});
|
||||
contacts_in_order.push(contact_model_id);
|
||||
},
|
||||
PhysicsAttributesId::Intersect(attr_id)=>{
|
||||
let intersect_model_id=IntersectModelId::new(model_id as u32);
|
||||
@@ -1063,7 +1060,6 @@ impl PhysicsData{
|
||||
attr_id,
|
||||
transform,
|
||||
});
|
||||
intersects_in_order.push(intersect_model_id);
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1073,14 +1069,23 @@ impl PhysicsData{
|
||||
(PhysicsMeshId::new(mesh_id as u32),mesh)
|
||||
).collect();
|
||||
let convex_mesh_aabb_list=
|
||||
//map the two lists into a single type so they can be processed with one closure
|
||||
contacts_in_order.iter().map(|model_id|{
|
||||
let model=contact_models.get(model_id).unwrap();
|
||||
(PhysicsModelId::Contact(*model_id),&model.mesh_id,&model.transform)
|
||||
}).chain(intersects_in_order.iter().map(|model_id|{
|
||||
let model=intersect_models.get(model_id).unwrap();
|
||||
(PhysicsModelId::Intersect(*model_id),&model.mesh_id,&model.transform)
|
||||
}))
|
||||
// use the map models iteration order to ensure that the
|
||||
// order that the models are passed into bvh::generate_bvh is consistent
|
||||
map.models.iter().enumerate().filter_map(|(model_id,model)|{
|
||||
match map.attributes.get(model.attributes.get() as usize)?{
|
||||
gameplay_attributes::CollisionAttributes::Decoration=>None,
|
||||
gameplay_attributes::CollisionAttributes::Contact(_)=>{
|
||||
let model_id=ContactModelId::new(model_id as u32);
|
||||
let model=contact_models.get(&model_id)?;
|
||||
Some((PhysicsModelId::Contact(model_id),&model.mesh_id,&model.transform))
|
||||
},
|
||||
gameplay_attributes::CollisionAttributes::Intersect(_)=>{
|
||||
let model_id=IntersectModelId::new(model_id as u32);
|
||||
let model=intersect_models.get(&model_id)?;
|
||||
Some((PhysicsModelId::Intersect(model_id),&model.mesh_id,&model.transform))
|
||||
},
|
||||
}
|
||||
})
|
||||
.flat_map(|(model_id,mesh_id,transform)|{
|
||||
meshes[mesh_id].submesh_views()
|
||||
.enumerate().map(move|(submesh_id,view)|{
|
||||
|
||||
Reference in New Issue
Block a user