1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-26 14:17:45 +00:00

Add types for short2/short4 vertex formats

As seen in 16d32cf5a8
This commit is contained in:
Joshua Goins 2024-04-17 20:44:12 -04:00
parent 7cf6ab8f60
commit 2e27a999d6
2 changed files with 32 additions and 10 deletions

View file

@ -520,11 +520,13 @@ impl MDL {
vertices[k as usize].bone_weight = MDL::read_byte_float4(&mut cursor).unwrap(); vertices[k as usize].bone_weight = MDL::read_byte_float4(&mut cursor).unwrap();
} }
VertexType::Byte4 => { VertexType::Byte4 => {
// TODO: This was used in Dawntrail models. Look into if this is really correct, but seems so? let bytes = MDL::read_byte4(&mut cursor).unwrap();
vertices[k as usize].bone_weight = MDL::read_byte_float4(&mut cursor).unwrap(); vertices[k as usize].bone_weight = [
} f32::from(bytes[0]),
VertexType::Unknown1 => { f32::from(bytes[1]),
// TODO: Unimplemented, needed for Dawntrail? f32::from(bytes[2]),
f32::from(bytes[3])
];
} }
_ => { _ => {
panic!("Unexpected vertex type for blendweight: {:#?}", element.vertex_type); panic!("Unexpected vertex type for blendweight: {:#?}", element.vertex_type);
@ -536,9 +538,6 @@ impl MDL {
VertexType::Byte4 => { VertexType::Byte4 => {
vertices[k as usize].bone_id = MDL::read_byte4(&mut cursor).unwrap(); vertices[k as usize].bone_id = MDL::read_byte4(&mut cursor).unwrap();
} }
VertexType::Unknown1 => {
// TODO: Unimplemented, needed for Dawntrail?
}
_ => { _ => {
panic!("Unexpected vertex type for blendindice: {:#?}", element.vertex_type); panic!("Unexpected vertex type for blendindice: {:#?}", element.vertex_type);
} }

View file

@ -12,17 +12,40 @@ const END_OF_STREAM: u8 = 0xFF;
#[brw(repr = u8)] #[brw(repr = u8)]
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]
pub enum VertexType { pub enum VertexType {
/// 1 32-bit float
Single1 = 0, Single1 = 0,
/// 2 32-bit floats
Single2 = 1, Single2 = 1,
/// 3 32-bit floats
Single3 = 2, Single3 = 2,
/// 4 32-bit floats
Single4 = 3, Single4 = 3,
/// 4 bytes
Byte4 = 5, Byte4 = 5,
/// 2 16-bit signed integers
Short2 = 6,
/// 4 16-bit signed integers
Short4 = 7,
/// 4 8-bit floats
ByteFloat4 = 8, ByteFloat4 = 8,
/// Duplicate of Short2?
Short2n = 9,
/// Duplicate of Short4?
Short4n = 10,
/// 2 16-bit floats
Half2 = 13, Half2 = 13,
/// 4 16-bit floats
Half4 = 14, Half4 = 14,
// Unknown vertex type, I seen them used in BlendIndices in Dawntrail /// 2 16-bit unsigned integers
Unknown1 = 17 UnsignedShort2 = 16,
/// 4 16-bit unsigned integers
UnsignedShort4 = 17
} }
#[binrw] #[binrw]