Refactor: Trim trailing whitespace
This commit is contained in:
@@ -7,8 +7,8 @@ Copyright (c) 2006-2015, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
@@ -25,16 +25,16 @@ conditions are met:
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -58,7 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
const std::string ObjFileParser::DEFAULT_MATERIAL = AI_DEFAULT_MATERIAL_NAME;
|
||||
const std::string ObjFileParser::DEFAULT_MATERIAL = AI_DEFAULT_MATERIAL_NAME;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Constructor with loaded data and directories.
|
||||
@@ -74,13 +74,13 @@ ObjFileParser::ObjFileParser(std::vector<char> &Data,const std::string &strModel
|
||||
// Create the model instance to store all the data
|
||||
m_pModel = new ObjFile::Model();
|
||||
m_pModel->m_ModelName = strModelName;
|
||||
|
||||
|
||||
// create default material and store it
|
||||
m_pModel->m_pDefaultMaterial = new ObjFile::Material();
|
||||
m_pModel->m_pDefaultMaterial->MaterialName.Set( DEFAULT_MATERIAL );
|
||||
m_pModel->m_MaterialLib.push_back( DEFAULT_MATERIAL );
|
||||
m_pModel->m_MaterialMap[ DEFAULT_MATERIAL ] = m_pModel->m_pDefaultMaterial;
|
||||
|
||||
|
||||
// Start parsing the file
|
||||
parseFile();
|
||||
}
|
||||
@@ -133,7 +133,7 @@ void ObjFileParser::parseFile()
|
||||
case 'l':
|
||||
case 'f':
|
||||
{
|
||||
getFace(*m_DataIt == 'f' ? aiPrimitiveType_POLYGON : (*m_DataIt == 'l'
|
||||
getFace(*m_DataIt == 'f' ? aiPrimitiveType_POLYGON : (*m_DataIt == 'l'
|
||||
? aiPrimitiveType_LINE : aiPrimitiveType_POINT));
|
||||
}
|
||||
break;
|
||||
@@ -176,7 +176,7 @@ void ObjFileParser::parseFile()
|
||||
getObjectName();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
{
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
@@ -213,14 +213,14 @@ void ObjFileParser::copyNextLine(char *pBuffer, size_t length)
|
||||
|
||||
// some OBJ files have line continuations using \ (such as in C++ et al)
|
||||
bool continuation = false;
|
||||
for (;m_DataIt != m_DataItEnd && index < length-1; ++m_DataIt)
|
||||
for (;m_DataIt != m_DataItEnd && index < length-1; ++m_DataIt)
|
||||
{
|
||||
const char c = *m_DataIt;
|
||||
if (c == '\\') {
|
||||
continuation = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (c == '\n' || c == '\r') {
|
||||
if(continuation) {
|
||||
pBuffer[ index++ ] = ' ';
|
||||
@@ -276,8 +276,8 @@ void ObjFileParser::getVector( std::vector<aiVector3D> &point3d_array ) {
|
||||
void ObjFileParser::getVector3(std::vector<aiVector3D> &point3d_array) {
|
||||
float x, y, z;
|
||||
copyNextWord(m_buffer, BUFFERSIZE);
|
||||
x = (float) fast_atof(m_buffer);
|
||||
|
||||
x = (float) fast_atof(m_buffer);
|
||||
|
||||
copyNextWord(m_buffer, BUFFERSIZE);
|
||||
y = (float) fast_atof(m_buffer);
|
||||
|
||||
@@ -293,8 +293,8 @@ void ObjFileParser::getVector3(std::vector<aiVector3D> &point3d_array) {
|
||||
void ObjFileParser::getVector2( std::vector<aiVector2D> &point2d_array ) {
|
||||
float x, y;
|
||||
copyNextWord(m_buffer, BUFFERSIZE);
|
||||
x = (float) fast_atof(m_buffer);
|
||||
|
||||
x = (float) fast_atof(m_buffer);
|
||||
|
||||
copyNextWord(m_buffer, BUFFERSIZE);
|
||||
y = (float) fast_atof(m_buffer);
|
||||
|
||||
@@ -355,7 +355,7 @@ void ObjFileParser::getFace(aiPrimitiveType type)
|
||||
{
|
||||
iPos = 0;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
//OBJ USES 1 Base ARRAYS!!!!
|
||||
const int iVal = atoi( pPtr );
|
||||
@@ -375,7 +375,7 @@ void ObjFileParser::getFace(aiPrimitiveType type)
|
||||
pIndices->push_back( iVal-1 );
|
||||
}
|
||||
else if ( 1 == iPos )
|
||||
{
|
||||
{
|
||||
pTexID->push_back( iVal-1 );
|
||||
}
|
||||
else if ( 2 == iPos )
|
||||
@@ -413,7 +413,7 @@ void ObjFileParser::getFace(aiPrimitiveType type)
|
||||
pPtr += iStep;
|
||||
}
|
||||
|
||||
if ( pIndices->empty() )
|
||||
if ( pIndices->empty() )
|
||||
{
|
||||
DefaultLogger::get()->error("Obj: Ignoring empty face");
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
@@ -421,28 +421,28 @@ void ObjFileParser::getFace(aiPrimitiveType type)
|
||||
}
|
||||
|
||||
ObjFile::Face *face = new ObjFile::Face( pIndices, pNormalID, pTexID, type );
|
||||
|
||||
|
||||
// Set active material, if one set
|
||||
if (NULL != m_pModel->m_pCurrentMaterial)
|
||||
if (NULL != m_pModel->m_pCurrentMaterial)
|
||||
face->m_pMaterial = m_pModel->m_pCurrentMaterial;
|
||||
else
|
||||
else
|
||||
face->m_pMaterial = m_pModel->m_pDefaultMaterial;
|
||||
|
||||
// Create a default object, if nothing is there
|
||||
if ( NULL == m_pModel->m_pCurrent )
|
||||
createObject( "defaultobject" );
|
||||
|
||||
|
||||
// Assign face to mesh
|
||||
if ( NULL == m_pModel->m_pCurrentMesh )
|
||||
{
|
||||
createMesh();
|
||||
}
|
||||
|
||||
|
||||
// Store the face
|
||||
m_pModel->m_pCurrentMesh->m_Faces.push_back( face );
|
||||
m_pModel->m_pCurrentMesh->m_uiNumIndices += (unsigned int)face->m_pVertices->size();
|
||||
m_pModel->m_pCurrentMesh->m_uiUVCoordinates[ 0 ] += (unsigned int)face->m_pTexturCoords[0].size();
|
||||
if( !m_pModel->m_pCurrentMesh->m_hasNormals && hasNormal )
|
||||
m_pModel->m_pCurrentMesh->m_uiUVCoordinates[ 0 ] += (unsigned int)face->m_pTexturCoords[0].size();
|
||||
if( !m_pModel->m_pCurrentMesh->m_hasNormals && hasNormal )
|
||||
{
|
||||
m_pModel->m_pCurrentMesh->m_hasNormals = true;
|
||||
}
|
||||
@@ -492,7 +492,7 @@ void ObjFileParser::getMaterialDesc()
|
||||
m_pModel->m_pCurrentMaterial = (*it).second;
|
||||
if ( needsNewMesh( strName ))
|
||||
{
|
||||
createMesh();
|
||||
createMesh();
|
||||
}
|
||||
m_pModel->m_pCurrentMesh->m_uiMaterialIndex = getMaterialIndex( strName );
|
||||
}
|
||||
@@ -528,7 +528,7 @@ void ObjFileParser::getMaterialLib()
|
||||
if( m_DataIt == m_DataItEnd ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
char *pStart = &(*m_DataIt);
|
||||
while( m_DataIt != m_DataItEnd && !IsLineEnd( *m_DataIt ) ) {
|
||||
++m_DataIt;
|
||||
@@ -550,8 +550,8 @@ void ObjFileParser::getMaterialLib()
|
||||
BaseImporter::TextFileToBuffer(pFile,buffer);
|
||||
m_pIO->Close( pFile );
|
||||
|
||||
// Importing the material library
|
||||
ObjFileMtlImporter mtlImporter( buffer, strMatName, m_pModel );
|
||||
// Importing the material library
|
||||
ObjFileMtlImporter mtlImporter( buffer, strMatName, m_pModel );
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@@ -581,7 +581,7 @@ void ObjFileParser::getNewMaterial()
|
||||
// Set new material
|
||||
if ( needsNewMesh( strMat ) )
|
||||
{
|
||||
createMesh();
|
||||
createMesh();
|
||||
}
|
||||
m_pModel->m_pCurrentMesh->m_uiMaterialIndex = getMaterialIndex( strMat );
|
||||
}
|
||||
@@ -608,11 +608,11 @@ int ObjFileParser::getMaterialIndex( const std::string &strMaterialName )
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Getter for a group name.
|
||||
// Getter for a group name.
|
||||
void ObjFileParser::getGroupName()
|
||||
{
|
||||
std::string strGroupName;
|
||||
|
||||
|
||||
m_DataIt = getName<DataArrayIt>(m_DataIt, m_DataItEnd, strGroupName);
|
||||
if( isEndOfBuffer( m_DataIt, m_DataItEnd ) ) {
|
||||
return;
|
||||
@@ -623,10 +623,10 @@ void ObjFileParser::getGroupName()
|
||||
{
|
||||
// Search for already existing entry
|
||||
ObjFile::Model::ConstGroupMapIt it = m_pModel->m_Groups.find(strGroupName);
|
||||
|
||||
|
||||
// We are mapping groups into the object structure
|
||||
createObject( strGroupName );
|
||||
|
||||
|
||||
// New group name, creating a new entry
|
||||
if (it == m_pModel->m_Groups.end())
|
||||
{
|
||||
@@ -662,7 +662,7 @@ void ObjFileParser::getGroupNumberAndResolution()
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Stores values for a new object instance, name will be used to
|
||||
// Stores values for a new object instance, name will be used to
|
||||
// identify it.
|
||||
void ObjFileParser::getObjectName()
|
||||
{
|
||||
@@ -676,11 +676,11 @@ void ObjFileParser::getObjectName()
|
||||
}
|
||||
|
||||
std::string strObjectName(pStart, &(*m_DataIt));
|
||||
if (!strObjectName.empty())
|
||||
if (!strObjectName.empty())
|
||||
{
|
||||
// Reset current object
|
||||
m_pModel->m_pCurrent = NULL;
|
||||
|
||||
|
||||
// Search for actual object
|
||||
for (std::vector<ObjFile::Object*>::const_iterator it = m_pModel->m_Objects.begin();
|
||||
it != m_pModel->m_Objects.end();
|
||||
@@ -710,15 +710,15 @@ void ObjFileParser::createObject(const std::string &strObjectName)
|
||||
m_pModel->m_pCurrent = new ObjFile::Object;
|
||||
m_pModel->m_pCurrent->m_strObjName = strObjectName;
|
||||
m_pModel->m_Objects.push_back( m_pModel->m_pCurrent );
|
||||
|
||||
|
||||
createMesh();
|
||||
|
||||
if( m_pModel->m_pCurrentMaterial )
|
||||
{
|
||||
m_pModel->m_pCurrentMesh->m_uiMaterialIndex =
|
||||
m_pModel->m_pCurrentMesh->m_uiMaterialIndex =
|
||||
getMaterialIndex( m_pModel->m_pCurrentMaterial->MaterialName.data );
|
||||
m_pModel->m_pCurrentMesh->m_pMaterial = m_pModel->m_pCurrentMaterial;
|
||||
}
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
// Creates a new mesh
|
||||
@@ -752,7 +752,7 @@ bool ObjFileParser::needsNewMesh( const std::string &rMaterialName )
|
||||
int curMatIdx = m_pModel->m_pCurrentMesh->m_uiMaterialIndex;
|
||||
if ( curMatIdx != int(ObjFile::Mesh::NoMaterial) || curMatIdx != matIdx )
|
||||
{
|
||||
// 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
|
||||
newMat = true;
|
||||
}
|
||||
@@ -762,7 +762,7 @@ bool ObjFileParser::needsNewMesh( const std::string &rMaterialName )
|
||||
// -------------------------------------------------------------------
|
||||
// Shows an error in parsing process.
|
||||
void ObjFileParser::reportErrorTokenInFace()
|
||||
{
|
||||
{
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
DefaultLogger::get()->error("OBJ: Not supported token in face description detected");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user