diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2016-04-29 19:35:20 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-05-01 15:43:11 +0000 |
commit | a01b14670e5b35a951ec57297613418dc829d65c (patch) | |
tree | d9bdcc4ca7b325ff5a1c2e68b801efe9e4d667b8 /src/plugins | |
parent | f9dc7c72090b9a11a3daf9e2c912213fbeec5739 (diff) |
Q_NULLPTR -> nullptr
Task-number: QTBUG-52736
Change-Id: I58f9cbcdf018e7b672d33dd865067485412b79fe
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/sceneparsers/assimp/assimphelpers.cpp | 4 | ||||
-rw-r--r-- | src/plugins/sceneparsers/assimp/assimpparser.cpp | 36 | ||||
-rw-r--r-- | src/plugins/sceneparsers/gltf/gltfparser.cpp | 92 |
3 files changed, 66 insertions, 66 deletions
diff --git a/src/plugins/sceneparsers/assimp/assimphelpers.cpp b/src/plugins/sceneparsers/assimp/assimphelpers.cpp index f07b770c0..a8d935216 100644 --- a/src/plugins/sceneparsers/assimp/assimphelpers.cpp +++ b/src/plugins/sceneparsers/assimp/assimphelpers.cpp @@ -65,7 +65,7 @@ AssimpIOStream::AssimpIOStream(QIODevice *device) : Assimp::IOStream(), m_device(device) { - Q_ASSERT(m_device != Q_NULLPTR); + Q_ASSERT(m_device != nullptr); } /*! @@ -213,7 +213,7 @@ Assimp::IOStream *AssimpIOSystem::Open(const char *pFile, const char *pMode) if (file->open(openMode)) return new AssimpIOStream(file.take()); - return Q_NULLPTR; + return nullptr; } /*! diff --git a/src/plugins/sceneparsers/assimp/assimpparser.cpp b/src/plugins/sceneparsers/assimp/assimpparser.cpp index 38a343d65..780a1e748 100644 --- a/src/plugins/sceneparsers/assimp/assimpparser.cpp +++ b/src/plugins/sceneparsers/assimp/assimpparser.cpp @@ -332,7 +332,7 @@ private: */ AssimpParser::AssimpParser() : QSceneIOHandler(), m_sceneParsed(false), - m_scene(Q_NULLPTR) + m_scene(nullptr) { } @@ -389,22 +389,22 @@ bool AssimpParser::isFileTypeSupported(const QUrl &source) const * node specified by \a id. If \a id is empty, the scene is assumed to be * the root node of the scene. * - * Returns \c Q_NULLPTR if \a id was specified but no node matching it was found. + * Returns \c nullptr if \a id was specified but no node matching it was found. */ Qt3DCore::QEntity *AssimpParser::scene(const QString &id) { // m_aiScene shouldn't be null. // If it is either, the file failed to be imported or // setFilePath was not called - if (m_scene == Q_NULLPTR || m_scene->m_aiScene == Q_NULLPTR) - return Q_NULLPTR; + if (m_scene == nullptr || m_scene->m_aiScene == nullptr) + return nullptr; aiNode *rootNode = m_scene->m_aiScene->mRootNode; // if id specified, tries to find node if (!id.isEmpty() && !(rootNode = rootNode->FindNode(id.toUtf8().constData()))) { qCDebug(AssimpParserLog) << Q_FUNC_INFO << " Couldn't find requested scene node"; - return Q_NULLPTR; + return nullptr; } // Builds the Qt3D scene using the Assimp aiScene @@ -414,12 +414,12 @@ Qt3DCore::QEntity *AssimpParser::scene(const QString &id) /*! * Returns a Node from the scene identified by \a id. - * Returns \c Q_NULLPTR if the node was not found. + * Returns \c nullptr if the node was not found. */ Qt3DCore::QEntity *AssimpParser::node(const QString &id) { - if (m_scene == Q_NULLPTR || m_scene->m_aiScene == Q_NULLPTR) - return Q_NULLPTR; + if (m_scene == nullptr || m_scene->m_aiScene == nullptr) + return nullptr; parse(); aiNode *n = m_scene->m_aiScene->mRootNode->FindNode(id.toUtf8().constData()); return node(n); @@ -430,8 +430,8 @@ Qt3DCore::QEntity *AssimpParser::node(const QString &id) */ Qt3DCore::QEntity *AssimpParser::node(aiNode *node) { - if (node == Q_NULLPTR) - return Q_NULLPTR; + if (node == nullptr) + return nullptr; QEntity *entityNode = QAbstractNodeFactory::createNode<Qt3DCore::QEntity>("QEntity"); entityNode->setObjectName(aiStringToQString(node->mName)); @@ -453,7 +453,7 @@ Qt3DCore::QEntity *AssimpParser::node(aiNode *node) // it conflicts with the variable node QEntity *child = this->node(node->mChildren[i]); // Are we sure each child are unique ??? - if (child != Q_NULLPTR) + if (child != nullptr) child->setParent(entityNode); } @@ -496,7 +496,7 @@ void AssimpParser::readSceneFile(const QString &path) aiProcess_JoinIdenticalVertices| aiProcess_GenSmoothNormals| aiProcess_FlipUVs); - if (m_scene->m_aiScene == Q_NULLPTR) { + if (m_scene->m_aiScene == nullptr) { qCWarning(AssimpParserLog) << "Assimp scene import failed"; return ; } @@ -510,7 +510,7 @@ void AssimpParser::cleanup() { m_sceneParsed = false; delete m_scene; - m_scene = Q_NULLPTR; + m_scene = nullptr; } /*! @@ -591,8 +591,8 @@ void AssimpParser::loadMesh(uint meshIndex) bool hasTangent = mesh->HasTangentsAndBitangents(); bool hasTexture = mesh->HasTextureCoords(0); bool hasColor = (colors != NULL); // NULL defined by Assimp - aiVector3D *tangents = hasTangent ? mesh->mTangents : Q_NULLPTR; - aiVector3D *textureCoord = hasTexture ? mesh->mTextureCoords[0] : Q_NULLPTR; + aiVector3D *tangents = hasTangent ? mesh->mTangents : nullptr; + aiVector3D *textureCoord = hasTexture ? mesh->mTextureCoords[0] : nullptr; // Add values in raw float array ushort chunkSize = 6 + (hasTangent ? 3 : 0) + (hasTexture ? 2 : 0) + (hasColor ? 4 : 0); @@ -762,7 +762,7 @@ void AssimpParser::loadCamera(uint cameraIndex) aiNode *cameraNode = m_scene->m_aiScene->mRootNode->FindNode(assimpCamera->mName); // If no node is associated to the camera in the scene, camera not saved - if (cameraNode == Q_NULLPTR) + if (cameraNode == nullptr) return ; QEntity *camera = QAbstractNodeFactory::createNode<Qt3DCore::QEntity>("QEntity"); @@ -958,12 +958,12 @@ QTexImageDataPtr AssimpRawTextureImage::AssimpRawTextureImageFunctor::operator() bool AssimpRawTextureImage::AssimpRawTextureImageFunctor::operator ==(const QTextureImageDataGenerator &other) const { const AssimpRawTextureImageFunctor *otherFunctor = functor_cast<AssimpRawTextureImageFunctor>(&other); - return (otherFunctor != Q_NULLPTR && otherFunctor->m_data == m_data); + return (otherFunctor != nullptr && otherFunctor->m_data == m_data); } AssimpParser::SceneImporter::SceneImporter() : m_importer(new Assimp::Importer()) - , m_aiScene(Q_NULLPTR) + , m_aiScene(nullptr) { // The Assimp::Importer manages the lifetime of the aiScene object } diff --git a/src/plugins/sceneparsers/gltf/gltfparser.cpp b/src/plugins/sceneparsers/gltf/gltfparser.cpp index b1a5ffb00..a246930bb 100644 --- a/src/plugins/sceneparsers/gltf/gltfparser.cpp +++ b/src/plugins/sceneparsers/gltf/gltfparser.cpp @@ -239,7 +239,7 @@ Qt3DCore::QEntity* GLTFParser::node(const QString &id) } QJsonObject jsonObj = nodes.value(id).toObject(); - QEntity* result = Q_NULLPTR; + QEntity* result = nullptr; // Qt3D has a limitation that a QEntity can only have 1 mesh and 1 material component // So if the node has only 1 mesh, we only create 1 QEntity @@ -275,7 +275,7 @@ Qt3DCore::QEntity* GLTFParser::node(const QString &id) } //If the entity contains no meshes, results will still be null here - if (result == Q_NULLPTR) + if (result == nullptr) result = new QEntity; if ( jsonObj.contains(KEY_CHILDREN) ) { @@ -291,7 +291,7 @@ Qt3DCore::QEntity* GLTFParser::node(const QString &id) // Node Transforms - Qt3DCore::QTransform *trans = Q_NULLPTR; + Qt3DCore::QTransform *trans = nullptr; if ( jsonObj.contains(KEY_MATRIX) ) { QMatrix4x4 m(Qt::Uninitialized); @@ -302,14 +302,14 @@ Qt3DCore::QEntity* GLTFParser::node(const QString &id) } // ADD MATRIX TRANSFORM COMPONENT TO ENTITY - if (trans == Q_NULLPTR) + if (trans == nullptr) trans = new Qt3DCore::QTransform; trans->setMatrix(m); } // Rotation quaternion if (jsonObj.contains(KEY_ROTATION)) { - if (trans == Q_NULLPTR) + if (trans == nullptr) trans = new Qt3DCore::QTransform; QJsonArray quaternionValues = jsonObj.value(KEY_ROTATION).toArray(); @@ -322,7 +322,7 @@ Qt3DCore::QEntity* GLTFParser::node(const QString &id) // Translation if (jsonObj.contains(KEY_TRANSLATION)) { - if (trans == Q_NULLPTR) + if (trans == nullptr) trans = new Qt3DCore::QTransform; QJsonArray translationValues = jsonObj.value(KEY_TRANSLATION).toArray(); @@ -333,7 +333,7 @@ Qt3DCore::QEntity* GLTFParser::node(const QString &id) // Scale if (jsonObj.contains(KEY_SCALE)) { - if (trans == Q_NULLPTR) + if (trans == nullptr) trans = new Qt3DCore::QTransform; QJsonArray scaleValues = jsonObj.value(KEY_SCALE).toArray(); @@ -343,7 +343,7 @@ Qt3DCore::QEntity* GLTFParser::node(const QString &id) } // Add the Transform component - if (trans != Q_NULLPTR) + if (trans != nullptr) result->addComponent(trans); if ( jsonObj.contains(KEY_CAMERA) ) { @@ -385,7 +385,7 @@ Qt3DCore::QEntity* GLTFParser::scene(const QString &id) GLTFParser::BufferData::BufferData() : length(0) - , data(Q_NULLPTR) + , data(nullptr) { } @@ -393,7 +393,7 @@ GLTFParser::BufferData::BufferData(QJsonObject json) { path = json.value(KEY_URI).toString(); length = json.value(KEY_BYTE_LENGTH).toInt(); - data = Q_NULLPTR; + data = nullptr; } GLTFParser::ParameterData::ParameterData() : @@ -513,7 +513,7 @@ QParameter *GLTFParser::parameterFromTechnique(QTechnique *technique, const QStr } } - return Q_NULLPTR; + return nullptr; } Qt3DCore::QEntity* GLTFParser::defaultScene() @@ -543,8 +543,8 @@ QMaterial *GLTFParser::materialWithCustomShader(const QString &id, const QJsonOb //Optional Core technique - QTechnique *coreTechnique = Q_NULLPTR; - QTechnique *gl2Technique = Q_NULLPTR; + QTechnique *coreTechnique = nullptr; + QTechnique *gl2Technique = nullptr; QString coreTechniqueName = jsonObj.value(KEY_TECHNIQUE_CORE).toString(); if (!coreTechniqueName.isNull()) { if (!m_techniques.contains(coreTechniqueName)) { @@ -582,9 +582,9 @@ QMaterial *GLTFParser::materialWithCustomShader(const QString &id, const QJsonOb QEffect* effect = new QEffect; effect->setObjectName(techniqueName); effect->addTechnique(technique); - if (coreTechnique != Q_NULLPTR) + if (coreTechnique != nullptr) effect->addTechnique(coreTechnique); - if (gl2Technique != Q_NULLPTR) + if (gl2Technique != nullptr) effect->addTechnique(gl2Technique); QMaterial* mat = new QMaterial; @@ -596,15 +596,15 @@ QMaterial *GLTFParser::materialWithCustomShader(const QString &id, const QJsonOb Q_FOREACH (QString vName, values.keys()) { QParameter *param = parameterFromTechnique(technique, vName); - if (param == Q_NULLPTR && coreTechnique != Q_NULLPTR) { + if (param == nullptr && coreTechnique != nullptr) { param = parameterFromTechnique(coreTechnique, vName); } - if (param == Q_NULLPTR && gl2Technique != Q_NULLPTR) { + if (param == nullptr && gl2Technique != nullptr) { param = parameterFromTechnique(gl2Technique, vName); } - if (param == Q_NULLPTR) { + if (param == nullptr) { qCWarning(GLTFParserLog) << "unknown parameter:" << vName << "in technique" << techniqueName << "processing material" << id; continue; @@ -666,7 +666,7 @@ QMaterial *GLTFParser::commonMaterial(const QJsonObject &jsonObj) params[propertyName] = var; } - QMaterial *mat = Q_NULLPTR; + QMaterial *mat = nullptr; if (hasNormalMap) { if (hasSpecularMap) { mat = new QNormalDiffuseSpecularMapMaterial; @@ -712,7 +712,7 @@ QMaterial* GLTFParser::material(const QString &id) QJsonObject jsonObj = mats.value(id).toObject(); - QMaterial *mat = Q_NULLPTR; + QMaterial *mat = nullptr; // Prefer common materials over custom shaders. if (jsonObj.contains(KEY_EXTENSIONS)) { @@ -733,7 +733,7 @@ QCameraLens* GLTFParser::camera(const QString &id) const QJsonObject cams = m_json.object().value(KEY_CAMERAS).toObject(); if (!cams.contains(id)) { qCWarning(GLTFParserLog) << "unknown camera" << id << "in GLTF file" << m_basePath; - return Q_NULLPTR; + return nullptr; } QJsonObject jsonObj = cams.value(id).toObject(); @@ -742,7 +742,7 @@ QCameraLens* GLTFParser::camera(const QString &id) const if (camTy == QStringLiteral("perspective")) { if (!jsonObj.contains(KEY_PERSPECTIVE)) { qCWarning(GLTFParserLog) << "camera:" << id << "missing 'perspective' object"; - return Q_NULLPTR; + return nullptr; } QJsonObject pObj = jsonObj.value(KEY_PERSPECTIVE).toObject(); @@ -757,10 +757,10 @@ QCameraLens* GLTFParser::camera(const QString &id) const } else if (camTy == QStringLiteral("orthographic")) { qCWarning(GLTFParserLog) << Q_FUNC_INFO << "implement me"; - return Q_NULLPTR; + return nullptr; } else { qCWarning(GLTFParserLog) << "camera:" << id << "has unsupported type:" << camTy; - return Q_NULLPTR; + return nullptr; } } @@ -828,7 +828,7 @@ void GLTFParser::cleanup() m_accessorDict.clear(); //Check for Materials with no parent Q_FOREACH (QMaterial *material, m_materialCache.values()) { - if (material->parent() == Q_NULLPTR) + if (material->parent() == nullptr) delete material; } m_materialCache.clear(); @@ -837,19 +837,19 @@ void GLTFParser::cleanup() m_shaderPaths.clear(); //Check for ShaderPrograms with no parent Q_FOREACH (QShaderProgram *program, m_programs.values()) { - if (program->parent() == Q_NULLPTR) + if (program->parent() == nullptr) delete program; } m_programs.clear(); //Check for Techniques with no parent Q_FOREACH (QTechnique *technique, m_techniques.values()) { - if (technique->parent() == Q_NULLPTR) + if (technique->parent() == nullptr) delete technique; } m_techniques.clear(); //Check for Textures with no parent Q_FOREACH (QAbstractTexture *texture, m_textures.values()) { - if (texture->parent() == Q_NULLPTR) + if (texture->parent() == nullptr) delete texture; } m_textures.clear(); @@ -977,9 +977,9 @@ void GLTFParser::processJSONTechnique(const QString &id, const QJsonObject &json QJsonObject attrs = jsonObject.value(KEY_ATTRIBUTES).toObject(); Q_FOREACH ( QString shaderAttributeName, attrs.keys() ) { QString pname = attrs.value(shaderAttributeName).toString(); - QParameter *parameter = paramDict.value(pname, Q_NULLPTR); + QParameter *parameter = paramDict.value(pname, nullptr); QString attributeName = pname; - if (parameter == Q_NULLPTR) { + if (parameter == nullptr) { qCWarning(GLTFParserLog) << Q_FUNC_INFO << "attribute " << pname << "defined in instanceProgram but not as parameter"; continue; @@ -999,8 +999,8 @@ void GLTFParser::processJSONTechnique(const QString &id, const QJsonObject &json QJsonObject uniforms = jsonObject.value(KEY_UNIFORMS).toObject(); Q_FOREACH (QString shaderUniformName, uniforms.keys()) { QString pname = uniforms.value(shaderUniformName).toString(); - QParameter *parameter = paramDict.value(pname, Q_NULLPTR); - if (parameter == Q_NULLPTR) { + QParameter *parameter = paramDict.value(pname, nullptr); + if (parameter == nullptr) { qCWarning(GLTFParserLog) << Q_FUNC_INFO << "uniform " << pname << "defined in instanceProgram but not as parameter"; continue; @@ -1031,7 +1031,7 @@ void GLTFParser::processJSONTechnique(const QString &id, const QJsonObject &json Q_FOREACH (QString functionName, functions.keys()) { int enableStateType = 0; QRenderState *renderState = buildState(functionName, functions.value(functionName), enableStateType); - if (renderState != Q_NULLPTR) { + if (renderState != nullptr) { //Remove the need to set a default state values for enableStateType enableStates.removeOne(enableStateType); pass->addRenderState(renderState); @@ -1041,7 +1041,7 @@ void GLTFParser::processJSONTechnique(const QString &id, const QJsonObject &json //Create render states with default values for any remaining enable states Q_FOREACH (int enableState, enableStates) { QRenderState *renderState = buildStateEnable(enableState); - if (renderState != Q_NULLPTR) + if (renderState != nullptr) pass->addRenderState(renderState); } @@ -1092,8 +1092,8 @@ void GLTFParser::processJSONMesh(const QString &id, const QJsonObject &json) attributeName = attrName; //Get buffer handle for accessor - Qt3DRender::QBuffer *buffer = m_buffers.value(m_accessorDict[k].bufferViewName, Q_NULLPTR); - if (buffer == Q_NULLPTR) { + Qt3DRender::QBuffer *buffer = m_buffers.value(m_accessorDict[k].bufferViewName, nullptr); + if (buffer == nullptr) { qCWarning(GLTFParserLog) << "unknown buffer-view:" << m_accessorDict[k].bufferViewName << "processing accessor:" << id; continue; } @@ -1115,8 +1115,8 @@ void GLTFParser::processJSONMesh(const QString &id, const QJsonObject &json) qCWarning(GLTFParserLog) << "unknown index accessor:" << k << "on mesh" << id; } else { //Get buffer handle for accessor - Qt3DRender::QBuffer *buffer = m_buffers.value(m_accessorDict[k].bufferViewName, Q_NULLPTR); - if (buffer == Q_NULLPTR) { + Qt3DRender::QBuffer *buffer = m_buffers.value(m_accessorDict[k].bufferViewName, nullptr); + if (buffer == nullptr) { qCWarning(GLTFParserLog) << "unknown buffer-view:" << m_accessorDict[k].bufferViewName << "processing accessor:" << id; continue; } @@ -1203,7 +1203,7 @@ void GLTFParser::processJSONTexture(const QString &id, const QJsonObject &jsonOb void GLTFParser::loadBufferData() { Q_FOREACH (QString bufferName, m_bufferDatas.keys()) { - if (m_bufferDatas[bufferName].data == Q_NULLPTR) { + if (m_bufferDatas[bufferName].data == nullptr) { QFile* bufferFile = resolveLocalData(m_bufferDatas[bufferName].path); QByteArray *data = new QByteArray(bufferFile->readAll()); m_bufferDatas[bufferName].data = data; @@ -1431,7 +1431,7 @@ QRenderState *GLTFParser::buildStateEnable(int state) if (state == GL_BLEND) { //It doesn't make sense to handle this state alone - return Q_NULLPTR; + return nullptr; } if (state == GL_CULL_FACE) { @@ -1456,7 +1456,7 @@ QRenderState *GLTFParser::buildStateEnable(int state) qCWarning(GLTFParserLog) << Q_FUNC_INFO << "unsupported render state:" << state; - return Q_NULLPTR; + return nullptr; } QRenderState* GLTFParser::buildState(const QString& functionName, const QJsonValue &value, int &type) @@ -1468,7 +1468,7 @@ QRenderState* GLTFParser::buildState(const QString& functionName, const QJsonVal type = GL_BLEND; //TODO: support render state blendColor qCWarning(GLTFParserLog) << Q_FUNC_INFO << "unsupported render state:" << functionName; - return Q_NULLPTR; + return nullptr; } if (functionName == QStringLiteral("blendEquationSeparate")) { @@ -1517,13 +1517,13 @@ QRenderState* GLTFParser::buildState(const QString& functionName, const QJsonVal QNoDepthMask *depthMask = new QNoDepthMask; return depthMask; } - return Q_NULLPTR; + return nullptr; } if (functionName == QStringLiteral("depthRange")) { //TODO: support render state depthRange qCWarning(GLTFParserLog) << Q_FUNC_INFO << "unsupported render state:" << functionName; - return Q_NULLPTR; + return nullptr; } if (functionName == QStringLiteral("frontFace")) { @@ -1535,7 +1535,7 @@ QRenderState* GLTFParser::buildState(const QString& functionName, const QJsonVal if (functionName == QStringLiteral("lineWidth")) { //TODO: support render state lineWidth qCWarning(GLTFParserLog) << Q_FUNC_INFO << "unsupported render state:" << functionName; - return Q_NULLPTR; + return nullptr; } if (functionName == QStringLiteral("polygonOffset")) { @@ -1557,7 +1557,7 @@ QRenderState* GLTFParser::buildState(const QString& functionName, const QJsonVal } qCWarning(GLTFParserLog) << Q_FUNC_INFO << "unsupported render state:" << functionName; - return Q_NULLPTR; + return nullptr; } } // namespace Qt3DRender |