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 binrw::{binread, binrw};
|
||||||
|
|
||||||
use super::read_bool_from;
|
use super::{HeapString, StringHeap, read_bool_from};
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[brw(repr = i32)]
|
#[brw(repr = i32)]
|
||||||
|
@ -16,10 +16,13 @@ pub enum ModelCollisionType {
|
||||||
|
|
||||||
#[binread]
|
#[binread]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[br(import(string_heap: &StringHeap))]
|
||||||
#[br(little)]
|
#[br(little)]
|
||||||
pub struct BGInstanceObject {
|
pub struct BGInstanceObject {
|
||||||
pub asset_path_string_offset: u32,
|
#[br(args(string_heap))]
|
||||||
pub collision_asset_path_string_offset: u32,
|
pub asset_path: HeapString,
|
||||||
|
#[br(args(string_heap))]
|
||||||
|
pub collision_asset_path: HeapString,
|
||||||
pub collision_type: ModelCollisionType,
|
pub collision_type: ModelCollisionType,
|
||||||
pub attribute_mask: u32,
|
pub attribute_mask: u32,
|
||||||
pub attribute: u32,
|
pub attribute: u32,
|
||||||
|
@ -30,6 +33,6 @@ pub struct BGInstanceObject {
|
||||||
pub render_shadow_enabled: bool,
|
pub render_shadow_enabled: bool,
|
||||||
#[br(map = read_bool_from::<u8>)]
|
#[br(map = read_bool_from::<u8>)]
|
||||||
pub render_light_shadow_enabeld: bool,
|
pub render_light_shadow_enabeld: bool,
|
||||||
padding: u8,
|
#[brw(pad_before = 1)] // padding
|
||||||
pub render_model_clip_range: f32,
|
pub render_model_clip_range: f32,
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,10 +302,10 @@ pub enum LayerEntryType {
|
||||||
|
|
||||||
#[binread]
|
#[binread]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[br(import(magic: &LayerEntryType))]
|
#[br(import(magic: &LayerEntryType, string_heap: &StringHeap))]
|
||||||
pub enum LayerEntryData {
|
pub enum LayerEntryData {
|
||||||
#[br(pre_assert(*magic == LayerEntryType::BG))]
|
#[br(pre_assert(*magic == LayerEntryType::BG))]
|
||||||
BG(BGInstanceObject),
|
BG(#[br(args(string_heap))] BGInstanceObject),
|
||||||
#[br(pre_assert(*magic == LayerEntryType::LayLight))]
|
#[br(pre_assert(*magic == LayerEntryType::LayLight))]
|
||||||
LayLight(LightInstanceObject),
|
LayLight(LightInstanceObject),
|
||||||
#[br(pre_assert(*magic == LayerEntryType::Vfx))]
|
#[br(pre_assert(*magic == LayerEntryType::Vfx))]
|
||||||
|
@ -488,7 +488,7 @@ enum LayerSetReferencedType {
|
||||||
#[br(import(data_heap: &StringHeap, string_heap: &StringHeap), stream = r)]
|
#[br(import(data_heap: &StringHeap, string_heap: &StringHeap), stream = r)]
|
||||||
#[bw(import(data_heap: &mut StringHeap, string_heap: &mut StringHeap))]
|
#[bw(import(data_heap: &mut StringHeap, string_heap: &mut StringHeap))]
|
||||||
#[allow(dead_code)] // most of the fields are unused at the moment
|
#[allow(dead_code)] // most of the fields are unused at the moment
|
||||||
struct LayerHeader {
|
pub struct LayerHeader {
|
||||||
pub layer_id: u32,
|
pub layer_id: u32,
|
||||||
|
|
||||||
#[brw(args(string_heap))]
|
#[brw(args(string_heap))]
|
||||||
|
@ -613,15 +613,15 @@ const LAYER_CHUNK_HEADER_SIZE: usize = 24;
|
||||||
#[binread]
|
#[binread]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[br(little)]
|
#[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
|
#[allow(dead_code)] // most of the fields are unused at the moment
|
||||||
pub struct InstanceObject {
|
pub struct InstanceObject {
|
||||||
asset_type: LayerEntryType,
|
asset_type: LayerEntryType,
|
||||||
pub instance_id: u32,
|
pub instance_id: u32,
|
||||||
#[br(parse_with = string_from_offset, args(start))]
|
#[br(args(string_heap))]
|
||||||
pub name: String,
|
pub name: HeapString,
|
||||||
pub transform: Transformation,
|
pub transform: Transformation,
|
||||||
#[br(args(&asset_type))]
|
#[br(args(&asset_type, string_heap))]
|
||||||
pub data: LayerEntryData,
|
pub data: LayerEntryData,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,8 +706,11 @@ impl LayerGroup {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let start = cursor.stream_position().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