diff --git a/rust/src/unity/asset_file.rs b/rust/src/unity/asset_file.rs index b7e9b6d7a..b4b8bdda6 100644 --- a/rust/src/unity/asset_file.rs +++ b/rust/src/unity/asset_file.rs @@ -144,6 +144,10 @@ mod tests { } for obj in asset_file.get_objects() { + if obj.file_id != 107 { + continue; + } + let data = &data[obj.byte_start as usize..obj.byte_start as usize + obj.byte_size]; match obj.class_id { ClassID::Transform => { diff --git a/rust/src/unity/types/binary.rs b/rust/src/unity/types/binary.rs index 046bca39b..1e03d06ae 100644 --- a/rust/src/unity/types/binary.rs +++ b/rust/src/unity/types/binary.rs @@ -1,5 +1,6 @@ use deku::prelude::*; +use crate::unity::util::deku_peek; // https://github.com/AssetRipper/TypeTreeDumps/blob/main/StructsDump/release/2019.4.39f1.dump // e.g. Outer Wilds @@ -123,6 +124,7 @@ pub struct MeshRenderer { #[derive(DekuRead, Clone, Debug)] #[deku(ctx = "version: UnityVersion")] pub struct Mesh { + #[deku(reader = "deku_peek(deku::reader, \"name\")")] pub name: CharArray, pub submeshes: UnityArray, pub shapes: BlendShapeData, @@ -131,6 +133,7 @@ pub struct Mesh { pub root_bone_name_hash: u32, pub bones_aabb: UnityArray, pub variable_bone_count_weights: UnityArray, + #[deku(reader = "deku_peek(deku::reader, \"mesh_compression\")")] pub mesh_compression: MeshCompression, pub is_readable: u8, pub keep_vertices: u8, @@ -142,10 +145,14 @@ pub struct Mesh { pub vertex_data: VertexData, #[deku(count = "(4 - deku::byte_offset % 4) % 4")] _alignment3: Vec, pub compressed_mesh: CompressedMesh, + #[deku(reader = "deku_peek(deku::reader, \"local_aabb\")")] pub local_aabb: AABB, + #[deku(reader = "deku_peek(deku::reader, \"mesh_usage_flags\")")] pub mesh_usage_flags: i32, + #[deku(reader = "deku_peek(deku::reader, \"baked_convex_collision_mesh\")")] pub baked_convex_collision_mesh: ByteArray, #[deku(count = "(4 - deku::byte_offset % 4) % 4")] _alignment4: Vec, + #[deku(reader = "deku_peek(deku::reader, \"baked_triangle_collision_mesh\")")] pub baked_triangle_collision_mesh: ByteArray, #[deku(count = "(4 - deku::byte_offset % 4) % 4")] _alignment5: Vec, pub mesh_metrics: [f32; 2], diff --git a/rust/src/unity/util.rs b/rust/src/unity/util.rs index 9564dab98..662891f6d 100644 --- a/rust/src/unity/util.rs +++ b/rust/src/unity/util.rs @@ -5,7 +5,7 @@ pub fn deku_peek<'a, T, R: deku::no_std_io::Read + deku::no_std_io::Seek>(reader where for<'b> T: DekuReader<'b, ()> + Debug { println!("deku_peek - {}", msg); - println!(" offset: {}", reader.bits_read); + println!(" offset: {} / {}", reader.bits_read >> 3, reader.bits_read); match T::from_reader_with_ctx(reader, ()) { Ok(value) => { println!(" value: {:?}", value);