From 7846d805283b1567d9f800afb8d3bf2c6c7c6afd Mon Sep 17 00:00:00 2001 From: ikpil Date: Thu, 13 Jul 2023 20:39:22 +0900 Subject: [PATCH] move --- src/DotRecast.Detour/DtNavMesh.cs | 46 ++++++++++++++++--------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/DotRecast.Detour/DtNavMesh.cs b/src/DotRecast.Detour/DtNavMesh.cs index 7399aa1..c23de7a 100644 --- a/src/DotRecast.Detour/DtNavMesh.cs +++ b/src/DotRecast.Detour/DtNavMesh.cs @@ -1710,6 +1710,30 @@ namespace DotRecast.Detour return DtStatus.DT_SUCCSESS; } + + public RcVec3f GetPolyCenter(long refs) + { + RcVec3f center = RcVec3f.Zero; + + var status = GetTileAndPolyByRef(refs, out var tile, out var poly); + if (status.Succeeded()) + { + for (int i = 0; i < poly.vertCount; ++i) + { + int v = poly.verts[i] * 3; + center.x += tile.data.verts[v]; + center.y += tile.data.verts[v + 1]; + center.z += tile.data.verts[v + 2]; + } + + float s = 1.0f / poly.vertCount; + center.x *= s; + center.y *= s; + center.z *= s; + } + + return center; + } /** * Get flags for edge in detail triangle. @@ -1737,28 +1761,6 @@ namespace DotRecast.Detour return tiles; } - public RcVec3f GetPolyCenter(long refs) - { - RcVec3f center = RcVec3f.Zero; - var status = GetTileAndPolyByRef(refs, out var tile, out var poly); - if (status.Succeeded()) - { - for (int i = 0; i < poly.vertCount; ++i) - { - int v = poly.verts[i] * 3; - center.x += tile.data.verts[v]; - center.y += tile.data.verts[v + 1]; - center.z += tile.data.verts[v + 2]; - } - - float s = 1.0f / poly.vertCount; - center.x *= s; - center.y *= s; - center.z *= s; - } - - return center; - } } } \ No newline at end of file