|
@@ -182,7 +182,7 @@ void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
|
|
|
|
|
|
getNameNoSpace(m_DataIt, m_DataItEnd, name);
|
|
getNameNoSpace(m_DataIt, m_DataItEnd, name);
|
|
|
|
|
|
- size_t nextSpace = name.find(" ");
|
|
|
|
|
|
+ size_t nextSpace = name.find(' ');
|
|
if (nextSpace != std::string::npos)
|
|
if (nextSpace != std::string::npos)
|
|
name = name.substr(0, nextSpace);
|
|
name = name.substr(0, nextSpace);
|
|
|
|
|
|
@@ -199,7 +199,7 @@ void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
|
|
|
|
|
|
getNameNoSpace(m_DataIt, m_DataItEnd, name);
|
|
getNameNoSpace(m_DataIt, m_DataItEnd, name);
|
|
|
|
|
|
- size_t nextSpace = name.find(" ");
|
|
|
|
|
|
+ size_t nextSpace = name.find(' ');
|
|
if (nextSpace != std::string::npos)
|
|
if (nextSpace != std::string::npos)
|
|
name = name.substr(0, nextSpace);
|
|
name = name.substr(0, nextSpace);
|
|
|
|
|
|
@@ -274,13 +274,8 @@ static bool isDataDefinitionEnd( const char *tmp ) {
|
|
|
|
|
|
static bool isNanOrInf(const char * in) {
|
|
static bool isNanOrInf(const char * in) {
|
|
// Look for "nan" or "inf", case insensitive
|
|
// Look for "nan" or "inf", case insensitive
|
|
- if ((in[0] == 'N' || in[0] == 'n') && ASSIMP_strincmp(in, "nan", 3) == 0) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- else if ((in[0] == 'I' || in[0] == 'i') && ASSIMP_strincmp(in, "inf", 3) == 0) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
|
|
+ return ((in[0] == 'N' || in[0] == 'n') && ASSIMP_strincmp(in, "nan", 3) == 0) ||
|
|
|
|
+ ((in[0] == 'I' || in[0] == 'i') && ASSIMP_strincmp(in, "inf", 3) == 0);
|
|
}
|
|
}
|
|
|
|
|
|
size_t ObjFileParser::getNumComponentsInDataDefinition() {
|
|
size_t ObjFileParser::getNumComponentsInDataDefinition() {
|
|
@@ -341,7 +336,7 @@ size_t ObjFileParser::getTexCoordVector( std::vector<aiVector3D> &point3d_array
|
|
if (!std::isfinite(z))
|
|
if (!std::isfinite(z))
|
|
z = 0;
|
|
z = 0;
|
|
|
|
|
|
- point3d_array.push_back( aiVector3D( x, y, z ) );
|
|
|
|
|
|
+ point3d_array.emplace_back( x, y, z );
|
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
|
return numComponents;
|
|
return numComponents;
|
|
}
|
|
}
|
|
@@ -357,7 +352,7 @@ void ObjFileParser::getVector3( std::vector<aiVector3D> &point3d_array ) {
|
|
copyNextWord( m_buffer, Buffersize );
|
|
copyNextWord( m_buffer, Buffersize );
|
|
z = ( ai_real ) fast_atof( m_buffer );
|
|
z = ( ai_real ) fast_atof( m_buffer );
|
|
|
|
|
|
- point3d_array.push_back( aiVector3D( x, y, z ) );
|
|
|
|
|
|
+ point3d_array.emplace_back( x, y, z );
|
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
|
}
|
|
}
|
|
|
|
|
|
@@ -378,7 +373,7 @@ void ObjFileParser::getHomogeneousVector3( std::vector<aiVector3D> &point3d_arra
|
|
if (w == 0)
|
|
if (w == 0)
|
|
throw DeadlyImportError("OBJ: Invalid component in homogeneous vector (Division by zero)");
|
|
throw DeadlyImportError("OBJ: Invalid component in homogeneous vector (Division by zero)");
|
|
|
|
|
|
- point3d_array.push_back( aiVector3D( x/w, y/w, z/w ) );
|
|
|
|
|
|
+ point3d_array.emplace_back( x/w, y/w, z/w );
|
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
|
}
|
|
}
|
|
|
|
|
|
@@ -393,7 +388,7 @@ void ObjFileParser::getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, st
|
|
copyNextWord( m_buffer, Buffersize );
|
|
copyNextWord( m_buffer, Buffersize );
|
|
z = ( ai_real ) fast_atof( m_buffer );
|
|
z = ( ai_real ) fast_atof( m_buffer );
|
|
|
|
|
|
- point3d_array_a.push_back( aiVector3D( x, y, z ) );
|
|
|
|
|
|
+ point3d_array_a.emplace_back( x, y, z );
|
|
|
|
|
|
copyNextWord(m_buffer, Buffersize);
|
|
copyNextWord(m_buffer, Buffersize);
|
|
x = (ai_real) fast_atof(m_buffer);
|
|
x = (ai_real) fast_atof(m_buffer);
|
|
@@ -404,7 +399,7 @@ void ObjFileParser::getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, st
|
|
copyNextWord( m_buffer, Buffersize );
|
|
copyNextWord( m_buffer, Buffersize );
|
|
z = ( ai_real ) fast_atof( m_buffer );
|
|
z = ( ai_real ) fast_atof( m_buffer );
|
|
|
|
|
|
- point3d_array_b.push_back( aiVector3D( x, y, z ) );
|
|
|
|
|
|
+ point3d_array_b.emplace_back( x, y, z );
|
|
|
|
|
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
|
}
|
|
}
|
|
@@ -417,7 +412,7 @@ void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) {
|
|
copyNextWord(m_buffer, Buffersize);
|
|
copyNextWord(m_buffer, Buffersize);
|
|
y = (ai_real) fast_atof(m_buffer);
|
|
y = (ai_real) fast_atof(m_buffer);
|
|
|
|
|
|
- point2d_array.push_back(aiVector2D(x, y));
|
|
|
|
|
|
+ point2d_array.emplace_back(x, y);
|
|
|
|
|
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
|
}
|
|
}
|
|
@@ -439,9 +434,9 @@ void ObjFileParser::getFace( aiPrimitiveType type ) {
|
|
|
|
|
|
const bool vt = (!m_pModel->m_TextureCoord.empty());
|
|
const bool vt = (!m_pModel->m_TextureCoord.empty());
|
|
const bool vn = (!m_pModel->m_Normals.empty());
|
|
const bool vn = (!m_pModel->m_Normals.empty());
|
|
- int iStep = 0, iPos = 0;
|
|
|
|
|
|
+ int iPos = 0;
|
|
while ( m_DataIt != m_DataItEnd ) {
|
|
while ( m_DataIt != m_DataItEnd ) {
|
|
- iStep = 1;
|
|
|
|
|
|
+ int iStep = 1;
|
|
|
|
|
|
if ( IsLineEnd( *m_DataIt ) ) {
|
|
if ( IsLineEnd( *m_DataIt ) ) {
|
|
break;
|
|
break;
|
|
@@ -845,7 +840,7 @@ void ObjFileParser::createMesh( const std::string &meshName )
|
|
bool ObjFileParser::needsNewMesh( const std::string &materialName )
|
|
bool ObjFileParser::needsNewMesh( const std::string &materialName )
|
|
{
|
|
{
|
|
// If no mesh data yet
|
|
// If no mesh data yet
|
|
- if(m_pModel->m_pCurrentMesh == 0)
|
|
|
|
|
|
+ if (m_pModel->m_pCurrentMesh == nullptr)
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -856,7 +851,7 @@ bool ObjFileParser::needsNewMesh( const std::string &materialName )
|
|
&& curMatIdx != matIdx
|
|
&& curMatIdx != matIdx
|
|
// no need create a new mesh if no faces in current
|
|
// no need create a new mesh if no faces in current
|
|
// lets say 'usemtl' goes straight after 'g'
|
|
// lets say 'usemtl' goes straight after 'g'
|
|
- && m_pModel->m_pCurrentMesh->m_Faces.size() > 0 )
|
|
|
|
|
|
+ && !m_pModel->m_pCurrentMesh->m_Faces.empty() )
|
|
{
|
|
{
|
|
// New material -> only one material per mesh, so we need to create a new
|
|
// New material -> only one material per mesh, so we need to create a new
|
|
// material
|
|
// material
|