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

Method RayCast

Source/Engine/Navigation/NavMeshRuntime.cpp:269–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267}
268
269bool NavMeshRuntime::RayCast(const Vector3& startPosition, const Vector3& endPosition, NavMeshHit& hitInfo) const
270{
271 ScopeLock lock(Locker);
272 const auto query = GetNavMeshQuery();
273 if (!query || !_navMesh)
274 return false;
275
276 dtQueryFilter filter;
277 InitFilter(filter);
278 Float3 extent = Properties.DefaultQueryExtent;
279
280 Float3 startPositionNavMesh, endPositionNavMesh;
281 Float3::Transform(startPosition, Properties.Rotation, startPositionNavMesh);
282 Float3::Transform(endPosition, Properties.Rotation, endPositionNavMesh);
283
284 dtPolyRef startPoly = 0;
285 if (!dtStatusSucceed(query->findNearestPoly(&startPositionNavMesh.X, &extent.X, &filter, &startPoly, nullptr)))
286 return false;
287
288 dtRaycastHit hit;
289 hit.path = nullptr;
290 hit.maxPath = 0;
291 const bool result = dtStatusSucceed(query->raycast(startPoly, &startPositionNavMesh.X, &endPositionNavMesh.X, &filter, 0, &hit));
292 if (hit.t >= MAX_float)
293 {
294 hitInfo.Position = endPosition;
295 hitInfo.Distance = 0;
296 }
297 else
298 {
299 hitInfo.Position = startPosition + (endPosition - startPosition) * hit.t;
300 hitInfo.Distance = hit.t;
301 }
302 hitInfo.Normal = *(Float3*)&hit.hitNormal;
303
304 return result;
305}
306
307void NavMeshRuntime::SetTileSize(float tileSize)
308{

Callers

nothing calls this directly

Calls 6

GetNavMeshQueryFunction · 0.85
InitFilterFunction · 0.85
dtStatusSucceedFunction · 0.85
findNearestPolyMethod · 0.80
TransformClass · 0.50
raycastMethod · 0.45

Tested by

no test coverage detected