summaryrefslogtreecommitdiffstats
path: root/src/render/io/gltfparser.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-07-20 09:10:08 +0200
committerSean Harmer <sean.harmer@kdab.com>2015-07-28 09:49:19 +0000
commit90623e3ccbeba4f498b3ce5c1b6c88f1122df434 (patch)
tree2e7a5b59b3d6830d0f0d70f1c1cec5cb6f355a9e /src/render/io/gltfparser.cpp
parent3fe37f854dcaa2d92e8936ccddd07800fb4d04d3 (diff)
Functors: remove dynamic_cast
Introduce a QAbstractFunctor class which QAbstractMeshFunctor and QTextureDataFunctor subclass Make all QAbstractFunctor subclasses implement an id() function (using QT3D_FUNCTOR(Class)). Use this id to compare to other QAbstractMeshFunctor and eventually static_cast into right type if possible using the functor_cast member function. Change-Id: Iface956e6cd818cbef204d8fa7bf2bc23c6ffa3f Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/io/gltfparser.cpp')
-rw-r--r--src/render/io/gltfparser.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/render/io/gltfparser.cpp b/src/render/io/gltfparser.cpp
index 745180e56..0cff55016 100644
--- a/src/render/io/gltfparser.cpp
+++ b/src/render/io/gltfparser.cpp
@@ -41,7 +41,7 @@
#include <Qt3DRenderer/private/renderlogging_p.h>
#include <Qt3DCore/qentity.h>
-#include <qmesh.h>
+#include <qabstractmesh.h>
#include <qmaterial.h>
#include <qtechnique.h>
#include <qshaderprogram.h>
@@ -203,29 +203,28 @@ const QString KEY_INTERNAL_FORMAT = QStringLiteral("internalFormat");
class GLTFParserMeshPrivate;
-class GLTFParserMesh : public QAbstractMesh
+class GLTFParserMeshFunctor : public QAbstractMeshFunctor
{
- Q_OBJECT
+public:
+ explicit GLTFParserMeshFunctor(QMeshDataPtr meshData = QMeshDataPtr());
+ QMeshDataPtr operator ()() Q_DECL_OVERRIDE;
+ bool operator ==(const QAbstractMeshFunctor &other) const Q_DECL_OVERRIDE;
+ QT3D_FUNCTOR(GLTFParserMeshFunctor)
private:
- class GLTFParserMeshFunctor : public QAbstractMeshFunctor
- {
- public:
- explicit GLTFParserMeshFunctor(QMeshDataPtr meshData);
- QMeshDataPtr operator ()() Q_DECL_OVERRIDE;
- bool operator ==(const QAbstractMeshFunctor &other) const Q_DECL_OVERRIDE;
-
- private:
- QMeshDataPtr m_meshData;
- };
+ QMeshDataPtr m_meshData;
+};
+class GLTFParserMesh : public QAbstractMesh
+{
+ Q_OBJECT
public:
explicit GLTFParserMesh(QNode *parent = 0);
void setData(QMeshDataPtr data);
- QAbstractMeshFunctorPtr meshFunctor() const Q_DECL_OVERRIDE;
+ QAbstractMeshFunctorPtr meshFunctor() const Q_DECL_FINAL;
protected:
- void copy(const QNode *ref) Q_DECL_OVERRIDE;
+ void copy(const QNode *ref) Q_DECL_FINAL;
private:
QT3D_CLONEABLE(GLTFParserMesh)
@@ -1030,18 +1029,18 @@ QAbstractMeshFunctorPtr GLTFParserMesh::meshFunctor() const
return QAbstractMeshFunctorPtr(new GLTFParserMeshFunctor(d->m_meshData));
}
-GLTFParserMesh::GLTFParserMeshFunctor::GLTFParserMeshFunctor(QMeshDataPtr meshData)
+GLTFParserMeshFunctor::GLTFParserMeshFunctor(QMeshDataPtr meshData)
: QAbstractMeshFunctor()
, m_meshData(meshData)
{
}
-QMeshDataPtr GLTFParserMesh::GLTFParserMeshFunctor::operator ()()
+QMeshDataPtr GLTFParserMeshFunctor::operator ()()
{
return m_meshData;
}
-bool GLTFParserMesh::GLTFParserMeshFunctor::operator ==(const QAbstractMeshFunctor &) const
+bool GLTFParserMeshFunctor::operator ==(const QAbstractMeshFunctor &) const
{
return false;
}
@@ -1050,4 +1049,6 @@ bool GLTFParserMesh::GLTFParserMeshFunctor::operator ==(const QAbstractMeshFunct
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(Qt3D::GLTFParserMeshFunctor)
+
#include "gltfparser.moc"