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

Method TestPath

Source/Engine/Navigation/NavMeshRuntime.cpp:158–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158bool NavMeshRuntime::TestPath(const Vector3& startPosition, const Vector3& endPosition) const
159{
160 ScopeLock lock(Locker);
161 const auto query = GetNavMeshQuery();
162 if (!query || !_navMesh)
163 return false;
164
165 dtQueryFilter filter;
166 InitFilter(filter);
167 Float3 extent = Properties.DefaultQueryExtent;
168
169 Float3 startPositionNavMesh, endPositionNavMesh;
170 Float3::Transform(startPosition, Properties.Rotation, startPositionNavMesh);
171 Float3::Transform(endPosition, Properties.Rotation, endPositionNavMesh);
172
173 dtPolyRef startPoly = 0;
174 if (!dtStatusSucceed(query->findNearestPoly(&startPositionNavMesh.X, &extent.X, &filter, &startPoly, nullptr)))
175 return false;
176 dtPolyRef endPoly = 0;
177 if (!dtStatusSucceed(query->findNearestPoly(&endPositionNavMesh.X, &extent.X, &filter, &endPoly, nullptr)))
178 return false;
179
180 dtPolyRef path[NAV_MESH_PATH_MAX_SIZE];
181 int32 pathSize;
182 const auto findPathStatus = query->findPath(startPoly, endPoly, &startPositionNavMesh.X, &endPositionNavMesh.X, &filter, path, &pathSize, NAV_MESH_PATH_MAX_SIZE);
183 if (dtStatusFailed(findPathStatus))
184 return false;
185 if (dtStatusDetail(findPathStatus, DT_PARTIAL_RESULT))
186 return false;
187
188 return true;
189}
190
191bool NavMeshRuntime::FindClosestPoint(const Vector3& point, Vector3& result) const
192{

Callers

nothing calls this directly

Calls 8

GetNavMeshQueryFunction · 0.85
InitFilterFunction · 0.85
dtStatusSucceedFunction · 0.85
dtStatusFailedFunction · 0.85
dtStatusDetailFunction · 0.85
findNearestPolyMethod · 0.80
findPathMethod · 0.80
TransformClass · 0.50

Tested by

no test coverage detected