MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / FindDistanceToWall

Method FindDistanceToWall

Source/Engine/Navigation/NavMeshRuntime.cpp:64–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64bool NavMeshRuntime::FindDistanceToWall(const Vector3& startPosition, NavMeshHit& hitInfo, float maxDistance) const
65{
66 ScopeLock lock(Locker);
67 const auto query = GetNavMeshQuery();
68 if (!query || !_navMesh)
69 return false;
70
71 dtQueryFilter filter;
72 InitFilter(filter);
73 Float3 extent = Properties.DefaultQueryExtent;
74
75 Float3 startPositionNavMesh;
76 Float3::Transform(startPosition, Properties.Rotation, startPositionNavMesh);
77
78 dtPolyRef startPoly = 0;
79 if (!dtStatusSucceed(query->findNearestPoly(&startPositionNavMesh.X, &extent.X, &filter, &startPoly, nullptr)))
80 return false;
81
82 Float3 hitPosition, hitNormal;
83 if (!dtStatusSucceed(query->findDistanceToWall(startPoly, &startPositionNavMesh.X, maxDistance, &filter, &hitInfo.Distance, &hitPosition.X, &hitNormal.X)))
84 return false;
85
86 Quaternion invRotation;
87 Quaternion::Invert(Properties.Rotation, invRotation);
88 Vector3::Transform(hitPosition, invRotation, hitInfo.Position);
89 Vector3::Transform(hitNormal, invRotation, hitInfo.Normal);
90
91 return true;
92}
93
94bool NavMeshRuntime::FindPath(const Vector3& startPosition, const Vector3& endPosition, Array<Vector3, HeapAllocation>& resultPath, NavMeshPathFlags& resultFlags) const
95{

Callers

nothing calls this directly

Calls 7

GetNavMeshQueryFunction · 0.85
InitFilterFunction · 0.85
dtStatusSucceedFunction · 0.85
findNearestPolyMethod · 0.80
findDistanceToWallMethod · 0.80
TransformClass · 0.50
InvertFunction · 0.50

Tested by

no test coverage detected