From 69a2d2d1fcee52a65956de99629d00c71fefcbc4 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Mon, 4 Nov 2024 20:06:59 -0500 Subject: [PATCH] Fix bounding boxes for rigged models --- .../BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs b/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs index eccb6e16..61278024 100644 --- a/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs +++ b/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs @@ -1399,6 +1399,19 @@ namespace Bfres.Structs min = CalculateBBMin(vertices); max = CalculateBBMax(vertices); } + else + { + //Find largest bounding box + foreach (var bounding in aabb) + { + min.X = Math.Min(bounding.Min.X, min.X); + min.Y = Math.Min(bounding.Min.Y, min.Y); + min.Z = Math.Min(bounding.Min.Z, min.Z); + max.X = Math.Min(bounding.Max.X, max.X); + max.Y = Math.Min(bounding.Max.Y, max.Y); + max.Z = Math.Min(bounding.Max.Z, max.Z); + } + } var c = (min + max) / 2.0f; var e = (max - min) / 2.0f;