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(); ).collect();
let mut mesh_id_from_render_config_id=HashMap::new(); 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 mut acquire_mesh_id_from_render_config_id=|old_mesh_id,render|{
let mesh=&loaded_meshes[&old_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()) *mesh_id_from_render_config_id.entry(old_mesh_id).or_insert_with(||HashMap::new())
.entry(render).or_insert_with(||{ .entry(render).or_insert_with(||{
let mesh_id=model::MeshId::new(self.primitive_meshes.len() as u32); let mesh_id=model::MeshId::new(self.primitive_meshes.len() as u32);
let mut mesh_clone=mesh.clone(); let mut mesh_clone=mesh.clone();
//add a render group lool //add a render group lool
mesh_clone.graphics_groups.push(model::IndexedGraphicsGroup{ mesh_clone.graphics_groups.push(model::IndexedGraphicsGroup{
render, render,
//guess that highest lod is highest quality //guess that highest lod is highest quality
groups:vec![model::PolygonGroupId::new(mesh_clone.polygon_groups.len() as u32)] groups:vec![model::PolygonGroupId::new(mesh_clone.polygon_groups.len() as u32)]
}); });
self.primitive_meshes.push(mesh_clone); self.primitive_meshes.push(mesh_clone);
mesh_id mesh_id
}) })
)
}; };
//now that the meshes are loaded, these models can be generated //now that the meshes are loaded, these models can be generated
let models_owned_attributes:Vec<ModelOwnedAttributes>= 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 //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 //insert into primitive_meshes
ModelDeferredAttributes{ Some(ModelDeferredAttributes{
mesh:acquire_mesh_id_from_render_config_id(deferred_model_deferred_attributes.model.mesh,deferred_model_deferred_attributes.render), 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, deferred_attributes:deferred_model_deferred_attributes.model.deferred_attributes,
color:deferred_model_deferred_attributes.model.color, color:deferred_model_deferred_attributes.model.color,
transform:deferred_model_deferred_attributes.model.transform, transform:deferred_model_deferred_attributes.model.transform,
} })
}).chain(self.primitive_models_deferred_attributes.into_iter()) }).chain(self.primitive_models_deferred_attributes.into_iter())
.enumerate().map(|(model_id,model_deferred_attributes)|{ .enumerate().map(|(model_id,model_deferred_attributes)|{
let model_id=model::ModelId::new(model_id as u32); let model_id=model::ModelId::new(model_id as u32);