diff --git a/assets/integration/FSD/Content/_mint/BPL_CSG.uasset b/assets/integration/FSD/Content/_mint/BPL_CSG.uasset index f9489762..a4cbdb67 100644 Binary files a/assets/integration/FSD/Content/_mint/BPL_CSG.uasset and b/assets/integration/FSD/Content/_mint/BPL_CSG.uasset differ diff --git a/assets/integration/FSD/Content/_mint/BPL_CSG.uexp b/assets/integration/FSD/Content/_mint/BPL_CSG.uexp index 5cb1dada..7a867aea 100644 Binary files a/assets/integration/FSD/Content/_mint/BPL_CSG.uexp and b/assets/integration/FSD/Content/_mint/BPL_CSG.uexp differ diff --git a/hook/src/hooks/debug_drawing.rs b/hook/src/hooks/debug_drawing.rs index f50e16c1..b09e0bac 100644 --- a/hook/src/hooks/debug_drawing.rs +++ b/hook/src/hooks/debug_drawing.rs @@ -54,6 +54,10 @@ pub fn kismet_hooks() -> &'static [(&'static str, ExecFn)] { "/Game/_mint/BPL_CSG.BPL_CSG_C:Get Procedural Mesh Vertices", exec_get_mesh_vertices as ExecFn, ), + ( + "/Game/_mint/BPL_CSG.BPL_CSG_C:Get Procedural Mesh Triangles", + exec_get_mesh_triangles as ExecFn, + ), ] } #[repr(C)] @@ -1093,6 +1097,7 @@ mod physx { pub refit_bvh: *const (), pub get_nb_triangles: unsafe extern "system" fn(this: NonNull) -> u32, pub get_triangles: unsafe extern "system" fn(this: NonNull) -> *const (), + pub get_triangle_mesh_flags: unsafe extern "system" fn(this: NonNull, &mut u8) -> u8, } #[repr(C)] @@ -1139,6 +1144,66 @@ unsafe extern "system" fn exec_get_mesh_vertices( } } +unsafe extern "system" fn exec_get_mesh_triangles( + _context: *mut ue::UObject, + stack: *mut ue::kismet::FFrame, + _result: *mut c_void, +) { + let stack = stack.as_mut().unwrap(); + + let mesh: Option> = arg(stack); + let _world_context: Option> = arg(stack); + + #[derive(Debug, Clone, Copy)] + #[repr(C)] + struct Tri { + a: T, + b: T, + c: T, + } + impl From> for Tri { + fn from(value: Tri) -> Self { + Self { + a: value.a as u32, + b: value.b as u32, + c: value.c as u32, + } + } + } + + stack.most_recent_property_address = std::ptr::null(); + ue::kismet::arg(stack, &mut TArray::>::default()); + let ret = (stack.most_recent_property_address as *mut TArray>) + .as_mut() + .unwrap(); + + ret.clear(); + + if let Some(mesh) = mesh { + if let Some(triangle_mesh) = element_ptr!(mesh => .triangle_mesh.*).nn() { + let vtable = element_ptr!(triangle_mesh => .vftable.*); + let num = element_ptr!(vtable => .get_nb_triangles.*)(triangle_mesh); + let ptr = element_ptr!(vtable => .get_triangles.*)(triangle_mesh); + let mut flags = 0; + let _ = element_ptr!(vtable => .get_triangle_mesh_flags.*)(triangle_mesh, &mut flags); + if flags & 2 != 0 { + for tri in std::slice::from_raw_parts(ptr as *const Tri, num as usize) { + ret.push((*tri).into()); + } + } else { + ret.extend_from_slice(std::slice::from_raw_parts( + ptr as *const Tri, + num as usize, + )); + } + } + } + + if !stack.code.is_null() { + stack.code = stack.code.add(1); + } +} + mod nav { use self::ue::TArray;