forked from bit/DotRecastNetSim
remove FindLocalNeighbourhoodResult
This commit is contained in:
parent
2392b446f7
commit
b49fa1deb2
|
@ -31,10 +31,10 @@ namespace DotRecast.Detour.Crowd
|
||||||
{
|
{
|
||||||
public const int MAX_LOCAL_SEGS = 8;
|
public const int MAX_LOCAL_SEGS = 8;
|
||||||
|
|
||||||
|
private RcVec3f m_center = new RcVec3f();
|
||||||
RcVec3f m_center = new RcVec3f();
|
private List<DtSegment> m_segs = new List<DtSegment>();
|
||||||
List<DtSegment> m_segs = new List<DtSegment>();
|
private List<long> m_polys = new List<long>();
|
||||||
List<long> m_polys = new List<long>();
|
private List<long> m_parents = new List<long>();
|
||||||
|
|
||||||
public DtLocalBoundary()
|
public DtLocalBoundary()
|
||||||
{
|
{
|
||||||
|
@ -90,21 +90,20 @@ namespace DotRecast.Detour.Crowd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(long refs, RcVec3f pos, float collisionQueryRange, DtNavMeshQuery navquery, IDtQueryFilter filter)
|
public void Update(long startRef, RcVec3f pos, float collisionQueryRange, DtNavMeshQuery navquery, IDtQueryFilter filter)
|
||||||
{
|
{
|
||||||
if (refs == 0)
|
if (startRef == 0)
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_center = pos;
|
m_center = pos;
|
||||||
|
|
||||||
// First query non-overlapping polygons.
|
// First query non-overlapping polygons.
|
||||||
Result<FindLocalNeighbourhoodResult> res = navquery.FindLocalNeighbourhood(refs, pos, collisionQueryRange,
|
var status = navquery.FindLocalNeighbourhood(startRef, pos, collisionQueryRange, filter, ref m_polys, ref m_parents);
|
||||||
filter);
|
if (status.Succeeded())
|
||||||
if (res.Succeeded())
|
|
||||||
{
|
{
|
||||||
m_polys = res.result.GetRefs();
|
|
||||||
m_segs.Clear();
|
m_segs.Clear();
|
||||||
// Secondly, store all polygon edges.
|
// Secondly, store all polygon edges.
|
||||||
for (int j = 0; j < m_polys.Count; ++j)
|
for (int j = 0; j < m_polys.Count; ++j)
|
||||||
|
|
|
@ -2788,22 +2788,21 @@ namespace DotRecast.Detour
|
||||||
/// @param[in] filter The polygon filter to apply to the query.
|
/// @param[in] filter The polygon filter to apply to the query.
|
||||||
/// @param[out] resultRef The reference ids of the polygons touched by the circle.
|
/// @param[out] resultRef The reference ids of the polygons touched by the circle.
|
||||||
/// @param[out] resultParent The reference ids of the parent polygons for each result.
|
/// @param[out] resultParent The reference ids of the parent polygons for each result.
|
||||||
/// Zero if a result polygon has no parent. [opt]
|
|
||||||
/// @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.
|
/// @returns The status flags for the query.
|
||||||
public Result<FindLocalNeighbourhoodResult> FindLocalNeighbourhood(long startRef, RcVec3f centerPos, float radius,
|
public DtStatus FindLocalNeighbourhood(long startRef, RcVec3f centerPos, float radius,
|
||||||
IDtQueryFilter filter)
|
IDtQueryFilter filter,
|
||||||
|
ref List<long> resultRef, ref List<long> resultParent)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(centerPos) || radius < 0
|
if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(centerPos) || radius < 0
|
||||||
|| !float.IsFinite(radius) || null == filter)
|
|| !float.IsFinite(radius) || null == filter)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<FindLocalNeighbourhoodResult>();
|
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<long> resultRef = new List<long>();
|
resultRef.Clear();
|
||||||
List<long> resultParent = new List<long>();
|
resultParent.Clear();
|
||||||
|
|
||||||
DtNodePool tinyNodePool = new DtNodePool();
|
DtNodePool tinyNodePool = new DtNodePool();
|
||||||
|
|
||||||
|
@ -2943,7 +2942,7 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Results.Success(new FindLocalNeighbourhoodResult(resultRef, resultParent));
|
return DtStatus.DT_SUCCSESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,47 +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 FindLocalNeighbourhoodResult
|
|
||||||
{
|
|
||||||
private readonly List<long> refs;
|
|
||||||
private readonly List<long> parentRefs;
|
|
||||||
|
|
||||||
public FindLocalNeighbourhoodResult(List<long> refs, List<long> parentRefs)
|
|
||||||
{
|
|
||||||
this.@refs = refs;
|
|
||||||
this.parentRefs = parentRefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<long> GetRefs()
|
|
||||||
{
|
|
||||||
return refs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<long> GetParentRefs()
|
|
||||||
{
|
|
||||||
return parentRefs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -472,13 +472,7 @@ public class TestNavmeshTool : IRcTool
|
||||||
if (m_sposSet && m_startRef != 0)
|
if (m_sposSet && m_startRef != 0)
|
||||||
{
|
{
|
||||||
m_neighbourhoodRadius = _impl.GetSample().GetSettings().agentRadius * 20.0f;
|
m_neighbourhoodRadius = _impl.GetSample().GetSettings().agentRadius * 20.0f;
|
||||||
Result<FindLocalNeighbourhoodResult> result = m_navQuery.FindLocalNeighbourhood(m_startRef, m_spos,
|
m_navQuery.FindLocalNeighbourhood(m_startRef, m_spos, m_neighbourhoodRadius, m_filter, ref m_polys, ref m_parent);
|
||||||
m_neighbourhoodRadius, m_filter);
|
|
||||||
if (result.Succeeded())
|
|
||||||
{
|
|
||||||
m_polys = result.result.GetRefs();
|
|
||||||
m_parent = result.result.GetParentRefs();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_toolMode == TestNavmeshToolMode.RANDOM_POINTS_IN_CIRCLE)
|
else if (m_toolMode == TestNavmeshToolMode.RANDOM_POINTS_IN_CIRCLE)
|
||||||
|
|
|
@ -16,8 +16,8 @@ freely, subject to the following restrictions:
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using DotRecast.Core;
|
using DotRecast.Core;
|
||||||
using DotRecast.Detour.QueryResults;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DotRecast.Detour.Test;
|
namespace DotRecast.Detour.Test;
|
||||||
|
@ -58,11 +58,13 @@ public class FindLocalNeighbourhoodTest : AbstractDetourTest
|
||||||
for (int i = 0; i < startRefs.Length; i++)
|
for (int i = 0; i < startRefs.Length; i++)
|
||||||
{
|
{
|
||||||
RcVec3f startPos = startPoss[i];
|
RcVec3f startPos = startPoss[i];
|
||||||
Result<FindLocalNeighbourhoodResult> poly = query.FindLocalNeighbourhood(startRefs[i], startPos, 3.5f, filter);
|
var refs = new List<long>();
|
||||||
Assert.That(poly.result.GetRefs().Count, Is.EqualTo(REFS[i].Length));
|
var parentRefs = new List<long>();
|
||||||
|
var status = query.FindLocalNeighbourhood(startRefs[i], startPos, 3.5f, filter, ref refs, ref parentRefs);
|
||||||
|
Assert.That(refs.Count, Is.EqualTo(REFS[i].Length));
|
||||||
for (int v = 0; v < REFS[i].Length; v++)
|
for (int v = 0; v < REFS[i].Length; v++)
|
||||||
{
|
{
|
||||||
Assert.That(poly.result.GetRefs()[v], Is.EqualTo(REFS[i][v]));
|
Assert.That(refs[v], Is.EqualTo(REFS[i][v]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue