CPathFinder::CPathFinder(): squareStates(int2(gs->mapx, gs->mapy), int2(gs->mapx, gs->mapy)) { heatMapping = true; InitHeatMap(); // Precalculated vectors. directionVector[PATHOPT_RIGHT].x = -2; directionVector[PATHOPT_LEFT ].x = 2; directionVector[PATHOPT_UP ].x = 0; directionVector[PATHOPT_DOWN ].x = 0; directionVector[(PATHOPT_RIGHT | PATHOPT_UP )].x = directionVector[PATHOPT_RIGHT].x + directionVector[PATHOPT_UP ].x; directionVector[(PATHOPT_LEFT | PATHOPT_UP )].x = directionVector[PATHOPT_LEFT ].x + directionVector[PATHOPT_UP ].x; directionVector[(PATHOPT_RIGHT | PATHOPT_DOWN)].x = directionVector[PATHOPT_RIGHT].x + directionVector[PATHOPT_DOWN].x; directionVector[(PATHOPT_LEFT | PATHOPT_DOWN)].x = directionVector[PATHOPT_LEFT ].x + directionVector[PATHOPT_DOWN].x; directionVector[PATHOPT_RIGHT].y = 0; directionVector[PATHOPT_LEFT ].y = 0; directionVector[PATHOPT_UP ].y = 2; directionVector[PATHOPT_DOWN ].y = -2; directionVector[(PATHOPT_RIGHT | PATHOPT_UP )].y = directionVector[PATHOPT_RIGHT].y + directionVector[PATHOPT_UP ].y; directionVector[(PATHOPT_LEFT | PATHOPT_UP )].y = directionVector[PATHOPT_LEFT ].y + directionVector[PATHOPT_UP ].y; directionVector[(PATHOPT_RIGHT | PATHOPT_DOWN)].y = directionVector[PATHOPT_RIGHT].y + directionVector[PATHOPT_DOWN].y; directionVector[(PATHOPT_LEFT | PATHOPT_DOWN)].y = directionVector[PATHOPT_LEFT ].y + directionVector[PATHOPT_DOWN].y; moveCost[PATHOPT_RIGHT] = 1; moveCost[PATHOPT_LEFT ] = 1; moveCost[PATHOPT_UP ] = 1; moveCost[PATHOPT_DOWN ] = 1; moveCost[(PATHOPT_RIGHT | PATHOPT_UP )] = 1.42f; moveCost[(PATHOPT_LEFT | PATHOPT_UP )] = 1.42f; moveCost[(PATHOPT_RIGHT | PATHOPT_DOWN)] = 1.42f; moveCost[(PATHOPT_LEFT | PATHOPT_DOWN)] = 1.42f; }
CPathFinder::CPathFinder() : heatMapOffset(0) , heatMapping(true) , start(ZeroVector) , startxSqr(0) , startzSqr(0) , startSquare(0) , goalSquare(0) , goalHeuristic(0.0f) , exactPath(false) , testMobile(false) , needPath(false) , maxSquaresToBeSearched(0) , testedNodes(0) , maxNodeCost(0.0f) , squareStates(int2(gs->mapx, gs->mapy) , int2(gs->mapx, gs->mapy)) { InitHeatMap(); // Precalculated vectors. directionVector[PATHOPT_RIGHT].x = -2; directionVector[PATHOPT_LEFT ].x = 2; directionVector[PATHOPT_UP ].x = 0; directionVector[PATHOPT_DOWN ].x = 0; directionVector[(PATHOPT_RIGHT | PATHOPT_UP )].x = directionVector[PATHOPT_RIGHT].x + directionVector[PATHOPT_UP ].x; directionVector[(PATHOPT_LEFT | PATHOPT_UP )].x = directionVector[PATHOPT_LEFT ].x + directionVector[PATHOPT_UP ].x; directionVector[(PATHOPT_RIGHT | PATHOPT_DOWN)].x = directionVector[PATHOPT_RIGHT].x + directionVector[PATHOPT_DOWN].x; directionVector[(PATHOPT_LEFT | PATHOPT_DOWN)].x = directionVector[PATHOPT_LEFT ].x + directionVector[PATHOPT_DOWN].x; directionVector[PATHOPT_RIGHT].y = 0; directionVector[PATHOPT_LEFT ].y = 0; directionVector[PATHOPT_UP ].y = 2; directionVector[PATHOPT_DOWN ].y = -2; directionVector[(PATHOPT_RIGHT | PATHOPT_UP )].y = directionVector[PATHOPT_RIGHT].y + directionVector[PATHOPT_UP ].y; directionVector[(PATHOPT_LEFT | PATHOPT_UP )].y = directionVector[PATHOPT_LEFT ].y + directionVector[PATHOPT_UP ].y; directionVector[(PATHOPT_RIGHT | PATHOPT_DOWN)].y = directionVector[PATHOPT_RIGHT].y + directionVector[PATHOPT_DOWN].y; directionVector[(PATHOPT_LEFT | PATHOPT_DOWN)].y = directionVector[PATHOPT_LEFT ].y + directionVector[PATHOPT_DOWN].y; moveCost[PATHOPT_RIGHT] = 1; moveCost[PATHOPT_LEFT ] = 1; moveCost[PATHOPT_UP ] = 1; moveCost[PATHOPT_DOWN ] = 1; moveCost[(PATHOPT_RIGHT | PATHOPT_UP )] = 1.42f; moveCost[(PATHOPT_LEFT | PATHOPT_UP )] = 1.42f; moveCost[(PATHOPT_RIGHT | PATHOPT_DOWN)] = 1.42f; moveCost[(PATHOPT_LEFT | PATHOPT_DOWN)] = 1.42f; }