MCPcopy Create free account
hub / github.com/axmolengine/axmol / initSlicedFindPath

Method initSlicedFindPath

3rdparty/recast/DetourNavMeshQuery.cpp:1216–1278  ·  view source on GitHub ↗

@par @warning Calling any non-slice methods before calling finalizeSlicedFindPath() or finalizeSlicedFindPathPartial() may result in corrupted data! The @p filter pointer is stored and used for the duration of the sliced path query.

Source from the content-addressed store, hash-verified

1214/// path query.
1215///
1216dtStatus dtNavMeshQuery::initSlicedFindPath(dtPolyRef startRef, dtPolyRef endRef,
1217 const float* startPos, const float* endPos,
1218 const dtQueryFilter* filter, const unsigned int options)
1219{
1220 dtAssert(m_nav);
1221 dtAssert(m_nodePool);
1222 dtAssert(m_openList);
1223
1224 // Init path state.
1225 memset(&m_query, 0, sizeof(dtQueryData));
1226 m_query.status = DT_FAILURE;
1227 m_query.startRef = startRef;
1228 m_query.endRef = endRef;
1229 if (startPos)
1230 dtVcopy(m_query.startPos, startPos);
1231 if (endPos)
1232 dtVcopy(m_query.endPos, endPos);
1233 m_query.filter = filter;
1234 m_query.options = options;
1235 m_query.raycastLimitSqr = FLT_MAX;
1236
1237 // Validate input
1238 if (!m_nav->isValidPolyRef(startRef) || !m_nav->isValidPolyRef(endRef) ||
1239 !startPos || !dtVisfinite(startPos) ||
1240 !endPos || !dtVisfinite(endPos) || !filter)
1241 {
1242 return DT_FAILURE | DT_INVALID_PARAM;
1243 }
1244
1245 // trade quality with performance?
1246 if (options & DT_FINDPATH_ANY_ANGLE)
1247 {
1248 // limiting to several times the character radius yields nice results. It is not sensitive
1249 // so it is enough to compute it from the first tile.
1250 const dtMeshTile* tile = m_nav->getTileByRef(startRef);
1251 float agentRadius = tile->header->walkableRadius;
1252 m_query.raycastLimitSqr = dtSqr(agentRadius * DT_RAY_CAST_LIMIT_PROPORTIONS);
1253 }
1254
1255 if (startRef == endRef)
1256 {
1257 m_query.status = DT_SUCCESS;
1258 return DT_SUCCESS;
1259 }
1260
1261 m_nodePool->clear();
1262 m_openList->clear();
1263
1264 dtNode* startNode = m_nodePool->getNode(startRef);
1265 dtVcopy(startNode->pos, startPos);
1266 startNode->pidx = 0;
1267 startNode->cost = 0;
1268 startNode->total = dtVdist(startPos, endPos) * H_SCALE;
1269 startNode->id = startRef;
1270 startNode->flags = DT_NODE_OPEN;
1271 m_openList->push(startNode);
1272
1273 m_query.status = DT_IN_PROGRESS;

Callers 3

updateMoveRequestMethod · 0.80
updateMethod · 0.80
optimizePathTopologyMethod · 0.80

Calls 9

dtVcopyFunction · 0.85
dtVisfiniteFunction · 0.85
dtSqrFunction · 0.85
dtVdistFunction · 0.85
isValidPolyRefMethod · 0.45
getTileByRefMethod · 0.45
clearMethod · 0.45
getNodeMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected