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

#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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ HeightField()

HeightField::HeightField ( QObject *  parent = nullptr)
explicit

Definition at line 50 of file HeightField.cc.

Member Function Documentation

◆ backingKeyFor()

TileMath::TileKey HeightField::backingKeyFor ( const TileMath::TileKey key) const
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.

◆ hasTile()

bool HeightField::hasTile ( const TileMath::TileKey key) const
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().

◆ heightAt()

◆ insertTile()

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.

◆ lookupCountForTest()

qint64 HeightField::lookupCountForTest ( ) const
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().

◆ regionChanged

void HeightField::regionChanged ( const QRectF &  worldRect)
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().

◆ samplePatch()

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

◆ setPinnedKeys()

void HeightField::setPinnedKeys ( QSet< TileMath::TileKey keys)
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().

◆ tileCount()

int HeightField::tileCount ( ) const
inline

Definition at line 68 of file HeightField.h.

References ElevationTilePyramid::tileCount().

Member Data Documentation

◆ kMaxGridSize

constexpr int HeightField::kMaxGridSize = 4096
staticconstexpr

Sanity cap on patch density: rejects absurd sizes before allocation.

Definition at line 44 of file HeightField.h.

Referenced by samplePatch().


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