forked from bit/DotRecastNetSim
change GetPolyFlags
This commit is contained in:
parent
4deaef03b4
commit
da6c972c23
|
@ -1609,33 +1609,41 @@ namespace DotRecast.Detour
|
||||||
return DtStatus.DT_SUCCSESS;
|
return DtStatus.DT_SUCCSESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result<int> GetPolyFlags(long refs)
|
/// Gets the user defined flags for the specified polygon.
|
||||||
|
/// @param[in] ref The polygon reference.
|
||||||
|
/// @param[out] resultFlags The polygon flags.
|
||||||
|
/// @return The status flags for the operation.
|
||||||
|
public DtStatus GetPolyFlags(long refs, out int resultFlags)
|
||||||
{
|
{
|
||||||
|
resultFlags = 0;
|
||||||
|
|
||||||
if (refs == 0)
|
if (refs == 0)
|
||||||
{
|
{
|
||||||
return Results.Failure<int>();
|
return DtStatus.DT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DecodePolyId(refs, out var salt, out var it, out var ip);
|
DecodePolyId(refs, out var salt, out var it, out var ip);
|
||||||
if (it >= m_maxTiles)
|
if (it >= m_maxTiles)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<int>();
|
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_tiles[it].salt != salt || m_tiles[it].data == null || m_tiles[it].data.header == null)
|
if (m_tiles[it].salt != salt || m_tiles[it].data == null || m_tiles[it].data.header == null)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<int>();
|
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
DtMeshTile tile = m_tiles[it];
|
DtMeshTile tile = m_tiles[it];
|
||||||
if (ip >= tile.data.header.polyCount)
|
if (ip >= tile.data.header.polyCount)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<int>();
|
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
DtPoly poly = tile.data.polys[ip];
|
DtPoly poly = tile.data.polys[ip];
|
||||||
|
|
||||||
return Results.Success(poly.flags);
|
resultFlags = poly.flags;
|
||||||
|
|
||||||
|
return DtStatus.DT_SUCCSESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DtStatus SetPolyArea(long refs, char area)
|
public DtStatus SetPolyArea(long refs, char area)
|
||||||
|
|
|
@ -163,10 +163,10 @@ public class CrowdTool : IRcTool
|
||||||
navquery.FindNearestPoly(p, halfExtents, filter, out var refs, out var nearestPt, out var _);
|
navquery.FindNearestPoly(p, halfExtents, filter, out var refs, out var nearestPt, out var _);
|
||||||
if (refs != 0)
|
if (refs != 0)
|
||||||
{
|
{
|
||||||
Result<int> flags = nav.GetPolyFlags(refs);
|
var status = nav.GetPolyFlags(refs, out var f);
|
||||||
if (flags.Succeeded())
|
if (status.Succeeded())
|
||||||
{
|
{
|
||||||
nav.SetPolyFlags(refs, flags.result ^ SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED);
|
nav.SetPolyFlags(refs, f ^ SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue