MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / init

Method init

Engine/source/navigation/navPath.cpp:285–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283}
284
285bool NavPath::init()
286{
287 mStatus = DT_FAILURE;
288
289 // Check that all the right data is provided.
290 if(!mMesh || !mMesh->getNavMesh())
291 return false;
292 if(!(mFromSet && mToSet) && !(mWaypoints && mWaypoints->size()))
293 return false;
294
295 // Initialise our query.
296 if(dtStatusFailed(mQuery->init(mMesh->getNavMesh(), MaxPathLen)))
297 return false;
298
299 mPoints.clear();
300 mFlags.clear();
301 mVisitPoints.clear();
302 mLength = 0.0f;
303
304 if(isServerObject())
305 setMaskBits(PathMask);
306
307 // Add points we need to visit in reverse order.
308 if(mWaypoints && mWaypoints->size())
309 {
310 if(mIsLooping && mFromSet)
311 mVisitPoints.push_back(mFrom);
312 if(mToSet)
313 mVisitPoints.push_front(mTo);
314 for(S32 i = mWaypoints->size() - 1; i >= 0; i--)
315 {
316 SceneObject *s = dynamic_cast<SceneObject*>(mWaypoints->at(i));
317 if(s)
318 {
319 mVisitPoints.push_back(s->getPosition());
320 // This is potentially slow, but safe.
321 if(!i && mIsLooping && !mFromSet)
322 mVisitPoints.push_front(s->getPosition());
323 }
324 }
325 if(mFromSet)
326 mVisitPoints.push_back(mFrom);
327 }
328 else
329 {
330 if(mIsLooping)
331 mVisitPoints.push_back(mFrom);
332 mVisitPoints.push_back(mTo);
333 mVisitPoints.push_back(mFrom);
334 }
335
336 return true;
337}
338
339void NavPath::resize()
340{

Callers 3

buildMethod · 0.45
createCoverPointsMethod · 0.45
loadMethod · 0.45

Calls 8

dtStatusFailedFunction · 0.85
getNavMeshMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
push_backMethod · 0.45
push_frontMethod · 0.45
atMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected