From 82d71df94e41e0fbda91502d3749ca2e9c1c703d Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 7 Oct 2023 21:46:40 -0700 Subject: [PATCH] texture fallbacks for corner wedge --- src/load_roblox.rs | 15 +++++++++------ src/primitives.rs | 13 ++++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/load_roblox.rs b/src/load_roblox.rs index a24a59e..1bb0149 100644 --- a/src/load_roblox.rs +++ b/src/load_roblox.rs @@ -178,7 +178,7 @@ impl RobloxFaceTextureDescription{ } type RobloxPartDescription=[Option;6]; type RobloxWedgeDescription=[Option;5]; -type RobloxCornerWedgeDescription=[Option;4]; +type RobloxCornerWedgeDescription=[Option;5]; #[derive(Clone,Eq,Hash,PartialEq)] enum RobloxBasePartDescription{ Sphere, @@ -380,9 +380,11 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> crate::model::Index f3,//Cube::Left->Wedge::Left f4,//Cube::Bottom->Wedge::Bottom ]), + //TODO: fix Left+Back texture coordinates to match roblox when not overwridden by Top primitives::Primitives::CornerWedge=>RobloxBasePartDescription::CornerWedge([ f0,//Cube::Right->CornerWedge::Right - f1,//Cube::Top->CornerWedge::Top + if f2.is_some(){f2}else{f1.clone()},//Cube::Back|Cube::Top->CornerWedge::TopBack + if f3.is_some(){f3}else{f1},//Cube::Left|Cube::Top->CornerWedge::TopLeft f4,//Cube::Bottom->CornerWedge::Bottom f5,//Cube::Front->CornerWedge::Front ]), @@ -441,10 +443,11 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> crate::model::Index for (face_id,roblox_face_description) in cornerwedge_texture_description.iter().enumerate(){ cornerwedge_face_description.insert( match face_id{ - 0=>primitives::CornerWedgeFace::Top, - 1=>primitives::CornerWedgeFace::Right, - 2=>primitives::CornerWedgeFace::Bottom, - 3=>primitives::CornerWedgeFace::Front, + 0=>primitives::CornerWedgeFace::Right, + 1=>primitives::CornerWedgeFace::TopBack, + 2=>primitives::CornerWedgeFace::TopLeft, + 3=>primitives::CornerWedgeFace::Bottom, + 4=>primitives::CornerWedgeFace::Front, _=>panic!("unreachable"), }, match roblox_face_description{ diff --git a/src/primitives.rs b/src/primitives.rs index fd290ff..1ca3571 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -107,8 +107,9 @@ local cornerWedgeVerticies = { */ #[derive(Hash,PartialEq,Eq)] pub enum CornerWedgeFace{ - Top, Right, + TopBack, + TopLeft, Bottom, Front, } @@ -162,7 +163,8 @@ pub type CornerWedgeFaceDescription=std::collections::HashMap::crate::model::IndexedModel{ let mut t=CornerWedgeFaceDescription::new(); t.insert(CornerWedgeFace::Right,FaceDescription::default()); - t.insert(CornerWedgeFace::Top,FaceDescription::default()); + t.insert(CornerWedgeFace::TopBack,FaceDescription::default()); + t.insert(CornerWedgeFace::TopLeft,FaceDescription::default()); t.insert(CornerWedgeFace::Bottom,FaceDescription::default()); t.insert(CornerWedgeFace::Front,FaceDescription::default()); generate_partial_unit_cornerwedge(t) @@ -456,9 +458,10 @@ pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescri } as u32; let face_id=match face{ CornerWedgeFace::Right => 0, - CornerWedgeFace::Top => 1, - CornerWedgeFace::Bottom => 2, - CornerWedgeFace::Front => 3, + CornerWedgeFace::TopBack => 1, + CornerWedgeFace::TopLeft => 2, + CornerWedgeFace::Bottom => 3, + CornerWedgeFace::Front => 4, }; //always push normal let normal_index=generated_normal.len() as u32;