From 76d0ac224c4e0d90d4e5d7ab8b6cf7ac08eb4d33 Mon Sep 17 00:00:00 2001 From: dexy Date: Sat, 27 Jul 2024 10:36:31 +1000 Subject: [PATCH] Don't generate VerticesShrunk and Octants for BoundBVH --- CodeWalker.Core/GameFiles/Resources/Bounds.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/CodeWalker.Core/GameFiles/Resources/Bounds.cs b/CodeWalker.Core/GameFiles/Resources/Bounds.cs index ab12600..3133a2b 100644 --- a/CodeWalker.Core/GameFiles/Resources/Bounds.cs +++ b/CodeWalker.Core/GameFiles/Resources/Bounds.cs @@ -1720,6 +1720,12 @@ namespace CodeWalker.GameFiles public void CalculateOctants() { + if (Type != BoundsType.Geometry) + { + Octants = null;//don't use octants for BoundBVH + return; + } + Octants = new BoundGeomOctants(); Vector3[] flipDirection = new Vector3[8] @@ -1797,8 +1803,9 @@ namespace CodeWalker.GameFiles //thanks to ranstar74 //https://github.com/ranstar74/rageAm/blob/master/projects/app/src/rage/physics/bounds/boundgeometry.cpp - if (Vertices == null) return;//must have existing vertices for this! VerticesShrunk = null; + if (Type != BoundsType.Geometry) return;//don't use VerticesShrunk for BoundBVH + if (Vertices == null) return;//must have existing vertices for this! var size = Vector3.Abs(BoxMax - BoxMin) * 0.5f; var margin = Math.Min(Math.Min(Math.Min(Margin, size.X), size.Y), size.Z); while (margin > 1e-6f) @@ -2016,6 +2023,12 @@ namespace CodeWalker.GameFiles public void CalculateVertsShrunkByNormals() { + if (Type != BoundsType.Geometry) + { + VerticesShrunk = null;//don't use VerticesShrunk for BoundBVH + return; + } + Vector3[] vertNormals = CalculateVertNormals(); VerticesShrunk = new Vector3[Vertices.Length];