change GetPolyFlags

This commit is contained in:
ikpil 2023-06-18 08:53:35 +09:00
parent 4deaef03b4
commit da6c972c23
2 changed files with 17 additions and 9 deletions

View File

@ -1609,33 +1609,41 @@ namespace DotRecast.Detour
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)
{
return Results.Failure<int>();
return DtStatus.DT_FAILURE;
}
DecodePolyId(refs, out var salt, out var it, out var ip);
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)
{
return Results.InvalidParam<int>();
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
}
DtMeshTile tile = m_tiles[it];
if (ip >= tile.data.header.polyCount)
{
return Results.InvalidParam<int>();
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
}
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)

View File

@ -163,10 +163,10 @@ public class CrowdTool : IRcTool
navquery.FindNearestPoly(p, halfExtents, filter, out var refs, out var nearestPt, out var _);
if (refs != 0)
{
Result<int> flags = nav.GetPolyFlags(refs);
if (flags.Succeeded())
var status = nav.GetPolyFlags(refs, out var f);
if (status.Succeeded())
{
nav.SetPolyFlags(refs, flags.result ^ SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED);
nav.SetPolyFlags(refs, f ^ SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED);
}
}
}