/** @par Behavior: - The movement is constrained to the surface of the navigation mesh. - The corridor is automatically adjusted (shorted or lengthened) in order to remain valid. - The new position will be located in the adjusted corridor's first polygon. The expected use case is that the desired position will be 'near' the current corridor. What is considered 'near' depends on local polygon density, query search extents, etc. The resulting position will differ from the desired position if the desired position is not on the navigation mesh, or it can't be reached using a local search. */ bool dtPathCorridor::movePosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter) { dtAssert(m_path); dtAssert(m_npath); // Move along navmesh and update new position. float result[3]; static const int MAX_VISITED = 16; dtPolyRef visited[MAX_VISITED]; int nvisited = 0; // [UE4: check status, it may fail due to runtime navmesh rebuild] const dtStatus status = navquery->moveAlongSurface(m_path[0], m_pos, npos, filter, result, visited, &nvisited, MAX_VISITED); if (dtStatusFailed(status)) { return false; } m_npath = dtMergeCorridorStartMoved(m_path, m_npath, m_maxPath, visited, nvisited); // Adjust the position to stay on top of the navmesh. float h = m_pos[1]; navquery->getPolyHeight(m_path[0], result, &h); result[1] = h; dtVcopy(m_pos, result); return true; }
/** @par Behavior: - The movement is constrained to the surface of the navigation mesh. - The corridor is automatically adjusted (shorted or lengthened) in order to remain valid. - The new position will be located in the adjusted corridor's first polygon. The expected use case is that the desired position will be 'near' the current corridor. What is considered 'near' depends on local polygon density, query search extents, etc. The resulting position will differ from the desired position if the desired position is not on the navigation mesh, or it can't be reached using a local search. */ void dtPathCorridor::movePosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter) { dtAssert(m_path); dtAssert(m_npath); // Move along navmesh and update new position. float result[3]; static const int MAX_VISITED = 16; dtPolyRef visited[MAX_VISITED]; int nvisited = 0; navquery->moveAlongSurface(m_path[0], m_pos, npos, filter, result, visited, &nvisited, MAX_VISITED); m_npath = dtMergeCorridorStartMoved(m_path, m_npath, m_maxPath, visited, nvisited); // Adjust the position to stay on top of the navmesh. float h = m_pos[1]; navquery->getPolyHeight(m_path[0], result, &h); result[1] = h; dtVcopy(m_pos, result); }