void PathGenerator::BuildPointPath(const float *startPoint, const float *endPoint) { float pathPoints[MAX_POINT_PATH_LENGTH*VERTEX_SIZE]; uint32 pointCount = 0; dtStatus dtResult = DT_FAILURE; if (_straightLine) { // if the path is a straight line then start and end position are enough dtResult = DT_SUCCESS; pointCount = 2; memcpy(&pathPoints[0], startPoint, sizeof(float)* 3); memcpy(&pathPoints[3], endPoint, sizeof(float)* 3); } else if (_useStraightPath) { dtResult = _navMeshQuery->findStraightPath( startPoint, // start position endPoint, // end position _pathPolyRefs, // current path _polyLength, // lenth of current path pathPoints, // [out] path corner points NULL, // [out] flags NULL, // [out] shortened path (int*)&pointCount, _pointPathLimit); // maximum number of points/polygons to use } else { dtResult = FindSmoothPath( startPoint, // start position endPoint, // end position _pathPolyRefs, // current path _polyLength, // length of current path pathPoints, // [out] path corner points (int*)&pointCount, _pointPathLimit); // maximum number of points } if (pointCount < 2 || dtStatusFailed(dtResult)) { // only happens if pass bad data to findStraightPath or navmesh is broken // single point paths can be generated here /// @todo check the exact cases TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath FAILED! path sized %d returned\n", pointCount); BuildShortcut(); _type = PATHFIND_NOPATH; return; } else if (pointCount == _pointPathLimit) { TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath FAILED! path sized %d returned, lower than limit set to %d\n", pointCount, _pointPathLimit); BuildShortcut(); _type = PATHFIND_SHORT; return; } _pathPoints.resize(pointCount); for (uint32 i = 0; i < pointCount; ++i) _pathPoints[i] = G3D::Vector3(pathPoints[i*VERTEX_SIZE+2], pathPoints[i*VERTEX_SIZE], pathPoints[i*VERTEX_SIZE+1]); NormalizePath(); // first point is always our current location - we need the next one SetActualEndPosition(_pathPoints[pointCount-1]); // force the given destination, if needed if (_forceDestination && (!(_type & PATHFIND_NORMAL) || !InRange(GetEndPosition(), GetActualEndPosition(), 1.0f, 1.0f))) { // we may want to keep partial subpath if (Dist3DSqr(GetActualEndPosition(), GetEndPosition()) < 0.3f * Dist3DSqr(GetStartPosition(), GetEndPosition())) { SetActualEndPosition(GetEndPosition()); _pathPoints[_pathPoints.size()-1] = GetEndPosition(); } else { SetActualEndPosition(GetEndPosition()); BuildShortcut(); } _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH); } TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath path type %d size %d poly-size %d\n", _type, pointCount, _polyLength); }
void PathGenerator::BuildPointPath(const float *startPoint, const float *endPoint) { float pathPoints[MAX_POINT_PATH_LENGTH*VERTEX_SIZE]; uint32 pointCount = 0; dtStatus dtResult = DT_FAILURE; if (_useStraightPath) { dtResult = _navMeshQuery->findStraightPath( startPoint, // start position endPoint, // end position _pathPolyRefs, // current path _polyLength, // lenth of current path pathPoints, // [out] path corner points NULL, // [out] flags NULL, // [out] shortened path (int*)&pointCount, _pointPathLimit); // maximum number of points/polygons to use } else { dtResult = FindSmoothPath( startPoint, // start position endPoint, // end position _pathPolyRefs, // current path _polyLength, // length of current path pathPoints, // [out] path corner points (int*)&pointCount, _pointPathLimit); // maximum number of points } if (pointCount < 2 || dtResult != DT_SUCCESS) { // only happens if pass bad data to findStraightPath or navmesh is broken // single point paths can be generated here // TODO : check the exact cases sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::BuildPointPath FAILED! path sized %d returned\n", pointCount); BuildShortcut(); _type = PATHFIND_NOPATH; return; } else if (pointCount == _pointPathLimit) { sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::BuildPointPath FAILED! path sized %d returned, lower than limit set to %d\n", pointCount, _pointPathLimit); BuildShortcut(); _type = PATHFIND_SHORT; return; } _pathPoints.resize(pointCount); for (uint32 i = 0; i < pointCount; ++i) _pathPoints[i] = Vector3(pathPoints[i*VERTEX_SIZE+2], pathPoints[i*VERTEX_SIZE], pathPoints[i*VERTEX_SIZE+1]); NormalizePath(); // first point is always our current location - we need the next one SetActualEndPosition(_pathPoints[pointCount-1]); // force the given destination, if needed if (_forceDestination && (!(_type & PATHFIND_NORMAL) || !InRange(GetEndPosition(), GetActualEndPosition(), 1.0f, 1.0f))) { // we may want to keep partial subpath if (Dist3DSqr(GetActualEndPosition(), GetEndPosition()) < 0.3f * Dist3DSqr(GetStartPosition(), GetEndPosition())) { SetActualEndPosition(GetEndPosition()); _pathPoints[_pathPoints.size()-1] = GetEndPosition(); } else { SetActualEndPosition(GetEndPosition()); BuildShortcut(); } _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH); } //Custom Point for Bugged Zone (By saqi) float startEndDist = Dist3DSqr(GetStartPosition(), GetEndPosition()); //Blade edge arena (mapid) if (_sourceUnit->GetMapId() == 562) { //Your Position & Target Position if (startEndDist < 2500.0f && endPoint[2] <= 6230.803223f && startPoint[2] >= 6230.803223f && endPoint[1] >= 11.000000 && startPoint[1] >= 11.000000f && endPoint[0] >= 247.547917f && endPoint[0] <= 252.298940f) // southeast pillar { // Path X,y,z _pathPoints.resize(4); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(6234.506836f, 256.696106f, 11.400018f); _pathPoints[2] = Vector3(6231.472656f, 252.849335f, 11.400018f); _pathPoints[3] = GetEndPosition(); } else if (startEndDist < 2500.0f && endPoint[2] >= 6246.201660f && startPoint[2] <= 6246.201660f && endPoint[1] >= 11.000000f && startPoint[1] >= 11.000000f && endPoint[0] >= 217.677917f && endPoint[0] <= 276.888794f) // northwest pillar { // Path X,y,z _pathPoints.resize(4); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(6242.146484f, 267.531030f, 11.400000f); _pathPoints[2] = Vector3(6246.985352f, 271.076599f, 11.400000f); _pathPoints[3] = GetEndPosition(); } if (startEndDist < 2500.0f && startPoint[2] <= 6230.803223f && endPoint[2] >= 6230.803223f && endPoint[1] >= 11.000000 && startPoint[1] >= 11.000000f && startPoint[0] >= 247.547917f && startPoint[0] <= 252.298940f) // southeast pillar { // Path X,y,z _pathPoints.resize(4); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(6231.472656f, 252.849335f, 11.400018f); _pathPoints[2] = Vector3(6234.506836f, 256.696106f, 11.400018f); _pathPoints[3] = GetEndPosition(); } else if (startEndDist < 4000.0f && startPoint[2] >= 6246.201660f && endPoint[2] <= 6246.201660f && endPoint[1] >= 11.000000f && startPoint[1] >= 11.000000f && startPoint[0] >= 217.677917f && startPoint[0] <= 276.888794f) // northwest pillar { // Path X,y,z _pathPoints.resize(4); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(6246.985352f, 271.076599f, 11.400000f); _pathPoints[2] = Vector3(6242.146484f, 267.531030f, 11.400000f); _pathPoints[3] = GetEndPosition(); } } //Dalaran Sewer if (_sourceUnit->GetMapId() == 617) { if (startPoint[2] >= 1330.033223f && startPoint[1] >= 9.000000f) // Canal 1# { // Path X,y,z _pathPoints.resize(5); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(1332.749268f, 816.274780f, 8.355900f); _pathPoints[2] = Vector3(1325.749268f, 816.602539f, 5.4000000f); _pathPoints[3] = Vector3(1328.749268f, 816.602539f, 3.4000000f); _pathPoints[4] = GetEndPosition(); } else if (startPoint[2] <= 1253.904785f && startPoint[1] >= 9.000000f) // Canal 2# { // Path X,y,z _pathPoints.resize(5); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(1252.425395f, 764.971680f, 8.000000f); _pathPoints[3] = Vector3(1255.425395f, 764.971680f, 5.3559000f); _pathPoints[3] = Vector3(1257.425395f, 764.971680f, 3.3559000f); _pathPoints[4] = GetEndPosition(); } } //Eye of The Storm if (_sourceUnit->GetMapId() == 566) { if (startPoint[2] <= 1850.003223f && startPoint[1] >= 1237.000000f && startPoint[0] >= 1501.420000f && startPoint[0] <= 1579.960000f) // StartZone Horde { // Path X,y,z _pathPoints.resize(5); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(1847.004468f, 1540.660539f, 1243.400000f); _pathPoints[2] = Vector3(1842.883268f, 1527.123839f, 1238.410000f); _pathPoints[3] = Vector3(1839.593268f, 1519.479539f, 1229.428000f); _pathPoints[4] = GetEndPosition(); } if (startPoint[2] >= 2484.003223f && startPoint[1] >= 1240.000000f && startPoint[0] >= 1567.420000f && startPoint[0] <= 1626.960000f) // StartZone Alliance { // Path X,y,z _pathPoints.resize(5); _pathPoints[0] = GetStartPosition(); _pathPoints[1] = Vector3(2485.154468f, 1596.583439f, 1244.898315f); _pathPoints[2] = Vector3(2482.733268f, 1608.305649f, 1238.092000f); _pathPoints[3] = Vector3(2488.073268f, 1623.749539f, 1227.788000f); _pathPoints[4] = GetEndPosition(); } } //Custom Point for Bugged Zone sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::BuildPointPath path type %d size %d poly-size %d\n", _type, pointCount, _polyLength); }