Fixed google code Issue 237
- check query status of moveAlongSurface() in path corridor
This commit is contained in:
parent
5d3fd07074
commit
a8d1cba68c
@ -92,14 +92,16 @@ public:
|
|||||||
/// @param[in] npos The desired new position. [(x, y, z)]
|
/// @param[in] npos The desired new position. [(x, y, z)]
|
||||||
/// @param[in] navquery The query object used to build the corridor.
|
/// @param[in] navquery The query object used to build the corridor.
|
||||||
/// @param[in] filter The filter to apply to the operation.
|
/// @param[in] filter The filter to apply to the operation.
|
||||||
void movePosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
|
/// @return Returns true if move succeeded.
|
||||||
|
bool movePosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
|
||||||
|
|
||||||
/// Moves the target from the curent location to the desired location, adjusting the corridor
|
/// Moves the target from the curent location to the desired location, adjusting the corridor
|
||||||
/// as needed to reflect the change.
|
/// as needed to reflect the change.
|
||||||
/// @param[in] npos The desired new target position. [(x, y, z)]
|
/// @param[in] npos The desired new target position. [(x, y, z)]
|
||||||
/// @param[in] navquery The query object used to build the corridor.
|
/// @param[in] navquery The query object used to build the corridor.
|
||||||
/// @param[in] filter The filter to apply to the operation.
|
/// @param[in] filter The filter to apply to the operation.
|
||||||
void moveTargetPosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
|
/// @return Returns true if move succeeded.
|
||||||
|
bool moveTargetPosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter);
|
||||||
|
|
||||||
/// Loads a new path and target into the corridor.
|
/// Loads a new path and target into the corridor.
|
||||||
/// @param[in] target The target location within the last polygon of the path. [(x, y, z)]
|
/// @param[in] target The target location within the last polygon of the path. [(x, y, z)]
|
||||||
|
@ -436,7 +436,7 @@ 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,
|
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.
|
or it can't be reached using a local search.
|
||||||
*/
|
*/
|
||||||
void dtPathCorridor::movePosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter)
|
bool dtPathCorridor::movePosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter)
|
||||||
{
|
{
|
||||||
dtAssert(m_path);
|
dtAssert(m_path);
|
||||||
dtAssert(m_npath);
|
dtAssert(m_npath);
|
||||||
@ -446,8 +446,9 @@ void dtPathCorridor::movePosition(const float* npos, dtNavMeshQuery* navquery, c
|
|||||||
static const int MAX_VISITED = 16;
|
static const int MAX_VISITED = 16;
|
||||||
dtPolyRef visited[MAX_VISITED];
|
dtPolyRef visited[MAX_VISITED];
|
||||||
int nvisited = 0;
|
int nvisited = 0;
|
||||||
navquery->moveAlongSurface(m_path[0], m_pos, npos, filter,
|
dtStatus status = navquery->moveAlongSurface(m_path[0], m_pos, npos, filter,
|
||||||
result, visited, &nvisited, MAX_VISITED);
|
result, visited, &nvisited, MAX_VISITED);
|
||||||
|
if (dtStatusSucceed(status)) {
|
||||||
m_npath = dtMergeCorridorStartMoved(m_path, m_npath, m_maxPath, visited, nvisited);
|
m_npath = dtMergeCorridorStartMoved(m_path, m_npath, m_maxPath, visited, nvisited);
|
||||||
|
|
||||||
// Adjust the position to stay on top of the navmesh.
|
// Adjust the position to stay on top of the navmesh.
|
||||||
@ -455,6 +456,9 @@ void dtPathCorridor::movePosition(const float* npos, dtNavMeshQuery* navquery, c
|
|||||||
navquery->getPolyHeight(m_path[0], result, &h);
|
navquery->getPolyHeight(m_path[0], result, &h);
|
||||||
result[1] = h;
|
result[1] = h;
|
||||||
dtVcopy(m_pos, result);
|
dtVcopy(m_pos, result);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -470,7 +474,7 @@ The expected use case is that the desired target will be 'near' the current corr
|
|||||||
|
|
||||||
The resulting target will differ from the desired target if the desired target is not on the navigation mesh, or it can't be reached using a local search.
|
The resulting target will differ from the desired target if the desired target is not on the navigation mesh, or it can't be reached using a local search.
|
||||||
*/
|
*/
|
||||||
void dtPathCorridor::moveTargetPosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter)
|
bool dtPathCorridor::moveTargetPosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter)
|
||||||
{
|
{
|
||||||
dtAssert(m_path);
|
dtAssert(m_path);
|
||||||
dtAssert(m_npath);
|
dtAssert(m_npath);
|
||||||
@ -480,10 +484,11 @@ void dtPathCorridor::moveTargetPosition(const float* npos, dtNavMeshQuery* navqu
|
|||||||
static const int MAX_VISITED = 16;
|
static const int MAX_VISITED = 16;
|
||||||
dtPolyRef visited[MAX_VISITED];
|
dtPolyRef visited[MAX_VISITED];
|
||||||
int nvisited = 0;
|
int nvisited = 0;
|
||||||
navquery->moveAlongSurface(m_path[m_npath-1], m_target, npos, filter,
|
dtStatus status = navquery->moveAlongSurface(m_path[m_npath-1], m_target, npos, filter,
|
||||||
result, visited, &nvisited, MAX_VISITED);
|
result, visited, &nvisited, MAX_VISITED);
|
||||||
|
if (dtStatusSucceed(status))
|
||||||
|
{
|
||||||
m_npath = dtMergeCorridorEndMoved(m_path, m_npath, m_maxPath, visited, nvisited);
|
m_npath = dtMergeCorridorEndMoved(m_path, m_npath, m_maxPath, visited, nvisited);
|
||||||
|
|
||||||
// TODO: should we do that?
|
// TODO: should we do that?
|
||||||
// Adjust the position to stay on top of the navmesh.
|
// Adjust the position to stay on top of the navmesh.
|
||||||
/* float h = m_target[1];
|
/* float h = m_target[1];
|
||||||
@ -491,6 +496,10 @@ void dtPathCorridor::moveTargetPosition(const float* npos, dtNavMeshQuery* navqu
|
|||||||
result[1] = h;*/
|
result[1] = h;*/
|
||||||
|
|
||||||
dtVcopy(m_target, result);
|
dtVcopy(m_target, result);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @par
|
/// @par
|
||||||
|
Loading…
x
Reference in New Issue
Block a user