diff --git a/src/DotRecast.Detour/DtNavMesh.cs b/src/DotRecast.Detour/DtNavMesh.cs index bd46b92..faaafac 100644 --- a/src/DotRecast.Detour/DtNavMesh.cs +++ b/src/DotRecast.Detour/DtNavMesh.cs @@ -1609,33 +1609,41 @@ namespace DotRecast.Detour return DtStatus.DT_SUCCSESS; } - public Result 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(); + return DtStatus.DT_FAILURE; } DecodePolyId(refs, out var salt, out var it, out var ip); if (it >= m_maxTiles) { - return Results.InvalidParam(); + 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(); + return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM; } DtMeshTile tile = m_tiles[it]; if (ip >= tile.data.header.polyCount) { - return Results.InvalidParam(); + 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) diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs index da6c688..7f6ac5d 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs @@ -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 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); } } }