diff --git a/src/map.rs b/src/map.rs index 1903d15..a2085af 100644 --- a/src/map.rs +++ b/src/map.rs @@ -264,13 +264,19 @@ impl StreamableMap{ } pub fn into_complete_map(mut self)->Result{ //load all meshes - let meshes=self.resource_blocks.meshes.into_values().map(|block_id| - read_mesh(&mut self.file,block_id) - ).collect::,_>>()?; + let mut meshes=Vec::with_capacity(self.resource_blocks.meshes.len()); + for mesh_id in 0..self.resource_blocks.meshes.len() as u32{ + let mesh_id=model::MeshId::new(mesh_id); + let block_id=self.resource_blocks.meshes[&mesh_id]; + meshes.push(read_mesh(&mut self.file,block_id)?); + }; //load all textures - let textures=self.resource_blocks.textures.into_values().map(|block_id| - read_texture(&mut self.file,block_id) - ).collect::,_>>()?; + let mut textures=Vec::with_capacity(self.resource_blocks.textures.len()); + for texture_id in 0..self.resource_blocks.textures.len() as u32{ + let texture_id=model::TextureId::new(texture_id); + let block_id=self.resource_blocks.textures[&texture_id]; + textures.push(read_texture(&mut self.file,block_id)?); + } let mut block_ids=Vec::new(); self.bvh.into_visitor(&mut |block_id|block_ids.push(block_id)); //load all regions