| 267 | } |
| 268 | |
| 269 | bool 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 | |
| 307 | void NavMeshRuntime::SetTileSize(float tileSize) |
| 308 | { |
nothing calls this directly
no test coverage detected