Skip to content

Commit

Permalink
Address some clazy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 16, 2018
1 parent ca427d3 commit 230e3b4
Show file tree
Hide file tree
Showing 77 changed files with 390 additions and 369 deletions.
6 changes: 3 additions & 3 deletions src/3d/CMakeLists.txt
Expand Up @@ -59,17 +59,20 @@ SET(QGIS_3D_MOC_HDRS
qgstessellatedpolygongeometry.h
qgswindow3dengine.h

chunks/qgschunkboundsentity_p.h
chunks/qgschunkedentity_p.h
chunks/qgschunkloader_p.h
chunks/qgschunkqueuejob_p.h

processing/qgs3dalgorithms.h

terrain/qgsdemterraintileloader_p.h
terrain/qgsflatterraingenerator.h
terrain/qgsterrainentity_p.h
terrain/qgsterraintexturegenerator_p.h
terrain/qgsterraintextureimage_p.h
terrain/qgsterraintileentity_p.h
terrain/qgsterraintileloader_p.h
)

QT5_WRAP_CPP(QGIS_3D_MOC_SRCS ${QGIS_3D_MOC_HDRS})
Expand All @@ -96,7 +99,6 @@ SET(QGIS_3D_HDRS
qgsvectorlayer3drenderer.h
qgswindow3dengine.h

chunks/qgschunkboundsentity_p.h
chunks/qgschunkedentity_p.h
chunks/qgschunklist_p.h
chunks/qgschunkloader_p.h
Expand All @@ -114,13 +116,11 @@ SET(QGIS_3D_HDRS
terrain/qgsdemterraingenerator.h
terrain/qgsdemterraintilegeometry_p.h
terrain/qgsdemterraintileloader_p.h
terrain/qgsflatterraingenerator.h
terrain/qgsterrainentity_p.h
terrain/qgsterraingenerator.h
terrain/qgsterraintexturegenerator_p.h
terrain/qgsterraintextureimage_p.h
terrain/qgsterraintileentity_p.h
terrain/qgsterraintileloader_p.h
#terrain/quantizedmeshgeometry.h
#terrain/quantizedmeshterraingenerator.h
)
Expand Down
38 changes: 1 addition & 37 deletions src/3d/chunks/qgschunkboundsentity_p.cpp
Expand Up @@ -15,37 +15,14 @@

#include "qgschunkboundsentity_p.h"

#include <Qt3DRender/QAttribute>
#include <Qt3DRender/QBuffer>
#include <Qt3DRender/QGeometry>
#include <Qt3DRender/QGeometryRenderer>
#include <Qt3DExtras/QPhongMaterial>

#include "qgsaabb.h"


///@cond PRIVATE

class LineMeshGeometry : public Qt3DRender::QGeometry
{
public:
LineMeshGeometry( Qt3DCore::QNode *parent = nullptr );

int vertexCount()
{
return mVertices.size();
}

void setVertices( QList<QVector3D> vertices );

private:
Qt3DRender::QAttribute *mPositionAttribute = nullptr;
Qt3DRender::QBuffer *mVertexBuffer = nullptr;
QList<QVector3D> mVertices;

};


LineMeshGeometry::LineMeshGeometry( Qt3DCore::QNode *parent )
: Qt3DRender::QGeometry( parent )
, mPositionAttribute( new Qt3DRender::QAttribute( this ) )
Expand All @@ -60,7 +37,7 @@ LineMeshGeometry::LineMeshGeometry( Qt3DCore::QNode *parent )
addAttribute( mPositionAttribute );
}

void LineMeshGeometry::setVertices( QList<QVector3D> vertices )
void LineMeshGeometry::setVertices( const QList<QVector3D> &vertices )
{
QByteArray vertexBufferData;
vertexBufferData.resize( vertices.size() * 3 * sizeof( float ) );
Expand All @@ -81,19 +58,6 @@ void LineMeshGeometry::setVertices( QList<QVector3D> vertices )
// ----------------


//! Geometry renderer for axis aligned bounding boxes - draws a box edges as lines
class AABBMesh : public Qt3DRender::QGeometryRenderer
{
public:
AABBMesh( Qt3DCore::QNode *parent = nullptr );

void setBoxes( const QList<QgsAABB> &bboxes );

private:
LineMeshGeometry *mLineMeshGeo = nullptr;
};


AABBMesh::AABBMesh( Qt3DCore::QNode *parent )
: Qt3DRender::QGeometryRenderer( parent )
{
Expand Down
43 changes: 43 additions & 0 deletions src/3d/chunks/qgschunkboundsentity_p.h
Expand Up @@ -28,6 +28,10 @@
//

#include <Qt3DCore/QEntity>
#include <Qt3DRender/QAttribute>
#include <Qt3DRender/QGeometry>
#include <QVector3D>
#include <Qt3DRender/QGeometryRenderer>

class QgsAABB;
class AABBMesh;
Expand All @@ -40,6 +44,8 @@ class AABBMesh;
*/
class QgsChunkBoundsEntity : public Qt3DCore::QEntity
{
Q_OBJECT

public:
//! Constructs the entity
QgsChunkBoundsEntity( Qt3DCore::QNode *parent = nullptr );
Expand All @@ -51,6 +57,43 @@ class QgsChunkBoundsEntity : public Qt3DCore::QEntity
AABBMesh *mAabbMesh = nullptr;
};


class LineMeshGeometry : public Qt3DRender::QGeometry
{
Q_OBJECT

public:
LineMeshGeometry( Qt3DCore::QNode *parent = nullptr );

int vertexCount()
{
return mVertices.size();
}

void setVertices( const QList<QVector3D> &vertices );

private:
Qt3DRender::QAttribute *mPositionAttribute = nullptr;
Qt3DRender::QBuffer *mVertexBuffer = nullptr;
QList<QVector3D> mVertices;

};


//! Geometry renderer for axis aligned bounding boxes - draws a box edges as lines
class AABBMesh : public Qt3DRender::QGeometryRenderer
{
Q_OBJECT

public:
AABBMesh( Qt3DCore::QNode *parent = nullptr );

void setBoxes( const QList<QgsAABB> &bboxes );

private:
LineMeshGeometry *mLineMeshGeo = nullptr;
};

/// @endcond

#endif // QGSCHUNKBOUNDSENTITY_P_H
2 changes: 1 addition & 1 deletion src/3d/chunks/qgschunknode_p.cpp
Expand Up @@ -54,7 +54,7 @@ QgsChunkNode::~QgsChunkNode()
delete mChildren[i];
}

bool QgsChunkNode::allChildChunksResident( const QTime &currentTime ) const
bool QgsChunkNode::allChildChunksResident( QTime currentTime ) const
{
for ( int i = 0; i < 4; ++i )
{
Expand Down
2 changes: 1 addition & 1 deletion src/3d/chunks/qgschunknode_p.h
Expand Up @@ -121,7 +121,7 @@ class QgsChunkNode
QgsChunkQueueJob *updater() const { return mUpdater; }

//! Returns true if all child chunks are available and thus this node could be swapped to the child nodes
bool allChildChunksResident( const QTime &currentTime ) const;
bool allChildChunksResident( QTime currentTime ) const;

//! make sure that all child nodes are at least skeleton nodes
void ensureAllChildrenExist();
Expand Down
4 changes: 2 additions & 2 deletions src/3d/qgs3dmapscene.cpp
Expand Up @@ -446,7 +446,7 @@ void Qgs3DMapScene::onLayerEntityPickEvent( Qt3DRender::QPickEvent *event )
// unfortunately we can't access which sub-entity triggered the pick event
// so as a temporary workaround let's just ignore the entity with selection
// and hope the event was the main entity (QTBUG-58206)
if ( geomRenderer->objectName() != "main" )
if ( geomRenderer->objectName() != QLatin1String( "main" ) )
continue;

if ( QgsTessellatedPolygonGeometry *g = qobject_cast<QgsTessellatedPolygonGeometry *>( geomRenderer->geometry() ) )
Expand Down Expand Up @@ -510,7 +510,7 @@ void Qgs3DMapScene::addLayerEntity( QgsMapLayer *layer )
// This is a bit of a hack and it should be handled in QgsMapLayer::setRenderer3D() but in qgis_core
// the vector layer 3D renderer class is not available. Maybe we need an intermediate map layer 3D renderer
// class in qgis_core that can be used to handle this case nicely.
if ( layer->type() == QgsMapLayer::VectorLayer && renderer->type() == "vector" )
if ( layer->type() == QgsMapLayer::VectorLayer && renderer->type() == QLatin1String( "vector" ) )
{
static_cast<QgsVectorLayer3DRenderer *>( renderer )->setLayer( static_cast<QgsVectorLayer *>( layer ) );
}
Expand Down

1 comment on commit 230e3b4

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 230e3b4 Oct 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nyalldawson , just to confirm, I'm able to compile QGIS all the way to this commit (the previous commit 5352629 successfully builds)

Please sign in to comment.