From 9ff946c3254e229038dbfc6015687300cf7d1557 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 12 Mar 2024 22:37:48 -0700 Subject: [PATCH] implement roblox mesh loading --- src/file.rs | 17 +++++++++++++---- src/model_physics.rs | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/file.rs b/src/file.rs index a6f19ef..27243fc 100644 --- a/src/file.rs +++ b/src/file.rs @@ -49,14 +49,25 @@ pub fn load>(path:P)->Result{ 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>(path:P)->Result) -> 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, }) }