本文整理汇总了C++中PathNode::Reuse方法的典型用法代码示例。如果您正苦于以下问题:C++ PathNode::Reuse方法的具体用法?C++ PathNode::Reuse怎么用?C++ PathNode::Reuse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathNode
的用法示例。
在下文中一共展示了PathNode::Reuse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NewPathNode
PathNode* MicroPather::NewPathNode( void* state, float costFromStart, float estToEnd, PathNode* parent )
{
// Try to find an existing node for this state.
unsigned key = Hash( state ); //(HASH_SIZE-1) & ( (unsigned)state + (((unsigned)state)>>8) + (((unsigned)state)>>16) + (((unsigned)state)>>24) );
if ( !hashTable[key] ) {
// There isn't even a hashtable yet - create and initialize the PathNode.
hashTable[key] = AllocatePathNode();
hashTable[key]->Init( frame, state, costFromStart, estToEnd, parent );
return hashTable[key];
}
PathNode* root = hashTable[key];
PathNode* up = 0;
while ( root ) {
up = root;
if ( root->state == state ) {
root->Reuse( frame, costFromStart, estToEnd, parent );
assert( root->state == state );
return root;
}
#ifdef USE_BINARY_HASH
else if ( state > root->state ) {
root = root->right;
}
#endif
else {
#ifdef USE_BINARY_HASH
assert( state < root->state );
#endif
root = root->left;
}
}
assert( up );
PathNode* pNode = AllocatePathNode();
pNode->Init( frame, state, costFromStart, estToEnd, parent );
#ifdef USE_BINARY_HASH
if ( state > up->state ) {
assert( up->right == 0 );
up->right = pNode;
}
else {
assert( up->left == 0 );
up->left = pNode;
}
#else
up->left = pNode;
#endif
return pNode;
}