- INFO_TARGET << "Pathfinder build costmap: min="
- << PPOS(m_limits.MinEdge) << ", max=" << PPOS(m_limits.MaxEdge) << std::endl;
- m_data.resize(m_max_index_x);
- for (int x = 0; x < m_max_index_x; x++) {
- m_data[x].resize(m_max_index_z);
- for (int z = 0; z < m_max_index_z; z++) {
- m_data[x][z].resize(m_max_index_y);
-
- int surfaces = 0;
- for (int y = 0; y < m_max_index_y; y++) {
- v3s16 ipos(x, y, z);
-
- v3s16 realpos = getRealPos(ipos);
-
- MapNode current = m_env->getMap().getNodeNoEx(realpos);
- MapNode below = m_env->getMap().getNodeNoEx(realpos + v3s16(0, -1, 0));
-
-
- if ((current.param0 == CONTENT_IGNORE) ||
- (below.param0 == CONTENT_IGNORE)) {
- DEBUG_OUT("Pathfinder: " << PPOS(realpos) <<
- " current or below is invalid element" << std::endl);
- if (current.param0 == CONTENT_IGNORE) {
- m_data[x][z][y].type = 'i';
- DEBUG_OUT(x << "," << y << "," << z << ": " << 'i' << std::endl);
- }
- continue;
- }
-
- //don't add anything if it isn't an air node
- if ((current.param0 != CONTENT_AIR) ||
- (below.param0 == CONTENT_AIR )) {
- DEBUG_OUT("Pathfinder: " << PPOS(realpos)
- << " not on surface" << std::endl);
- if (current.param0 != CONTENT_AIR) {
- m_data[x][z][y].type = 's';
- DEBUG_OUT(x << "," << y << "," << z << ": " << 's' << std::endl);
- }
- else {
- m_data[x][z][y].type = '-';
- DEBUG_OUT(x << "," << y << "," << z << ": " << '-' << std::endl);
- }
- continue;
- }
-
- surfaces++;
-
- m_data[x][z][y].valid = true;
- m_data[x][z][y].pos = realpos;
- m_data[x][z][y].type = 'g';
- DEBUG_OUT(x << "," << y << "," << z << ": " << 'a' << std::endl);
-
- if (m_prefetch) {
- m_data[x][z][y].directions[DIR_XP] =
- calcCost(realpos,v3s16( 1, 0, 0));
- m_data[x][z][y].directions[DIR_XM] =
- calcCost(realpos,v3s16(-1, 0, 0));
- m_data[x][z][y].directions[DIR_ZP] =
- calcCost(realpos,v3s16( 0, 0, 1));
- m_data[x][z][y].directions[DIR_ZM] =
- calcCost(realpos,v3s16( 0, 0,-1));
- }
-
- }
-
- if (surfaces >= 1 ) {
- for (int y = 0; y < m_max_index_y; y++) {
- if (m_data[x][z][y].valid) {
- m_data[x][z][y].surfaces = surfaces;
- }
- }
- }
- }
- }
- return true;