Yes the value of totalCost is 3.40282347e+038.
I guess that's the max value of the float?
Im not sure how it becomes this however. I found out this:
1. It happens when I try to add the first node during solving the pathfind (see below). The code continues but it crashes with that "open.Push()" function (which adds the starting node I guess).
int MicroPather::Solve( void* startNode, void* endNode, vector< void* >* path, float* cost )
{
#ifdef DEBUG_PATH
printf( "Path: " );
graph->PrintStateInfo( startNode );
printf( " --> " );
graph->PrintStateInfo( endNode );
printf( " min cost=%f\n", graph->LeastCostEstimate( startNode, endNode ) );
#endif
*cost = 0.0f;
if ( startNode == endNode )
return START_END_SAME;
++frame;
// // In "reuse" mode, reset the costs.
// if ( pathNodeMem )
// ReuseAll();
OpenQueue open( graph );
ClosedSet closed( graph );
open.Push( NewPathNode( startNode, // node
0, // cost from start
graph->LeastCostEstimate( startNode, endNode ),
0 ) );
2. The NewPathNode returns a node with totalCost = 3.40282347e+038 which causes the problem. See below (function continues but the "return root" at the bottom is returning the node with the strange totalCost already.
PathNode* MicroPather::NewPathNode( void* state, float costFromStart, float estToEnd, PathNode* parent )
{
// Try to find an existing node for this state.
unsigned key = Hash( (unsigned) 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;
}
Im kind of at a loss here...