From 04fd0abea038b73f7cd572777a1238a63422b877 Mon Sep 17 00:00:00 2001 From: ikpil Date: Wed, 26 Jul 2023 00:03:48 +0900 Subject: [PATCH] change public api in StraightPathItem --- src/DotRecast.Detour.Crowd/DtCrowd.cs | 4 +-- src/DotRecast.Detour.Crowd/DtCrowdAgent.cs | 14 ++++---- src/DotRecast.Detour.Crowd/DtPathCorridor.cs | 6 ++-- src/DotRecast.Detour/StraightPathItem.cs | 15 --------- src/DotRecast.Recast.Demo/Tools/CrowdTool.cs | 8 ++--- .../Tools/TestNavmeshTool.cs | 32 +++++++++---------- 6 files changed, 32 insertions(+), 47 deletions(-) diff --git a/src/DotRecast.Detour.Crowd/DtCrowd.cs b/src/DotRecast.Detour.Crowd/DtCrowd.cs index 1e48674..39bbf31 100644 --- a/src/DotRecast.Detour.Crowd/DtCrowd.cs +++ b/src/DotRecast.Detour.Crowd/DtCrowd.cs @@ -944,7 +944,7 @@ namespace DotRecast.Detour.Crowd // and short cut to there. if ((ag.option.updateFlags & DtCrowdAgentParams.DT_CROWD_OPTIMIZE_VIS) != 0 && ag.corners.Count > 0) { - RcVec3f target = ag.corners[Math.Min(1, ag.corners.Count - 1)].GetPos(); + RcVec3f target = ag.corners[Math.Min(1, ag.corners.Count - 1)].pos; ag.corridor.OptimizePathVisibility(target, ag.option.pathOptimizationRange, _navQuery, _filters[ag.option.queryFilterType]); @@ -993,7 +993,7 @@ namespace DotRecast.Detour.Crowd // Adjust the path over the off-mesh connection. long[] refs = new long[2]; - if (ag.corridor.MoveOverOffmeshConnection(ag.corners[ag.corners.Count - 1].GetRef(), refs, ref anim.startPos, + if (ag.corridor.MoveOverOffmeshConnection(ag.corners[ag.corners.Count - 1].refs, refs, ref anim.startPos, ref anim.endPos, _navQuery)) { anim.initPos = ag.npos; diff --git a/src/DotRecast.Detour.Crowd/DtCrowdAgent.cs b/src/DotRecast.Detour.Crowd/DtCrowdAgent.cs index 81d6957..f84ef83 100644 --- a/src/DotRecast.Detour.Crowd/DtCrowdAgent.cs +++ b/src/DotRecast.Detour.Crowd/DtCrowdAgent.cs @@ -131,13 +131,13 @@ namespace DotRecast.Detour.Crowd if (0 == corners.Count) return false; - bool offMeshConnection = ((corners[corners.Count - 1].GetFlags() + bool offMeshConnection = ((corners[corners.Count - 1].flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0) ? true : false; if (offMeshConnection) { - float distSq = RcVec3f.Dist2DSqr(npos, corners[corners.Count - 1].GetPos()); + float distSq = RcVec3f.Dist2DSqr(npos, corners[corners.Count - 1].pos); if (distSq < radius * radius) return true; } @@ -150,9 +150,9 @@ namespace DotRecast.Detour.Crowd if (0 == corners.Count) return range; - bool endOfPath = ((corners[corners.Count - 1].GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_END) != 0) ? true : false; + bool endOfPath = ((corners[corners.Count - 1].flags & DtNavMeshQuery.DT_STRAIGHTPATH_END) != 0) ? true : false; if (endOfPath) - return Math.Min(RcVec3f.Dist2D(npos, corners[corners.Count - 1].GetPos()), range); + return Math.Min(RcVec3f.Dist2D(npos, corners[corners.Count - 1].pos), range); return range; } @@ -164,8 +164,8 @@ namespace DotRecast.Detour.Crowd { int ip0 = 0; int ip1 = Math.Min(1, corners.Count - 1); - var p0 = corners[ip0].GetPos(); - var p1 = corners[ip1].GetPos(); + var p0 = corners[ip0].pos; + var p1 = corners[ip1].pos; var dir0 = p0.Subtract(npos); var dir1 = p1.Subtract(npos); @@ -191,7 +191,7 @@ namespace DotRecast.Detour.Crowd RcVec3f dir = new RcVec3f(); if (0 < corners.Count) { - dir = corners[0].GetPos().Subtract(npos); + dir = corners[0].pos.Subtract(npos); dir.y = 0; dir.Normalize(); } diff --git a/src/DotRecast.Detour.Crowd/DtPathCorridor.cs b/src/DotRecast.Detour.Crowd/DtPathCorridor.cs index a172a57..9a95d1e 100644 --- a/src/DotRecast.Detour.Crowd/DtPathCorridor.cs +++ b/src/DotRecast.Detour.Crowd/DtPathCorridor.cs @@ -123,8 +123,8 @@ namespace DotRecast.Detour.Crowd int start = 0; foreach (StraightPathItem spi in corners) { - if ((spi.GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0 - || RcVec3f.Dist2DSqr(spi.GetPos(), m_pos) > MIN_TARGET_DIST) + if ((spi.flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0 + || RcVec3f.Dist2DSqr(spi.pos, m_pos) > MIN_TARGET_DIST) { break; } @@ -137,7 +137,7 @@ namespace DotRecast.Detour.Crowd for (int i = start; i < corners.Count; i++) { StraightPathItem spi = corners[i]; - if ((spi.GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0) + if ((spi.flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0) { end = i + 1; break; diff --git a/src/DotRecast.Detour/StraightPathItem.cs b/src/DotRecast.Detour/StraightPathItem.cs index 4818b3d..3a6099b 100644 --- a/src/DotRecast.Detour/StraightPathItem.cs +++ b/src/DotRecast.Detour/StraightPathItem.cs @@ -35,20 +35,5 @@ namespace DotRecast.Detour this.flags = flags; this.refs = refs; } - - public RcVec3f GetPos() - { - return pos; - } - - public int GetFlags() - { - return flags; - } - - public long GetRef() - { - return refs; - } } } \ No newline at end of file diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs index a739854..eaa6da3 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs @@ -426,16 +426,16 @@ public class CrowdTool : IRcTool dd.Begin(LINES, 2.0f); for (int j = 0; j < ag.corners.Count; ++j) { - RcVec3f va = j == 0 ? pos : ag.corners[j - 1].GetPos(); - RcVec3f vb = ag.corners[j].GetPos(); + RcVec3f va = j == 0 ? pos : ag.corners[j - 1].pos; + RcVec3f vb = ag.corners[j].pos; dd.Vertex(va.x, va.y + radius, va.z, DuRGBA(128, 0, 0, 192)); dd.Vertex(vb.x, vb.y + radius, vb.z, DuRGBA(128, 0, 0, 192)); } - if ((ag.corners[ag.corners.Count - 1].GetFlags() + if ((ag.corners[ag.corners.Count - 1].flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0) { - RcVec3f v = ag.corners[ag.corners.Count - 1].GetPos(); + RcVec3f v = ag.corners[ag.corners.Count - 1].pos; dd.Vertex(v.x, v.y, v.z, DuRGBA(192, 0, 0, 192)); dd.Vertex(v.x, v.y + radius * 2, v.z, DuRGBA(192, 0, 0, 192)); } diff --git a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs index 13ba882..7bb1ab9 100644 --- a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs @@ -456,7 +456,7 @@ public class TestNavmeshTool : IRcTool StraightPathItem straightPathItem = m_straightPath[i]; StraightPathItem straightPathItem2 = m_straightPath[i + 1]; int col; - if ((straightPathItem.GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0) + if ((straightPathItem.flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0) { col = offMeshCol; } @@ -465,10 +465,10 @@ public class TestNavmeshTool : IRcTool col = spathCol; } - dd.Vertex(straightPathItem.GetPos().x, straightPathItem.GetPos().y + 0.4f, - straightPathItem.GetPos().z, col); - dd.Vertex(straightPathItem2.GetPos().x, straightPathItem2.GetPos().y + 0.4f, - straightPathItem2.GetPos().z, col); + dd.Vertex(straightPathItem.pos.x, straightPathItem.pos.y + 0.4f, + straightPathItem.pos.z, col); + dd.Vertex(straightPathItem2.pos.x, straightPathItem2.pos.y + 0.4f, + straightPathItem2.pos.z, col); } dd.End(); @@ -477,15 +477,15 @@ public class TestNavmeshTool : IRcTool { StraightPathItem straightPathItem = m_straightPath[i]; int col; - if ((straightPathItem.GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_START) != 0) + if ((straightPathItem.flags & DtNavMeshQuery.DT_STRAIGHTPATH_START) != 0) { col = startCol; } - else if ((straightPathItem.GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_END) != 0) + else if ((straightPathItem.flags & DtNavMeshQuery.DT_STRAIGHTPATH_END) != 0) { col = endCol; } - else if ((straightPathItem.GetFlags() & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0) + else if ((straightPathItem.flags & DtNavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0) { col = offMeshCol; } @@ -494,8 +494,8 @@ public class TestNavmeshTool : IRcTool col = spathCol; } - dd.Vertex(straightPathItem.GetPos().x, straightPathItem.GetPos().y + 0.4f, - straightPathItem.GetPos().z, col); + dd.Vertex(straightPathItem.pos.x, straightPathItem.pos.y + 0.4f, + straightPathItem.pos.z, col); } dd.End(); @@ -523,10 +523,10 @@ public class TestNavmeshTool : IRcTool { StraightPathItem straightPathItem = m_straightPath[i]; StraightPathItem straightPathItem2 = m_straightPath[i + 1]; - dd.Vertex(straightPathItem.GetPos().x, straightPathItem.GetPos().y + 0.4f, - straightPathItem.GetPos().z, spathCol); - dd.Vertex(straightPathItem2.GetPos().x, straightPathItem2.GetPos().y + 0.4f, - straightPathItem2.GetPos().z, spathCol); + dd.Vertex(straightPathItem.pos.x, straightPathItem.pos.y + 0.4f, + straightPathItem.pos.z, spathCol); + dd.Vertex(straightPathItem2.pos.x, straightPathItem2.pos.y + 0.4f, + straightPathItem2.pos.z, spathCol); } dd.End(); @@ -534,8 +534,8 @@ public class TestNavmeshTool : IRcTool for (int i = 0; i < m_straightPath.Count; ++i) { StraightPathItem straightPathItem = m_straightPath[i]; - dd.Vertex(straightPathItem.GetPos().x, straightPathItem.GetPos().y + 0.4f, - straightPathItem.GetPos().z, spathCol); + dd.Vertex(straightPathItem.pos.x, straightPathItem.pos.y + 0.4f, + straightPathItem.pos.z, spathCol); } dd.End();