summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-03-16 04:13:32 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-03-16 11:06:14 +0000
commit137265904638da501a175f1332ec880d77bfd214 (patch)
tree91dcac9b73bdd9c0130f28365b1b0dbee7a40312 /src
parent5dc05523555c35d3ea043ed2405dcdf9e6b62ba4 (diff)
[.*SceneParser] Minor clean-up
Change-Id: I171a3e44383f2f5160b24113de6d92725ed19fe9 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/sceneparsers/assimp/assimpparser.cpp12
-rw-r--r--src/plugins/sceneparsers/assimp/assimpparser_p.h22
-rw-r--r--src/render/io/abstractsceneparser.cpp2
-rw-r--r--src/render/io/abstractsceneparser_p.h18
-rw-r--r--src/render/io/gltfparser.cpp14
-rw-r--r--src/render/io/gltfparser_p.h18
6 files changed, 38 insertions, 48 deletions
diff --git a/src/plugins/sceneparsers/assimp/assimpparser.cpp b/src/plugins/sceneparsers/assimp/assimpparser.cpp
index 054c3ab79..5cbdc7b46 100644
--- a/src/plugins/sceneparsers/assimp/assimpparser.cpp
+++ b/src/plugins/sceneparsers/assimp/assimpparser.cpp
@@ -249,12 +249,12 @@ AssimpParser::~AssimpParser()
* Return true if the provided \a path has a suffix supported
* by the Assimp Assets importer.
*/
-bool AssimpParser::isAssimpPath(const QString& path)
+bool AssimpParser::isAssimpPath(const QString &path)
{
QFileInfo fileInfo(path);
if (!fileInfo.exists() ||
- !AssimpParser::assimpSupportedFormats().contains(fileInfo.suffix().toLower()))
+ !AssimpParser::assimpSupportedFormatsList.contains(fileInfo.suffix().toLower()))
return false;
return true;
}
@@ -290,7 +290,7 @@ void AssimpParser::setSource(const QUrl &source)
* Returns true if the extension of \a path is supported by
* the assimp parser.
*/
-bool AssimpParser::isExtensionSupported(const QUrl &source)
+bool AssimpParser::isExtensionSupported(const QUrl &source) const
{
const QString path = QUrlHelper::urlToLocalFileOrQrc(source);
return AssimpParser::isAssimpPath(path);
@@ -303,7 +303,7 @@ bool AssimpParser::isExtensionSupported(const QUrl &source)
*
* Returns Q_NULLPTR if \a id was specified but not node matching it can be found.
*/
-QEntity *AssimpParser::scene(QString id)
+QEntity *AssimpParser::scene(const QString &id)
{
// m_aiScene shouldn't be null.
// If it is either, the file failed to be imported or
@@ -328,7 +328,7 @@ QEntity *AssimpParser::scene(QString id)
* Returns a Node from the scene identified by \a id.
* Returns Q_NULLPTR if no node can be found.
*/
-QEntity *AssimpParser::node(QString id)
+QEntity *AssimpParser::node(const QString &id)
{
if (m_scene == Q_NULLPTR || m_scene->m_aiScene == Q_NULLPTR)
return Q_NULLPTR;
@@ -914,7 +914,7 @@ AssimpParser::SceneImporter::~SceneImporter()
delete m_importer;
}
-} // Qt3D
+} // namespace Qt3D
QT_END_NAMESPACE
diff --git a/src/plugins/sceneparsers/assimp/assimpparser_p.h b/src/plugins/sceneparsers/assimp/assimpparser_p.h
index 31bfb7bc1..d24472522 100644
--- a/src/plugins/sceneparsers/assimp/assimpparser_p.h
+++ b/src/plugins/sceneparsers/assimp/assimpparser_p.h
@@ -71,25 +71,19 @@ class AssimpParser : public AbstractSceneParser
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt3DRenderer.AssimParser")
+
public:
AssimpParser();
~AssimpParser();
- static bool isAssimpPath(const QString& path);
-
// SceneParserInterface interface
void setSource(const QUrl& source) Q_DECL_OVERRIDE;
- bool isExtensionSupported(const QUrl &source) Q_DECL_OVERRIDE;
- QEntity *scene(QString id = QString()) Q_DECL_OVERRIDE;
- QEntity *node(QString id) Q_DECL_OVERRIDE;
-
- QEntity *defaultScene();
- QMeshDataPtr mesh(QString id);
- QMaterial *material(QString id);
- QCamera *camera(QString id);
-
-private :
+ bool isExtensionSupported(const QUrl &source) const Q_DECL_OVERRIDE;
+ QEntity *scene(const QString &id = QString()) Q_DECL_OVERRIDE;
+ QEntity *node(const QString &id) Q_DECL_OVERRIDE;
+private:
+ static bool isAssimpPath(const QString &path);
static QStringList assimpSupportedFormats();
static QMatrix4x4 aiMatrix4x4ToQMatrix4x4(const aiMatrix4x4 &matrix);
@@ -138,11 +132,9 @@ private :
bool m_sceneParsed;
AssimpParser::SceneImporter *m_scene;
static QStringList assimpSupportedFormatsList;
-
-
};
-}
+} // namespace Qt3D
QT_END_NAMESPACE
diff --git a/src/render/io/abstractsceneparser.cpp b/src/render/io/abstractsceneparser.cpp
index a8fd7175a..3019e0b77 100644
--- a/src/render/io/abstractsceneparser.cpp
+++ b/src/render/io/abstractsceneparser.cpp
@@ -80,6 +80,6 @@ void AbstractSceneParser::logInfo(const QString &info)
qCDebug(Render::Io) << info;
}
-} // Qt3D namespace
+} // namespace Qt3D
QT_END_NAMESPACE
diff --git a/src/render/io/abstractsceneparser_p.h b/src/render/io/abstractsceneparser_p.h
index c6aef1729..83257e3b9 100644
--- a/src/render/io/abstractsceneparser_p.h
+++ b/src/render/io/abstractsceneparser_p.h
@@ -59,7 +59,6 @@ class QT3DRENDERERSHARED_EXPORT AbstractSceneParser : public QObject
Q_PROPERTY(QStringList errors READ errors NOTIFY errorsChanged)
public:
-
enum ParserStatus {
Empty,
Loading,
@@ -70,20 +69,19 @@ public:
AbstractSceneParser();
virtual ~AbstractSceneParser();
- virtual void setSource(const QUrl &source) = 0;
- virtual bool isExtensionSupported(const QUrl &source) = 0;
- virtual QEntity *scene(QString id = QString()) = 0;
- virtual QEntity *node(QString id) = 0;
+ virtual void setSource(const QUrl &source) = 0;
+ virtual bool isExtensionSupported(const QUrl &source) const = 0;
+ virtual QEntity *scene(const QString &id = QString()) = 0;
+ virtual QEntity *node(const QString &id) = 0;
ParserStatus parserStatus() const;
- QStringList errors() const;
+ QStringList errors() const;
Q_SIGNALS:
- void parserStatusChanged();
- void errorsChanged();
+ void parserStatusChanged();
+ void errorsChanged();
protected:
-
void setParserStatus(ParserStatus parserStatus);
void logError(const QString &error);
void logInfo(const QString &info);
@@ -93,7 +91,7 @@ private:
QStringList m_errors;
};
-}
+} // namespace Qt3D
QT_END_NAMESPACE
diff --git a/src/render/io/gltfparser.cpp b/src/render/io/gltfparser.cpp
index 570ceab77..d3848473e 100644
--- a/src/render/io/gltfparser.cpp
+++ b/src/render/io/gltfparser.cpp
@@ -309,13 +309,13 @@ void GLTFParser::setSource(const QUrl &source)
* Returns true if the extension of \a path is supported by the
* GLTF parser.
*/
-bool GLTFParser::isExtensionSupported(const QUrl &source)
+bool GLTFParser::isExtensionSupported(const QUrl &source) const
{
const QString path = QUrlHelper::urlToLocalFileOrQrc(source);
return GLTFParser::isGLTFPath(path);
}
-QMeshDataPtr GLTFParser::mesh(QString id)
+QMeshDataPtr GLTFParser::mesh(const QString &id)
{
parse();
if (m_meshDict.contains(id))
@@ -336,7 +336,7 @@ QEntity* GLTFParser::defaultScene()
return scene(m_defaultScene);
}
-QEntity* GLTFParser::scene(QString id)
+QEntity* GLTFParser::scene(const QString &id)
{
parse();
@@ -359,7 +359,7 @@ QEntity* GLTFParser::scene(QString id)
return sceneEntity;
}
-QEntity* GLTFParser::node(QString id)
+QEntity* GLTFParser::node(const QString &id)
{
QJsonObject nodes = m_json.object().value(KEY_NODES).toObject();
if (!nodes.contains(id)) {
@@ -460,7 +460,7 @@ QEntity* GLTFParser::node(QString id)
#undef far
#endif
-QCameraLens* GLTFParser::camera(QString id)
+QCameraLens* GLTFParser::camera(const QString &id)
{
parse();
QJsonObject cams = m_json.object().value(KEY_CAMERAS).toObject();
@@ -496,7 +496,7 @@ QCameraLens* GLTFParser::camera(QString id)
}
}
-QMaterial* GLTFParser::material(QString id)
+QMaterial* GLTFParser::material(const QString &id)
{
parse();
@@ -1048,7 +1048,7 @@ bool GLTFParserMesh::GLTFParserMeshFunctor::operator ==(const QAbstractMeshFunct
return false;
}
-} // of namespace Qt3D
+} // namespace Qt3D
QT_END_NAMESPACE
diff --git a/src/render/io/gltfparser_p.h b/src/render/io/gltfparser_p.h
index a72e03793..d18e4483e 100644
--- a/src/render/io/gltfparser_p.h
+++ b/src/render/io/gltfparser_p.h
@@ -70,28 +70,28 @@ class GLTFParser : public AbstractSceneParser
public:
GLTFParser();
- static bool isGLTFPath(const QString &path);
void setBasePath(const QString& path);
bool setJSON( QJsonDocument json );
// SceneParserInterface interface
void setSource(const QUrl &source) Q_DECL_OVERRIDE;
- bool isExtensionSupported(const QUrl &source) Q_DECL_OVERRIDE;
+ bool isExtensionSupported(const QUrl &source) const Q_DECL_OVERRIDE;
/**
* @brief instantiate Create Nodes based on glTf JSON document
* @return A new scene-graph fragment based on the provided glTf
*/
- QEntity *node(QString id) Q_DECL_OVERRIDE;
- QEntity *scene(QString id) Q_DECL_OVERRIDE;
+ QEntity *node(const QString &id) Q_DECL_OVERRIDE;
+ QEntity *scene(const QString &id = QString()) Q_DECL_OVERRIDE;
+private:
+ static bool isGLTFPath(const QString &path);
QEntity *defaultScene();
- QMeshDataPtr mesh(QString id);
- QMaterial *material(QString id);
- QCameraLens *camera(QString id);
+ QMeshDataPtr mesh(const QString &id);
+ QMaterial *material(const QString &id);
+ QCameraLens *camera(const QString &id);
-private:
void parse();
void processJSONMesh( QString id, QJsonObject jsonObj );
@@ -158,7 +158,7 @@ private:
//Render::RenderState *buildState(const QByteArray& nm, QJsonValue obj);
};
-}
+} // namespace Qt3D
QT_END_NAMESPACE