texture fallbacks for corner wedge

This commit is contained in:
Quaternions 2023-10-07 21:46:40 -07:00
parent 684dbda73a
commit 82d71df94e
2 changed files with 17 additions and 11 deletions

View File

@ -178,7 +178,7 @@ impl RobloxFaceTextureDescription{
} }
type RobloxPartDescription=[Option<RobloxFaceTextureDescription>;6]; type RobloxPartDescription=[Option<RobloxFaceTextureDescription>;6];
type RobloxWedgeDescription=[Option<RobloxFaceTextureDescription>;5]; type RobloxWedgeDescription=[Option<RobloxFaceTextureDescription>;5];
type RobloxCornerWedgeDescription=[Option<RobloxFaceTextureDescription>;4]; type RobloxCornerWedgeDescription=[Option<RobloxFaceTextureDescription>;5];
#[derive(Clone,Eq,Hash,PartialEq)] #[derive(Clone,Eq,Hash,PartialEq)]
enum RobloxBasePartDescription{ enum RobloxBasePartDescription{
Sphere, Sphere,
@ -380,9 +380,11 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> crate::model::Index
f3,//Cube::Left->Wedge::Left f3,//Cube::Left->Wedge::Left
f4,//Cube::Bottom->Wedge::Bottom f4,//Cube::Bottom->Wedge::Bottom
]), ]),
//TODO: fix Left+Back texture coordinates to match roblox when not overwridden by Top
primitives::Primitives::CornerWedge=>RobloxBasePartDescription::CornerWedge([ primitives::Primitives::CornerWedge=>RobloxBasePartDescription::CornerWedge([
f0,//Cube::Right->CornerWedge::Right 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 f4,//Cube::Bottom->CornerWedge::Bottom
f5,//Cube::Front->CornerWedge::Front 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(){ for (face_id,roblox_face_description) in cornerwedge_texture_description.iter().enumerate(){
cornerwedge_face_description.insert( cornerwedge_face_description.insert(
match face_id{ match face_id{
0=>primitives::CornerWedgeFace::Top, 0=>primitives::CornerWedgeFace::Right,
1=>primitives::CornerWedgeFace::Right, 1=>primitives::CornerWedgeFace::TopBack,
2=>primitives::CornerWedgeFace::Bottom, 2=>primitives::CornerWedgeFace::TopLeft,
3=>primitives::CornerWedgeFace::Front, 3=>primitives::CornerWedgeFace::Bottom,
4=>primitives::CornerWedgeFace::Front,
_=>panic!("unreachable"), _=>panic!("unreachable"),
}, },
match roblox_face_description{ match roblox_face_description{

View File

@ -107,8 +107,9 @@ local cornerWedgeVerticies = {
*/ */
#[derive(Hash,PartialEq,Eq)] #[derive(Hash,PartialEq,Eq)]
pub enum CornerWedgeFace{ pub enum CornerWedgeFace{
Top,
Right, Right,
TopBack,
TopLeft,
Bottom, Bottom,
Front, Front,
} }
@ -162,7 +163,8 @@ pub type CornerWedgeFaceDescription=std::collections::HashMap::<CornerWedgeFace,
pub fn unit_cornerwedge()->crate::model::IndexedModel{ pub fn unit_cornerwedge()->crate::model::IndexedModel{
let mut t=CornerWedgeFaceDescription::new(); let mut t=CornerWedgeFaceDescription::new();
t.insert(CornerWedgeFace::Right,FaceDescription::default()); 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::Bottom,FaceDescription::default());
t.insert(CornerWedgeFace::Front,FaceDescription::default()); t.insert(CornerWedgeFace::Front,FaceDescription::default());
generate_partial_unit_cornerwedge(t) generate_partial_unit_cornerwedge(t)
@ -456,9 +458,10 @@ pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescri
} as u32; } as u32;
let face_id=match face{ let face_id=match face{
CornerWedgeFace::Right => 0, CornerWedgeFace::Right => 0,
CornerWedgeFace::Top => 1, CornerWedgeFace::TopBack => 1,
CornerWedgeFace::Bottom => 2, CornerWedgeFace::TopLeft => 2,
CornerWedgeFace::Front => 3, CornerWedgeFace::Bottom => 3,
CornerWedgeFace::Front => 4,
}; };
//always push normal //always push normal
let normal_index=generated_normal.len() as u32; let normal_index=generated_normal.len() as u32;