QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
SurfaceModel Class Reference

#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< Patchpatches () const
 
std::optional< Patchpatch (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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SurfaceModel()

Member Function Documentation

◆ edgeLodDeltas()

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().

◆ patch()

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().

◆ patchAdded

void SurfaceModel::patchAdded ( const TileMath::TileKey key)
signal

Referenced by update().

◆ patchCount()

int SurfaceModel::patchCount ( ) const
inline

Definition at line 116 of file SurfaceModel.h.

◆ patchEdgeDeltasChanged

void SurfaceModel::patchEdgeDeltasChanged ( const TileMath::TileKey key)
signal

A neighbor add/remove changed the patch's edge LOD deltas: consumers must re-pull edgeLodDeltas (heights are unchanged)

Referenced by update().

◆ patches()

QList< SurfaceModel::Patch > SurfaceModel::patches ( ) const

Definition at line 235 of file SurfaceModel.cc.

References SurfaceModel::Patch::key.

Referenced by SurfacePatchModel::analyzeSurface().

◆ patchMeshChanged

void SurfaceModel::patchMeshChanged ( const TileMath::TileKey key)
signal

The patch's mesh content changed (heights re-sampled): consumers must re-pull heights.

◆ patchRemoved

void SurfaceModel::patchRemoved ( const TileMath::TileKey key)
signal

Referenced by update().

◆ pendingCount()

int SurfaceModel::pendingCount ( ) const
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().

◆ takeUpdateStats()

SurfaceModel::UpdateStats SurfaceModel::takeUpdateStats ( )

Returns the counters accumulated since the previous call and resets them.

Definition at line 228 of file SurfaceModel.cc.

◆ update()

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.

◆ updateSettled()

bool SurfaceModel::updateSettled ( ) const
inline

False while a scheduled update pass or deferred patch churn is outstanding.

Definition at line 90 of file SurfaceModel.h.

◆ visibleGroundRect()

QRectF SurfaceModel::visibleGroundRect ( ) const
inline

Estimated visible ground region in world meters (see class comment)

Definition at line 114 of file SurfaceModel.h.

Member Data Documentation

◆ kGridSize

constexpr int SurfaceModel::kGridSize = 16
staticconstexpr

mesh cells per patch edge

Definition at line 50 of file SurfaceModel.h.

Referenced by SurfacePatchModel::analyzeSurface(), SurfacePatchModel::gridSize(), and update().

◆ kMaxPatchAddsPerUpdate

constexpr int SurfaceModel::kMaxPatchAddsPerUpdate = 2
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().

◆ kMaxPatches

constexpr int SurfaceModel::kMaxPatches = 256
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.

◆ kMaxPatchRemovalsPerUpdate

constexpr int SurfaceModel::kMaxPatchRemovalsPerUpdate = 4
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().

◆ kMaxRangeMultiplier

constexpr double SurfaceModel::kMaxRangeMultiplier = 40.0
staticconstexpr

visible-range cap in camera distances

Definition at line 67 of file SurfaceModel.h.

Referenced by SurfacePatchModel::analyzeSurface(), and SurfacePatchModel::maxRangeMultiplier().

◆ kRecullHeightMargin

constexpr double SurfaceModel::kRecullHeightMargin = 25.0
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.

◆ kRefinePixelThreshold

constexpr double SurfaceModel::kRefinePixelThreshold = 384.0
staticconstexpr

subdivide above this projected size

Definition at line 66 of file SurfaceModel.h.

◆ kVisibleSampleGrid

constexpr int SurfaceModel::kVisibleSampleGrid = 5
staticconstexpr

NxN screen samples for visible-region estimation

Definition at line 68 of file SurfaceModel.h.


The documentation for this class was generated from the following files: