mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-20 03:37:47 +00:00
Remove temporary padding "fixes" for Dawntrail models
According to https://github.com/TexTools/xivModdingFramework/pull/60 the bone table structure changed. Now the correct bone table is loaded for Dawntrail.
This commit is contained in:
parent
2e27a999d6
commit
774740c470
2 changed files with 44 additions and 11 deletions
51
src/model.rs
51
src/model.rs
|
@ -206,6 +206,22 @@ struct BoneTable {
|
||||||
bone_count: u8,
|
bone_count: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[binrw]
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
struct BoneTableV2 {
|
||||||
|
#[br(pad_before = 2)]
|
||||||
|
bone_count: u16,
|
||||||
|
|
||||||
|
#[br(count = bone_count)]
|
||||||
|
bone_indices: Vec<u16>,
|
||||||
|
|
||||||
|
// align to 4 bytes
|
||||||
|
// TODO: use br align_to?
|
||||||
|
#[br(if(bone_count % 2 == 0))]
|
||||||
|
padding: u16
|
||||||
|
}
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
@ -301,8 +317,13 @@ struct ModelData {
|
||||||
bone_name_offsets: Vec<u32>,
|
bone_name_offsets: Vec<u32>,
|
||||||
|
|
||||||
#[br(count = header.bone_table_count)]
|
#[br(count = header.bone_table_count)]
|
||||||
|
#[br(if(file_header.version <= 0x1000005))]
|
||||||
bone_tables: Vec<BoneTable>,
|
bone_tables: Vec<BoneTable>,
|
||||||
|
|
||||||
|
#[br(count = header.bone_table_count)]
|
||||||
|
#[br(if(file_header.version >= 0x1000005))]
|
||||||
|
bone_tables_v2: Vec<BoneTableV2>,
|
||||||
|
|
||||||
#[br(count = header.shape_count)]
|
#[br(count = header.shape_count)]
|
||||||
shapes: Vec<ShapeStruct>,
|
shapes: Vec<ShapeStruct>,
|
||||||
|
|
||||||
|
@ -312,12 +333,7 @@ struct ModelData {
|
||||||
#[br(count = header.shape_value_count)]
|
#[br(count = header.shape_value_count)]
|
||||||
shape_values: Vec<ShapeValue>,
|
shape_values: Vec<ShapeValue>,
|
||||||
|
|
||||||
// TODO: Dawntrail mysteries
|
submesh_bone_map_size: u16,
|
||||||
#[br(if(file_header.version >= 0x01000006))]
|
|
||||||
#[br(count = 24)]
|
|
||||||
_padding1: Vec<u8>,
|
|
||||||
|
|
||||||
submesh_bone_map_size: u32,
|
|
||||||
|
|
||||||
#[br(count = submesh_bone_map_size / 2)]
|
#[br(count = submesh_bone_map_size / 2)]
|
||||||
submesh_bone_map: Vec<u16>,
|
submesh_bone_map: Vec<u16>,
|
||||||
|
@ -326,11 +342,6 @@ struct ModelData {
|
||||||
#[br(count = padding_amount)]
|
#[br(count = padding_amount)]
|
||||||
unknown_padding: Vec<u8>,
|
unknown_padding: Vec<u8>,
|
||||||
|
|
||||||
// TODO: Dawntrail mysteries
|
|
||||||
#[br(if(file_header.version >= 0x01000006))]
|
|
||||||
#[br(count = 385)]
|
|
||||||
_padding2: Vec<u8>,
|
|
||||||
|
|
||||||
bounding_box: BoundingBox,
|
bounding_box: BoundingBox,
|
||||||
model_bounding_box: BoundingBox,
|
model_bounding_box: BoundingBox,
|
||||||
water_bounding_box: BoundingBox,
|
water_bounding_box: BoundingBox,
|
||||||
|
@ -528,6 +539,15 @@ impl MDL {
|
||||||
f32::from(bytes[3])
|
f32::from(bytes[3])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
VertexType::UnsignedShort4 => {
|
||||||
|
let bytes = MDL::read_unsigned_short4(&mut cursor).unwrap();
|
||||||
|
vertices[k as usize].bone_weight = [
|
||||||
|
f32::from(bytes[0]),
|
||||||
|
f32::from(bytes[1]),
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
@ -538,6 +558,15 @@ 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::UnsignedShort4 => {
|
||||||
|
let shorts = MDL::read_unsigned_short4(&mut cursor).unwrap();
|
||||||
|
vertices[k as usize].bone_id = [
|
||||||
|
shorts[0] as u8,
|
||||||
|
shorts[1] as u8,
|
||||||
|
shorts[2] as u8,
|
||||||
|
shorts[3] as u8
|
||||||
|
];
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
panic!("Unexpected vertex type for blendindice: {:#?}", element.vertex_type);
|
panic!("Unexpected vertex type for blendindice: {:#?}", element.vertex_type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,10 @@ impl MDL {
|
||||||
cursor.write_le::<[f32; 4]>(vec)
|
cursor.write_le::<[f32; 4]>(vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn read_unsigned_short4(cursor: &mut Cursor<ByteSpan>) -> BinResult<[u16; 4]> {
|
||||||
|
cursor.read_le::<[u16; 4]>()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn pad_slice<const N: usize>(small_slice: &[f32; N], fill: f32) -> [f32; 4] {
|
pub(crate) fn pad_slice<const N: usize>(small_slice: &[f32; N], fill: f32) -> [f32; 4] {
|
||||||
let mut bigger_slice: [f32; 4] = [fill, fill, fill, fill];
|
let mut bigger_slice: [f32; 4] = [fill, fill, fill, fill];
|
||||||
bigger_slice[..N].copy_from_slice(&small_slice[..N]);
|
bigger_slice[..N].copy_from_slice(&small_slice[..N]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue