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

@ -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;
}
// ------------------------------------------------------------------------------------------------
@ -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 )
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() )
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 ) )
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)
if( m_DataIt == m_DataItEnd ) {
return;
}
char *pStart = &(*m_DataIt);
while ( m_DataIt != m_DataItEnd && !isSeparator( *m_DataIt ) )
while( m_DataIt != m_DataItEnd && !isSeparator( *m_DataIt ) ) {
++m_DataIt;
}
std::string strObjectName(pStart, &(*m_DataIt));
if (!strObjectName.empty())
@ -678,9 +684,10 @@ void ObjFileParser::getObjectName()
}
// Allocate a new object, if current one was not found before
if ( NULL == m_pModel->m_pCurrent )
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