Refactor: Trim trailing whitespace

This commit is contained in:
Richard
2015-05-18 21:52:10 -06:00
parent 4c1a0507fe
commit a96a595a7a
313 changed files with 7022 additions and 7022 deletions

View File

@@ -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.
---------------------------------------------------------------------------
*/
@@ -75,7 +75,7 @@ using namespace std;
// ------------------------------------------------------------------------------------------------
// Default constructor
ObjFileImporter::ObjFileImporter() :
m_Buffer(),
m_Buffer(),
m_pRootObject( NULL ),
m_strAbsPath( "" )
{
@@ -115,7 +115,7 @@ const aiImporterDesc* ObjFileImporter::GetInfo () const
// ------------------------------------------------------------------------------------------------
// Obj-file import implementation
void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
{
{
// Read file into memory
const std::string mode = "rb";
boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile, mode));
@@ -135,7 +135,7 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
// Get the model name
std::string strModelName;
std::string::size_type pos = pFile.find_last_of( "\\/" );
if ( pos != std::string::npos )
if ( pos != std::string::npos )
{
strModelName = pFile.substr(pos+1, pFile.size() - pos - 1);
}
@@ -166,7 +166,7 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
// And create the proper return structures out of it
CreateDataFromImport(parser.GetModel(), pScene);
// Clean up allocated storage for the next import
// Clean up allocated storage for the next import
m_Buffer.clear();
}
@@ -176,7 +176,7 @@ void ObjFileImporter::CreateDataFromImport(const ObjFile::Model* pModel, aiScene
if( 0L == pModel ) {
return;
}
// Create the root node of the scene
pScene->mRootNode = new aiNode;
if ( !pModel->m_ModelName.empty() )
@@ -188,9 +188,9 @@ void ObjFileImporter::CreateDataFromImport(const ObjFile::Model* pModel, aiScene
{
// This is a fatal error, so break down the application
ai_assert(false);
}
}
// Create nodes for the whole scene
// Create nodes for the whole scene
std::vector<aiMesh*> MeshArray;
for (size_t index = 0; index < pModel->m_Objects.size(); index++)
{
@@ -213,21 +213,21 @@ void ObjFileImporter::CreateDataFromImport(const ObjFile::Model* pModel, aiScene
// ------------------------------------------------------------------------------------------------
// Creates all nodes of the model
aiNode *ObjFileImporter::createNodes(const ObjFile::Model* pModel, const ObjFile::Object* pObject,
aiNode *pParent, aiScene* pScene,
aiNode *ObjFileImporter::createNodes(const ObjFile::Model* pModel, const ObjFile::Object* pObject,
aiNode *pParent, aiScene* pScene,
std::vector<aiMesh*> &MeshArray )
{
ai_assert( NULL != pModel );
if( NULL == pObject ) {
return NULL;
}
// Store older mesh size to be able to computes mesh offsets for new mesh instances
const size_t oldMeshSize = MeshArray.size();
aiNode *pNode = new aiNode;
pNode->mName = pObject->m_strObjName;
// If we have a parent node, store it
if( pParent != NULL ) {
appendChildToParentNode( pParent, pNode );
@@ -236,7 +236,7 @@ aiNode *ObjFileImporter::createNodes(const ObjFile::Model* pModel, const ObjFile
for ( size_t i=0; i< pObject->m_Meshes.size(); i++ )
{
unsigned int meshId = pObject->m_Meshes[ i ];
aiMesh *pMesh = createTopology( pModel, pObject, meshId );
aiMesh *pMesh = createTopology( pModel, pObject, meshId );
if( pMesh && pMesh->mNumFaces > 0 ) {
MeshArray.push_back( pMesh );
}
@@ -266,18 +266,18 @@ aiNode *ObjFileImporter::createNodes(const ObjFile::Model* pModel, const ObjFile
index++;
}
}
return pNode;
}
// ------------------------------------------------------------------------------------------------
// Create topology data
aiMesh *ObjFileImporter::createTopology( const ObjFile::Model* pModel, const ObjFile::Object* pData,
aiMesh *ObjFileImporter::createTopology( const ObjFile::Model* pModel, const ObjFile::Object* pData,
unsigned int meshIndex )
{
// Checking preconditions
ai_assert( NULL != pModel );
if( NULL == pData ) {
return NULL;
}
@@ -346,7 +346,7 @@ aiMesh *ObjFileImporter::createTopology( const ObjFile::Model* pModel, const Obj
const unsigned int uiNumIndices = (unsigned int) pObjMesh->m_Faces[ index ]->m_pVertices->size();
uiIdxCount += pFace->mNumIndices = (unsigned int) uiNumIndices;
if (pFace->mNumIndices > 0) {
pFace->mIndices = new unsigned int[ uiNumIndices ];
pFace->mIndices = new unsigned int[ uiNumIndices ];
}
}
}
@@ -359,15 +359,15 @@ aiMesh *ObjFileImporter::createTopology( const ObjFile::Model* pModel, const Obj
// ------------------------------------------------------------------------------------------------
// Creates a vertex array
void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
const ObjFile::Object* pCurrentObject,
void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
const ObjFile::Object* pCurrentObject,
unsigned int uiMeshIndex,
aiMesh* pMesh,
unsigned int numIndices)
{
// Checking preconditions
ai_assert( NULL != pCurrentObject );
// Break, if no faces are stored in object
if ( pCurrentObject->m_Meshes.empty() )
return;
@@ -380,35 +380,35 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
// Copy vertices of this mesh instance
pMesh->mNumVertices = numIndices;
pMesh->mVertices = new aiVector3D[ pMesh->mNumVertices ];
// Allocate buffer for normal vectors
if ( !pModel->m_Normals.empty() && pObjMesh->m_hasNormals )
pMesh->mNormals = new aiVector3D[ pMesh->mNumVertices ];
// Allocate buffer for texture coordinates
if ( !pModel->m_TextureCoord.empty() && pObjMesh->m_uiUVCoordinates[0] )
{
pMesh->mNumUVComponents[ 0 ] = 2;
pMesh->mTextureCoords[ 0 ] = new aiVector3D[ pMesh->mNumVertices ];
}
// Copy vertices, normals and textures into aiMesh instance
unsigned int newIndex = 0, outIndex = 0;
for ( size_t index=0; index < pObjMesh->m_Faces.size(); index++ )
{
// Get source face
ObjFile::Face *pSourceFace = pObjMesh->m_Faces[ index ];
ObjFile::Face *pSourceFace = pObjMesh->m_Faces[ index ];
// Copy all index arrays
for ( size_t vertexIndex = 0, outVertexIndex = 0; vertexIndex < pSourceFace->m_pVertices->size(); vertexIndex++ )
{
const unsigned int vertex = pSourceFace->m_pVertices->at( vertexIndex );
if ( vertex >= pModel->m_Vertices.size() )
if ( vertex >= pModel->m_Vertices.size() )
throw DeadlyImportError( "OBJ: vertex index out of range" );
pMesh->mVertices[ newIndex ] = pModel->m_Vertices[ vertex ];
// Copy all normals
// Copy all normals
if ( !pModel->m_Normals.empty() && vertexIndex < pSourceFace->m_pNormals->size())
{
const unsigned int normal = pSourceFace->m_pNormals->at( vertexIndex );
@@ -417,13 +417,13 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
pMesh->mNormals[ newIndex ] = pModel->m_Normals[ normal ];
}
// Copy all texture coordinates
if ( !pModel->m_TextureCoord.empty() && vertexIndex < pSourceFace->m_pTexturCoords->size())
{
const unsigned int tex = pSourceFace->m_pTexturCoords->at( vertexIndex );
ai_assert( tex < pModel->m_TextureCoord.size() );
if ( tex >= pModel->m_TextureCoord.size() )
throw DeadlyImportError("OBJ: texture coordinate index out of range");
@@ -438,23 +438,23 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
// Get destination face
aiFace *pDestFace = &pMesh->mFaces[ outIndex ];
const bool last = ( vertexIndex == pSourceFace->m_pVertices->size() - 1 );
if (pSourceFace->m_PrimitiveType != aiPrimitiveType_LINE || !last)
const bool last = ( vertexIndex == pSourceFace->m_pVertices->size() - 1 );
if (pSourceFace->m_PrimitiveType != aiPrimitiveType_LINE || !last)
{
pDestFace->mIndices[ outVertexIndex ] = newIndex;
outVertexIndex++;
}
if (pSourceFace->m_PrimitiveType == aiPrimitiveType_POINT)
if (pSourceFace->m_PrimitiveType == aiPrimitiveType_POINT)
{
outIndex++;
outVertexIndex = 0;
}
else if (pSourceFace->m_PrimitiveType == aiPrimitiveType_LINE)
else if (pSourceFace->m_PrimitiveType == aiPrimitiveType_LINE)
{
outVertexIndex = 0;
if(!last)
if(!last)
outIndex++;
if (vertexIndex) {
@@ -479,20 +479,20 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
}
++newIndex;
}
}
}
}
// ------------------------------------------------------------------------------------------------
// Counts all stored meshes
// Counts all stored meshes
void ObjFileImporter::countObjects(const std::vector<ObjFile::Object*> &rObjects, int &iNumMeshes)
{
iNumMeshes = 0;
if ( rObjects.empty() )
if ( rObjects.empty() )
return;
iNumMeshes += static_cast<unsigned int>( rObjects.size() );
for (std::vector<ObjFile::Object*>::const_iterator it = rObjects.begin();
it != rObjects.end();
it != rObjects.end();
++it)
{
if (!(*it)->m_SubObjects.empty())
@@ -503,7 +503,7 @@ void ObjFileImporter::countObjects(const std::vector<ObjFile::Object*> &rObjects
}
// ------------------------------------------------------------------------------------------------
// Add clamp mode property to material if necessary
// Add clamp mode property to material if necessary
void ObjFileImporter::addTextureMappingModeProperty(aiMaterial* mat, aiTextureType type, int clampMode)
{
ai_assert( NULL != mat);
@@ -512,7 +512,7 @@ void ObjFileImporter::addTextureMappingModeProperty(aiMaterial* mat, aiTextureTy
}
// ------------------------------------------------------------------------------------------------
// Creates the material
// Creates the material
void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pScene )
{
ai_assert( NULL != pScene );
@@ -525,14 +525,14 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc
DefaultLogger::get()->debug("OBJ: no materials specified");
return;
}
pScene->mMaterials = new aiMaterial*[ numMaterials ];
for ( unsigned int matIndex = 0; matIndex < numMaterials; matIndex++ )
{
{
// Store material name
std::map<std::string, ObjFile::Material*>::const_iterator it;
it = pModel->m_MaterialMap.find( pModel->m_MaterialLib[ matIndex ] );
// No material found, use the default material
if ( pModel->m_MaterialMap.end() == it )
continue;
@@ -543,7 +543,7 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc
// convert illumination model
int sm = 0;
switch (pCurrentMaterial->illumination_model)
switch (pCurrentMaterial->illumination_model)
{
case 0:
sm = aiShadingMode_NoShading;
@@ -558,7 +558,7 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc
sm = aiShadingMode_Gouraud;
DefaultLogger::get()->error("OBJ: unexpected illumination model (0-2 recognized)");
}
mat->AddProperty<int>( &sm, 1, AI_MATKEY_SHADING_MODEL);
// multiplying the specular exponent with 2 seems to yield better results
@@ -576,7 +576,7 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc
mat->AddProperty( &pCurrentMaterial->ior, 1, AI_MATKEY_REFRACTI );
// Adding textures
if ( 0 != pCurrentMaterial->texture.length )
if ( 0 != pCurrentMaterial->texture.length )
{
mat->AddProperty( &pCurrentMaterial->texture, AI_MATKEY_TEXTURE_DIFFUSE(0));
if (pCurrentMaterial->clamp[ObjFile::Material::TextureDiffuseType])
@@ -650,12 +650,12 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc
addTextureMappingModeProperty(mat, aiTextureType_SHININESS);
}
}
// Store material property info in material array in scene
pScene->mMaterials[ pScene->mNumMaterials ] = mat;
pScene->mNumMaterials++;
}
// Test number of created materials.
ai_assert( pScene->mNumMaterials == numMaterials );
}
@@ -670,8 +670,8 @@ void ObjFileImporter::appendChildToParentNode(aiNode *pParent, aiNode *pChild)
// Assign parent to child
pChild->mParent = pParent;
// If already children was assigned to the parent node, store them in a
// If already children was assigned to the parent node, store them in a
std::vector<aiNode*> temp;
if (pParent->mChildren != NULL)
{
@@ -682,7 +682,7 @@ void ObjFileImporter::appendChildToParentNode(aiNode *pParent, aiNode *pChild)
}
delete [] pParent->mChildren;
}
// Copy node instances into parent node
pParent->mNumChildren++;
pParent->mChildren = new aiNode*[ pParent->mNumChildren ];