update: some micro improvements, replace post-increment operator with pre-increment operator.

Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>
pull/309/head
Kim Kulling 2014-07-03 20:33:52 +02:00
parent 0856ff9659
commit b3b732c12b
5 changed files with 34 additions and 24 deletions

View File

@ -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

View File

@ -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<aiVector3D>& 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

View File

@ -550,13 +550,15 @@ void ObjFileParser::getNewMaterial()
{
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
m_DataIt = getNextWord<DataArrayIt>(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<std::string, ObjFile::Material*>::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<DataArrayIt>(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<DataArrayIt>(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<DataArrayIt>( 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 )

View File

@ -259,4 +259,4 @@ unsigned int tokenize( const string_type& str, std::vector<string_type>& tokens,
} // Namespace Assimp
#endif
#endif // OBJ_TOOLS_H_INC

View File

@ -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