| 189 | } |
| 190 | |
| 191 | bool 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 | |
| 217 | bool NavMeshRuntime::FindRandomPoint(Vector3& result) const |
| 218 | { |
nothing calls this directly
no test coverage detected