completely ignore meshes that fail to load

This commit is contained in:
Quaternions 2024-03-12 22:35:47 -07:00
parent e4cd556f94
commit 5faac6b2b3

View File

@ -760,33 +760,38 @@ impl PartialMap1{
).collect();
let mut mesh_id_from_render_config_id=HashMap::new();
//ignore meshes that fail to load completely for now
let mut acquire_mesh_id_from_render_config_id=|old_mesh_id,render|{
let mesh=&loaded_meshes[&old_mesh_id];
*mesh_id_from_render_config_id.entry(old_mesh_id).or_insert_with(||HashMap::new())
.entry(render).or_insert_with(||{
let mesh_id=model::MeshId::new(self.primitive_meshes.len() as u32);
let mut mesh_clone=mesh.clone();
//add a render group lool
mesh_clone.graphics_groups.push(model::IndexedGraphicsGroup{
render,
//guess that highest lod is highest quality
groups:vec![model::PolygonGroupId::new(mesh_clone.polygon_groups.len() as u32)]
});
self.primitive_meshes.push(mesh_clone);
mesh_id
})
loaded_meshes.get(&old_mesh_id).map(|mesh|
*mesh_id_from_render_config_id.entry(old_mesh_id).or_insert_with(||HashMap::new())
.entry(render).or_insert_with(||{
let mesh_id=model::MeshId::new(self.primitive_meshes.len() as u32);
let mut mesh_clone=mesh.clone();
//add a render group lool
mesh_clone.graphics_groups.push(model::IndexedGraphicsGroup{
render,
//guess that highest lod is highest quality
groups:vec![model::PolygonGroupId::new(mesh_clone.polygon_groups.len() as u32)]
});
self.primitive_meshes.push(mesh_clone);
mesh_id
})
)
};
//now that the meshes are loaded, these models can be generated
let models_owned_attributes:Vec<ModelOwnedAttributes>=
self.deferred_models_deferred_attributes.into_iter().map(|deferred_model_deferred_attributes|{
self.deferred_models_deferred_attributes.into_iter().flat_map(|deferred_model_deferred_attributes|{
//meshes need to be cloned from loaded_meshes with a new id when they are used with a new render_id
//insert into primitive_meshes
ModelDeferredAttributes{
mesh:acquire_mesh_id_from_render_config_id(deferred_model_deferred_attributes.model.mesh,deferred_model_deferred_attributes.render),
Some(ModelDeferredAttributes{
mesh:acquire_mesh_id_from_render_config_id(
deferred_model_deferred_attributes.model.mesh,
deferred_model_deferred_attributes.render
)?,
deferred_attributes:deferred_model_deferred_attributes.model.deferred_attributes,
color:deferred_model_deferred_attributes.model.color,
transform:deferred_model_deferred_attributes.model.transform,
}
})
}).chain(self.primitive_models_deferred_attributes.into_iter())
.enumerate().map(|(model_id,model_deferred_attributes)|{
let model_id=model::ModelId::new(model_id as u32);