diff --git a/src/map.rs b/src/map.rs index 4cb0fe7e..7af7c4d8 100755 --- a/src/map.rs +++ b/src/map.rs @@ -524,7 +524,7 @@ pub struct SMeshInstanceOcclusionBounds { #[derive(BinRead, Debug, Clone)] pub struct Unk80809178 { // Points to havok pre-tag - pub unk0: RelPointer, + pub unk0: RelPointer, pub unk8: u32, pub unkc: u32, @@ -539,7 +539,7 @@ pub struct Unk80809178 { #[derive(BinRead, Debug, Clone)] pub struct Unk8080917b { // Points to havok pre-tag - pub unk0: RelPointer, + pub unk0: RelPointer, pub unk8: u32, pub unkc: u32, pub kind: u8, @@ -547,7 +547,7 @@ pub struct Unk8080917b { } #[derive(BinRead, Debug, Clone)] -pub struct Unk80809121 { +pub struct SSlipSurfaceVolume { pub unk0: [u32; 4], pub havok_file: TagHash, pub unk14: u32, diff --git a/src/map_resources.rs b/src/map_resources.rs index ffefe575..ebe697b0 100755 --- a/src/map_resources.rs +++ b/src/map_resources.rs @@ -41,7 +41,7 @@ pub enum MapResource { Decoration(AABB, TagHash), InstantKillBarrier(TagHash, u32, Option), TurnbackKillBarrier(TagHash, u32, Option), - Unk80809121(TagHash), + SlipSurfaceVolume(TagHash, Option), Unk808068d4(TagHash), PlayAreaBounds(TagHash, Option), Unk80808246(TagHash, u32, Option), @@ -107,7 +107,16 @@ impl MapResource { ) } } - MapResource::Unk80809121(h) => format!("Unk80809121 (havok {h})"), + MapResource::SlipSurfaceVolume(t, s) => { + if s.is_some() { + format!("Slippey Surface Volume (havok {t})") + } else { + format!( + "Slippey Surface Volume (havok {t})\n{} Havok shape visualization failed to load", + ICON_ALERT + ) + } + } MapResource::AmbientSound(s) => { if let Some(s) = s { format!( @@ -211,6 +220,9 @@ impl MapResource { 1.0, self.debug_color(), ), + MapResource::SlipSurfaceVolume(_, Some(shape)) => { + debug_shapes.custom_shape(*transform, shape.clone(), self.debug_color(), true); + } MapResource::InstantKillBarrier(_, _, Some(shape)) => { debug_shapes.custom_shape(*transform, shape.clone(), self.debug_color(), true); } @@ -349,7 +361,7 @@ mapresource_info!( 9, Unk808085c0, [255, 96, 96], ICON_HELP 10, Unk80806a40, [255, 44, 44], ICON_HELP 11, Decoration, [80, 210, 80], ICON_PINE_TREE - 12, Unk80809121, [96, 96, 255], ICON_HELP + 12, SlipSurfaceVolume, [96, 96, 255], ICON_HELP 13, Unk808068d4, [22, 230, 190], ICON_WAVES 14, CubemapVolume, [50, 255, 50], ICON_SPHERE 15, NamedArea, [0, 127, 0], ICON_TAG diff --git a/src/mapload_temporary.rs b/src/mapload_temporary.rs index 28e89fbd..bfc4a005 100644 --- a/src/mapload_temporary.rs +++ b/src/mapload_temporary.rs @@ -21,7 +21,7 @@ use crate::{ map::SMapDataTable, map::{ SMeshInstanceOcclusionBounds, SShadowingLight, SimpleLight, Unk808068d4, Unk80806ac2, - Unk80806c98, Unk80806d19, Unk80808246, Unk808085c2, Unk80808604, Unk80808cb7, Unk80809121, + Unk80806c98, Unk80806d19, Unk80808246, Unk808085c2, Unk80808604, Unk80808cb7, SSlipSurfaceVolume, Unk80809178, Unk8080917b, Unk80809802, }, render::{cbuffer::ConstantBufferCached, debug::CustomDebugShape, renderer::RendererShared}, @@ -1592,12 +1592,44 @@ fn load_datatable_into_scene( .seek(SeekFrom::Start(data.data_resource.offset)) .unwrap(); - let d: Unk80809121 = table_data.read_le()?; + let d: SSlipSurfaceVolume = table_data.read_le()?; + + let (havok_debugshape, new_transform) = + if let Ok(havok_data) = package_manager().read_tag(d.havok_file) { + let mut cur = Cursor::new(&havok_data); + match destiny_havok::shape_collection::read_shape_collection(&mut cur) { + Ok(o) => { + if (d.shape_index as usize) < o.len() { + let mut shape = o[d.shape_index as usize].clone(); + + let center = shape.center(); + shape.apply_transform(Mat4::from_translation(-center)); + + let new_transform = Transform::from_mat4( + transform.to_mat4() * Mat4::from_translation(center), + ); + + ( + CustomDebugShape::from_havok_shape(&dcs, &shape).ok(), + Some(new_transform), + ) + } else { + (None, None) + } + } + Err(e) => { + error!("Failed to read shapes: {e}"); + (None, None) + } + } + } else { + (None, None) + }; ents.push(scene.spawn(( - transform, + new_transform.unwrap_or(transform), ResourcePoint { - resource: MapResource::Unk80809121(d.havok_file), + resource: MapResource::SlipSurfaceVolume(d.havok_file, havok_debugshape), has_havok_data: true, ..base_rp },