change GetPolyArea

This commit is contained in:
ikpil 2023-06-18 14:23:56 +09:00
parent 8a5614eca4
commit 7ae7c3f41e
1 changed files with 12 additions and 9 deletions

View File

@ -1677,33 +1677,36 @@ namespace DotRecast.Detour
return DtStatus.DT_SUCCSESS; return DtStatus.DT_SUCCSESS;
} }
public Result<int> GetPolyArea(long refs) public DtStatus GetPolyArea(long refs, out int resultArea)
{ {
resultArea = 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];
resultArea = poly.GetArea();
return Results.Success(poly.GetArea()); return DtStatus.DT_SUCCSESS;
} }
/** /**