implement roblox mesh loading

This commit is contained in:
Quaternions 2024-03-12 22:37:48 -07:00
parent 3756af9638
commit 5fdcf9047c
2 changed files with 15 additions and 5 deletions

View File

@ -49,14 +49,25 @@ pub fn load<P:AsRef<std::path::Path>>(path:P)->Result<strafesnet_common::map::Co
DataStructure::Roblox(dom)=>{
let mut loader=strafesnet_deferred_loader::roblox_legacy();
let (texture_loader,mesh_loader)=loader.get_inner_mut();
let map_step1=strafesnet_rbx_loader::convert(
&dom,
|name|loader.acquire_render_config_id(name)
|name|texture_loader.acquire_render_config_id(name),
|name|mesh_loader.acquire_mesh_id(name),
);
let meshpart_meshes=mesh_loader.load_meshes().map_err(LoadError::Io)?;
let map_step2=map_step1.add_meshpart_meshes_and_calculate_attributes(
meshpart_meshes.into_iter().map(|(mesh_id,loader_model)|
(mesh_id,strafesnet_rbx_loader::data::RobloxMeshBytes::new(loader_model.get()))
)
);
let (textures,render_configs)=loader.into_render_configs().map_err(LoadError::Io)?.consume();
let map=map_step1.add_render_configs_and_textures(
let map=map_step2.add_render_configs_and_textures(
render_configs.into_iter(),
textures.into_iter().map(|(texture_id,texture)|
(texture_id,match texture{
@ -74,9 +85,7 @@ pub fn load<P:AsRef<std::path::Path>>(path:P)->Result<strafesnet_common::map::Co
let map_step1=strafesnet_bsp_loader::convert(
&bsp,
//acquire_render_config_id
|name|texture_loader.acquire_render_config_id(name),
//acquire_mesh_id
|name|mesh_loader.acquire_mesh_id(name),
);

View File

@ -284,6 +284,7 @@ impl EdgePool{
#[derive(Debug)]
pub enum PhysicsMeshError{
ZeroVertices,
NoPhysicsGroups,
}
impl std::fmt::Display for PhysicsMeshError{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@ -404,7 +405,7 @@ impl TryFrom<&model::Mesh> for PhysicsMesh{
faces,
verts,
},
complete_mesh:mesh_topologies.pop().unwrap(),
complete_mesh:mesh_topologies.pop().ok_or(PhysicsMeshError::NoPhysicsGroups)?,
submeshes:mesh_topologies,
})
}