55 const int gridWidth = grid.
width;
56 const int gridHeight = grid.
height;
58 if (!_pyramid.
insertTile(key, std::move(grid), &evicted)) {
59 qCWarning(GeoMapHeightFieldLog) <<
"insertTile rejected: key" << key <<
"grid" << gridWidth <<
"x"
64 qCDebug(GeoMapHeightFieldVerboseLog) <<
"inserted tile" << key;
69 return QRectF(corner.x(), corner.y(), span, span);
72 qCDebug(GeoMapHeightFieldVerboseLog) <<
"evicted tile" << evicted;
123 qCWarning(GeoMapHeightFieldLog) <<
"samplePatch rejected: key" << key <<
"gridSize" << gridSize;
124 return QList<float>();
142 const double u = (std::ldexp(
double(n), view.key.zoom - key.
zoom) / gridSize) - view.
key.
x;
143 const double v = (std::ldexp(
double(m), view.key.zoom - key.
zoom) / gridSize) - view.key.y;
144 return static_cast<float>(heightAtUV(*view.grid, u, v));
159 QVarLengthArray<TileMemo, 9> memos;
162 const auto resolveCell = [&,
this](qint64 cx, qint64 cy) {
164 for (
const TileMemo& memo : memos) {
165 if (memo.tile == tile) {
171 if (!_pyramid.
hasDescendant(tile) && (memos.size() < memos.capacity())) {
172 memos.append({tile, view});
177 const auto boundaryHeight = [&](qint64 n, qint64 m) ->
float {
181 const auto touchingCells = [&](qint64 s, qint64(&cells)[2]) {
183 const qint64 cell = s / gridSize;
184 if (cell < cellCount) {
185 cells[count++] = cell;
187 if (((s % gridSize) == 0) && (cell > 0)) {
188 cells[count++] = cell - 1;
194 const int xCount = touchingCells(n << shiftToMax, xCells);
195 const int yCount = touchingCells(m << shiftToMax, yCells);
200 for (
int yi = 0; yi < yCount; yi++) {
201 for (
int xi = 0; xi < xCount; xi++) {
204 return viewHeight(view, n, m);
211 QList<float> heights;
212 heights.reserve(qsizetype(gridSize + 1) * (gridSize + 1));
213 for (
int row = 0; row <= gridSize; row++) {
214 const qint64 m = (qint64(key.
y) * gridSize) + row;
215 for (
int col = 0; col <= gridSize; col++) {
216 const qint64 n = (qint64(key.
x) * gridSize) + col;
217 if ((row == 0) || (row == gridSize) || (col == 0) || (col == gridSize)) {
218 heights.append(boundaryHeight(n, m));
220 heights.append(patchView.
isValid() ? viewHeight(patchView, n, m) : 0.0f);