summaryrefslogtreecommitdiffstats
path: root/src/render/io/gltfparser.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2014-07-28 14:27:00 +0200
committerSean Harmer <sean.harmer@kdab.com>2014-08-13 20:19:21 +0200
commitac2a027203db16364e2d4fe74559a5ec765354a2 (patch)
tree70b6f329603f965f3c78fdcf948525da9d8edd7c /src/render/io/gltfparser.cpp
parent2557e52a14a737db537798e1528b1ca2b0af9d47 (diff)
GLTFParserMesh implements doClone and copy methods
Change-Id: Id79399535aae8b8e0f14e9edf40e05375803a64f Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/io/gltfparser.cpp')
-rw-r--r--src/render/io/gltfparser.cpp54
1 files changed, 48 insertions, 6 deletions
diff --git a/src/render/io/gltfparser.cpp b/src/render/io/gltfparser.cpp
index 431adb06c..4464ef335 100644
--- a/src/render/io/gltfparser.cpp
+++ b/src/render/io/gltfparser.cpp
@@ -202,6 +202,32 @@ QParameter::OpenGLTypes parseType(const QByteArray &s)
} // of anonymous namespace
+class GLTFParserMesh : public QAbstractMesh
+{
+ Q_OBJECT
+private:
+ class GLTFParserMeshFunctor : public QAbstractMeshFunctor
+ {
+ public:
+ explicit GLTFParserMeshFunctor(MeshDataPtr meshData);
+ QAbstractMeshDataPtr operator ()() Q_DECL_OVERRIDE;
+
+ private:
+ MeshDataPtr m_meshData;
+ };
+
+public:
+ explicit GLTFParserMesh(QNode *parent = 0);
+
+ void copy(const QNode *ref) Q_DECL_OVERRIDE;
+ void setData(MeshDataPtr data);
+ QAbstractMeshFunctorPtr meshFunctor() const Q_DECL_OVERRIDE;
+
+private:
+ MeshDataPtr m_meshData;
+ GLTFParserMesh *doClone(QNode *clonedParent) const Q_DECL_OVERRIDE;
+};
+
GLTFParser::GLTFParser() : AbstractSceneParser(),
m_parseDone(false)
{
@@ -960,29 +986,43 @@ QVariant GLTFParser::parameterValueFromJSON(QParameter* p, QJsonValue val)
return QVariant();
}
-GLTFParser::GLTFParserMesh::GLTFParserMesh(QNode *parent)
+GLTFParserMesh::GLTFParserMesh(QNode *parent)
: QAbstractMesh(parent)
{
}
-void GLTFParser::GLTFParserMesh::setData(MeshDataPtr data)
+void GLTFParserMesh::copy(const QNode *ref)
+{
+ QAbstractMesh::copy(ref);
+ const GLTFParserMesh *gltfMesh = qobject_cast<const GLTFParserMesh *>(ref);
+ if (gltfMesh != Q_NULLPTR) {
+ m_meshData = gltfMesh->m_meshData;
+ }
+}
+
+void GLTFParserMesh::setData(MeshDataPtr data)
{
m_meshData = data;
QAbstractMesh::setDirty(this);
}
-QAbstractMeshFunctorPtr GLTFParser::GLTFParserMesh::meshFunctor() const
+QAbstractMeshFunctorPtr GLTFParserMesh::meshFunctor() const
{
- return QAbstractMeshFunctorPtr(new GLTFParserMesh::GLTFParserMeshFunctor(m_meshData));
+ return QAbstractMeshFunctorPtr(new GLTFParserMeshFunctor(m_meshData));
}
-GLTFParser::GLTFParserMesh::GLTFParserMeshFunctor::GLTFParserMeshFunctor(MeshDataPtr meshData)
+GLTFParserMesh *GLTFParserMesh::doClone(QNode *clonedParent) const
+{
+ return new GLTFParserMesh(clonedParent);
+}
+
+GLTFParserMesh::GLTFParserMeshFunctor::GLTFParserMeshFunctor(MeshDataPtr meshData)
: QAbstractMeshFunctor()
, m_meshData(meshData)
{
}
-QAbstractMeshDataPtr GLTFParser::GLTFParserMesh::GLTFParserMeshFunctor::operator ()()
+QAbstractMeshDataPtr GLTFParserMesh::GLTFParserMeshFunctor::operator ()()
{
return m_meshData;
}
@@ -990,3 +1030,5 @@ QAbstractMeshDataPtr GLTFParser::GLTFParserMesh::GLTFParserMeshFunctor::operator
} // of namespace Qt3D
QT_END_NAMESPACE
+
+#include "gltfparser.moc"