Skip to content

Commit 97b46d9

Browse files
committedSep 27, 2017
Law & order in "terrain" subdir
No actual code changes, just renaming / cleanups
1 parent 692c1a8 commit 97b46d9

16 files changed

+181
-221
lines changed
 

‎src/3d/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ SET(QGIS_3D_MOC_HDRS
5858
chunks/qgschunkqueuejob_p.h
5959

6060
terrain/qgsdemterraintileloader_p.h
61-
terrain/qgsdemterraintilegeometry_p.h
6261
terrain/qgsterrainentity_p.h
6362
terrain/qgsterraingenerator.h
6463
terrain/qgsterraintexturegenerator_p.h

‎src/3d/terrain/qgsdemterraingenerator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ QgsTerrainGenerator::Type QgsDemTerrainGenerator::type() const
3838

3939
QgsRectangle QgsDemTerrainGenerator::extent() const
4040
{
41-
return terrainTilingScheme.tileToExtent( 0, 0, 0 );
41+
return mTerrainTilingScheme.tileToExtent( 0, 0, 0 );
4242
}
4343

4444
float QgsDemTerrainGenerator::heightAt( double x, double y, const Qgs3DMapSettings &map ) const
@@ -75,12 +75,12 @@ void QgsDemTerrainGenerator::updateGenerator()
7575
QgsRasterLayer *dem = layer();
7676
if ( dem )
7777
{
78-
terrainTilingScheme = QgsTilingScheme( dem->extent(), dem->crs() );
79-
mHeightMapGenerator.reset( new QgsDemHeightMapGenerator( dem, terrainTilingScheme, mResolution ) );
78+
mTerrainTilingScheme = QgsTilingScheme( dem->extent(), dem->crs() );
79+
mHeightMapGenerator.reset( new QgsDemHeightMapGenerator( dem, mTerrainTilingScheme, mResolution ) );
8080
}
8181
else
8282
{
83-
terrainTilingScheme = QgsTilingScheme();
83+
mTerrainTilingScheme = QgsTilingScheme();
8484
mHeightMapGenerator.reset();
8585
}
8686
}

‎src/3d/terrain/qgsdemterraintilegeometry_p.cpp

Lines changed: 59 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -109,31 +109,31 @@ class PlaneVertexBufferFunctor : public QBufferDataGenerator
109109
{
110110
public:
111111
explicit PlaneVertexBufferFunctor( int resolution, const QByteArray &heightMap )
112-
: m_resolution( resolution )
113-
, m_heightMap( heightMap )
112+
: mResolution( resolution )
113+
, mHeightMap( heightMap )
114114
{}
115115

116116
~PlaneVertexBufferFunctor() {}
117117

118118
QByteArray operator()() Q_DECL_FINAL
119119
{
120-
return createPlaneVertexData( m_resolution, m_heightMap );
120+
return createPlaneVertexData( mResolution, mHeightMap );
121121
}
122122

123123
bool operator ==( const QBufferDataGenerator &other ) const Q_DECL_FINAL
124124
{
125125
const PlaneVertexBufferFunctor *otherFunctor = functor_cast<PlaneVertexBufferFunctor>( &other );
126126
if ( otherFunctor != nullptr )
127-
return ( otherFunctor->m_resolution == m_resolution &&
128-
otherFunctor->m_heightMap == m_heightMap );
127+
return ( otherFunctor->mResolution == mResolution &&
128+
otherFunctor->mHeightMap == mHeightMap );
129129
return false;
130130
}
131131

132132
QT3D_FUNCTOR( PlaneVertexBufferFunctor )
133133

134134
private:
135-
int m_resolution;
136-
QByteArray m_heightMap;
135+
int mResolution;
136+
QByteArray mHeightMap;
137137
};
138138

139139

@@ -142,28 +142,28 @@ class PlaneIndexBufferFunctor : public QBufferDataGenerator
142142
{
143143
public:
144144
explicit PlaneIndexBufferFunctor( int resolution )
145-
: m_resolution( resolution )
145+
: mResolution( resolution )
146146
{}
147147

148148
~PlaneIndexBufferFunctor() {}
149149

150150
QByteArray operator()() Q_DECL_FINAL
151151
{
152-
return createPlaneIndexData( m_resolution );
152+
return createPlaneIndexData( mResolution );
153153
}
154154

155155
bool operator ==( const QBufferDataGenerator &other ) const Q_DECL_FINAL
156156
{
157157
const PlaneIndexBufferFunctor *otherFunctor = functor_cast<PlaneIndexBufferFunctor>( &other );
158158
if ( otherFunctor != nullptr )
159-
return ( otherFunctor->m_resolution == m_resolution );
159+
return ( otherFunctor->mResolution == mResolution );
160160
return false;
161161
}
162162

163163
QT3D_FUNCTOR( PlaneIndexBufferFunctor )
164164

165165
private:
166-
int m_resolution;
166+
int mResolution;
167167
};
168168

169169

@@ -172,14 +172,8 @@ class PlaneIndexBufferFunctor : public QBufferDataGenerator
172172

173173
DemTerrainTileGeometry::DemTerrainTileGeometry( int resolution, const QByteArray &heightMap, DemTerrainTileGeometry::QNode *parent )
174174
: QGeometry( parent )
175-
, m_resolution( resolution )
176-
, m_heightMap( heightMap )
177-
, m_positionAttribute( nullptr )
178-
, m_normalAttribute( nullptr )
179-
, m_texCoordAttribute( nullptr )
180-
, m_indexAttribute( nullptr )
181-
, m_vertexBuffer( nullptr )
182-
, m_indexBuffer( nullptr )
175+
, mResolution( resolution )
176+
, mHeightMap( heightMap )
183177
{
184178
init();
185179
}
@@ -188,80 +182,59 @@ DemTerrainTileGeometry::~DemTerrainTileGeometry()
188182
{
189183
}
190184

191-
QAttribute *DemTerrainTileGeometry::positionAttribute() const
192-
{
193-
return m_positionAttribute;
194-
}
195-
196-
QAttribute *DemTerrainTileGeometry::normalAttribute() const
197-
{
198-
return m_normalAttribute;
199-
}
200-
201-
QAttribute *DemTerrainTileGeometry::texCoordAttribute() const
202-
{
203-
return m_texCoordAttribute;
204-
}
205-
206-
QAttribute *DemTerrainTileGeometry::indexAttribute() const
207-
{
208-
return m_indexAttribute;
209-
}
210-
211-
212185
void DemTerrainTileGeometry::init()
213186
{
214-
m_positionAttribute = new QAttribute( this );
215-
m_normalAttribute = new QAttribute( this );
216-
m_texCoordAttribute = new QAttribute( this );
217-
m_indexAttribute = new QAttribute( this );
218-
m_vertexBuffer = new Qt3DRender::QBuffer( Qt3DRender::QBuffer::VertexBuffer, this );
219-
m_indexBuffer = new Qt3DRender::QBuffer( Qt3DRender::QBuffer::IndexBuffer, this );
220-
221-
const int nVerts = m_resolution * m_resolution;
187+
mPositionAttribute = new QAttribute( this );
188+
mNormalAttribute = new QAttribute( this );
189+
mTexCoordAttribute = new QAttribute( this );
190+
mIndexAttribute = new QAttribute( this );
191+
mVertexBuffer = new Qt3DRender::QBuffer( Qt3DRender::QBuffer::VertexBuffer, this );
192+
mIndexBuffer = new Qt3DRender::QBuffer( Qt3DRender::QBuffer::IndexBuffer, this );
193+
194+
const int nVerts = mResolution * mResolution;
222195
const int stride = ( 3 + 2 + 3 ) * sizeof( float );
223-
const int faces = 2 * ( m_resolution - 1 ) * ( m_resolution - 1 );
224-
225-
m_positionAttribute->setName( QAttribute::defaultPositionAttributeName() );
226-
m_positionAttribute->setVertexBaseType( QAttribute::Float );
227-
m_positionAttribute->setVertexSize( 3 );
228-
m_positionAttribute->setAttributeType( QAttribute::VertexAttribute );
229-
m_positionAttribute->setBuffer( m_vertexBuffer );
230-
m_positionAttribute->setByteStride( stride );
231-
m_positionAttribute->setCount( nVerts );
232-
233-
m_texCoordAttribute->setName( QAttribute::defaultTextureCoordinateAttributeName() );
234-
m_texCoordAttribute->setVertexBaseType( QAttribute::Float );
235-
m_texCoordAttribute->setVertexSize( 2 );
236-
m_texCoordAttribute->setAttributeType( QAttribute::VertexAttribute );
237-
m_texCoordAttribute->setBuffer( m_vertexBuffer );
238-
m_texCoordAttribute->setByteStride( stride );
239-
m_texCoordAttribute->setByteOffset( 3 * sizeof( float ) );
240-
m_texCoordAttribute->setCount( nVerts );
241-
242-
m_normalAttribute->setName( QAttribute::defaultNormalAttributeName() );
243-
m_normalAttribute->setVertexBaseType( QAttribute::Float );
244-
m_normalAttribute->setVertexSize( 3 );
245-
m_normalAttribute->setAttributeType( QAttribute::VertexAttribute );
246-
m_normalAttribute->setBuffer( m_vertexBuffer );
247-
m_normalAttribute->setByteStride( stride );
248-
m_normalAttribute->setByteOffset( 5 * sizeof( float ) );
249-
m_normalAttribute->setCount( nVerts );
250-
251-
m_indexAttribute->setAttributeType( QAttribute::IndexAttribute );
252-
m_indexAttribute->setVertexBaseType( QAttribute::UnsignedInt );
253-
m_indexAttribute->setBuffer( m_indexBuffer );
196+
const int faces = 2 * ( mResolution - 1 ) * ( mResolution - 1 );
197+
198+
mPositionAttribute->setName( QAttribute::defaultPositionAttributeName() );
199+
mPositionAttribute->setVertexBaseType( QAttribute::Float );
200+
mPositionAttribute->setVertexSize( 3 );
201+
mPositionAttribute->setAttributeType( QAttribute::VertexAttribute );
202+
mPositionAttribute->setBuffer( mVertexBuffer );
203+
mPositionAttribute->setByteStride( stride );
204+
mPositionAttribute->setCount( nVerts );
205+
206+
mTexCoordAttribute->setName( QAttribute::defaultTextureCoordinateAttributeName() );
207+
mTexCoordAttribute->setVertexBaseType( QAttribute::Float );
208+
mTexCoordAttribute->setVertexSize( 2 );
209+
mTexCoordAttribute->setAttributeType( QAttribute::VertexAttribute );
210+
mTexCoordAttribute->setBuffer( mVertexBuffer );
211+
mTexCoordAttribute->setByteStride( stride );
212+
mTexCoordAttribute->setByteOffset( 3 * sizeof( float ) );
213+
mTexCoordAttribute->setCount( nVerts );
214+
215+
mNormalAttribute->setName( QAttribute::defaultNormalAttributeName() );
216+
mNormalAttribute->setVertexBaseType( QAttribute::Float );
217+
mNormalAttribute->setVertexSize( 3 );
218+
mNormalAttribute->setAttributeType( QAttribute::VertexAttribute );
219+
mNormalAttribute->setBuffer( mVertexBuffer );
220+
mNormalAttribute->setByteStride( stride );
221+
mNormalAttribute->setByteOffset( 5 * sizeof( float ) );
222+
mNormalAttribute->setCount( nVerts );
223+
224+
mIndexAttribute->setAttributeType( QAttribute::IndexAttribute );
225+
mIndexAttribute->setVertexBaseType( QAttribute::UnsignedInt );
226+
mIndexAttribute->setBuffer( mIndexBuffer );
254227

255228
// Each primitive has 3 vertives
256-
m_indexAttribute->setCount( faces * 3 );
229+
mIndexAttribute->setCount( faces * 3 );
257230

258-
m_vertexBuffer->setDataGenerator( QSharedPointer<PlaneVertexBufferFunctor>::create( m_resolution, m_heightMap ) );
259-
m_indexBuffer->setDataGenerator( QSharedPointer<PlaneIndexBufferFunctor>::create( m_resolution ) );
231+
mVertexBuffer->setDataGenerator( QSharedPointer<PlaneVertexBufferFunctor>::create( mResolution, mHeightMap ) );
232+
mIndexBuffer->setDataGenerator( QSharedPointer<PlaneIndexBufferFunctor>::create( mResolution ) );
260233

261-
addAttribute( m_positionAttribute );
262-
addAttribute( m_texCoordAttribute );
263-
addAttribute( m_normalAttribute );
264-
addAttribute( m_indexAttribute );
234+
addAttribute( mPositionAttribute );
235+
addAttribute( mTexCoordAttribute );
236+
addAttribute( mNormalAttribute );
237+
addAttribute( mIndexAttribute );
265238
}
266239

267240
/// @endcond

‎src/3d/terrain/qgsdemterraintilegeometry_p.h

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,38 +34,23 @@ namespace Qt3DRender
3434
*/
3535
class DemTerrainTileGeometry : public Qt3DRender::QGeometry
3636
{
37-
Q_OBJECT
38-
Q_PROPERTY( Qt3DRender::QAttribute *positionAttribute READ positionAttribute CONSTANT )
39-
Q_PROPERTY( Qt3DRender::QAttribute *normalAttribute READ normalAttribute CONSTANT )
40-
Q_PROPERTY( Qt3DRender::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT )
41-
Q_PROPERTY( Qt3DRender::QAttribute *indexAttribute READ indexAttribute CONSTANT )
42-
4337
public:
4438
//! Constructs a terrain tile geometry. Resolution is the number of vertices on one side of the tile,
4539
//! heightMap is array of float values with one height value for each vertex
4640
explicit DemTerrainTileGeometry( int resolution, const QByteArray &heightMap, QNode *parent = nullptr );
4741
~DemTerrainTileGeometry();
4842

49-
//! Returns geometry attribute for vertex positions
50-
Qt3DRender::QAttribute *positionAttribute() const;
51-
//! Returns geometry attribute for vertex normals
52-
Qt3DRender::QAttribute *normalAttribute() const;
53-
//! Returns geometry attribute for texture coordinates for vertices
54-
Qt3DRender::QAttribute *texCoordAttribute() const;
55-
//! Returns attribute for indices of triangles
56-
Qt3DRender::QAttribute *indexAttribute() const;
57-
5843
private:
5944
void init();
6045

61-
int m_resolution;
62-
QByteArray m_heightMap;
63-
Qt3DRender::QAttribute *m_positionAttribute;
64-
Qt3DRender::QAttribute *m_normalAttribute;
65-
Qt3DRender::QAttribute *m_texCoordAttribute;
66-
Qt3DRender::QAttribute *m_indexAttribute;
67-
Qt3DRender::QBuffer *m_vertexBuffer;
68-
Qt3DRender::QBuffer *m_indexBuffer;
46+
int mResolution;
47+
QByteArray mHeightMap;
48+
Qt3DRender::QAttribute *mPositionAttribute = nullptr;
49+
Qt3DRender::QAttribute *mNormalAttribute = nullptr;
50+
Qt3DRender::QAttribute *mTexCoordAttribute = nullptr;
51+
Qt3DRender::QAttribute *mIndexAttribute = nullptr;
52+
Qt3DRender::QBuffer *mVertexBuffer = nullptr;
53+
Qt3DRender::QBuffer *mIndexBuffer = nullptr;
6954
};
7055

7156
/// @endcond

‎src/3d/terrain/qgsdemterraintileloader_p.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ static void _heightMapMinMax( const QByteArray &heightMap, float &zMin, float &z
2929

3030
QgsDemTerrainTileLoader::QgsDemTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkNode *node )
3131
: QgsTerrainTileLoader( terrain, node )
32-
, resolution( 0 )
32+
, mResolution( 0 )
3333
{
3434

3535
const Qgs3DMapSettings &map = terrain->map3D();
3636
QgsDemTerrainGenerator *generator = static_cast<QgsDemTerrainGenerator *>( map.terrainGenerator() );
3737

3838
// get heightmap asynchronously
3939
connect( generator->heightMapGenerator(), &QgsDemHeightMapGenerator::heightMapReady, this, &QgsDemTerrainTileLoader::onHeightMapReady );
40-
heightMapJobId = generator->heightMapGenerator()->render( node->tileX(), node->tileY(), node->tileZ() );
41-
resolution = generator->heightMapGenerator()->resolution();
40+
mHeightMapJobId = generator->heightMapGenerator()->render( node->tileX(), node->tileY(), node->tileZ() );
41+
mResolution = generator->heightMapGenerator()->resolution();
4242
}
4343

4444
QgsDemTerrainTileLoader::~QgsDemTerrainTileLoader()
@@ -53,7 +53,7 @@ Qt3DCore::QEntity *QgsDemTerrainTileLoader::createEntity( Qt3DCore::QEntity *par
5353
// create geometry renderer
5454

5555
Qt3DRender::QGeometryRenderer *mesh = new Qt3DRender::QGeometryRenderer;
56-
mesh->setGeometry( new DemTerrainTileGeometry( resolution, heightMap, mesh ) );
56+
mesh->setGeometry( new DemTerrainTileGeometry( mResolution, mHeightMap, mesh ) );
5757
entity->addComponent( mesh ); // takes ownership if the component has no parent
5858

5959
// create material
@@ -67,10 +67,10 @@ Qt3DCore::QEntity *QgsDemTerrainTileLoader::createEntity( Qt3DCore::QEntity *par
6767
entity->addComponent( transform );
6868

6969
float zMin, zMax;
70-
_heightMapMinMax( heightMap, zMin, zMax );
70+
_heightMapMinMax( mHeightMap, zMin, zMax );
7171

7272
const Qgs3DMapSettings &map = terrain()->map3D();
73-
QgsRectangle extent = map.terrainGenerator()->terrainTilingScheme.tileToExtent( mNode->tileX(), mNode->tileY(), mNode->tileZ() ); //node->extent;
73+
QgsRectangle extent = map.terrainGenerator()->tilingScheme().tileToExtent( mNode->tileX(), mNode->tileY(), mNode->tileZ() ); //node->extent;
7474
double x0 = extent.xMinimum() - map.originX;
7575
double y0 = extent.yMinimum() - map.originY;
7676
double side = extent.width();
@@ -88,10 +88,10 @@ Qt3DCore::QEntity *QgsDemTerrainTileLoader::createEntity( Qt3DCore::QEntity *par
8888

8989
void QgsDemTerrainTileLoader::onHeightMapReady( int jobId, const QByteArray &heightMap )
9090
{
91-
if ( heightMapJobId == jobId )
91+
if ( mHeightMapJobId == jobId )
9292
{
93-
this->heightMap = heightMap;
94-
heightMapJobId = -1;
93+
this->mHeightMap = heightMap;
94+
mHeightMapJobId = -1;
9595

9696
// continue loading - texture
9797
loadTexture();
@@ -106,17 +106,17 @@ void QgsDemTerrainTileLoader::onHeightMapReady( int jobId, const QByteArray &hei
106106
#include <QFutureWatcher>
107107

108108
QgsDemHeightMapGenerator::QgsDemHeightMapGenerator( QgsRasterLayer *dtm, const QgsTilingScheme &tilingScheme, int resolution )
109-
: dtm( dtm )
110-
, clonedProvider( ( QgsRasterDataProvider * )dtm->dataProvider()->clone() )
111-
, tilingScheme( tilingScheme )
112-
, res( resolution )
113-
, lastJobId( 0 )
109+
: mDtm( dtm )
110+
, mClonedProvider( ( QgsRasterDataProvider * )dtm->dataProvider()->clone() )
111+
, mTilingScheme( tilingScheme )
112+
, mResolution( resolution )
113+
, mLastJobId( 0 )
114114
{
115115
}
116116

117117
QgsDemHeightMapGenerator::~QgsDemHeightMapGenerator()
118118
{
119-
delete clonedProvider;
119+
delete mClonedProvider;
120120
}
121121

122122
#include <QElapsedTimer>
@@ -143,44 +143,44 @@ static QByteArray _readDtmData( QgsRasterDataProvider *provider, const QgsRectan
143143

144144
int QgsDemHeightMapGenerator::render( int x, int y, int z )
145145
{
146-
Q_ASSERT( jobs.isEmpty() ); // should be always just one active job...
146+
Q_ASSERT( mJobs.isEmpty() ); // should be always just one active job...
147147

148148
// extend the rect by half-pixel on each side? to get the values in "corners"
149-
QgsRectangle extent = tilingScheme.tileToExtent( x, y, z );
150-
float mapUnitsPerPixel = extent.width() / res;
149+
QgsRectangle extent = mTilingScheme.tileToExtent( x, y, z );
150+
float mapUnitsPerPixel = extent.width() / mResolution;
151151
extent.grow( mapUnitsPerPixel / 2 );
152152
// but make sure not to go beyond the full extent (returns invalid values)
153-
QgsRectangle fullExtent = tilingScheme.tileToExtent( 0, 0, 0 );
153+
QgsRectangle fullExtent = mTilingScheme.tileToExtent( 0, 0, 0 );
154154
extent = extent.intersect( &fullExtent );
155155

156156
JobData jd;
157-
jd.jobId = ++lastJobId;
157+
jd.jobId = ++mLastJobId;
158158
jd.extent = extent;
159159
jd.timer.start();
160160
// make a clone of the data provider so it is safe to use in worker thread
161-
jd.future = QtConcurrent::run( _readDtmData, clonedProvider, extent, res );
161+
jd.future = QtConcurrent::run( _readDtmData, mClonedProvider, extent, mResolution );
162162

163163
QFutureWatcher<QByteArray> *fw = new QFutureWatcher<QByteArray>;
164164
fw->setFuture( jd.future );
165165
connect( fw, &QFutureWatcher<QByteArray>::finished, this, &QgsDemHeightMapGenerator::onFutureFinished );
166166

167-
jobs.insert( fw, jd );
168-
qDebug() << "[TT] added job: " << jd.jobId << " " << x << "|" << y << "|" << z << " .... in queue: " << jobs.count();
167+
mJobs.insert( fw, jd );
168+
qDebug() << "[TT] added job: " << jd.jobId << " " << x << "|" << y << "|" << z << " .... in queue: " << mJobs.count();
169169

170170
return jd.jobId;
171171
}
172172

173173
QByteArray QgsDemHeightMapGenerator::renderSynchronously( int x, int y, int z )
174174
{
175175
// extend the rect by half-pixel on each side? to get the values in "corners"
176-
QgsRectangle extent = tilingScheme.tileToExtent( x, y, z );
177-
float mapUnitsPerPixel = extent.width() / res;
176+
QgsRectangle extent = mTilingScheme.tileToExtent( x, y, z );
177+
float mapUnitsPerPixel = extent.width() / mResolution;
178178
extent.grow( mapUnitsPerPixel / 2 );
179179
// but make sure not to go beyond the full extent (returns invalid values)
180-
QgsRectangle fullExtent = tilingScheme.tileToExtent( 0, 0, 0 );
180+
QgsRectangle fullExtent = mTilingScheme.tileToExtent( 0, 0, 0 );
181181
extent = extent.intersect( &fullExtent );
182182

183-
QgsRasterBlock *block = dtm->dataProvider()->block( 1, extent, res, res );
183+
QgsRasterBlock *block = mDtm->dataProvider()->block( 1, extent, mResolution, mResolution );
184184

185185
QByteArray data;
186186
if ( block )
@@ -198,13 +198,13 @@ float QgsDemHeightMapGenerator::heightAt( double x, double y )
198198
{
199199
// TODO: this is quite a primitive implementation: better to use heightmaps currently in use
200200
int res = 1024;
201-
QgsRectangle rect = dtm->extent();
202-
if ( dtmCoarseData.isEmpty() )
201+
QgsRectangle rect = mDtm->extent();
202+
if ( mDtmCoarseData.isEmpty() )
203203
{
204-
QgsRasterBlock *block = dtm->dataProvider()->block( 1, rect, res, res );
204+
QgsRasterBlock *block = mDtm->dataProvider()->block( 1, rect, res, res );
205205
block->convert( Qgis::Float32 );
206-
dtmCoarseData = block->data();
207-
dtmCoarseData.detach(); // make a deep copy
206+
mDtmCoarseData = block->data();
207+
mDtmCoarseData.detach(); // make a deep copy
208208
delete block;
209209
}
210210

@@ -213,20 +213,20 @@ float QgsDemHeightMapGenerator::heightAt( double x, double y )
213213
cellX = qBound( 0, cellX, res - 1 );
214214
cellY = qBound( 0, cellY, res - 1 );
215215

216-
const float *data = ( const float * ) dtmCoarseData.constData();
216+
const float *data = ( const float * ) mDtmCoarseData.constData();
217217
return data[cellX + cellY * res];
218218
}
219219

220220
void QgsDemHeightMapGenerator::onFutureFinished()
221221
{
222222
QFutureWatcher<QByteArray> *fw = static_cast<QFutureWatcher<QByteArray>*>( sender() );
223223
Q_ASSERT( fw );
224-
Q_ASSERT( jobs.contains( fw ) );
225-
JobData jobData = jobs.value( fw );
224+
Q_ASSERT( mJobs.contains( fw ) );
225+
JobData jobData = mJobs.value( fw );
226226

227-
jobs.remove( fw );
227+
mJobs.remove( fw );
228228
fw->deleteLater();
229-
qDebug() << "[TT] finished job " << jobData.jobId << "total time " << jobData.timer.elapsed() << "ms ... in queue: " << jobs.count();
229+
qDebug() << "[TT] finished job " << jobData.jobId << "total time " << jobData.timer.elapsed() << "ms ... in queue: " << mJobs.count();
230230

231231
QByteArray data = jobData.future.result();
232232
emit heightMapReady( jobData.jobId, data );

‎src/3d/terrain/qgsdemterraintileloader_p.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class QgsDemTerrainTileLoader : public QgsTerrainTileLoader
3232
Q_OBJECT
3333
public:
3434
//! Constructs loader for the given chunk node
35-
QgsDemTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkNode *mNode );
35+
QgsDemTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkNode *node );
3636
~QgsDemTerrainTileLoader();
3737

3838
virtual Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent );
@@ -42,9 +42,9 @@ class QgsDemTerrainTileLoader : public QgsTerrainTileLoader
4242

4343
private:
4444

45-
int heightMapJobId;
46-
QByteArray heightMap;
47-
int resolution;
45+
int mHeightMapJobId;
46+
QByteArray mHeightMap;
47+
int mResolution;
4848
};
4949

5050

@@ -69,7 +69,7 @@ class QgsDemHeightMapGenerator : public QObject
6969
QByteArray renderSynchronously( int x, int y, int z );
7070

7171
//! Returns resolution(number of height values on each side of tile)
72-
int resolution() const { return res; }
72+
int resolution() const { return mResolution; }
7373

7474
//! returns height at given position (in terrain's CRS)
7575
float heightAt( double x, double y );
@@ -83,16 +83,16 @@ class QgsDemHeightMapGenerator : public QObject
8383

8484
private:
8585
//! raster used to build terrain
86-
QgsRasterLayer *dtm;
86+
QgsRasterLayer *mDtm;
8787

8888
//! cloned provider to be used in worker thread
89-
QgsRasterDataProvider *clonedProvider;
89+
QgsRasterDataProvider *mClonedProvider;
9090

91-
QgsTilingScheme tilingScheme;
91+
QgsTilingScheme mTilingScheme;
9292

93-
int res;
93+
int mResolution;
9494

95-
int lastJobId;
95+
int mLastJobId;
9696

9797
struct JobData
9898
{
@@ -103,10 +103,10 @@ class QgsDemHeightMapGenerator : public QObject
103103
QElapsedTimer timer;
104104
};
105105

106-
QHash<QFutureWatcher<QByteArray>*, JobData> jobs;
106+
QHash<QFutureWatcher<QByteArray>*, JobData> mJobs;
107107

108108
//! used for height queries
109-
QByteArray dtmCoarseData;
109+
QByteArray mDtmCoarseData;
110110
};
111111

112112
/// @endcond

‎src/3d/terrain/qgsflatterraingenerator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ QgsTerrainGenerator::Type QgsFlatTerrainGenerator::type() const
103103

104104
QgsRectangle QgsFlatTerrainGenerator::extent() const
105105
{
106-
return terrainTilingScheme.tileToExtent( 0, 0, 0 );
106+
return mTerrainTilingScheme.tileToExtent( 0, 0, 0 );
107107
}
108108

109109
void QgsFlatTerrainGenerator::rootChunkHeightRange( float &hMin, float &hMax ) const
@@ -153,11 +153,11 @@ void QgsFlatTerrainGenerator::updateTilingScheme()
153153
{
154154
if ( mExtent.isNull() )
155155
{
156-
terrainTilingScheme = QgsTilingScheme();
156+
mTerrainTilingScheme = QgsTilingScheme();
157157
}
158158
else
159159
{
160160
// the real extent will be a square where the given extent fully fits
161-
terrainTilingScheme = QgsTilingScheme( mExtent, mCrs );
161+
mTerrainTilingScheme = QgsTilingScheme( mExtent, mCrs );
162162
}
163163
}

‎src/3d/terrain/qgsflatterraingenerator.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#include "qgsrectangle.h"
99

10-
//#include "chunkloader.h"
11-
1210

1311
/** \ingroup 3d
1412
* Terrain generator that creates a simple square flat area.

‎src/3d/terrain/qgsterrainentity_p.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ QgsTerrainEntity::QgsTerrainEntity( int maxLevel, const Qgs3DMapSettings &map, Q
4141
: QgsChunkedEntity( map.terrainGenerator()->rootChunkBbox( map ),
4242
map.terrainGenerator()->rootChunkError( map ),
4343
map.maxTerrainScreenError(), maxLevel, map.terrainGenerator(), parent )
44-
, map( map )
44+
, mMap( map )
4545
, mTerrainPicker( nullptr )
4646
{
4747
map.terrainGenerator()->setTerrain( this );
@@ -77,7 +77,7 @@ QgsTerrainEntity::~QgsTerrainEntity()
7777

7878
void QgsTerrainEntity::onShowBoundingBoxesChanged()
7979
{
80-
setShowBoundingBoxes( map.showTerrainBoundingBoxes() );
80+
setShowBoundingBoxes( mMap.showTerrainBoundingBoxes() );
8181
}
8282

8383

@@ -121,7 +121,7 @@ void QgsTerrainEntity::connectToLayersRepaintRequest()
121121
disconnect( layer, &QgsMapLayer::repaintRequested, this, &QgsTerrainEntity::invalidateMapImages );
122122
}
123123

124-
mLayers = map.layers();
124+
mLayers = mMap.layers();
125125

126126
Q_FOREACH ( QgsMapLayer *layer, mLayers )
127127
{

‎src/3d/terrain/qgsterrainentity_p.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ class QgsTerrainEntity : public QgsChunkedEntity
3939
Q_OBJECT
4040
public:
4141
//! Constructs terrain entity. The argument maxLevel determines how deep the tree of tiles will be
42-
explicit QgsTerrainEntity( int mMaxLevel, const Qgs3DMapSettings &map, Qt3DCore::QNode *parent = nullptr );
42+
explicit QgsTerrainEntity( int maxLevel, const Qgs3DMapSettings &map, Qt3DCore::QNode *parent = nullptr );
4343

4444
~QgsTerrainEntity();
4545

4646
//! Returns associated 3D map settings
47-
const Qgs3DMapSettings &map3D() const { return map; }
47+
const Qgs3DMapSettings &map3D() const { return mMap; }
4848
//! Returns pointer to the generator of textures for terrain tiles
4949
QgsTerrainTextureGenerator *textureGenerator() { return mTextureGenerator; }
5050
//! Returns transform from terrain's CRS to map CRS
@@ -62,7 +62,7 @@ class QgsTerrainEntity : public QgsChunkedEntity
6262

6363
void connectToLayersRepaintRequest();
6464

65-
const Qgs3DMapSettings &map;
65+
const Qgs3DMapSettings &mMap;
6666
//! picker of terrain to know height of terrain when dragging
6767
Qt3DRender::QObjectPicker *mTerrainPicker;
6868
QgsTerrainTextureGenerator *mTextureGenerator;

‎src/3d/terrain/qgsterraingenerator.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,14 @@ class QgsTerrainGenerator : public QgsChunkLoaderFactory
7171
//! Converts terrain generator type enumeration into a string
7272
static QString typeToString( Type type );
7373

74-
//! Returns CRS of the terrain
75-
QgsCoordinateReferenceSystem crs() const { return terrainTilingScheme.crs; }
74+
//! Returns tiling scheme of the terrain
75+
const QgsTilingScheme &tilingScheme() const { return mTerrainTilingScheme; }
7676

77-
QgsTilingScheme terrainTilingScheme; //!< Tiling scheme of the terrain
77+
//! Returns CRS of the terrain
78+
QgsCoordinateReferenceSystem crs() const { return mTerrainTilingScheme.crs; }
7879

80+
protected:
81+
QgsTilingScheme mTerrainTilingScheme; //!< Tiling scheme of the terrain
7982
QgsTerrainEntity *mTerrain = nullptr;
8083
};
8184

‎src/3d/terrain/qgsterraintexturegenerator_p.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
///@cond PRIVATE
1111

1212
QgsTerrainTextureGenerator::QgsTerrainTextureGenerator( const Qgs3DMapSettings &map )
13-
: map( map )
14-
, lastJobId( 0 )
13+
: mMap( map )
14+
, mLastJobId( 0 )
1515
{
1616
}
1717

@@ -25,27 +25,27 @@ int QgsTerrainTextureGenerator::render( const QgsRectangle &extent, const QStrin
2525
job->start();
2626

2727
JobData jobData;
28-
jobData.jobId = ++lastJobId;
28+
jobData.jobId = ++mLastJobId;
2929
jobData.job = job;
3030
jobData.extent = extent;
3131
jobData.debugText = debugText;
3232

33-
jobs.insert( job, jobData );
33+
mJobs.insert( job, jobData );
3434
//qDebug() << "added job: " << jobData.jobId << " .... in queue: " << jobs.count();
3535
return jobData.jobId;
3636
}
3737

3838
void QgsTerrainTextureGenerator::cancelJob( int jobId )
3939
{
40-
Q_FOREACH ( const JobData &jd, jobs )
40+
Q_FOREACH ( const JobData &jd, mJobs )
4141
{
4242
if ( jd.jobId == jobId )
4343
{
4444
//qDebug() << "canceling job " << jobId;
4545
jd.job->cancelWithoutBlocking();
4646
disconnect( jd.job, &QgsMapRendererJob::finished, this, &QgsTerrainTextureGenerator::onRenderingFinished );
4747
jd.job->deleteLater();
48-
jobs.remove( jd.job );
48+
mJobs.remove( jd.job );
4949
return;
5050
}
5151
}
@@ -67,7 +67,7 @@ QImage QgsTerrainTextureGenerator::renderSynchronously( const QgsRectangle &exte
6767
QgsMapRendererCustomPainterJob job( mapSettings, &p );
6868
job.renderSynchronously();
6969

70-
if ( map.showTerrainTilesInfo() )
70+
if ( mMap.showTerrainTilesInfo() )
7171
{
7272
// extra tile information for debugging
7373
p.setPen( Qt::white );
@@ -85,12 +85,12 @@ void QgsTerrainTextureGenerator::onRenderingFinished()
8585
{
8686
QgsMapRendererSequentialJob *mapJob = static_cast<QgsMapRendererSequentialJob *>( sender() );
8787

88-
Q_ASSERT( jobs.contains( mapJob ) );
89-
JobData jobData = jobs.value( mapJob );
88+
Q_ASSERT( mJobs.contains( mapJob ) );
89+
JobData jobData = mJobs.value( mapJob );
9090

9191
QImage img = mapJob->renderedImage();
9292

93-
if ( map.showTerrainTilesInfo() )
93+
if ( mMap.showTerrainTilesInfo() )
9494
{
9595
// extra tile information for debugging
9696
QPainter p( &img );
@@ -101,7 +101,7 @@ void QgsTerrainTextureGenerator::onRenderingFinished()
101101
}
102102

103103
mapJob->deleteLater();
104-
jobs.remove( mapJob );
104+
mJobs.remove( mapJob );
105105

106106
//qDebug() << "finished job " << jobData.jobId << " ... in queue: " << jobs.count();
107107

@@ -112,10 +112,10 @@ void QgsTerrainTextureGenerator::onRenderingFinished()
112112
QgsMapSettings QgsTerrainTextureGenerator::baseMapSettings()
113113
{
114114
QgsMapSettings mapSettings;
115-
mapSettings.setLayers( map.layers() );
116-
mapSettings.setOutputSize( QSize( map.mapTileResolution(), map.mapTileResolution() ) );
117-
mapSettings.setDestinationCrs( map.crs );
118-
mapSettings.setBackgroundColor( map.backgroundColor() );
115+
mapSettings.setLayers( mMap.layers() );
116+
mapSettings.setOutputSize( QSize( mMap.mapTileResolution(), mMap.mapTileResolution() ) );
117+
mapSettings.setDestinationCrs( mMap.crs );
118+
mapSettings.setBackgroundColor( mMap.backgroundColor() );
119119
return mapSettings;
120120
}
121121

‎src/3d/terrain/qgsterraintexturegenerator_p.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class QgsTerrainTextureGenerator : public QObject
6060
private:
6161
QgsMapSettings baseMapSettings();
6262

63-
const Qgs3DMapSettings &map;
63+
const Qgs3DMapSettings &mMap;
6464

6565
struct JobData
6666
{
@@ -70,8 +70,8 @@ class QgsTerrainTextureGenerator : public QObject
7070
QString debugText;
7171
};
7272

73-
QHash<QgsMapRendererSequentialJob *, JobData> jobs;
74-
int lastJobId;
73+
QHash<QgsMapRendererSequentialJob *, JobData> mJobs;
74+
int mLastJobId;
7575
};
7676

7777
/// @endcond

‎src/3d/terrain/qgsterraintextureimage_p.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
class TerrainTextureImageDataGenerator : public Qt3DRender::QTextureImageDataGenerator
1010
{
1111
public:
12-
QgsRectangle extent;
13-
QString debugText;
14-
QImage img;
15-
int version;
1612

1713
static QImage placeholderImage()
1814
{
@@ -26,23 +22,29 @@ class TerrainTextureImageDataGenerator : public Qt3DRender::QTextureImageDataGen
2622
}
2723

2824
TerrainTextureImageDataGenerator( const QgsRectangle &extent, const QString &debugText, const QImage &img, int version )
29-
: extent( extent ), debugText( debugText ), img( img ), version( version ) {}
25+
: mExtent( extent ), mDebugText( debugText ), mImage( img ), mVersion( version ) {}
3026

3127
virtual Qt3DRender::QTextureImageDataPtr operator()() override
3228
{
3329
Qt3DRender::QTextureImageDataPtr dataPtr = Qt3DRender::QTextureImageDataPtr::create();
34-
dataPtr->setImage( img.isNull() ? placeholderImage() : img ); // will copy image data to the internal byte array
30+
dataPtr->setImage( mImage.isNull() ? placeholderImage() : mImage ); // will copy image data to the internal byte array
3531
return dataPtr;
3632
}
3733

3834
virtual bool operator ==( const QTextureImageDataGenerator &other ) const override
3935
{
4036
const TerrainTextureImageDataGenerator *otherFunctor = functor_cast<TerrainTextureImageDataGenerator>( &other );
41-
return otherFunctor != nullptr && otherFunctor->version == version &&
42-
extent == otherFunctor->extent;
37+
return otherFunctor != nullptr && otherFunctor->mVersion == mVersion &&
38+
mExtent == otherFunctor->mExtent;
4339
}
4440

4541
QT3D_FUNCTOR( TerrainTextureImageDataGenerator )
42+
43+
private:
44+
QgsRectangle mExtent;
45+
QString mDebugText;
46+
QImage mImage;
47+
int mVersion;
4648
};
4749

4850

@@ -52,10 +54,10 @@ class TerrainTextureImageDataGenerator : public Qt3DRender::QTextureImageDataGen
5254

5355
QgsTerrainTextureImage::QgsTerrainTextureImage( const QImage &image, const QgsRectangle &extent, const QString &debugText, Qt3DCore::QNode *parent )
5456
: Qt3DRender::QAbstractTextureImage( parent )
55-
, extent( extent )
56-
, debugText( debugText )
57-
, img( image )
58-
, version( 1 )
57+
, mExtent( extent )
58+
, mDebugText( debugText )
59+
, mImage( image )
60+
, mVersion( 1 )
5961
{
6062
}
6163

@@ -66,20 +68,20 @@ QgsTerrainTextureImage::~QgsTerrainTextureImage()
6668

6769
Qt3DRender::QTextureImageDataGeneratorPtr QgsTerrainTextureImage::dataGenerator() const
6870
{
69-
return Qt3DRender::QTextureImageDataGeneratorPtr( new TerrainTextureImageDataGenerator( extent, debugText, img, version ) );
71+
return Qt3DRender::QTextureImageDataGeneratorPtr( new TerrainTextureImageDataGenerator( mExtent, mDebugText, mImage, mVersion ) );
7072
}
7173

7274
void QgsTerrainTextureImage::invalidate()
7375
{
74-
img = QImage();
75-
version++;
76+
mImage = QImage();
77+
mVersion++;
7678
notifyDataGeneratorChanged();
7779
}
7880

7981
void QgsTerrainTextureImage::setImage( const QImage &img )
8082
{
81-
this->img = img;
82-
version++;
83+
this->mImage = img;
84+
mVersion++;
8385
notifyDataGeneratorChanged();
8486
}
8587

‎src/3d/terrain/qgsterraintextureimage_p.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ class QgsTerrainTextureImage : public Qt3DRender::QAbstractTextureImage
3838
//! Clears the current map image and emits signal that data generator has changed
3939
void invalidate();
4040
//! Stores a new map image and emits signal that data generator has changed
41-
void setImage( const QImage &img );
41+
void setImage( const QImage &image );
4242

4343
//! Returns extent of the image in map coordinates
44-
QgsRectangle imageExtent() const { return extent; }
44+
QgsRectangle imageExtent() const { return mExtent; }
4545
//! Returns debug information (normally map tile coordinates)
46-
QString imageDebugText() const { return debugText; }
46+
QString imageDebugText() const { return mDebugText; }
4747

4848
private:
49-
QgsRectangle extent;
50-
QString debugText;
51-
QImage img;
52-
int version;
53-
int jobId;
49+
QgsRectangle mExtent;
50+
QString mDebugText;
51+
QImage mImage;
52+
int mVersion;
53+
int mJobId;
5454
};
5555

5656
/// @endcond

‎src/3d/terrain/qgsterraintileloader_p.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ QgsTerrainTileLoader::QgsTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkN
4141
tz = node->tileZ();
4242
}
4343

44-
QgsRectangle extentTerrainCrs = map.terrainGenerator()->terrainTilingScheme.tileToExtent( tx, ty, tz );
44+
QgsRectangle extentTerrainCrs = map.terrainGenerator()->tilingScheme().tileToExtent( tx, ty, tz );
4545
mExtentMapCrs = terrain->terrainToMapTransform().transformBoundingBox( extentTerrainCrs );
4646
mTileDebugText = QString( "%1 | %2 | %3" ).arg( tx ).arg( ty ).arg( tz );
4747
}

0 commit comments

Comments
 (0)
Please sign in to comment.