MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / GetPathNode

Method GetPathNode

Source/Utils/micropather.cpp:435–458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433
434
435PathNode* PathNodePool::GetPathNode( unsigned frame, cPosition _state, float _costFromStart, float _estToGoal, PathNode* _parent )
436{
437 unsigned key = Hash( _state );
438
439 PathNode* root = hashTable[key];
440 while( root ) {
441 if ( root->state == _state ) {
442 if ( root->frame == frame ) // This is the correct state and correct frame.
443 break;
444 // Correct state, wrong frame.
445 root->Init( frame, _state, _costFromStart, _estToGoal, _parent );
446 break;
447 }
448 root = ( _state < root->state ) ? root->child[0] : root->child[1];
449 }
450 if ( !root ) {
451 // allocate new one
452 root = Alloc();
453 root->Clear();
454 root->Init( frame, _state, _costFromStart, _estToGoal, _parent );
455 AddPathNode( key, root );
456 }
457 return root;
458}
459
460
461void PathNode::Init( unsigned _frame,

Callers 3

GetNodeNeighborsMethod · 0.80
SolveMethod · 0.80
SolveForNearStatesMethod · 0.80

Calls 2

InitMethod · 0.80
ClearMethod · 0.45

Tested by

no test coverage detected