summaryrefslogtreecommitdiffstats
path: root/src/render/io
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2014-07-15 16:27:54 +0200
committerSean Harmer <sean.harmer@kdab.com>2014-07-19 23:19:34 +0200
commit90e3ebfec5c521acfa2f5aa756d9216a2051d477 (patch)
tree3100c7b718cc97fec7e7e198af5ada22442d1b9e /src/render/io
parent65061f869f59d579113e153a3753249477dd723e (diff)
QAbstractMeshFunctor
Each QAbstractMesh class now has to implement a QAbstractMeshFunctor class. When a mesh is set to dirty, the functor is sent through a QChangeArbiter notification to the backend. The backend, using the functor can then rebuild the mesh. There should be no issue if the frontend mesh is deleted while the backend is creating the mesh as the functor has no direct reference to the frontend element and contains all the data needed for a complete creation of the mesh. Change-Id: I4984f03a612e74c688bfb6cc2f19d9241b517457 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/io')
-rw-r--r--src/render/io/assimpparser.cpp22
-rw-r--r--src/render/io/assimpparser.h15
-rw-r--r--src/render/io/gltfparser.cpp20
-rw-r--r--src/render/io/gltfparser.h16
4 files changed, 62 insertions, 11 deletions
diff --git a/src/render/io/assimpparser.cpp b/src/render/io/assimpparser.cpp
index 48acfebcc..5b5bbf9be 100644
--- a/src/render/io/assimpparser.cpp
+++ b/src/render/io/assimpparser.cpp
@@ -793,16 +793,30 @@ AssimpParser::AssimpMesh::AssimpMesh(QNode *parent)
{
}
-bool AssimpParser::AssimpMesh::load()
+void AssimpParser::AssimpMesh::setData(MeshDataPtr data)
{
- return true;
+ m_meshData = data;
+ QAbstractMesh::setDirty(this);
}
-void AssimpParser::AssimpMesh::setData(MeshDataPtr data)
+QAbstractMeshFunctorPtr AssimpParser::AssimpMesh::meshFunctor() const
+{
+ return QAbstractMeshFunctorPtr(new AssimpMeshFunctor(m_meshData));
+}
+
+AssimpParser::AssimpMeshFunctor::AssimpMeshFunctor(MeshDataPtr meshData)
+ : QAbstractMeshFunctor()
+ , m_meshData(meshData)
{
- QAbstractMesh::setData(data.staticCast<QAbstractMeshData>());
+}
+
+QAbstractMeshDataPtr AssimpParser::AssimpMeshFunctor::operator()()
+{
+ return m_meshData;
}
} // Qt3D
QT_END_NAMESPACE
+
+
diff --git a/src/render/io/assimpparser.h b/src/render/io/assimpparser.h
index c706fd8ab..db3c55d34 100644
--- a/src/render/io/assimpparser.h
+++ b/src/render/io/assimpparser.h
@@ -90,13 +90,24 @@ public:
private :
+ class AssimpMeshFunctor : public QAbstractMeshFunctor
+ {
+ public:
+ explicit AssimpMeshFunctor(MeshDataPtr meshData);
+ QAbstractMeshDataPtr operator()() Q_DECL_OVERRIDE;
+ private:
+ MeshDataPtr m_meshData;
+ };
+
class AssimpMesh : public QAbstractMesh
{
public :
- AssimpMesh(QNode *parent = 0);
+ explicit AssimpMesh(QNode *parent = 0);
- bool load() Q_DECL_OVERRIDE;
+ QAbstractMeshFunctorPtr meshFunctor() const Q_DECL_OVERRIDE;
void setData(MeshDataPtr data);
+ private:
+ MeshDataPtr m_meshData;
};
static QStringList assimpSupportedFormats();
diff --git a/src/render/io/gltfparser.cpp b/src/render/io/gltfparser.cpp
index fa23b3ca2..431adb06c 100644
--- a/src/render/io/gltfparser.cpp
+++ b/src/render/io/gltfparser.cpp
@@ -965,14 +965,26 @@ GLTFParser::GLTFParserMesh::GLTFParserMesh(QNode *parent)
{
}
-bool GLTFParser::GLTFParserMesh::load()
+void GLTFParser::GLTFParserMesh::setData(MeshDataPtr data)
{
- return true;
+ m_meshData = data;
+ QAbstractMesh::setDirty(this);
}
-void GLTFParser::GLTFParserMesh::setData(MeshDataPtr data)
+QAbstractMeshFunctorPtr GLTFParser::GLTFParserMesh::meshFunctor() const
+{
+ return QAbstractMeshFunctorPtr(new GLTFParserMesh::GLTFParserMeshFunctor(m_meshData));
+}
+
+GLTFParser::GLTFParserMesh::GLTFParserMeshFunctor::GLTFParserMeshFunctor(MeshDataPtr meshData)
+ : QAbstractMeshFunctor()
+ , m_meshData(meshData)
+{
+}
+
+QAbstractMeshDataPtr GLTFParser::GLTFParserMesh::GLTFParserMeshFunctor::operator ()()
{
- QAbstractMesh::setData(data.staticCast<QAbstractMeshData>());
+ return m_meshData;
}
} // of namespace Qt3D
diff --git a/src/render/io/gltfparser.h b/src/render/io/gltfparser.h
index d06dc6d0b..422b746f4 100644
--- a/src/render/io/gltfparser.h
+++ b/src/render/io/gltfparser.h
@@ -100,11 +100,25 @@ private:
class GLTFParserMesh : public QAbstractMesh
{
+ private:
+ class GLTFParserMeshFunctor : public QAbstractMeshFunctor
+ {
+ public:
+ explicit GLTFParserMeshFunctor(MeshDataPtr meshData);
+ QAbstractMeshDataPtr operator ()();
+
+ private:
+ MeshDataPtr m_meshData;
+ };
+
public:
GLTFParserMesh(QNode *parent = 0);
- bool load() Q_DECL_OVERRIDE;
void setData(MeshDataPtr data);
+ QAbstractMeshFunctorPtr meshFunctor() const Q_DECL_OVERRIDE;
+
+ private:
+ MeshDataPtr m_meshData;
};
void parse();