From bb8c53aee217629111d2abbb2be0e1a9c574378c Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 3 Oct 2023 16:32:50 -0700 Subject: [PATCH] check transparency when generating models --- src/load_roblox.rs | 3 --- src/main.rs | 14 +++++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/load_roblox.rs b/src/load_roblox.rs index 80698cb9..efd490a3 100644 --- a/src/load_roblox.rs +++ b/src/load_roblox.rs @@ -153,9 +153,6 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> crate::model::Index spawn_point=model_transform.transform_point3(-glam::Vec3::Y)+glam::vec3(0.0,2.5+0.1,0.0); println!("Found MapStart{:?}",spawn_point); } - if *transparency==1.0 { - continue; - } //TODO: also detect "CylinderMesh" etc here let shape=match &object.class[..]{ diff --git a/src/main.rs b/src/main.rs index 72b8db79..3ebc278c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -164,11 +164,15 @@ impl GraphicsData { let mut unique_texture_models=Vec::with_capacity(indexed_models_len); for mut model in indexed_models.models.into_iter(){ //convert ModelInstance into ModelGraphicsInstance - let instances:Vec=model.instances.iter().map(|instance|{ - ModelGraphicsInstance{ - transform: glam::Mat4::from(instance.transform), - normal_transform: glam::Mat4::from(instance.transform.inverse()).transpose(), - color: instance.color, + let instances:Vec=model.instances.into_iter().filter_map(|instance|{ + if instance.color.w==0.0{ + None + }else{ + Some(ModelGraphicsInstance{ + transform: glam::Mat4::from(instance.transform), + normal_transform: glam::Mat4::from(instance.transform.inverse()).transpose(), + color: instance.color, + }) } }).collect(); //check each group, if it's using a new texture then make a new clone of the model