|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <SurfaceModel.h>
Inheritance diagram for SurfaceModel:
Collaboration diagram for SurfaceModel:Classes | |
| struct | Patch |
| struct | UpdateStats |
| update() call/duration counters for the perf overlay More... | |
Signals | |
| void | patchAdded (const TileMath::TileKey &key) |
| void | patchMeshChanged (const TileMath::TileKey &key) |
| The patch's mesh content changed (heights re-sampled): consumers must re-pull heights. | |
| void | patchEdgeDeltasChanged (const TileMath::TileKey &key) |
| void | patchRemoved (const TileMath::TileKey &key) |
| void | surfaceHeightsChanged () |
Public Member Functions | |
| SurfaceModel (GeoMapCamera *camera, HeightSource *heightSource, HeightField *field, QObject *parent=nullptr) | |
| void | update () |
| bool | updateSettled () const |
| False while a scheduled update pass or deferred patch churn is outstanding. | |
| QList< Patch > | patches () const |
| std::optional< Patch > | patch (const TileMath::TileKey &key) const |
| Single-patch lookup; std::nullopt when the key is not resident. | |
| std::optional< double > | renderedHeightAt (const QPointF &world) const |
| QList< int > | edgeLodDeltas (const TileMath::TileKey &key) const |
| UpdateStats | takeUpdateStats () |
| Returns the counters accumulated since the previous call and resets them. | |
| QRectF | visibleGroundRect () const |
| Estimated visible ground region in world meters (see class comment) | |
| int | patchCount () const |
| int | pendingCount () const |
Static Public Attributes | |
| static constexpr int | kGridSize = 16 |
| static constexpr int | kMaxPatches = 256 |
| static constexpr int | kMaxPatchAddsPerUpdate = 2 |
| static constexpr int | kMaxPatchRemovalsPerUpdate = 4 |
| static constexpr double | kRefinePixelThreshold = 384.0 |
| subdivide above this projected size | |
| static constexpr double | kMaxRangeMultiplier = 40.0 |
| visible-range cap in camera distances | |
| static constexpr int | kVisibleSampleGrid = 5 |
| static constexpr double | kRecullHeightMargin = 25.0 |
Maintains the active set of surface mesh patches for the current camera view.
Patches follow the slippy-tile quadtree. On every camera change the model refines the quadtree by screen-space error (a patch subdivides while its projected size exceeds the refinement threshold), culls against the visible ground region, and diffs the result against the current set.
Patches are views of the continuous HeightField: a new patch meshes immediately from the field's best estimate (never a flat placeholder with real neighbors), tile coverage is requested from the height source, and when data arrives the field's regionChanged re-meshes exactly the patches touching the changed region. A patch being replaced across LOD changes may only be removed once the replacements covering it are resident, so LOD churn and panning never open holes in the surface.
The visible ground region is estimated by sampling screen points through the camera and capping horizon misses at a distance-scaled range, so far-horizon coverage at high tilt is approximate (coarse patches there are acceptable).
Definition at line 47 of file SurfaceModel.h.
| SurfaceModel::SurfaceModel | ( | GeoMapCamera * | camera, |
| HeightSource * | heightSource, | ||
| HeightField * | field, | ||
| QObject * | parent = nullptr |
||
| ) |
Definition at line 72 of file SurfaceModel.cc.
References GeoMapCamera::centerChanged(), GeoMapCamera::centerElevationChanged(), GeoMapCamera::distanceChanged(), GeoMapCamera::fieldOfViewChanged(), GeoMapCamera::headingChanged(), SettingsManager::instance(), Fact::rawValueChanged(), HeightField::regionChanged(), GeoMapCamera::tiltChanged(), and GeoMapCamera::viewportSizeChanged().
| QList< int > SurfaceModel::edgeLodDeltas | ( | const TileMath::TileKey & | key | ) | const |
How many LOD levels coarser the resident neighbor across each edge renders, as {north, south, west, east} for PatchGeometry stitching. 0 = same/finer/no neighbor (unconstrained).
Definition at line 371 of file SurfaceModel.cc.
Referenced by SurfacePatchModel::data().
| std::optional< SurfaceModel::Patch > SurfaceModel::patch | ( | const TileMath::TileKey & | key | ) | const |
Single-patch lookup; std::nullopt when the key is not resident.
Definition at line 316 of file SurfaceModel.cc.
Referenced by SurfacePatchModel::data().
|
signal |
|
inline |
Definition at line 130 of file SurfaceModel.h.
|
signal |
A neighbor add/remove changed the patch's edge LOD deltas: consumers must re-pull edgeLodDeltas (heights are unchanged)
| QList< SurfaceModel::Patch > SurfaceModel::patches | ( | ) | const |
Definition at line 305 of file SurfaceModel.cc.
References SurfaceModel::Patch::key.
Referenced by SurfacePatchModel::analyzeSurface().
|
signal |
The patch's mesh content changed (heights re-sampled): consumers must re-pull heights.
|
signal |
|
inline |
Always 0: patches mesh immediately from the field. Kept for the perf overlay bindings until the downstream plumbing is removed (step 8).
Definition at line 134 of file SurfaceModel.h.
Referenced by SurfacePatchModel::pendingCount().
| std::optional< double > SurfaceModel::renderedHeightAt | ( | const QPointF & | world | ) | const |
Height of the rendered surface at a world point (true meters): the drawn mesh (triangles, stitched edges) of the finest resident patch covering it, so items sit on what is drawn. std::nullopt where no patch renders.
Definition at line 326 of file SurfaceModel.cc.
References TileMath::isValidKey(), kGridSize, TileMath::kMaxZoom, TileMath::kMinZoom, PatchMesh::surfaceHeight(), TileMath::tileForWorld(), TileMath::TileKey::x, and TileMath::TileKey::y.
|
signal |
renderedHeightAt answers (or the field beyond the patches) may have changed: patches re-meshed, added, or removed
Referenced by update().
| SurfaceModel::UpdateStats SurfaceModel::takeUpdateStats | ( | ) |
Returns the counters accumulated since the previous call and resets them.
Definition at line 296 of file SurfaceModel.cc.
| void SurfaceModel::update | ( | ) |
Recompute the active patch set from the current camera state. Called automatically on camera changes; safe to call directly (idempotent). One call adds at most kMaxPatchAddsPerUpdate patches; leftovers are completed by self-scheduled follow-up passes (see updateSettled).
Definition at line 111 of file SurfaceModel.cc.
References GeoMapCamera::cameraGroundPosition(), GeoMapCamera::distance(), GeoMapCamera::isPositioned(), SurfaceModel::UpdateStats::maxUs, surfaceHeightsChanged(), GeoMapCamera::tilt(), SurfaceModel::UpdateStats::totalUs, SurfaceModel::UpdateStats::updates, and GeoMapCamera::viewportSize().
|
inline |
False while a scheduled update pass or deferred patch churn is outstanding.
Definition at line 97 of file SurfaceModel.h.
|
inline |
Estimated visible ground region in world meters (see class comment)
Definition at line 128 of file SurfaceModel.h.
|
staticconstexpr |
mesh cells per patch edge
Definition at line 54 of file SurfaceModel.h.
Referenced by SurfacePatchModel::analyzeSurface(), SurfacePatchModel::gridSize(), and renderedHeightAt().
|
staticconstexpr |
Churn cap: each added patch synchronously creates a render delegate (geometry + texture, ~0.75 ms on desktop), so one update pass adds at most this many; the remainder streams over follow-up scheduled passes. Budgets size the worst-case pass, not throughput: saturated passes run back-to-back, so ops/sec is budget/passCost and stays constant.
Definition at line 64 of file SurfaceModel.h.
|
staticconstexpr |
Budget for the desired patch set; refinement stays coarser rather than exceed it. The resident set can transiently exceed it while retiring patches from the previous LOD generation cover for pending replacements (worst case ~2x).
Definition at line 58 of file SurfaceModel.h.
|
staticconstexpr |
Removal counterpart: delegate destruction is also synchronous, and high-tilt pose jumps invalidate hundreds of patches at once (400+ ms single passes in capture data when removals were unbounded). Higher than the add cap so drains outpace fills under sustained churn.
Definition at line 69 of file SurfaceModel.h.
|
staticconstexpr |
visible-range cap in camera distances
Definition at line 71 of file SurfaceModel.h.
Referenced by SurfacePatchModel::analyzeSurface(), SurfacePatchModel::maxRangeMultiplier(), and SurfacePatchModel::surfaceCoordinateAtScreenPoint().
|
staticconstexpr |
Re-cull when resident terrain grows taller than the last cull assumed by more than this (scene units); avoids update churn on every patch delivery
Definition at line 75 of file SurfaceModel.h.
|
staticconstexpr |
subdivide above this projected size
Definition at line 70 of file SurfaceModel.h.
|
staticconstexpr |
NxN screen samples for visible-region estimation
Definition at line 72 of file SurfaceModel.h.