From b3b732c12b12e995110a041f5083384983b2c0b9 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 3 Jul 2014 20:33:52 +0200 Subject: [PATCH] update: some micro improvements, replace post-increment operator with pre-increment operator. Signed-off-by: Kim Kulling --- code/CalcTangentsProcess.cpp | 4 ++-- code/ObjExporter.cpp | 15 +++++++++------ code/ObjFileParser.cpp | 36 +++++++++++++++++++++--------------- code/ObjTools.h | 2 +- code/ParsingUtils.h | 1 + 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/code/CalcTangentsProcess.cpp b/code/CalcTangentsProcess.cpp index 46ab8f868..4ceca3f7a 100644 --- a/code/CalcTangentsProcess.cpp +++ b/code/CalcTangentsProcess.cpp @@ -115,9 +115,9 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) // we assume that the mesh is still in the verbose vertex format where each face has its own set // of vertices and no vertices are shared between faces. Sadly I don't know any quick test to // assert() it here. - //assert( must be verbose, dammit); + // assert( must be verbose, dammit); - if (pMesh->mTangents) // thisimplies that mBitangents is also there + if (pMesh->mTangents) // this implies that mBitangents is also there return false; // If the mesh consists of lines and/or points but not of diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index 282983965..4ed2824e5 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -75,6 +75,7 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene } // end of namespace Assimp +static const std::string MaterialExt = ".mtl"; // ------------------------------------------------------------------------------------------------ ObjExporter :: ObjExporter(const char* _filename, const aiScene* pScene) @@ -107,7 +108,7 @@ std::string ObjExporter :: GetMaterialLibName() // ------------------------------------------------------------------------------------------------ std::string ObjExporter :: GetMaterialLibFileName() { - return filename + ".mtl"; + return filename + MaterialExt; } // ------------------------------------------------------------------------------------------------ @@ -132,7 +133,7 @@ std::string ObjExporter :: GetMaterialName(unsigned int index) } // ------------------------------------------------------------------------------------------------ -void ObjExporter :: WriteMaterialFile() +void ObjExporter::WriteMaterialFile() { WriteHeader(mOutputMat); @@ -281,7 +282,7 @@ void ObjExporter::vecIndexMap::getVectors( std::vector& vecs ) } // ------------------------------------------------------------------------------------------------ -void ObjExporter :: AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat) +void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat) { meshes.push_back(MeshInstance()); MeshInstance& mesh = meshes.back(); @@ -332,7 +333,7 @@ void ObjExporter :: AddMesh(const aiString& name, const aiMesh* m, const aiMatri } // ------------------------------------------------------------------------------------------------ -void ObjExporter :: AddNode(const aiNode* nd, const aiMatrix4x4& mParent) +void ObjExporter::AddNode(const aiNode* nd, const aiMatrix4x4& mParent) { const aiMatrix4x4& mAbs = mParent * nd->mTransformation; @@ -345,5 +346,7 @@ void ObjExporter :: AddNode(const aiNode* nd, const aiMatrix4x4& mParent) } } -#endif -#endif +// ------------------------------------------------------------------------------------------------ + +#endif // ASSIMP_BUILD_NO_OBJ_EXPORTER +#endif // ASSIMP_BUILD_NO_EXPORT diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 5b8305723..f2e65db71 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -550,13 +550,15 @@ void ObjFileParser::getNewMaterial() { m_DataIt = getNextToken(m_DataIt, m_DataItEnd); m_DataIt = getNextWord(m_DataIt, m_DataItEnd); - if ( m_DataIt == m_DataItEnd ) - return; + if( m_DataIt == m_DataItEnd ) { + return; + } char *pStart = &(*m_DataIt); std::string strMat( pStart, *m_DataIt ); - while ( m_DataIt != m_DataItEnd && isSeparator( *m_DataIt ) ) - m_DataIt++; + while( m_DataIt != m_DataItEnd && isSeparator( *m_DataIt ) ) { + ++m_DataIt; + } std::map::iterator it = m_pModel->m_MaterialMap.find( strMat ); if ( it == m_pModel->m_MaterialMap.end() ) { @@ -581,8 +583,9 @@ void ObjFileParser::getNewMaterial() int ObjFileParser::getMaterialIndex( const std::string &strMaterialName ) { int mat_index = -1; - if ( strMaterialName.empty() ) - return mat_index; + if( strMaterialName.empty() ) { + return mat_index; + } for (size_t index = 0; index < m_pModel->m_MaterialLib.size(); ++index) { if ( strMaterialName == m_pModel->m_MaterialLib[ index ]) @@ -601,8 +604,9 @@ void ObjFileParser::getGroupName() std::string strGroupName; m_DataIt = getName(m_DataIt, m_DataItEnd, strGroupName); - if ( isEndOfBuffer( m_DataIt, m_DataItEnd ) ) - return; + if( isEndOfBuffer( m_DataIt, m_DataItEnd ) ) { + return; + } // Change active group, if necessary if ( m_pModel->m_strActiveGroup != strGroupName ) @@ -653,11 +657,13 @@ void ObjFileParser::getGroupNumberAndResolution() void ObjFileParser::getObjectName() { m_DataIt = getNextToken(m_DataIt, m_DataItEnd); - if (m_DataIt == m_DataItEnd) - return; + if( m_DataIt == m_DataItEnd ) { + return; + } char *pStart = &(*m_DataIt); - while ( m_DataIt != m_DataItEnd && !isSeparator( *m_DataIt ) ) - ++m_DataIt; + while( m_DataIt != m_DataItEnd && !isSeparator( *m_DataIt ) ) { + ++m_DataIt; + } std::string strObjectName(pStart, &(*m_DataIt)); if (!strObjectName.empty()) @@ -678,8 +684,9 @@ void ObjFileParser::getObjectName() } // Allocate a new object, if current one was not found before - if ( NULL == m_pModel->m_pCurrent ) - createObject(strObjectName); + if( NULL == m_pModel->m_pCurrent ) { + createObject( strObjectName ); + } } m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); } @@ -694,7 +701,6 @@ void ObjFileParser::createObject(const std::string &strObjectName) m_pModel->m_pCurrent->m_strObjName = strObjectName; m_pModel->m_Objects.push_back( m_pModel->m_pCurrent ); - createMesh(); if( m_pModel->m_pCurrentMaterial ) diff --git a/code/ObjTools.h b/code/ObjTools.h index 530588368..047c9a4cd 100644 --- a/code/ObjTools.h +++ b/code/ObjTools.h @@ -259,4 +259,4 @@ unsigned int tokenize( const string_type& str, std::vector& tokens, } // Namespace Assimp -#endif +#endif // OBJ_TOOLS_H_INC diff --git a/code/ParsingUtils.h b/code/ParsingUtils.h index 422471fc8..d0e8ba681 100644 --- a/code/ParsingUtils.h +++ b/code/ParsingUtils.h @@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_PARSING_UTILS_H_INC #include "StringComparison.h" + namespace Assimp { // NOTE: the functions below are mostly intended as replacement for