|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <HeightField.h>
Inheritance diagram for HeightField:
Collaboration diagram for HeightField:Signals | |
| void | regionChanged (const QRectF &worldRect) |
Public Member Functions | |
| HeightField (QObject *parent=nullptr) | |
| bool | insertTile (const TileMath::TileKey &key, ElevationTilePyramid::Grid grid) |
| void | setPinnedKeys (QSet< TileMath::TileKey > keys) |
| double | heightAt (const QPointF &world) const |
| QList< float > | samplePatch (const TileMath::TileKey &key, int gridSize) const |
| int | tileCount () const |
| bool | hasTile (const TileMath::TileKey &key) const |
| True when the backing pyramid holds this exact tile. | |
| TileMath::TileKey | backingKeyFor (const TileMath::TileKey &key) const |
| qint64 | lookupCountForTest () const |
Static Public Attributes | |
| static constexpr int | kMaxGridSize = 4096 |
| Sanity cap on patch density: rejects absurd sizes before allocation. | |
The one continuous terrain heightfield of the drape design: best-estimate height everywhere, by construction — real data where a tile is stored, ancestor-interpolated estimate where only coarser data exists, zero where nothing is known. There is no "missing" region, only coarser-estimate regions, so any two callers asking for the same world position always get the same answer regardless of which patch they mesh.
Heights are sampled bilinearly between grid sample centers (pixel-center convention, clamped at tile edges), matching the terrarium tile layout.
Not thread-safe: confine to one thread or synchronize externally. This includes the const sampling methods — they mutate an internal memo cache, so even concurrent reads race.
Definition at line 34 of file HeightField.h.
|
explicit |
Definition at line 50 of file HeightField.cc.
|
inline |
Stored tile that backs samples for key (the tile itself when present, else its nearest stored ancestor); invalid when nothing covers it
Definition at line 75 of file HeightField.h.
References ElevationTilePyramid::bestTileFor(), ElevationTilePyramid::View::isValid(), and ElevationTilePyramid::View::key.
|
inline |
True when the backing pyramid holds this exact tile.
Definition at line 71 of file HeightField.h.
References ElevationTilePyramid::hasTile().
Referenced by ProceduralHeightSource::requestTile(), and TerrariumTileFetcher::requestTile().
| double HeightField::heightAt | ( | const QPointF & | world | ) | const |
Best-estimate height (meters) at a mercator world position; 0.0 where no stored tile covers the position
Definition at line 79 of file HeightField.cc.
References ElevationTilePyramid::bestTileFor(), ElevationTilePyramid::View::grid, ElevationTilePyramid::hasDescendant(), ElevationTilePyramid::View::isValid(), ElevationTilePyramid::View::key, TileMath::kMaxZoom, TileMath::tileForWorld(), TileMath::tileMinCorner(), TileMath::tileSpanAtZoom(), TileMath::TileKey::x, TileMath::TileKey::y, and TileMath::TileKey::zoom.
Referenced by SurfacePatchModel::terrainHeightAt().
| bool HeightField::insertTile | ( | const TileMath::TileKey & | key, |
| ElevationTilePyramid::Grid | grid | ||
| ) |
Stores a decoded tile in the backing pyramid; invalid keys/grids rejected. Emits regionChanged for the tile's world extent on success, and additionally for the extent of any tile the insert evicted — eviction changes the answer there too.
Definition at line 52 of file HeightField.cc.
References ElevationTilePyramid::Grid::height, ElevationTilePyramid::insertTile(), TileMath::isValidKey(), regionChanged(), TileMath::tileMinCorner(), TileMath::tileSpanAtZoom(), and ElevationTilePyramid::Grid::width.
|
inline |
Perf instrumentation: pyramid resolutions performed so far (memoized sampling keeps this far below one per sampled vertex). Test hook, not API — semantics track the resolution strategy.
Definition at line 84 of file HeightField.h.
References ElevationTilePyramid::lookupCountForTest().
|
signal |
Best-estimate heights changed within this rect (TileMath world meters, y north; min-corner + positive spans — don't use top()/bottom()). The rect is closed: patch edge vertices exactly on its boundary sample the new data, but QRectF::intersects() is false for edge-only contact, so inflate the patch rect (e.g. marginsAdded) before testing
Referenced by insertTile(), and SurfaceModel::SurfaceModel().
| QList< float > HeightField::samplePatch | ( | const TileMath::TileKey & | key, |
| int | gridSize | ||
| ) | const |
The (gridSize+1)^2 vertex heights of a patch, row-major from the NW corner. Empty for invalid keys or gridSize outside [1, kMaxGridSize]. Boundary vertices resolve by canonical world position rather than the patch's own backing view, so coincident vertices of neighboring patches sample bit-identical heights even across different backing tiles — patch edges never crack where data exists.
Definition at line 120 of file HeightField.cc.
References ElevationTilePyramid::bestTileFor(), ElevationTilePyramid::hasDescendant(), ElevationTilePyramid::View::isValid(), TileMath::isValidKey(), ElevationTilePyramid::View::key, kMaxGridSize, TileMath::kMaxZoom, TileMath::TileKey::x, TileMath::TileKey::y, and TileMath::TileKey::zoom.
Referenced by PatchGeometry::sampleFromField(), and SurfaceModel::update().
|
inline |
Tiles that must not be evicted because they back rendered patches (or resolve them as ancestors); see ElevationTilePyramid::setPinnedKeys
Definition at line 54 of file HeightField.h.
References ElevationTilePyramid::setPinnedKeys().
Referenced by SurfaceModel::update().
|
inline |
Definition at line 68 of file HeightField.h.
References ElevationTilePyramid::tileCount().
|
staticconstexpr |
Sanity cap on patch density: rejects absurd sizes before allocation.
Definition at line 44 of file HeightField.h.
Referenced by samplePatch().