diff --git a/src/DotRecast.Detour/DtNavMesh.cs b/src/DotRecast.Detour/DtNavMesh.cs index 1427198..4c930a9 100644 --- a/src/DotRecast.Detour/DtNavMesh.cs +++ b/src/DotRecast.Detour/DtNavMesh.cs @@ -1767,5 +1767,27 @@ namespace DotRecast.Detour return tiles; } + + public void ComputeBounds(out RcVec3f bmin, out RcVec3f bmax) + { + bmin = RcVec3f.Of(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); + bmax = RcVec3f.Of(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); + for (int t = 0; t < GetMaxTiles(); ++t) + { + DtMeshTile tile = GetTile(t); + if (tile != null && tile.data != null) + { + for (int i = 0; i < tile.data.verts.Length; i += 3) + { + bmin.x = Math.Min(bmin.x, tile.data.verts[i]); + bmin.y = Math.Min(bmin.y, tile.data.verts[i + 1]); + bmin.z = Math.Min(bmin.z, tile.data.verts[i + 2]); + bmax.x = Math.Max(bmax.x, tile.data.verts[i]); + bmax.y = Math.Max(bmax.y, tile.data.verts[i + 1]); + bmax.z = Math.Max(bmax.z, tile.data.verts[i + 2]); + } + } + } + } } } \ No newline at end of file diff --git a/src/DotRecast.Detour/NavMeshUtils.cs b/src/DotRecast.Detour/NavMeshUtils.cs deleted file mode 100644 index 1d025a3..0000000 --- a/src/DotRecast.Detour/NavMeshUtils.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* -recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: -1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -using System; -using DotRecast.Core; -using DotRecast.Detour; - -namespace DotRecast.Detour -{ - public static class NavMeshUtils - { - public static RcVec3f[] GetNavMeshBounds(DtNavMesh mesh) - { - RcVec3f bmin = RcVec3f.Of(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); - RcVec3f bmax = RcVec3f.Of(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); - for (int t = 0; t < mesh.GetMaxTiles(); ++t) - { - DtMeshTile tile = mesh.GetTile(t); - if (tile != null && tile.data != null) - { - for (int i = 0; i < tile.data.verts.Length; i += 3) - { - bmin.x = Math.Min(bmin.x, tile.data.verts[i]); - bmin.y = Math.Min(bmin.y, tile.data.verts[i + 1]); - bmin.z = Math.Min(bmin.z, tile.data.verts[i + 2]); - bmax.x = Math.Max(bmax.x, tile.data.verts[i]); - bmax.y = Math.Max(bmax.y, tile.data.verts[i + 1]); - bmax.z = Math.Max(bmax.z, tile.data.verts[i + 2]); - } - } - } - - return new[] { bmin, bmax }; - } - } -} \ No newline at end of file