diff --git a/bff-derive/src/lib.rs b/bff-derive/src/lib.rs index 0b70409..3683214 100644 --- a/bff-derive/src/lib.rs +++ b/bff-derive/src/lib.rs @@ -154,6 +154,8 @@ pub fn serialize_bits(_attr: TokenStream, input: TokenStream) -> TokenStream { where S: serde::Serializer, { + use serde::ser::SerializeStruct; + use serde::Serialize; let mut state = serializer.serialize_struct(#name_str, #field_count)?; #(#serialize_fields)* state.end() diff --git a/bff/src/class/animation/v1_381_67_09_pc.rs b/bff/src/class/animation/v1_381_67_09_pc.rs index d9ebb46..7c93be5 100644 --- a/bff/src/class/animation/v1_381_67_09_pc.rs +++ b/bff/src/class/animation/v1_381_67_09_pc.rs @@ -3,7 +3,7 @@ use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::name::Name; +use crate::link_header::ResourceObjectLinkHeader; use crate::keyframer::{KeyframerFloatComp, KeyframerVec3fComp, KeyframerMessage, KeyframerRot, KeyframerBezierRot}; #[derive(BinRead, Debug, Serialize)] @@ -64,12 +64,7 @@ struct Unknown14 { } #[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct AnimationBodyV1_381_67_09PC { duration: f32, blending: f32, @@ -85,4 +80,4 @@ pub struct AnimationBodyV1_381_67_09PC { unknown15s: DynArray, } -pub type AnimationV1_381_67_09PC = TrivialClass; +pub type AnimationV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/binary/v1_381_67_09_pc.rs b/bff/src/class/binary/v1_381_67_09_pc.rs index 5ff4ab9..1bda8b1 100644 --- a/bff/src/class/binary/v1_381_67_09_pc.rs +++ b/bff/src/class/binary/v1_381_67_09_pc.rs @@ -1,11 +1,10 @@ use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u12, u20, u4, Bitsized, DebugBits, Number}; +use bilge::prelude::*; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; -use crate::name::Name; +use crate::link_header::ResourceObjectLinkHeader; #[serialize_bits] #[bitsize(32)] @@ -55,15 +54,10 @@ struct Internal { } #[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct BinaryBodyV1_381_67_09PC { data_size: u32, data: Internal, } -pub type BinaryV1_381_67_09PC = TrivialClass; +pub type BinaryV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/camera/v1_381_67_09_pc.rs b/bff/src/class/camera/v1_381_67_09_pc.rs index 83bd258..abc8723 100644 --- a/bff/src/class/camera/v1_381_67_09_pc.rs +++ b/bff/src/class/camera/v1_381_67_09_pc.rs @@ -1,85 +1,16 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u15, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; -use crate::math::{Mat4f, Quat}; use crate::name::Name; - -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, -} +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ObjectLinkHeaderV1_381_67_09PC))] pub struct CameraBodyV1_381_67_09PC { angle_of_view: f32, zero: f32, node_name: Name, } -pub type CameraV1_381_67_09PC = TrivialClass; +pub type CameraV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/camera_zone/v1_06_63_02_pc.rs b/bff/src/class/camera_zone/v1_06_63_02_pc.rs index 8e581fc..2857828 100644 --- a/bff/src/class/camera_zone/v1_06_63_02_pc.rs +++ b/bff/src/class/camera_zone/v1_06_63_02_pc.rs @@ -3,27 +3,8 @@ use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{Mat, Sphere, Vec2f, Vec3f, Vec4f, RGBA}; -use crate::name::Name; - -#[derive(BinRead, Debug, Serialize)] -struct Box { - mat: Mat<3, 4>, - vec: Vec3f, - scale: f32, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkInfo { - link_name: Name, - links: DynArray, - data_crc32: Name, - b_sphere_local: Sphere, - b_box: Box, - fade_out_distance: f32, - flags: u32, - r#type: u16, -} +use crate::link_header::ObjectLinkHeaderV1_06_63_02PC; +use crate::math::{Vec2f, Vec3f, Vec4f, RGBA}; #[derive(BinRead, Debug, Serialize)] struct RangeSizeOffset { @@ -94,7 +75,7 @@ struct ZoneTriggers { } #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkInfo))] +#[br(import(_link_header: &ObjectLinkHeaderV1_06_63_02PC))] pub struct CameraZoneBodyV1_06_63_02PC { spline_zone: SplineZoneZ, triggers: DynArray, @@ -102,4 +83,4 @@ pub struct CameraZoneBodyV1_06_63_02PC { trigger_ids: DynArray, } -pub type CameraZoneV1_06_63_02PC = TrivialClass; +pub type CameraZoneV1_06_63_02PC = TrivialClass; diff --git a/bff/src/class/collision_vol/v1_291_03_06_pc.rs b/bff/src/class/collision_vol/v1_291_03_06_pc.rs index e1aa229..4c5db8d 100644 --- a/bff/src/class/collision_vol/v1_291_03_06_pc.rs +++ b/bff/src/class/collision_vol/v1_291_03_06_pc.rs @@ -3,21 +3,10 @@ use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{Mat4f, Sphere}; +use crate::link_header::ObjectLinkHeaderV1_06_63_02PC; +use crate::math::Mat4f; use crate::name::Name; -#[derive(BinRead, Debug, Serialize)] -pub struct LinkInfo { - link_crc32: Name, - links: DynArray, - data_crc32: Name, - b_sphere_local: Sphere, - unknown_matrix: Mat4f, - fade_out_distance: f32, - flags: u32, - r#type: u16, -} - #[derive(BinRead, Debug, Serialize)] struct CollisionVolInfo { local_transform: Mat4f, @@ -25,7 +14,7 @@ struct CollisionVolInfo { } #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkInfo))] +#[br(import(_link_header: &ObjectLinkHeaderV1_06_63_02PC))] pub struct CollisionVolBodyV1_291_03_06PC { collision_vol_infos: DynArray, in_message_id: u32, @@ -37,4 +26,4 @@ pub struct CollisionVolBodyV1_291_03_06PC { anim_start_time: f32, } -pub type CollisionVolV1_291_03_06PC = TrivialClass; +pub type CollisionVolV1_291_03_06PC = TrivialClass; diff --git a/bff/src/class/collision_vol/v1_381_67_09_pc.rs b/bff/src/class/collision_vol/v1_381_67_09_pc.rs index 8fa64e4..573acb6 100644 --- a/bff/src/class/collision_vol/v1_381_67_09_pc.rs +++ b/bff/src/class/collision_vol/v1_381_67_09_pc.rs @@ -1,80 +1,12 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u15, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{Mat4f, Quat}; +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; +use crate::math::Mat4f; use crate::name::Name; -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, -} - #[derive(BinRead, Debug, Serialize)] struct CollisionVolInfo { local_transform: Mat4f, @@ -82,7 +14,7 @@ struct CollisionVolInfo { } #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ObjectLinkHeaderV1_381_67_09PC))] pub struct CollisionVolBodyV1_381_67_09PC { collision_vol_info: DynArray, in_message_id: Name, @@ -95,4 +27,4 @@ pub struct CollisionVolBodyV1_381_67_09PC { delay: f32, } -pub type CollisionVolV1_381_67_09PC = TrivialClass; +pub type CollisionVolV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/fonts/v1_381_67_09_pc.rs b/bff/src/class/fonts/v1_381_67_09_pc.rs index 10d9675..a38a4c0 100644 --- a/bff/src/class/fonts/v1_381_67_09_pc.rs +++ b/bff/src/class/fonts/v1_381_67_09_pc.rs @@ -3,6 +3,7 @@ use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::ResourceObjectLinkHeader; use crate::map::BffMap; use crate::math::Vec2f; use crate::name::Name; @@ -18,15 +19,10 @@ struct Character { } #[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct FontsBodyV1_381_67_09PC { characters: BffMap, material_names: DynArray, } -pub type FontsV1_381_67_09PC = TrivialClass; +pub type FontsV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/game_obj/v1_381_67_09_pc.rs b/bff/src/class/game_obj/v1_381_67_09_pc.rs index 7b657c0..70ce93a 100644 --- a/bff/src/class/game_obj/v1_381_67_09_pc.rs +++ b/bff/src/class/game_obj/v1_381_67_09_pc.rs @@ -3,6 +3,7 @@ use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::ResourceObjectLinkHeader; use crate::name::Name; use crate::strings::PascalStringNull; @@ -14,14 +15,9 @@ struct Prefab { } #[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct GameObjBodyV1_381_67_09PC { prefabs: DynArray, } -pub type GameObjV1_381_67_09PC = TrivialClass; +pub type GameObjV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/gen_world/v1_381_67_09_pc.rs b/bff/src/class/gen_world/v1_381_67_09_pc.rs index e5a413f..efb4ebb 100644 --- a/bff/src/class/gen_world/v1_381_67_09_pc.rs +++ b/bff/src/class/gen_world/v1_381_67_09_pc.rs @@ -1,13 +1,11 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u15, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; use crate::map::BffMap; -use crate::math::{Mat4f, Quat, Vec2f, Vec3f}; +use crate::math::{Mat4f, Vec2f, Vec3f}; use crate::name::Name; use crate::strings::{FixedStringNull, PascalStringNull}; @@ -63,74 +61,8 @@ struct Region { region_edges_indices: DynArray, } -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, -} - #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ObjectLinkHeaderV1_381_67_09PC))] pub struct GenWorldBodyV1_381_67_09PC { node_name: Name, user_define_name: Name, @@ -148,4 +80,4 @@ pub struct GenWorldBodyV1_381_67_09PC { regions: BffMap, Region>, } -pub type GenWorldV1_381_67_09PC = TrivialClass; +pub type GenWorldV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/gw_road/v1_381_67_09_pc.rs b/bff/src/class/gw_road/v1_381_67_09_pc.rs index b99ad26..94e6ec2 100644 --- a/bff/src/class/gw_road/v1_381_67_09_pc.rs +++ b/bff/src/class/gw_road/v1_381_67_09_pc.rs @@ -3,6 +3,7 @@ use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::ResourceObjectLinkHeader; use crate::math::Vec2f; use crate::name::Name; @@ -34,12 +35,7 @@ struct Unused5 { } #[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct GwRoadBodyV1_381_67_09PC { road_count: u32, gen_road_min: Vec2f, @@ -54,4 +50,4 @@ pub struct GwRoadBodyV1_381_67_09PC { gen_world_name: Name, } -pub type GwRoadV1_381_67_09PC = TrivialClass; +pub type GwRoadV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/light/v1_291_03_06_pc.rs b/bff/src/class/light/v1_291_03_06_pc.rs index 6694cc8..2051745 100644 --- a/bff/src/class/light/v1_291_03_06_pc.rs +++ b/bff/src/class/light/v1_291_03_06_pc.rs @@ -2,24 +2,11 @@ use binrw::BinRead; use serde::Serialize; use crate::class::trivial_class::TrivialClass; -use crate::dynarray::DynArray; -use crate::math::{Mat4f, Quat, Sphere, Vec3f, RGBA}; -use crate::name::Name; +use crate::link_header::ObjectLinkHeaderV1_06_63_02PC; +use crate::math::{Quat, Vec3f, RGBA}; #[derive(BinRead, Debug, Serialize)] -pub struct LinkInfo { - link_crc32: Name, - links: DynArray, - data_crc32: Name, - b_sphere_local: Sphere, - unknown_matrix: Mat4f, - fade_out_distance: f32, - flags: u32, - r#type: u16, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkInfo))] +#[br(import(_link_header: &ObjectLinkHeaderV1_06_63_02PC))] pub struct LightBodyV1_291_03_06PC { rotation: Quat, direction: Vec3f, @@ -28,4 +15,4 @@ pub struct LightBodyV1_291_03_06PC { position: Vec3f, } -pub type LightV1_291_03_06PC = TrivialClass; +pub type LightV1_291_03_06PC = TrivialClass; diff --git a/bff/src/class/light/v1_381_67_09_pc.rs b/bff/src/class/light/v1_381_67_09_pc.rs index 9005709..6dc0701 100644 --- a/bff/src/class/light/v1_381_67_09_pc.rs +++ b/bff/src/class/light/v1_381_67_09_pc.rs @@ -1,81 +1,12 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u15, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; -use crate::math::{Mat4f, Quat, Vec3f, Vec4f}; -use crate::name::Name; - -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, -} +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; +use crate::math::{Quat, Vec3f, Vec4f}; #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ObjectLinkHeaderV1_381_67_09PC))] pub struct LightBodyV1_381_67_09PC { rotation: Quat, direction: Vec3f, @@ -84,4 +15,4 @@ pub struct LightBodyV1_381_67_09PC { position: Vec3f, } -pub type LightV1_381_67_09PC = TrivialClass; +pub type LightV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/light_data/v1_381_67_09_pc.rs b/bff/src/class/light_data/v1_381_67_09_pc.rs index 3c17374..2212d92 100644 --- a/bff/src/class/light_data/v1_381_67_09_pc.rs +++ b/bff/src/class/light_data/v1_381_67_09_pc.rs @@ -1,42 +1,14 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u19, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; +use crate::link_header::{ResourceObjectLinkHeader, ObjectDatasFlagsV1_381_67_09PC}; use crate::math::{Vec3, Vec3f}; -use crate::name::Name; - -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectDatasFlags { - fl_objectdatas_hide: u1, - fl_objectdatas_code_control: u1, - fl_objectdatas_cloned: u1, - fl_objectdatas_skinned: u1, - fl_objectdatas_morphed: u1, - fl_objectdatas_vreflect: u1, - fl_objectdatas_hide_shadow: u1, - fl_objectdatas_static_shadow: u1, - fl_objectdatas_vp0_hide: u1, - fl_objectdatas_vp1_hide: u1, - fl_objectdatas_vp2_hide: u1, - fl_objectdatas_vp3_hide: u1, - fl_objectdatas_last: u1, - padding: u19, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct LightDataBodyV1_381_67_09PC { - object_datas_flags: ObjectDatasFlags, + object_datas_flags: ObjectDatasFlagsV1_381_67_09PC, facing: Vec3f, local_collision_sphere: Vec3f, unused_vec: Vec3, @@ -44,4 +16,4 @@ pub struct LightDataBodyV1_381_67_09PC { local_collision_sphere_facing: Vec3f, } -pub type LightDataV1_381_67_09PC = TrivialClass; +pub type LightDataV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/lod/v1_06_63_02_pc.rs b/bff/src/class/lod/v1_06_63_02_pc.rs index 8b31cd5..ad52064 100644 --- a/bff/src/class/lod/v1_06_63_02_pc.rs +++ b/bff/src/class/lod/v1_06_63_02_pc.rs @@ -4,21 +4,10 @@ use serde_big_array::BigArray; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{DynBox, DynSphere, Mat4f, Sphere, Vec3f}; +use crate::link_header::ObjectLinkHeaderV1_06_63_02PC; +use crate::math::{DynBox, DynSphere, Vec3f}; use crate::name::Name; -#[derive(BinRead, Debug, Serialize)] -pub struct LinkInfo { - link_crc32: Name, - linked_crc32: DynArray, - lod_data_crc32: Name, - b_sphere_local: Sphere, - unk_matrix: Mat4f, - fade_out_distance: f32, - flags: u32, - r#type: u16, -} - #[derive(BinRead, Debug, Serialize)] struct ClassRes { id: u32, @@ -38,7 +27,7 @@ struct CylindreCol { } #[derive(BinRead, Debug, Serialize)] -#[br(import(link_header: &LinkInfo))] +#[br(import(link_header: &ObjectLinkHeaderV1_06_63_02PC))] pub struct LodBodyV1_06_63_02PC { b_sphere_col_node: Name, #[br(if(b_sphere_col_node != 0))] @@ -50,9 +39,9 @@ pub struct LodBodyV1_06_63_02PC { component_crc32s: DynArray, shadow_crc32: Name, anims: DynArray, - #[br(if(link_header.flags & 1048576 >= 1))] + #[br(if(link_header.flags() & 0x100000 != 0))] sounds: Option>, user_define_crc32: Name, } -pub type LodV1_06_63_02PC = TrivialClass; +pub type LodV1_06_63_02PC = TrivialClass; diff --git a/bff/src/class/lod/v1_291_03_06_pc.rs b/bff/src/class/lod/v1_291_03_06_pc.rs index 2c2c77a..f5bfe5f 100644 --- a/bff/src/class/lod/v1_291_03_06_pc.rs +++ b/bff/src/class/lod/v1_291_03_06_pc.rs @@ -4,22 +4,11 @@ use serde_big_array::BigArray; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{DynBox, DynSphere, Mat4f, Sphere, Vec3f}; +use crate::link_header::ObjectLinkHeaderV1_06_63_02PC; +use crate::math::{DynBox, DynSphere, Vec3f}; use crate::name::Name; use crate::option::BffOption; -#[derive(BinRead, Debug, Serialize)] -pub struct LinkInfo { - link_crc32: Name, - links: DynArray, - lod_data_crc32: Name, - b_sphere_local: Sphere, - unknown_matrix: Mat4f, - fade_out_distance: f32, - flags: u32, - r#type: u16, -} - #[derive(BinRead, Debug, Serialize)] struct CylindreCol { #[serde(with = "BigArray")] @@ -39,7 +28,7 @@ struct ClassRes { } #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkInfo))] +#[br(import(_link_header: &ObjectLinkHeaderV1_06_63_02PC))] pub struct LodBodyV1_291_03_06PC { b_sphere_col_node: Name, #[br(if(b_sphere_col_node != 0))] @@ -55,4 +44,4 @@ pub struct LodBodyV1_291_03_06PC { user_define_crc32: Name, } -pub type LodV1_291_03_06PC = TrivialClass; +pub type LodV1_291_03_06PC = TrivialClass; diff --git a/bff/src/class/lod/v1_381_67_09_pc.rs b/bff/src/class/lod/v1_381_67_09_pc.rs index 9e9e59e..b081766 100644 --- a/bff/src/class/lod/v1_381_67_09_pc.rs +++ b/bff/src/class/lod/v1_381_67_09_pc.rs @@ -1,82 +1,14 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u15, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; use crate::map::BffMap; -use crate::math::{DynBox, DynSphere, Mat4f, Quat}; +use crate::math::{DynBox, DynSphere}; use crate::name::Name; use crate::option::BffOption; -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, -} - #[derive(BinRead, Debug, Serialize)] struct FadeDistances { x: f32, @@ -85,7 +17,7 @@ struct FadeDistances { } #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ObjectLinkHeaderV1_381_67_09PC))] pub struct LodBodyV1_381_67_09PC { collision_spheres: DynArray, collision_boxes: DynArray, @@ -97,4 +29,4 @@ pub struct LodBodyV1_381_67_09PC { user_define_name: Name, } -pub type LodV1_381_67_09PC = TrivialClass; +pub type LodV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/lod_data/v1_381_67_09_pc.rs b/bff/src/class/lod_data/v1_381_67_09_pc.rs index a5157dd..924f9f7 100644 --- a/bff/src/class/lod_data/v1_381_67_09_pc.rs +++ b/bff/src/class/lod_data/v1_381_67_09_pc.rs @@ -1,11 +1,9 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u19, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::{ResourceObjectLinkHeader, ObjectDatasFlagsV1_381_67_09PC}; use crate::math::Vec3f; use crate::name::Name; use crate::option::BffOption; @@ -30,38 +28,13 @@ struct Extended { zero11: u32, } -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectDatasFlags { - fl_objectdatas_hide: u1, - fl_objectdatas_code_control: u1, - fl_objectdatas_cloned: u1, - fl_objectdatas_skinned: u1, - fl_objectdatas_morphed: u1, - fl_objectdatas_vreflect: u1, - fl_objectdatas_hide_shadow: u1, - fl_objectdatas_static_shadow: u1, - fl_objectdatas_vp0_hide: u1, - fl_objectdatas_vp1_hide: u1, - fl_objectdatas_vp2_hide: u1, - fl_objectdatas_vp3_hide: u1, - fl_objectdatas_last: u1, - padding: u19, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - flags: ObjectDatasFlags, -} - #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct LodDataBodyV1_381_67_09PC { + flags: ObjectDatasFlagsV1_381_67_09PC, mesh_data_names: DynArray, zero: u32, extended: BffOption, } -pub type LodDataV1_381_67_09PC = TrivialClass; +pub type LodDataV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/material/v1_381_67_09_pc.rs b/bff/src/class/material/v1_381_67_09_pc.rs index b95d271..87f6108 100644 --- a/bff/src/class/material/v1_381_67_09_pc.rs +++ b/bff/src/class/material/v1_381_67_09_pc.rs @@ -1,10 +1,10 @@ use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u23, u26, u5, Bitsized, DebugBits, Number}; +use bilge::prelude::*; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; +use crate::link_header::ResourceObjectLinkHeader; use crate::math::{Vec2f, RGB}; use crate::name::Name; @@ -34,12 +34,7 @@ struct MaterialRdrFlags { } #[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct MaterialBodyV1_381_67_09PC { diffuse: RGB, opacity: f32, @@ -74,4 +69,4 @@ pub struct MaterialBodyV1_381_67_09PC { unused_bitmap_name1: Name, } -pub type MaterialV1_381_67_09PC = TrivialClass; +pub type MaterialV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/material_anim/v1_381_67_09_pc.rs b/bff/src/class/material_anim/v1_381_67_09_pc.rs index d82bd8b..e59a01c 100644 --- a/bff/src/class/material_anim/v1_381_67_09_pc.rs +++ b/bff/src/class/material_anim/v1_381_67_09_pc.rs @@ -1,10 +1,10 @@ use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, Bitsized, DebugBits, Number}; +use bilge::prelude::*; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; +use crate::link_header::ResourceObjectLinkHeader; use crate::name::Name; use crate::keyframer::{KeyframerFlag, KeyframerFloatLinearComp, KeyframerHdl, KeyframerVec2fLinear, KeyframerVec3fLinear, KeyframerVec4fLinear}; @@ -23,12 +23,7 @@ struct MaterialAnimFlags { } #[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct MaterialAnimBodyV1_381_67_09PC { bitmap_name_keyframer: KeyframerHdl, scroll_keyframer: KeyframerVec2fLinear, @@ -46,4 +41,4 @@ pub struct MaterialAnimBodyV1_381_67_09PC { flags: MaterialAnimFlags, } -pub type MaterialAnimV1_381_67_09PC = TrivialClass; +pub type MaterialAnimV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/material_obj/v1_381_67_09_pc.rs b/bff/src/class/material_obj/v1_381_67_09_pc.rs index 488453f..8efc2d5 100644 --- a/bff/src/class/material_obj/v1_381_67_09_pc.rs +++ b/bff/src/class/material_obj/v1_381_67_09_pc.rs @@ -3,18 +3,14 @@ use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::ResourceObjectLinkHeader; use crate::map::BffMap; use crate::name::Name; #[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct MaterialObjBodyV1_381_67_09PC { entries: BffMap>, } -pub type MaterialObjV1_381_67_09PC = TrivialClass; +pub type MaterialObjV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/mesh/v1_381_67_09_pc.rs b/bff/src/class/mesh/v1_381_67_09_pc.rs index 05073a9..8cdc3c2 100644 --- a/bff/src/class/mesh/v1_381_67_09_pc.rs +++ b/bff/src/class/mesh/v1_381_67_09_pc.rs @@ -1,18 +1,16 @@ use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u12, u15, u2, u24, Bitsized, DebugBits, Number}; +use bilge::prelude::*; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; use crate::map::BffMap; use crate::math::{ DynBox, DynSphere, - Mat4f, NumeratorFloat, - Quat, RangeBeginSize, RangeFirstLast, Vec2f, @@ -27,61 +25,6 @@ type VertexBlendIndex = f32; type DisplacementVectorComponent = NumeratorFloat; type ShortVecWeird = [NumeratorFloat; 3]; -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - #[derive(BinRead, Debug, Serialize)] struct FadeDistances { x: f32, @@ -91,13 +34,7 @@ struct FadeDistances { #[derive(BinRead, Debug, Serialize)] pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, + object_link_header: ObjectLinkHeaderV1_381_67_09PC, names: DynArray, fade: FadeDistances, dyn_spheres: DynArray, diff --git a/bff/src/class/mesh_data/v1_381_67_09_pc.rs b/bff/src/class/mesh_data/v1_381_67_09_pc.rs index 3b8a6b0..357f3f2 100644 --- a/bff/src/class/mesh_data/v1_381_67_09_pc.rs +++ b/bff/src/class/mesh_data/v1_381_67_09_pc.rs @@ -1,11 +1,10 @@ use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u19, Bitsized, DebugBits, Number}; +use bilge::prelude::*; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; -use crate::name::Name; +use crate::link_header::ResourceObjectLinkHeader; #[serialize_bits] #[bitsize(32)] @@ -28,12 +27,7 @@ struct ObjectDatasFlags { } #[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct MeshDataBodyV1_381_67_09PC { flags: ObjectDatasFlags, zero0: u32, @@ -42,4 +36,4 @@ pub struct MeshDataBodyV1_381_67_09PC { zero3: u32, } -pub type MeshDataV1_381_67_09PC = TrivialClass; +pub type MeshDataV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/node/v1_381_67_09_pc.rs b/bff/src/class/node/v1_381_67_09_pc.rs index 2c1e48b..84a96d9 100644 --- a/bff/src/class/node/v1_381_67_09_pc.rs +++ b/bff/src/class/node/v1_381_67_09_pc.rs @@ -2,24 +2,12 @@ use binrw::BinRead; use serde::Serialize; use crate::class::trivial_class::TrivialClass; -use crate::math::{Mat4f, Quat, Sphere, Vec3f, RGBA}; +use crate::link_header::ResourceObjectLinkHeader; +use crate::math::{Mat4f, Quat, Sphere, Vec3f, RGBA, Rect}; use crate::name::Name; #[derive(BinRead, Debug, Serialize)] -struct Rect { - x1: i32, - y1: i32, - x2: i32, - y2: i32, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct NodeBodyV1_381_67_09PC { parent_name: Name, head_child_name: Name, @@ -47,4 +35,4 @@ pub struct NodeBodyV1_381_67_09PC { world_transform_mat4: Mat4f, } -pub type NodeV1_381_67_09PC = TrivialClass; +pub type NodeV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/omni/v1_381_67_09_pc.rs b/bff/src/class/omni/v1_381_67_09_pc.rs index 8ee441f..978d3a8 100644 --- a/bff/src/class/omni/v1_381_67_09_pc.rs +++ b/bff/src/class/omni/v1_381_67_09_pc.rs @@ -1,81 +1,13 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u15, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; -use crate::math::{Mat4f, Quat}; +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; +use crate::math::Mat4f; use crate::name::Name; -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, -} - #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ObjectLinkHeaderV1_381_67_09PC))] pub struct OmniBodyV1_381_67_09PC { scale_matrix: Mat4f, translation_matrix: Mat4f, @@ -84,4 +16,4 @@ pub struct OmniBodyV1_381_67_09PC { material_anim_name1: Name, } -pub type OmniV1_381_67_09PC = TrivialClass; +pub type OmniV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/particles/v1_381_67_09_pc.rs b/bff/src/class/particles/v1_381_67_09_pc.rs index b0732ce..6a08f89 100644 --- a/bff/src/class/particles/v1_381_67_09_pc.rs +++ b/bff/src/class/particles/v1_381_67_09_pc.rs @@ -1,12 +1,12 @@ use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u15, Bitsized, DebugBits, Number}; +use bilge::prelude::*; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{Mat4f, Quat, Vec3f}; +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; +use crate::math::{Mat4f, Vec3f}; use crate::name::Name; use crate::keyframer::{KeyframerFloatLinear, KeyframerVec2fLinear, KeyframerVec3fLinear, KeyframerVec4fLinear}; @@ -61,74 +61,8 @@ struct ParticlesEmitter { material_anim_name: Name, } -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, -} - #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ObjectLinkHeaderV1_381_67_09PC))] pub struct ParticlesBodyV1_381_67_09PC { particles_emitters: DynArray, mats: DynArray, @@ -136,4 +70,4 @@ pub struct ParticlesBodyV1_381_67_09PC { unknown3: u16, } -pub type ParticlesV1_381_67_09PC = TrivialClass; +pub type ParticlesV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/particles_data/v1_381_67_09_pc.rs b/bff/src/class/particles_data/v1_381_67_09_pc.rs index 4be7f22..8f9334f 100644 --- a/bff/src/class/particles_data/v1_381_67_09_pc.rs +++ b/bff/src/class/particles_data/v1_381_67_09_pc.rs @@ -1,38 +1,10 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u19, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::{ResourceObjectLinkHeader, ObjectDatasFlagsV1_381_67_09PC}; use crate::math::Vec3f; -use crate::name::Name; - -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectDatasFlags { - fl_objectdatas_hide: u1, - fl_objectdatas_code_control: u1, - fl_objectdatas_cloned: u1, - fl_objectdatas_skinned: u1, - fl_objectdatas_morphed: u1, - fl_objectdatas_vreflect: u1, - fl_objectdatas_hide_shadow: u1, - fl_objectdatas_static_shadow: u1, - fl_objectdatas_vp0_hide: u1, - fl_objectdatas_vp1_hide: u1, - fl_objectdatas_vp2_hide: u1, - fl_objectdatas_vp3_hide: u1, - fl_objectdatas_last: u1, - padding: u19, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} #[derive(BinRead, Debug, Serialize)] struct FadeDistances { @@ -42,13 +14,13 @@ struct FadeDistances { } #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct ParticlesDataBodyV1_381_67_09PC { - flags: ObjectDatasFlags, + flags: ObjectDatasFlagsV1_381_67_09PC, position: Vec3f, fade: FadeDistances, shorts: DynArray, zero: u32, } -pub type ParticlesDataV1_381_67_09PC = TrivialClass; +pub type ParticlesDataV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/rot_shape/v1_06_63_02_pc.rs b/bff/src/class/rot_shape/v1_06_63_02_pc.rs index 7170f42..28a3205 100644 --- a/bff/src/class/rot_shape/v1_06_63_02_pc.rs +++ b/bff/src/class/rot_shape/v1_06_63_02_pc.rs @@ -6,36 +6,6 @@ use crate::dynarray::DynArray; use crate::math::{Mat, Sphere, Vec2f, Vec3f}; use crate::name::Name; -#[derive(BinRead, Debug, Serialize)] -struct Box { - mat: Mat<3, 4>, - vec: Vec3f, - maybe_scale: f32, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkInfo { - link_crc32: Name, - linked_crc32: DynArray, - data_crc32: Name, - b_sphere_local: Sphere, - b_box: Box, - fade_out_distance: f32, - flags: u32, - r#type: u16, -} - -#[derive(BinRead, Debug, Serialize)] -struct ObjectHeader { - data_size: u32, - link_size: u32, - decompressed_size: u32, - compressed_size: u32, - class_crc32: Name, - name_crc32: Name, - link_info: LinkInfo, -} - #[derive(BinRead, Debug, Serialize)] struct PointsRelated0 { data: [u8; 12], @@ -69,8 +39,8 @@ struct Morpher { } #[derive(BinRead, Debug, Serialize)] -struct Points { - header: ObjectHeader, +struct LinkInfo { + object_link_header: ObjectV1_06_63_02PC, vertices: DynArray, points_relateds1: DynArray, morpher: Morpher, diff --git a/bff/src/class/rot_shape/v1_291_03_06_pc.rs b/bff/src/class/rot_shape/v1_291_03_06_pc.rs index 8eade71..9349dec 100644 --- a/bff/src/class/rot_shape/v1_291_03_06_pc.rs +++ b/bff/src/class/rot_shape/v1_291_03_06_pc.rs @@ -3,16 +3,10 @@ use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{Mat, Sphere, Vec2f, Vec3f}; +use crate::link_header::ObjectLinkHeaderV1_06_63_02PC; +use crate::math::{Vec2f, Vec3f}; use crate::name::Name; -#[derive(BinRead, Debug, Serialize)] -struct Box { - matrix: Mat<3, 4>, - vector: Vec3f, - scale: f32, -} - #[derive(BinRead, Debug, Serialize)] struct PointsRelated0 { data: [u8; 16], @@ -23,18 +17,6 @@ struct PointsRelated1 { data: [u8; 4], } -#[derive(BinRead, Debug, Serialize)] -pub struct LinkInfo { - link_crc32: Name, - links: DynArray, - data_crc32: Name, - b_sphere_local: Sphere, - b_box: Box, - fade_out_distance: f32, - flags: u32, - r#type: u16, -} - #[derive(BinRead, Debug, Serialize)] struct Points { vertices: DynArray, @@ -43,7 +25,7 @@ struct Points { } #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkInfo))] +#[br(import(_link_header: &ObjectLinkHeaderV1_06_63_02PC))] pub struct RotShapeBodyV1_291_03_06PC { points: Points, material_indices: DynArray, @@ -54,4 +36,4 @@ pub struct RotShapeBodyV1_291_03_06PC { rot_shape_type: u16, } -pub type RotShapeV1_291_03_06PC = TrivialClass; +pub type RotShapeV1_291_03_06PC = TrivialClass; diff --git a/bff/src/class/rot_shape/v1_381_67_09_pc.rs b/bff/src/class/rot_shape/v1_381_67_09_pc.rs index 194b14c..32dcc35 100644 --- a/bff/src/class/rot_shape/v1_381_67_09_pc.rs +++ b/bff/src/class/rot_shape/v1_381_67_09_pc.rs @@ -1,12 +1,10 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u15, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{Mat4f, Quat, Vec2f, Vec3f}; +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; +use crate::math::{Vec2f, Vec3f}; use crate::name::Name; #[derive(BinRead, Debug, Serialize)] @@ -16,74 +14,8 @@ enum BillboardMode { CompleteBillboard = 1, } -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, -} - #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ObjectLinkHeaderV1_381_67_09PC))] pub struct RotShapeBodyV1_381_67_09PC { origins: DynArray, zero: f32, @@ -95,4 +27,4 @@ pub struct RotShapeBodyV1_381_67_09PC { billboard_mode: BillboardMode, } -pub type RotShapeV1_381_67_09PC = TrivialClass; +pub type RotShapeV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/rot_shape_data/v1_381_67_09_pc.rs b/bff/src/class/rot_shape_data/v1_381_67_09_pc.rs index fec4622..d461bd8 100644 --- a/bff/src/class/rot_shape_data/v1_381_67_09_pc.rs +++ b/bff/src/class/rot_shape_data/v1_381_67_09_pc.rs @@ -1,45 +1,17 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u19, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::name::Name; - -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectDatasFlags { - fl_objectdatas_hide: u1, - fl_objectdatas_code_control: u1, - fl_objectdatas_cloned: u1, - fl_objectdatas_skinned: u1, - fl_objectdatas_morphed: u1, - fl_objectdatas_vreflect: u1, - fl_objectdatas_hide_shadow: u1, - fl_objectdatas_static_shadow: u1, - fl_objectdatas_vp0_hide: u1, - fl_objectdatas_vp1_hide: u1, - fl_objectdatas_vp2_hide: u1, - fl_objectdatas_vp3_hide: u1, - fl_objectdatas_last: u1, - padding: u19, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} +use crate::link_header::{ResourceObjectLinkHeader, ObjectDatasFlagsV1_381_67_09PC}; #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct RotShapeDataBodyV1_381_67_09PC { - flags: ObjectDatasFlags, + flags: ObjectDatasFlagsV1_381_67_09PC, zeros: DynArray, #[br(count = zeros.len() * 28)] pad: Vec, } -pub type RotShapeDataV1_381_67_09PC = TrivialClass; +pub type RotShapeDataV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/rtc/v1_381_67_09_pc.rs b/bff/src/class/rtc/v1_381_67_09_pc.rs index c3ffa34..759510e 100644 --- a/bff/src/class/rtc/v1_381_67_09_pc.rs +++ b/bff/src/class/rtc/v1_381_67_09_pc.rs @@ -3,6 +3,7 @@ use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::ResourceObjectLinkHeader; use crate::name::Name; use crate::keyframer::{KeyframerFloatComp, KeyframerVec3fComp, KeyframerMessage, KeyframerRot, KeyframerFloat, KeyframerVec3f}; @@ -57,12 +58,7 @@ struct Unknown9 { } #[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct RtcBodyV1_381_67_09PC { duration: f32, unknown1s: DynArray, @@ -76,4 +72,4 @@ pub struct RtcBodyV1_381_67_09PC { unknown30: KeyframerMessage, } -pub type RtcV1_381_67_09PC = TrivialClass; +pub type RtcV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/skel/v1_381_67_09_pc.rs b/bff/src/class/skel/v1_381_67_09_pc.rs index e93fb45..8c4bbdd 100644 --- a/bff/src/class/skel/v1_381_67_09_pc.rs +++ b/bff/src/class/skel/v1_381_67_09_pc.rs @@ -1,11 +1,9 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u19, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::{ResourceObjectLinkHeader, ObjectDatasFlagsV1_381_67_09PC}; use crate::math::{Mat4f, Quat, Sphere, Vec3, Vec3f}; use crate::name::Name; @@ -51,35 +49,10 @@ struct BoxColBone { names: [Name; 3], } -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectDatasFlags { - fl_objectdatas_hide: u1, - fl_objectdatas_code_control: u1, - fl_objectdatas_cloned: u1, - fl_objectdatas_skinned: u1, - fl_objectdatas_morphed: u1, - fl_objectdatas_vreflect: u1, - fl_objectdatas_hide_shadow: u1, - fl_objectdatas_static_shadow: u1, - fl_objectdatas_vp0_hide: u1, - fl_objectdatas_vp1_hide: u1, - fl_objectdatas_vp2_hide: u1, - fl_objectdatas_vp3_hide: u1, - fl_objectdatas_last: u1, - padding: u19, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - flags: ObjectDatasFlags, -} - #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct SkelBodyV1_381_67_09PC { + flags: ObjectDatasFlagsV1_381_67_09PC, bounding_sphere_center: Sphere, bones: DynArray, material_names: DynArray, @@ -91,4 +64,4 @@ pub struct SkelBodyV1_381_67_09PC { box_col_bones: DynArray, } -pub type SkelV1_381_67_09PC = TrivialClass; +pub type SkelV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/skin/v1_291_03_06_pc.rs b/bff/src/class/skin/v1_291_03_06_pc.rs index 09f6426..693d7f6 100644 --- a/bff/src/class/skin/v1_291_03_06_pc.rs +++ b/bff/src/class/skin/v1_291_03_06_pc.rs @@ -3,22 +3,10 @@ use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::ObjectLinkHeaderV1_06_63_02PC; use crate::map::BffMap; -use crate::math::{Mat4f, Sphere}; use crate::name::Name; -#[derive(BinRead, Debug, Serialize)] -pub struct LinkInfo { - link_crc32: Name, - links: DynArray, - skel_crc32: Name, - b_sphere_local: Sphere, - unknown_matrix: Mat4f, - fade_out_distance: f32, - flags: u32, - r#type: u16, -} - #[derive(BinRead, Debug, Serialize)] struct Unknown1 { unknown1: [u8; 8], @@ -69,7 +57,7 @@ struct SkinSection { } #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkInfo))] +#[br(import(_link_header: &ObjectLinkHeaderV1_06_63_02PC))] pub struct SkinBodyV1_291_03_06PC { mesh_crc32s: DynArray, unknown0s: DynArray, @@ -83,4 +71,4 @@ pub struct SkinBodyV1_291_03_06PC { skin_sections: DynArray, } -pub type SkinV1_291_03_06PC = TrivialClass; +pub type SkinV1_291_03_06PC = TrivialClass; diff --git a/bff/src/class/skin/v1_381_67_09_pc.rs b/bff/src/class/skin/v1_381_67_09_pc.rs index 184cc9e..b16bafb 100644 --- a/bff/src/class/skin/v1_381_67_09_pc.rs +++ b/bff/src/class/skin/v1_381_67_09_pc.rs @@ -1,12 +1,9 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u15, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{Mat4f, Quat}; +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; use crate::name::Name; #[derive(BinRead, Debug, Serialize)] @@ -24,74 +21,8 @@ struct SkinSection { skin_subsections: DynArray, } -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, -} - #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ObjectLinkHeaderV1_381_67_09PC))] pub struct SkinBodyV1_381_67_09PC { mesh_names: DynArray, zeros: [u32; 4], @@ -101,4 +32,4 @@ pub struct SkinBodyV1_381_67_09PC { skin_sections: DynArray, } -pub type SkinV1_381_67_09PC = TrivialClass; +pub type SkinV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/sound/v1_291_03_06_pc.rs b/bff/src/class/sound/v1_291_03_06_pc.rs index f80a3d6..bef36f5 100644 --- a/bff/src/class/sound/v1_291_03_06_pc.rs +++ b/bff/src/class/sound/v1_291_03_06_pc.rs @@ -1,7 +1,6 @@ use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u13, Bitsized, DebugBits, Number}; +use bilge::prelude::*; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; diff --git a/bff/src/class/sound/v1_381_67_09_pc.rs b/bff/src/class/sound/v1_381_67_09_pc.rs index 7a68d37..3b4e2a4 100644 --- a/bff/src/class/sound/v1_381_67_09_pc.rs +++ b/bff/src/class/sound/v1_381_67_09_pc.rs @@ -1,7 +1,6 @@ use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u13, Bitsized, DebugBits, Number}; +use bilge::prelude::*; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; diff --git a/bff/src/class/spline/v1_06_63_02_pc.rs b/bff/src/class/spline/v1_06_63_02_pc.rs index b73b5dd..1ac2b6b 100644 --- a/bff/src/class/spline/v1_06_63_02_pc.rs +++ b/bff/src/class/spline/v1_06_63_02_pc.rs @@ -3,27 +3,8 @@ use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{Mat, Sphere, Vec3f, Vec4f}; -use crate::name::Name; - -#[derive(BinRead, Debug, Serialize)] -struct Box { - mat: Mat<3, 4>, - vec: Vec3f, - scale: f32, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkInfo { - link_name: Name, - links: DynArray, - data_crc32: Name, - b_sphere_local: Sphere, - b_box: Box, - fade_out_distance: f32, - flags: u32, - r#type: u16, -} +use crate::link_header::ObjectLinkHeaderV1_06_63_02PC; +use crate::math::{Vec3f, Vec4f}; #[derive(BinRead, Debug, Serialize)] struct Segment { @@ -41,7 +22,7 @@ struct Spline { } #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkInfo))] +#[br(import(_link_header: &ObjectLinkHeaderV1_06_63_02PC))] pub struct SplineBodyV1_06_63_02PC { points: DynArray, splines: DynArray, @@ -49,4 +30,4 @@ pub struct SplineBodyV1_06_63_02PC { length: f32, } -pub type SplineV1_06_63_02PC = TrivialClass; +pub type SplineV1_06_63_02PC = TrivialClass; diff --git a/bff/src/class/spline/v1_381_67_09_pc.rs b/bff/src/class/spline/v1_381_67_09_pc.rs index d20e3d1..8beeade 100644 --- a/bff/src/class/spline/v1_381_67_09_pc.rs +++ b/bff/src/class/spline/v1_381_67_09_pc.rs @@ -1,13 +1,10 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u15, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{Mat4f, Quat, Vec3f, Vec4f}; -use crate::name::Name; +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; +use crate::math::{Vec3f, Vec4f}; #[derive(BinRead, Debug, Serialize)] struct SplineSegmentSubdivision { @@ -24,74 +21,8 @@ struct SplineSegment { spline_segment_subdivisions: [SplineSegmentSubdivision; 8], } -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, -} - #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ObjectLinkHeaderV1_381_67_09PC))] pub struct SplineBodyV1_381_67_09PC { points: DynArray, spline_segments: DynArray, @@ -99,4 +30,4 @@ pub struct SplineBodyV1_381_67_09PC { length: f32, } -pub type SplineV1_381_67_09PC = TrivialClass; +pub type SplineV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/spline_graph/v1_381_67_09_pc.rs b/bff/src/class/spline_graph/v1_381_67_09_pc.rs index d8ee167..b335153 100644 --- a/bff/src/class/spline_graph/v1_381_67_09_pc.rs +++ b/bff/src/class/spline_graph/v1_381_67_09_pc.rs @@ -1,13 +1,10 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u15, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{Mat4f, Quat, Vec3f, Vec4f}; -use crate::name::Name; +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; +use crate::math::{Vec3f, Vec4f}; #[derive(BinRead, Debug, Serialize)] struct SplineSegmentSubdivision { @@ -24,74 +21,8 @@ struct SplineSegment { spline_segment_subdivisions: [SplineSegmentSubdivision; 8], } -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, -} - #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ObjectLinkHeaderV1_381_67_09PC))] pub struct SplineGraphBodyV1_381_67_09PC { points: DynArray, spline_segments: DynArray, @@ -102,4 +33,4 @@ pub struct SplineGraphBodyV1_381_67_09PC { spline_segment_datas: DynArray>, } -pub type SplineGraphV1_381_67_09PC = TrivialClass; +pub type SplineGraphV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/surface/v1_06_63_02_pc.rs b/bff/src/class/surface/v1_06_63_02_pc.rs index e02f02a..71a1507 100644 --- a/bff/src/class/surface/v1_06_63_02_pc.rs +++ b/bff/src/class/surface/v1_06_63_02_pc.rs @@ -1,7 +1,6 @@ use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u3, u5, Bitsized, DebugBits, Number}; +use bilge::prelude::*; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; @@ -10,23 +9,6 @@ use crate::math::{Mat4f, Sphere, Vec2f, Vec3f, Vec4f, RGB}; use crate::name::Name; use crate::option::BffOption; -#[derive(BinRead, Debug, Serialize)] -struct Box { - transformation: Mat4f, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkInfo { - link_crc32: Name, - links: DynArray, - surface_data_crc32: Name, - b_sphere_local: Sphere, - unknown_matrix: Mat4f, - fade_out_distance: f32, - flags: u32, - r#type: u16, -} - #[derive(BinRead, Debug, Serialize)] struct PointsRelated0 { vec3: Vec3f, @@ -164,7 +146,7 @@ struct ShouldDrawRelated { } #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkInfo))] +#[br(import(_link_header: &ObjectV1_06_63_02PC))] pub struct SurfaceBodyV1_06_63_02PC { points: Points, edge_cols: DynArray, @@ -179,4 +161,4 @@ pub struct SurfaceBodyV1_06_63_02PC { sead_index: BffOption, } -pub type SurfaceV1_06_63_02PC = TrivialClass; +pub type SurfaceV1_06_63_02PC = TrivialClass; diff --git a/bff/src/class/surface/v1_291_03_06_pc.rs b/bff/src/class/surface/v1_291_03_06_pc.rs index 50a2c67..530bf5a 100644 --- a/bff/src/class/surface/v1_291_03_06_pc.rs +++ b/bff/src/class/surface/v1_291_03_06_pc.rs @@ -1,27 +1,15 @@ use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u3, u5, Bitsized, DebugBits, Number}; +use bilge::prelude::*; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::ObjectLinkHeaderV1_06_63_02PC; use crate::math::{Mat4f, Sphere, Vec2f, Vec3f, Vec4f, RGB}; use crate::name::Name; use crate::option::BffOption; -#[derive(BinRead, Debug, Serialize)] -pub struct LinkInfo { - link_crc32: Name, - links: DynArray, - surface_data_crc32: Name, - b_sphere_local: Sphere, - unknown_matrix: Mat4f, - fade_out_distance: f32, - flags: u32, - r#type: u16, -} - #[derive(BinRead, Debug, Serialize)] struct PointsRelated0 { vector: Vec3f, @@ -151,7 +139,7 @@ struct SeadIndex { } #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkInfo))] +#[br(import(_link_header: &ObjectLinkHeaderV1_06_63_02PC))] pub struct SurfaceBodyV1_291_03_06PC { points: Points, edge_cols: DynArray, @@ -166,4 +154,4 @@ pub struct SurfaceBodyV1_291_03_06PC { sead_index: BffOption, } -pub type SurfaceV1_291_03_06PC = TrivialClass; +pub type SurfaceV1_291_03_06PC = TrivialClass; diff --git a/bff/src/class/surface/v1_381_67_09_pc.rs b/bff/src/class/surface/v1_381_67_09_pc.rs index 206d83a..26a4fee 100644 --- a/bff/src/class/surface/v1_381_67_09_pc.rs +++ b/bff/src/class/surface/v1_381_67_09_pc.rs @@ -1,13 +1,13 @@ use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u15, u3, u5, Bitsized, DebugBits, Number}; +use bilge::prelude::*; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use serde_big_array::BigArray; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{Mat4f, Quat, RangeBeginSize, Vec2f, Vec3f, Vec4f}; +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; +use crate::math::{Mat4f, RangeBeginSize, Vec2f, Vec3f, Vec4f}; use crate::name::Name; use crate::option::BffOption; @@ -77,74 +77,8 @@ struct SeadIndex { patch_count: u32, } -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, -} - #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ObjectLinkHeaderV1_381_67_09PC))] pub struct SurfaceBodyV1_381_67_09PC { points: DynArray, vec4fs: DynArray, @@ -160,4 +94,4 @@ pub struct SurfaceBodyV1_381_67_09PC { sead_index: BffOption, } -pub type SurfaceV1_381_67_09PC = TrivialClass; +pub type SurfaceV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/surface_datas/v1_381_67_09_pc.rs b/bff/src/class/surface_datas/v1_381_67_09_pc.rs index e7d72bd..0ee6999 100644 --- a/bff/src/class/surface_datas/v1_381_67_09_pc.rs +++ b/bff/src/class/surface_datas/v1_381_67_09_pc.rs @@ -1,41 +1,13 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u19, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; -use crate::name::Name; - -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectDatasFlags { - fl_objectdatas_hide: u1, - fl_objectdatas_code_control: u1, - fl_objectdatas_cloned: u1, - fl_objectdatas_skinned: u1, - fl_objectdatas_morphed: u1, - fl_objectdatas_vreflect: u1, - fl_objectdatas_hide_shadow: u1, - fl_objectdatas_static_shadow: u1, - fl_objectdatas_vp0_hide: u1, - fl_objectdatas_vp1_hide: u1, - fl_objectdatas_vp2_hide: u1, - fl_objectdatas_vp3_hide: u1, - fl_objectdatas_last: u1, - padding: u19, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} +use crate::link_header::{ResourceObjectLinkHeader, ObjectDatasFlagsV1_381_67_09PC}; #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct SurfaceDatasBodyV1_381_67_09PC { - flags: ObjectDatasFlags, + flags: ObjectDatasFlagsV1_381_67_09PC, } -pub type SurfaceDatasV1_381_67_09PC = TrivialClass; +pub type SurfaceDatasV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/user_define/v1_291_03_06_pc.rs b/bff/src/class/user_define/v1_291_03_06_pc.rs index f33ec1e..c9c51fd 100644 --- a/bff/src/class/user_define/v1_291_03_06_pc.rs +++ b/bff/src/class/user_define/v1_291_03_06_pc.rs @@ -2,12 +2,13 @@ use binrw::BinRead; use serde::Serialize; use crate::class::trivial_class::TrivialClass; +use crate::link_header::ResourceObjectLinkHeader; use crate::strings::PascalString; #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &()))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct UserDefineBodyV1_291_03_06PC { data: PascalString, } -pub type UserDefineV1_291_03_06PC = TrivialClass<(), UserDefineBodyV1_291_03_06PC>; +pub type UserDefineV1_291_03_06PC = TrivialClass; diff --git a/bff/src/class/warp/v1_06_63_02_pc.rs b/bff/src/class/warp/v1_06_63_02_pc.rs index 0f7d7b5..79d373f 100644 --- a/bff/src/class/warp/v1_06_63_02_pc.rs +++ b/bff/src/class/warp/v1_06_63_02_pc.rs @@ -3,11 +3,12 @@ use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::ResourceObjectLinkHeader; use crate::math::Vec3f; use crate::name::Name; #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &()))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct WarpBodyV1_06_63_02PC { flag: u32, vertices: [Vec3f; 8], @@ -17,4 +18,4 @@ pub struct WarpBodyV1_06_63_02PC { anim_frame_names: DynArray, } -pub type WarpV1_06_63_02PC = TrivialClass<(), WarpBodyV1_06_63_02PC>; +pub type WarpV1_06_63_02PC = TrivialClass; diff --git a/bff/src/class/world/v1_381_67_09_pc.rs b/bff/src/class/world/v1_381_67_09_pc.rs index a6aa6f2..6c02f4f 100644 --- a/bff/src/class/world/v1_381_67_09_pc.rs +++ b/bff/src/class/world/v1_381_67_09_pc.rs @@ -3,6 +3,7 @@ use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; +use crate::link_header::ResourceObjectLinkHeader; use crate::math::Mat4f; use crate::name::Name; @@ -17,12 +18,7 @@ struct Unknown2 { } #[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ResourceObjectLinkHeader))] pub struct WorldBodyV1_381_67_09PC { node_name0: Name, warp_name: Name, @@ -48,4 +44,4 @@ pub struct WorldBodyV1_381_67_09PC { material_anim_name: DynArray, } -pub type WorldV1_381_67_09PC = TrivialClass; +pub type WorldV1_381_67_09PC = TrivialClass; diff --git a/bff/src/class/world_ref/v1_381_67_09_pc.rs b/bff/src/class/world_ref/v1_381_67_09_pc.rs index 5a887b9..bbcd2a9 100644 --- a/bff/src/class/world_ref/v1_381_67_09_pc.rs +++ b/bff/src/class/world_ref/v1_381_67_09_pc.rs @@ -1,12 +1,10 @@ -use bff_derive::serialize_bits; -use bilge::prelude::{bitsize, u1, u15, Bitsized, DebugBits, Number}; use binrw::BinRead; -use serde::ser::SerializeStruct; use serde::Serialize; use crate::class::trivial_class::TrivialClass; use crate::dynarray::DynArray; -use crate::math::{Mat4f, Quat, Vec3f}; +use crate::link_header::ObjectLinkHeaderV1_381_67_09PC; +use crate::math::{Mat4f, Vec3f}; use crate::name::Name; use crate::strings::PascalStringNull; @@ -16,74 +14,8 @@ struct UUIDPair { uuid1: u32, } -#[serialize_bits] -#[bitsize(32)] -#[derive(BinRead, DebugBits)] -struct ObjectFlags { - fl_object_init: u1, - fl_object_max_bsphere: u1, - fl_object_skinned: u1, - fl_object_morphed: u1, - fl_object_orientedbbox: u1, - fl_object_no_seaddisplay: u1, - fl_object_no_seadcollide: u1, - fl_object_no_display: u1, - fl_object_transparent: u1, - fl_object_optimized_vertex: u1, - fl_object_linear_mapping: u1, - fl_object_skinned_with_one_bone: u1, - fl_object_light_baked: u1, - fl_object_light_baked_with_material: u1, - fl_object_shadow_receiver: u1, - fl_object_no_tesselate: u1, - fl_object_last: u1, - padding: u15, -} - -#[derive(BinRead, Debug, Serialize)] -#[br(repr = u16)] -enum ObjectType { - Points = 0, - Surface = 1, - Spline = 2, - Skin = 3, - RotShape = 4, - Lod = 5, - Mesh = 6, - Camera = 7, - SplineZone = 9, - Occluder = 10, - CameraZone = 11, - Light = 12, - HFog = 13, - CollisionVol = 14, - Emiter = 15, - Omni = 16, - Graph = 17, - Particles = 18, - Flare = 19, - HField = 20, - Tree = 21, - GenWorld = 22, - Road = 23, - GenWorldSurface = 24, - SplineGraph = 25, - WorldRef = 26, -} - -#[derive(BinRead, Debug, Serialize)] -pub struct LinkHeader { - link_name: Name, - data_name: Name, - rot: Quat, - transform: Mat4f, - radius: f32, - flags: ObjectFlags, - r#type: ObjectType, -} - #[derive(BinRead, Debug, Serialize)] -#[br(import(_link_header: &LinkHeader))] +#[br(import(_link_header: &ObjectLinkHeaderV1_381_67_09PC))] pub struct WorldRefBodyV1_381_67_09PC { node_name0: Name, warp_name: Name, @@ -102,4 +34,4 @@ pub struct WorldRefBodyV1_381_67_09PC { zero: u32, } -pub type WorldRefV1_381_67_09PC = TrivialClass; +pub type WorldRefV1_381_67_09PC = TrivialClass; diff --git a/bff/src/lib.rs b/bff/src/lib.rs index 8250dca..faee106 100644 --- a/bff/src/lib.rs +++ b/bff/src/lib.rs @@ -18,6 +18,7 @@ pub mod strings; pub mod traits; pub mod versions; pub mod keyframer; +pub mod link_header; pub type BffResult = std::result::Result; pub type Endian = binrw::Endian; diff --git a/bff/src/link_header.rs b/bff/src/link_header.rs new file mode 100644 index 0000000..bf3ee3c --- /dev/null +++ b/bff/src/link_header.rs @@ -0,0 +1,114 @@ +use crate::{name::Name, math::{Quat, Mat4f, Sphere}, dynarray::DynArray}; +use bff_derive::serialize_bits; +use bilge::prelude::*; +use serde::Serialize; +use binrw::BinRead; + +#[derive(BinRead, Debug, Serialize)] +pub struct ResourceObjectLinkHeader { + link_name: Name, +} + +#[serialize_bits] +#[bitsize(32)] +#[derive(BinRead, DebugBits)] +pub struct ObjectDatasFlagsV1_381_67_09PC { + fl_objectdatas_hide: u1, + fl_objectdatas_code_control: u1, + fl_objectdatas_cloned: u1, + fl_objectdatas_skinned: u1, + fl_objectdatas_morphed: u1, + fl_objectdatas_vreflect: u1, + fl_objectdatas_hide_shadow: u1, + fl_objectdatas_static_shadow: u1, + fl_objectdatas_vp0_hide: u1, + fl_objectdatas_vp1_hide: u1, + fl_objectdatas_vp2_hide: u1, + fl_objectdatas_vp3_hide: u1, + fl_objectdatas_last: u1, + padding: u19, +} + +#[serialize_bits] +#[bitsize(32)] +#[derive(BinRead, DebugBits)] +pub struct ObjectFlagsV1_381_67_09PC { + fl_object_init: u1, + fl_object_max_bsphere: u1, + fl_object_skinned: u1, + fl_object_morphed: u1, + fl_object_orientedbbox: u1, + fl_object_no_seaddisplay: u1, + fl_object_no_seadcollide: u1, + fl_object_no_display: u1, + fl_object_transparent: u1, + fl_object_optimized_vertex: u1, + fl_object_linear_mapping: u1, + fl_object_skinned_with_one_bone: u1, + fl_object_light_baked: u1, + fl_object_light_baked_with_material: u1, + fl_object_shadow_receiver: u1, + fl_object_no_tesselate: u1, + fl_object_last: u1, + padding: u15, +} + +#[derive(BinRead, Debug, Serialize)] +#[br(repr = u16)] +pub enum ObjectType { + Points = 0, + Surface = 1, + Spline = 2, + Skin = 3, + RotShape = 4, + Lod = 5, + Mesh = 6, + Camera = 7, + SplineZone = 9, + Occluder = 10, + CameraZone = 11, + Light = 12, + HFog = 13, + CollisionVol = 14, + Emiter = 15, + Omni = 16, + Graph = 17, + Particles = 18, + Flare = 19, + HField = 20, + Tree = 21, + GenWorld = 22, + Road = 23, + GenWorldSurface = 24, + SplineGraph = 25, + WorldRef = 26, +} + +#[derive(BinRead, Debug, Serialize)] +pub struct ObjectLinkHeaderV1_381_67_09PC { + link_name: Name, + data_name: Name, + rot: Quat, + transform: Mat4f, + radius: f32, + flags: ObjectFlagsV1_381_67_09PC, + r#type: ObjectType, +} + +#[derive(BinRead, Debug, Serialize)] +pub struct ObjectLinkHeaderV1_06_63_02PC { + link_crc32: Name, + links: DynArray, + data_crc32: Name, + b_sphere_local: Sphere, + unknown_matrix: Mat4f, + fade_out_distance: f32, + flags: u32, + r#type: u16, +} + +impl ObjectLinkHeaderV1_06_63_02PC { + pub fn flags(&self) -> u32 { + self.flags + } +}