forked from bit/DotRecastNetSim
changed GetEdgeMidPoint, GetEdgeIntersectionPoint
This commit is contained in:
parent
7ae7c3f41e
commit
b6ee6816de
|
@ -901,14 +901,13 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
// If the node is visited the first time, calculate node position.
|
// If the node is visited the first time, calculate node position.
|
||||||
var neighbourPos = neighbourNode.pos;
|
var neighbourPos = neighbourNode.pos;
|
||||||
var midpod = neighbourRef == endRef
|
var empStatus = neighbourRef == endRef
|
||||||
? GetEdgeIntersectionPoint(bestNode.pos, bestRef, bestPoly, bestTile, endPos, neighbourRef,
|
? GetEdgeIntersectionPoint(bestNode.pos, bestRef, bestPoly, bestTile,
|
||||||
neighbourPoly, neighbourTile)
|
endPos, neighbourRef, neighbourPoly, neighbourTile,
|
||||||
: GetEdgeMidPoint(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly, neighbourTile);
|
ref neighbourPos)
|
||||||
if (!midpod.Failed())
|
: GetEdgeMidPoint(bestRef, bestPoly, bestTile,
|
||||||
{
|
neighbourRef, neighbourPoly, neighbourTile,
|
||||||
neighbourPos = midpod.result;
|
ref neighbourPos);
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate cost and heuristic.
|
// Calculate cost and heuristic.
|
||||||
float cost = 0;
|
float cost = 0;
|
||||||
|
@ -1220,14 +1219,13 @@ namespace DotRecast.Detour
|
||||||
// If the node is visited the first time, calculate node
|
// If the node is visited the first time, calculate node
|
||||||
// position.
|
// position.
|
||||||
var neighbourPos = neighbourNode.pos;
|
var neighbourPos = neighbourNode.pos;
|
||||||
var midpod = neighbourRef == m_query.endRef
|
var empStatus = neighbourRef == m_query.endRef
|
||||||
? GetEdgeIntersectionPoint(bestNode.pos, bestRef, bestPoly, bestTile, m_query.endPos,
|
? GetEdgeIntersectionPoint(bestNode.pos, bestRef, bestPoly, bestTile,
|
||||||
neighbourRef, neighbourPoly, neighbourTile)
|
m_query.endPos, neighbourRef, neighbourPoly, neighbourTile,
|
||||||
: GetEdgeMidPoint(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly, neighbourTile);
|
ref neighbourPos)
|
||||||
if (!midpod.Failed())
|
: GetEdgeMidPoint(bestRef, bestPoly, bestTile,
|
||||||
{
|
neighbourRef, neighbourPoly, neighbourTile,
|
||||||
neighbourPos = midpod.result;
|
ref neighbourPos);
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate cost and heuristic.
|
// Calculate cost and heuristic.
|
||||||
float cost = 0;
|
float cost = 0;
|
||||||
|
@ -1583,7 +1581,7 @@ namespace DotRecast.Detour
|
||||||
if (i + 1 < path.Count)
|
if (i + 1 < path.Count)
|
||||||
{
|
{
|
||||||
int fromType; // // fromType is ignored.
|
int fromType; // // fromType is ignored.
|
||||||
|
|
||||||
// Next portal.
|
// Next portal.
|
||||||
var ppStatus = GetPortalPoints(path[i], path[i + 1], out left, out right, out fromType, out toType);
|
var ppStatus = GetPortalPoints(path[i], path[i + 1], out left, out right, out fromType, out toType);
|
||||||
if (ppStatus.Failed())
|
if (ppStatus.Failed())
|
||||||
|
@ -2087,29 +2085,30 @@ namespace DotRecast.Detour
|
||||||
return DtStatus.DT_SUCCSESS;
|
return DtStatus.DT_SUCCSESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Result<RcVec3f> GetEdgeMidPoint(long from, DtPoly fromPoly, DtMeshTile fromTile, long to,
|
protected DtStatus GetEdgeMidPoint(long from, DtPoly fromPoly, DtMeshTile fromTile, long to,
|
||||||
DtPoly toPoly, DtMeshTile toTile)
|
DtPoly toPoly, DtMeshTile toTile, ref RcVec3f mid)
|
||||||
{
|
{
|
||||||
var ppStatus = GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, out var left, out var right);
|
var ppStatus = GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, out var left, out var right);
|
||||||
if (ppStatus.Failed())
|
if (ppStatus.Failed())
|
||||||
{
|
{
|
||||||
return Results.Of<RcVec3f>(ppStatus, "");
|
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
RcVec3f mid = new RcVec3f();
|
|
||||||
mid.x = (left.x + right.x) * 0.5f;
|
mid.x = (left.x + right.x) * 0.5f;
|
||||||
mid.y = (left.y + right.y) * 0.5f;
|
mid.y = (left.y + right.y) * 0.5f;
|
||||||
mid.z = (left.z + right.z) * 0.5f;
|
mid.z = (left.z + right.z) * 0.5f;
|
||||||
return Results.Success(mid);
|
|
||||||
|
return DtStatus.DT_SUCCSESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Result<RcVec3f> GetEdgeIntersectionPoint(RcVec3f fromPos, long from, DtPoly fromPoly, DtMeshTile fromTile,
|
protected DtStatus GetEdgeIntersectionPoint(RcVec3f fromPos, long from, DtPoly fromPoly, DtMeshTile fromTile,
|
||||||
RcVec3f toPos, long to, DtPoly toPoly, DtMeshTile toTile)
|
RcVec3f toPos, long to, DtPoly toPoly, DtMeshTile toTile,
|
||||||
|
ref RcVec3f pt)
|
||||||
{
|
{
|
||||||
var ppStatus = GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, out var left, out var right);
|
var ppStatus = GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, out var left, out var right);
|
||||||
if (ppStatus.Failed())
|
if (ppStatus.Failed())
|
||||||
{
|
{
|
||||||
return Results.Of<RcVec3f>(ppStatus, "");
|
return DtStatus.DT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
float t = 0.5f;
|
float t = 0.5f;
|
||||||
|
@ -2118,8 +2117,8 @@ namespace DotRecast.Detour
|
||||||
t = Clamp(t2, 0.1f, 0.9f);
|
t = Clamp(t2, 0.1f, 0.9f);
|
||||||
}
|
}
|
||||||
|
|
||||||
RcVec3f pt = RcVec3f.Lerp(left, right, t);
|
pt = RcVec3f.Lerp(left, right, t);
|
||||||
return Results.Success(pt);
|
return DtStatus.DT_SUCCSESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private const float s = 1.0f / 255.0f;
|
private const float s = 1.0f / 255.0f;
|
||||||
|
@ -3271,12 +3270,9 @@ namespace DotRecast.Detour
|
||||||
// Cost
|
// Cost
|
||||||
if (neighbourNode.flags == 0)
|
if (neighbourNode.flags == 0)
|
||||||
{
|
{
|
||||||
var midPoint = GetEdgeMidPoint(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly,
|
GetEdgeMidPoint(bestRef, bestPoly, bestTile,
|
||||||
neighbourTile);
|
neighbourRef, neighbourPoly, neighbourTile,
|
||||||
if (midPoint.Succeeded())
|
ref neighbourNode.pos);
|
||||||
{
|
|
||||||
neighbourNode.pos = midPoint.result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float total = bestNode.total + RcVec3f.Distance(bestNode.pos, neighbourNode.pos);
|
float total = bestNode.total + RcVec3f.Distance(bestNode.pos, neighbourNode.pos);
|
||||||
|
|
|
@ -136,12 +136,9 @@ namespace DotRecast.Detour
|
||||||
// If the node is visited the first time, calculate node position.
|
// If the node is visited the first time, calculate node position.
|
||||||
if (neighbourNode.flags == 0)
|
if (neighbourNode.flags == 0)
|
||||||
{
|
{
|
||||||
var midpod = GetEdgeMidPoint(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly,
|
GetEdgeMidPoint(bestRef, bestPoly, bestTile,
|
||||||
neighbourTile);
|
neighbourRef, neighbourPoly, neighbourTile,
|
||||||
if (!midpod.Failed())
|
ref neighbourNode.pos);
|
||||||
{
|
|
||||||
neighbourNode.pos = midpod.result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate cost and heuristic.
|
// Calculate cost and heuristic.
|
||||||
|
@ -345,12 +342,9 @@ namespace DotRecast.Detour
|
||||||
// position.
|
// position.
|
||||||
if (neighbourNode.flags == 0)
|
if (neighbourNode.flags == 0)
|
||||||
{
|
{
|
||||||
var midpod = GetEdgeMidPoint(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly,
|
GetEdgeMidPoint(bestRef, bestPoly, bestTile,
|
||||||
neighbourTile);
|
neighbourRef, neighbourPoly, neighbourTile,
|
||||||
if (!midpod.Failed())
|
ref neighbourNode.pos);
|
||||||
{
|
|
||||||
neighbourNode.pos = midpod.result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate cost and heuristic.
|
// Calculate cost and heuristic.
|
||||||
|
@ -624,7 +618,7 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
|
|
||||||
DtStatus details = m_query.status;
|
DtStatus details = m_query.status;
|
||||||
|
|
||||||
// Reset query.
|
// Reset query.
|
||||||
m_query = new DtQueryData();
|
m_query = new DtQueryData();
|
||||||
|
|
||||||
|
@ -783,12 +777,9 @@ namespace DotRecast.Detour
|
||||||
// Cost
|
// Cost
|
||||||
if (neighbourNode.flags == 0)
|
if (neighbourNode.flags == 0)
|
||||||
{
|
{
|
||||||
var midPoint = GetEdgeMidPoint(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly,
|
GetEdgeMidPoint(bestRef, bestPoly, bestTile,
|
||||||
neighbourTile);
|
neighbourRef, neighbourPoly, neighbourTile,
|
||||||
if (midPoint.Succeeded())
|
ref neighbourNode.pos);
|
||||||
{
|
|
||||||
neighbourNode.pos = midPoint.result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float total = bestNode.total + RcVec3f.Distance(bestNode.pos, neighbourNode.pos);
|
float total = bestNode.total + RcVec3f.Distance(bestNode.pos, neighbourNode.pos);
|
||||||
|
|
Loading…
Reference in New Issue