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

Method FindClosestPoint

Source/Engine/Navigation/NavMeshRuntime.cpp:191–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191bool NavMeshRuntime::FindClosestPoint(const Vector3& point, Vector3& result) const
192{
193 ScopeLock lock(Locker);
194 const auto query = GetNavMeshQuery();
195 if (!query || !_navMesh)
196 return false;
197
198 dtQueryFilter filter;
199 InitFilter(filter);
200 Float3 extent = Properties.DefaultQueryExtent;
201
202 Float3 pointNavMesh;
203 Float3::Transform(point, Properties.Rotation, pointNavMesh);
204
205 dtPolyRef startPoly = 0;
206 Float3 nearestPt;
207 if (!dtStatusSucceed(query->findNearestPoly(&pointNavMesh.X, &extent.X, &filter, &startPoly, &nearestPt.X)))
208 return false;
209
210 Quaternion invRotation;
211 Quaternion::Invert(Properties.Rotation, invRotation);
212 Vector3::Transform(nearestPt, invRotation, result);
213
214 return true;
215}
216
217bool NavMeshRuntime::FindRandomPoint(Vector3& result) const
218{

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected