|
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) |
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. | |
| 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 43 of file SurfaceModel.h.
| SurfaceModel::SurfaceModel | ( | GeoMapCamera * | camera, |
| HeightSource * | heightSource, | ||
| HeightField * | field, | ||
| QObject * | parent = nullptr |
||
| ) |
Definition at line 55 of file SurfaceModel.cc.
References GeoMapCamera::centerChanged(), GeoMapCamera::centerElevationChanged(), GeoMapCamera::distanceChanged(), GeoMapCamera::fieldOfViewChanged(), GeoMapCamera::headingChanged(), 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 254 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 245 of file SurfaceModel.cc.
Referenced by SurfacePatchModel::data().
|
signal |
Referenced by update().
|
inline |
Definition at line 116 of file SurfaceModel.h.
|
signal |
A neighbor add/remove changed the patch's edge LOD deltas: consumers must re-pull edgeLodDeltas (heights are unchanged)
Referenced by update().
| QList< SurfaceModel::Patch > SurfaceModel::patches | ( | ) | const |
Definition at line 235 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 |
Referenced by update().
|
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 120 of file SurfaceModel.h.
Referenced by SurfacePatchModel::pendingCount().
| SurfaceModel::UpdateStats SurfaceModel::takeUpdateStats | ( | ) |
Returns the counters accumulated since the previous call and resets them.
Definition at line 228 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 87 of file SurfaceModel.cc.
References GeoMapCamera::cameraGroundPosition(), GeoMapCamera::distance(), GeoMapCamera::isPositioned(), kGridSize, kMaxPatchAddsPerUpdate, kMaxPatchRemovalsPerUpdate, TileMath::kMinZoom, SurfaceModel::UpdateStats::maxUs, patchAdded(), patchEdgeDeltasChanged(), patchRemoved(), HeightSource::requestTile(), HeightField::samplePatch(), HeightField::setPinnedKeys(), GeoMapCamera::tilt(), SurfaceModel::UpdateStats::totalUs, SurfaceModel::UpdateStats::updates, GeoMapCamera::viewportSize(), TileMath::TileKey::x, TileMath::TileKey::y, and TileMath::TileKey::zoom.
|
inline |
False while a scheduled update pass or deferred patch churn is outstanding.
Definition at line 90 of file SurfaceModel.h.
|
inline |
Estimated visible ground region in world meters (see class comment)
Definition at line 114 of file SurfaceModel.h.
|
staticconstexpr |
mesh cells per patch edge
Definition at line 50 of file SurfaceModel.h.
Referenced by SurfacePatchModel::analyzeSurface(), SurfacePatchModel::gridSize(), and update().
|
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 60 of file SurfaceModel.h.
Referenced by update().
|
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 54 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 65 of file SurfaceModel.h.
Referenced by update().
|
staticconstexpr |
visible-range cap in camera distances
Definition at line 67 of file SurfaceModel.h.
Referenced by SurfacePatchModel::analyzeSurface(), and SurfacePatchModel::maxRangeMultiplier().
|
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 71 of file SurfaceModel.h.
|
staticconstexpr |
subdivide above this projected size
Definition at line 66 of file SurfaceModel.h.
|
staticconstexpr |
NxN screen samples for visible-region estimation
Definition at line 68 of file SurfaceModel.h.