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

#include <PatchGeometry.h>

+ Inheritance diagram for PatchGeometry:
+ Collaboration diagram for PatchGeometry:

Signals

void gridSizeChanged ()
 
void spanChanged ()
 
void heightsChanged ()
 
void edgeLodDeltasChanged ()
 
void heightFieldChanged ()
 

Public Member Functions

 PatchGeometry (QQuick3DObject *parent=nullptr)
 
int gridSize () const
 
void setGridSize (int gridSize)
 
qreal span () const
 
void setSpan (qreal span)
 
QList< float > heights () const
 (gridSize+1)^2 heights row-major from the north-west corner; empty = flat
 
void setHeights (const QList< float > &heights)
 
HeightFieldheightField () const
 Field for sampleFromField to sample from; not owned, may be null.
 
void setHeightField (HeightField *heightField)
 
bool sampleFromField (const TileMath::TileKey &key)
 
void setEdgeLodDeltas (int north, int south, int west, int east)
 
QList< int > edgeLodDeltas () const
 QML-bindable form of the deltas: {north, south, west, east}.
 
void setEdgeLodDeltas (const QList< int > &deltas)
 

Static Public Attributes

static constexpr int kMinGridSize = 1
 
static constexpr int kMaxGridSize = 256
 
static constexpr double kSkirtDepthFraction
 base skirt depth (fraction of span); scaled by 2^maxEdgeDelta
 

Protected Member Functions

void componentComplete () override
 

Detailed Description

Grid mesh for one surface patch of the GeoMap engine.

Local space: origin at the patch center, x east, y north, z up (meters). The grid has (gridSize+1)^2 vertices spanning [-span/2, +span/2] in x/y, displaced in z by the height grid (row-major from the north-west corner, matching HeightSource). Empty heights produce a flat patch at z=0.

Skirt geometry hangs from all four edges to hide cracks between adjacent patches of different LOD levels. UVs map (0,0) at the north-west corner to (1,1) at the south-east corner, matching raster tile orientation.

Known limitation: normals are central differences over this patch's own height grid (one-sided at edges), so lit materials show shading seams at patch borders. Fix when lit terrain matters (M2): deliver a one-sample apron from the HeightSource so edge normals use neighboring data.

Definition at line 38 of file PatchGeometry.h.

Constructor & Destructor Documentation

◆ PatchGeometry()

PatchGeometry::PatchGeometry ( QQuick3DObject *  parent = nullptr)
explicit

Definition at line 13 of file PatchGeometry.cc.

Member Function Documentation

◆ componentComplete()

void PatchGeometry::componentComplete ( )
overrideprotected

Definition at line 18 of file PatchGeometry.cc.

◆ edgeLodDeltas()

QList< int > PatchGeometry::edgeLodDeltas ( ) const
inline

QML-bindable form of the deltas: {north, south, west, east}.

Definition at line 87 of file PatchGeometry.h.

◆ edgeLodDeltasChanged

void PatchGeometry::edgeLodDeltasChanged ( )
signal

Referenced by setEdgeLodDeltas(), and setGridSize().

◆ gridSize()

int PatchGeometry::gridSize ( ) const
inline

Definition at line 56 of file PatchGeometry.h.

Referenced by setGridSize().

◆ gridSizeChanged

void PatchGeometry::gridSizeChanged ( )
signal

Referenced by setGridSize().

◆ heightField()

HeightField * PatchGeometry::heightField ( ) const
inline

Field for sampleFromField to sample from; not owned, may be null.

Definition at line 70 of file PatchGeometry.h.

Referenced by setHeightField().

◆ heightFieldChanged

void PatchGeometry::heightFieldChanged ( )
signal

Referenced by setHeightField().

◆ heights()

QList< float > PatchGeometry::heights ( ) const
inline

(gridSize+1)^2 heights row-major from the north-west corner; empty = flat

Definition at line 65 of file PatchGeometry.h.

Referenced by setHeights().

◆ heightsChanged

void PatchGeometry::heightsChanged ( )
signal

Referenced by sampleFromField(), and setHeights().

◆ sampleFromField()

bool PatchGeometry::sampleFromField ( const TileMath::TileKey key)

Samples the height field at this patch's vertex world positions (tile key at the current gridSize) and rebuilds the mesh. Returns false when no field is set or the key is invalid.

Definition at line 71 of file PatchGeometry.cc.

References heightsChanged(), and HeightField::samplePatch().

◆ setEdgeLodDeltas() [1/2]

void PatchGeometry::setEdgeLodDeltas ( const QList< int > &  deltas)

Definition at line 135 of file PatchGeometry.cc.

References setEdgeLodDeltas().

◆ setEdgeLodDeltas() [2/2]

void PatchGeometry::setEdgeLodDeltas ( int  north,
int  south,
int  west,
int  east 
)

How many LOD levels coarser each edge's neighbor renders (0 = same or finer: unconstrained). Non-coincident edge vertices are collapsed onto the segments between the coincident ones so no T-junction cracks open; HeightField::samplePatch's canonical boundary resolution guarantees the coincident vertices already match the coarse neighbor's rendered edge.

Definition at line 111 of file PatchGeometry.cc.

References edgeLodDeltasChanged(), and kMaxGridSize.

Referenced by setEdgeLodDeltas().

◆ setGridSize()

void PatchGeometry::setGridSize ( int  gridSize)

◆ setHeightField()

void PatchGeometry::setHeightField ( HeightField heightField)

Definition at line 91 of file PatchGeometry.cc.

References heightField(), and heightFieldChanged().

◆ setHeights()

void PatchGeometry::setHeights ( const QList< float > &  heights)

Definition at line 61 of file PatchGeometry.cc.

References heights(), and heightsChanged().

◆ setSpan()

void PatchGeometry::setSpan ( qreal  span)

Definition at line 51 of file PatchGeometry.cc.

References span(), and spanChanged().

◆ span()

qreal PatchGeometry::span ( ) const
inline

Definition at line 60 of file PatchGeometry.h.

Referenced by setSpan().

◆ spanChanged

void PatchGeometry::spanChanged ( )
signal

Referenced by setSpan().

Member Data Documentation

◆ kMaxGridSize

constexpr int PatchGeometry::kMaxGridSize = 256
staticconstexpr

Definition at line 52 of file PatchGeometry.h.

Referenced by setEdgeLodDeltas(), and setGridSize().

◆ kMinGridSize

constexpr int PatchGeometry::kMinGridSize = 1
staticconstexpr

Definition at line 51 of file PatchGeometry.h.

Referenced by setGridSize().

◆ kSkirtDepthFraction

constexpr double PatchGeometry::kSkirtDepthFraction
staticconstexpr
Initial value:
=
0.05

base skirt depth (fraction of span); scaled by 2^maxEdgeDelta

Definition at line 53 of file PatchGeometry.h.


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