1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-22 04:37:46 +00:00

Add support for single3/4 normals and UVs

Seems to be common in TexTools imported MDLs
This commit is contained in:
Joshua Goins 2023-07-09 11:56:45 -04:00
parent bd104fbae0
commit b3f8523677

View file

@ -466,6 +466,9 @@ impl MDL {
VertexType::Half4 => {
vertices[k as usize].normal.clone_from_slice(&MDL::read_half4(&mut cursor).unwrap()[0..3]);
}
VertexType::Single3 => {
vertices[k as usize].normal = MDL::read_single3(&mut cursor).unwrap();
}
_ => {
panic!("Unexpected vertex type for normal: {:#?}", element.vertex_type);
}
@ -476,6 +479,9 @@ impl MDL {
VertexType::Half4 => {
vertices[k as usize].uv.clone_from_slice(&MDL::read_half4(&mut cursor).unwrap()[0..2]);
}
VertexType::Single4 => {
vertices[k as usize].uv.clone_from_slice(&MDL::read_single4(&mut cursor).unwrap()[0..2]);
}
_ => {
panic!("Unexpected vertex type for uv: {:#?}", element.vertex_type);
}
@ -542,4 +548,8 @@ impl MDL {
fn read_single3(cursor: &mut Cursor<&MemoryBuffer>) -> BinResult<[f32; 3]> {
cursor.read_le::<[f32; 3]>()
}
fn read_single4(cursor: &mut Cursor<&MemoryBuffer>) -> BinResult<[f32; 4]> {
cursor.read_le::<[f32; 4]>()
}
}