From 90e3ebfec5c521acfa2f5aa756d9216a2051d477 Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Tue, 15 Jul 2014 16:27:54 +0200 Subject: 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 --- src/render/io/gltfparser.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/render/io/gltfparser.cpp') 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()); + return m_meshData; } } // of namespace Qt3D -- cgit v1.2.3