| 433 | |
| 434 | |
| 435 | PathNode* 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 | |
| 461 | void PathNode::Init( unsigned _frame, |
no test coverage detected