forked from mirror/DotRecast
remove FindPolysAroundResult
This commit is contained in:
parent
36ad2e1498
commit
40229226dc
|
@ -2416,7 +2416,7 @@ namespace DotRecast.Detour
|
|||
/// If the result arrays are to small to hold the entire result set, they will be
|
||||
/// filled to capacity.
|
||||
///
|
||||
/// @}
|
||||
///@}
|
||||
/// @name Dijkstra Search Functions
|
||||
/// @{
|
||||
/// Finds the polygons along the navigation graph that touch the specified circle.
|
||||
|
@ -2431,20 +2431,21 @@ namespace DotRecast.Detour
|
|||
/// @param[out] resultCount The number of polygons found. [opt]
|
||||
/// @param[in] maxResult The maximum number of polygons the result arrays can hold.
|
||||
/// @returns The status flags for the query.
|
||||
public Result<FindPolysAroundResult> FindPolysAroundCircle(long startRef, RcVec3f centerPos, float radius, IDtQueryFilter filter)
|
||||
public DtStatus FindPolysAroundCircle(long startRef, RcVec3f centerPos, float radius, IDtQueryFilter filter,
|
||||
out List<long> resultRef, out List<long> resultParent, out List<float> resultCost)
|
||||
{
|
||||
// Validate input
|
||||
// TODO : check performance
|
||||
resultRef = new List<long>();
|
||||
resultParent = new List<long>();
|
||||
resultCost = new List<float>();
|
||||
|
||||
// Validate input
|
||||
if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(centerPos) || radius < 0
|
||||
|| !float.IsFinite(radius) || null == filter)
|
||||
{
|
||||
return Results.InvalidParam<FindPolysAroundResult>();
|
||||
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
|
||||
}
|
||||
|
||||
List<long> resultRef = new List<long>();
|
||||
List<long> resultParent = new List<long>();
|
||||
List<float> resultCost = new List<float>();
|
||||
|
||||
m_nodePool.Clear();
|
||||
m_openList.Clear();
|
||||
|
||||
|
@ -2564,7 +2565,7 @@ namespace DotRecast.Detour
|
|||
}
|
||||
}
|
||||
|
||||
return Results.Success(new FindPolysAroundResult(resultRef, resultParent, resultCost));
|
||||
return DtStatus.DT_SUCCSESS;
|
||||
}
|
||||
|
||||
/// @par
|
||||
|
@ -2577,7 +2578,7 @@ namespace DotRecast.Detour
|
|||
/// Candidate polygons are found by searching the graph beginning at the start
|
||||
/// polygon.
|
||||
///
|
||||
/// The same intersection test restrictions that apply to FindPolysAroundCircle()
|
||||
/// The same intersection test restrictions that apply to findPolysAroundCircle()
|
||||
/// method apply to this method.
|
||||
///
|
||||
/// The 3D centroid of the search polygon is used as the start position for cost
|
||||
|
@ -2602,19 +2603,20 @@ namespace DotRecast.Detour
|
|||
/// @param[out] resultCount The number of polygons found.
|
||||
/// @param[in] maxResult The maximum number of polygons the result arrays can hold.
|
||||
/// @returns The status flags for the query.
|
||||
public Result<FindPolysAroundResult> FindPolysAroundShape(long startRef, float[] verts, IDtQueryFilter filter)
|
||||
public DtStatus FindPolysAroundShape(long startRef, float[] verts, IDtQueryFilter filter,
|
||||
out List<long> resultRef, out List<long> resultParent, out List<float> resultCost)
|
||||
{
|
||||
resultRef = new List<long>();
|
||||
resultParent = new List<long>();
|
||||
resultCost = new List<float>();
|
||||
|
||||
// Validate input
|
||||
int nverts = verts.Length / 3;
|
||||
if (!m_nav.IsValidPolyRef(startRef) || null == verts || nverts < 3 || null == filter)
|
||||
{
|
||||
return Results.InvalidParam<FindPolysAroundResult>();
|
||||
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
|
||||
}
|
||||
|
||||
List<long> resultRef = new List<long>();
|
||||
List<long> resultParent = new List<long>();
|
||||
List<float> resultCost = new List<float>();
|
||||
|
||||
m_nodePool.Clear();
|
||||
m_openList.Clear();
|
||||
|
||||
|
@ -2751,7 +2753,7 @@ namespace DotRecast.Detour
|
|||
}
|
||||
}
|
||||
|
||||
return Results.Success(new FindPolysAroundResult(resultRef, resultParent, resultCost));
|
||||
return DtStatus.DT_SUCCSESS;
|
||||
}
|
||||
|
||||
/// @par
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
|
||||
recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org
|
||||
DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com
|
||||
|
||||
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.Collections.Generic;
|
||||
|
||||
namespace DotRecast.Detour.QueryResults
|
||||
{
|
||||
// TODO: (PP) Add comments
|
||||
public class FindPolysAroundResult
|
||||
{
|
||||
private readonly List<long> refs;
|
||||
private readonly List<long> parentRefs;
|
||||
private readonly List<float> costs;
|
||||
|
||||
public FindPolysAroundResult(List<long> refs, List<long> parentRefs, List<float> costs)
|
||||
{
|
||||
this.@refs = refs;
|
||||
this.parentRefs = parentRefs;
|
||||
this.costs = costs;
|
||||
}
|
||||
|
||||
public List<long> GetRefs()
|
||||
{
|
||||
return refs;
|
||||
}
|
||||
|
||||
public List<long> GetParentRefs()
|
||||
{
|
||||
return parentRefs;
|
||||
}
|
||||
|
||||
public List<float> GetCosts()
|
||||
{
|
||||
return costs;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -425,12 +425,11 @@ public class TestNavmeshTool : ITool
|
|||
float dx = m_epos.x - m_spos.x;
|
||||
float dz = m_epos.z - m_spos.z;
|
||||
float dist = (float)Math.Sqrt(dx * dx + dz * dz);
|
||||
Result<FindPolysAroundResult> result = m_navQuery.FindPolysAroundCircle(m_startRef, m_spos, dist,
|
||||
m_filter);
|
||||
if (result.Succeeded())
|
||||
var status = m_navQuery.FindPolysAroundCircle(m_startRef, m_spos, dist, m_filter, out var refs, out var parentRefs, out var costs);
|
||||
if (status.Succeeded())
|
||||
{
|
||||
m_polys = result.result.GetRefs();
|
||||
m_parent = result.result.GetParentRefs();
|
||||
m_polys = refs;
|
||||
m_parent = parentRefs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -458,11 +457,11 @@ public class TestNavmeshTool : ITool
|
|||
m_queryPoly[10] = m_epos.y + agentHeight / 2;
|
||||
m_queryPoly[11] = m_epos.z + nz;
|
||||
|
||||
Result<FindPolysAroundResult> result = m_navQuery.FindPolysAroundShape(m_startRef, m_queryPoly, m_filter);
|
||||
if (result.Succeeded())
|
||||
var status = m_navQuery.FindPolysAroundShape(m_startRef, m_queryPoly, m_filter, out var refs, out var parentRefs, out var costs);
|
||||
if (status.Succeeded())
|
||||
{
|
||||
m_polys = result.result.GetRefs();
|
||||
m_parent = result.result.GetParentRefs();
|
||||
m_polys = refs;
|
||||
m_parent = parentRefs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,19 +106,19 @@ public class FindPolysAroundCircleTest : AbstractDetourTest
|
|||
{
|
||||
long startRef = startRefs[i];
|
||||
RcVec3f startPos = startPoss[i];
|
||||
Result<FindPolysAroundResult> result = query.FindPolysAroundCircle(startRef, startPos, 7.5f, filter);
|
||||
Assert.That(result.Succeeded(), Is.True);
|
||||
FindPolysAroundResult polys = result.result;
|
||||
Assert.That(polys.GetRefs().Count, Is.EqualTo(REFS[i].Length));
|
||||
var status = query.FindPolysAroundCircle(startRef, startPos, 7.5f, filter, out var refs, out var parentRefs, out var costs);
|
||||
Assert.That(status.Succeeded(), Is.True);
|
||||
|
||||
Assert.That(refs.Count, Is.EqualTo(REFS[i].Length));
|
||||
for (int v = 0; v < REFS[i].Length; v++)
|
||||
{
|
||||
bool found = false;
|
||||
for (int w = 0; w < REFS[i].Length; w++)
|
||||
{
|
||||
if (REFS[i][v] == polys.GetRefs()[w])
|
||||
if (REFS[i][v] == refs[w])
|
||||
{
|
||||
Assert.That(polys.GetParentRefs()[w], Is.EqualTo(PARENT_REFS[i][v]));
|
||||
Assert.That(polys.GetCosts()[w], Is.EqualTo(COSTS[i][v]).Within(0.01f));
|
||||
Assert.That(parentRefs[w], Is.EqualTo(PARENT_REFS[i][v]));
|
||||
Assert.That(costs[w], Is.EqualTo(COSTS[i][v]).Within(0.01f));
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,17 +133,17 @@ public class FindPolysAroundShapeTest : AbstractDetourTest
|
|||
{
|
||||
long startRef = startRefs[i];
|
||||
RcVec3f startPos = startPoss[i];
|
||||
Result<FindPolysAroundResult> polys = query.FindPolysAroundShape(startRef, GetQueryPoly(startPos, endPoss[i]), filter);
|
||||
Assert.That(polys.result.GetRefs().Count, Is.EqualTo(REFS[i].Length));
|
||||
query.FindPolysAroundShape(startRef, GetQueryPoly(startPos, endPoss[i]), filter, out var refs, out var parentRefs, out var costs);
|
||||
Assert.That(refs.Count, Is.EqualTo(REFS[i].Length));
|
||||
for (int v = 0; v < REFS[i].Length; v++)
|
||||
{
|
||||
bool found = false;
|
||||
for (int w = 0; w < REFS[i].Length; w++)
|
||||
{
|
||||
if (REFS[i][v] == polys.result.GetRefs()[w])
|
||||
if (REFS[i][v] == refs[w])
|
||||
{
|
||||
Assert.That(polys.result.GetParentRefs()[w], Is.EqualTo(PARENT_REFS[i][v]));
|
||||
Assert.That(polys.result.GetCosts()[w], Is.EqualTo(COSTS[i][v]).Within(0.01f));
|
||||
Assert.That(parentRefs[w], Is.EqualTo(PARENT_REFS[i][v]));
|
||||
Assert.That(costs[w], Is.EqualTo(COSTS[i][v]).Within(0.01f));
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue