-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(cherry picked from commit 2397f23fc301f4c32408045ab55b19f88ee08599)
- Loading branch information
Showing
5 changed files
with
61 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using DotRecast.Core; | ||
using DotRecast.Core.Numerics; | ||
|
||
namespace DotRecast.Detour | ||
{ | ||
public struct DtHeightSamplePolyQuery : IDtPolyQuery | ||
{ | ||
private readonly DtNavMeshQuery _navMeshQuery; | ||
private readonly RcVec3f _pt; | ||
private readonly float _maxHeight; | ||
public float MinHeight { get; private set; } | ||
public bool Found { get; private set; } | ||
|
||
public DtHeightSamplePolyQuery(DtNavMeshQuery navMeshQuery, RcVec3f pt, float minHeight, float maxHeight) | ||
{ | ||
_navMeshQuery = navMeshQuery; | ||
_pt = pt; | ||
MinHeight = minHeight; | ||
_maxHeight = maxHeight; | ||
Found = default; | ||
} | ||
|
||
public void Process(DtMeshTile tile, Span<DtPoly> poly, Span<long> refs, int count) | ||
{ | ||
for (int i = 0; i < count; i++) | ||
{ | ||
ProcessSingle(refs[i]); | ||
} | ||
} | ||
|
||
private void ProcessSingle(long refs) | ||
{ | ||
var status = _navMeshQuery.GetPolyHeight(refs, _pt, out var h); | ||
if (!status.Succeeded()) | ||
return; | ||
|
||
if (!(h > MinHeight) || !(h < _maxHeight)) | ||
return; | ||
|
||
MinHeight = h; | ||
Found = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters