Skip to content

Commit 97b46d9

Browse files
committed
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

0 commit comments

Comments
 (0)