mirror of
https://github.com/redstrate/Physis.git
synced 2025-05-15 22:47:46 +00:00
Read BGInstanceObject asset and collision paths, expose LayerHeader
This commit is contained in:
parent
6413a592f0
commit
39f1c9665f
2 changed files with 18 additions and 12 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
use binrw::{binread, binrw};
|
||||
|
||||
use super::read_bool_from;
|
||||
use super::{HeapString, StringHeap, read_bool_from};
|
||||
|
||||
#[binrw]
|
||||
#[brw(repr = i32)]
|
||||
|
@ -16,10 +16,13 @@ pub enum ModelCollisionType {
|
|||
|
||||
#[binread]
|
||||
#[derive(Debug)]
|
||||
#[br(import(string_heap: &StringHeap))]
|
||||
#[br(little)]
|
||||
pub struct BGInstanceObject {
|
||||
pub asset_path_string_offset: u32,
|
||||
pub collision_asset_path_string_offset: u32,
|
||||
#[br(args(string_heap))]
|
||||
pub asset_path: HeapString,
|
||||
#[br(args(string_heap))]
|
||||
pub collision_asset_path: HeapString,
|
||||
pub collision_type: ModelCollisionType,
|
||||
pub attribute_mask: u32,
|
||||
pub attribute: u32,
|
||||
|
@ -30,6 +33,6 @@ pub struct BGInstanceObject {
|
|||
pub render_shadow_enabled: bool,
|
||||
#[br(map = read_bool_from::<u8>)]
|
||||
pub render_light_shadow_enabeld: bool,
|
||||
padding: u8,
|
||||
#[brw(pad_before = 1)] // padding
|
||||
pub render_model_clip_range: f32,
|
||||
}
|
||||
|
|
|
@ -302,10 +302,10 @@ pub enum LayerEntryType {
|
|||
|
||||
#[binread]
|
||||
#[derive(Debug)]
|
||||
#[br(import(magic: &LayerEntryType))]
|
||||
#[br(import(magic: &LayerEntryType, string_heap: &StringHeap))]
|
||||
pub enum LayerEntryData {
|
||||
#[br(pre_assert(*magic == LayerEntryType::BG))]
|
||||
BG(BGInstanceObject),
|
||||
BG(#[br(args(string_heap))] BGInstanceObject),
|
||||
#[br(pre_assert(*magic == LayerEntryType::LayLight))]
|
||||
LayLight(LightInstanceObject),
|
||||
#[br(pre_assert(*magic == LayerEntryType::Vfx))]
|
||||
|
@ -488,7 +488,7 @@ enum LayerSetReferencedType {
|
|||
#[br(import(data_heap: &StringHeap, string_heap: &StringHeap), stream = r)]
|
||||
#[bw(import(data_heap: &mut StringHeap, string_heap: &mut StringHeap))]
|
||||
#[allow(dead_code)] // most of the fields are unused at the moment
|
||||
struct LayerHeader {
|
||||
pub struct LayerHeader {
|
||||
pub layer_id: u32,
|
||||
|
||||
#[brw(args(string_heap))]
|
||||
|
@ -613,15 +613,15 @@ const LAYER_CHUNK_HEADER_SIZE: usize = 24;
|
|||
#[binread]
|
||||
#[derive(Debug)]
|
||||
#[br(little)]
|
||||
#[br(import(start: u64))]
|
||||
#[br(import(start: u64, string_heap: &StringHeap))]
|
||||
#[allow(dead_code)] // most of the fields are unused at the moment
|
||||
pub struct InstanceObject {
|
||||
asset_type: LayerEntryType,
|
||||
pub instance_id: u32,
|
||||
#[br(parse_with = string_from_offset, args(start))]
|
||||
pub name: String,
|
||||
#[br(args(string_heap))]
|
||||
pub name: HeapString,
|
||||
pub transform: Transformation,
|
||||
#[br(args(&asset_type))]
|
||||
#[br(args(&asset_type, string_heap))]
|
||||
pub data: LayerEntryData,
|
||||
}
|
||||
|
||||
|
@ -706,8 +706,11 @@ impl LayerGroup {
|
|||
.unwrap();
|
||||
|
||||
let start = cursor.stream_position().unwrap();
|
||||
let string_heap = StringHeap::from(start);
|
||||
|
||||
objects.push(InstanceObject::read_le_args(&mut cursor, (start,)).unwrap());
|
||||
objects.push(
|
||||
InstanceObject::read_le_args(&mut cursor, (start, &string_heap)).unwrap(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue