From 685612b9f4f5e0ca5a7cb3e14693d493604a2e62 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 11 Oct 2013 15:29:17 +0200 Subject: [PATCH] - refactoring : remove not used mesh index from private method in obj-importer. - refactoring : remove commented code. Signed-off-by: Kim Kulling --- code/ObjFileData.h | 4 ++-- code/ObjFileImporter.cpp | 10 +++++----- code/ObjFileImporter.h | 2 +- code/ObjFileParser.cpp | 10 +++------- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/code/ObjFileData.h b/code/ObjFileData.h index 4331a7d10..7b30efe2e 100755 --- a/code/ObjFileData.h +++ b/code/ObjFileData.h @@ -277,7 +277,7 @@ struct Model //! Material map std::map m_MaterialMap; - //! \brief Default constructor + //! \brief The default class constructor Model() : m_ModelName(""), m_pCurrent(NULL), @@ -290,7 +290,7 @@ struct Model // empty } - //! \brief Destructor + //! \brief The class destructor ~Model() { // Clear all stored object instances diff --git a/code/ObjFileImporter.cpp b/code/ObjFileImporter.cpp index f8568391d..14c8e8aff 100644 --- a/code/ObjFileImporter.cpp +++ b/code/ObjFileImporter.cpp @@ -123,8 +123,9 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene, // Get the file-size and validate it, throwing an exception when fails size_t fileSize = file->FileSize(); - if( fileSize < 16) + if( fileSize < 16) { throw DeadlyImportError( "OBJ-file is too small."); + } // Allocate buffer and read file into it TextFileToBuffer(file.get(),m_Buffer); @@ -167,15 +168,15 @@ void ObjFileImporter::CreateDataFromImport(const ObjFile::Model* pModel, aiScene } else { - // This is an error, so break down the application + // This is a fatal error, so break down the application ai_assert(false); - } + } // Create nodes for the whole scene std::vector MeshArray; for (size_t index = 0; index < pModel->m_Objects.size(); index++) { - createNodes(pModel, pModel->m_Objects[ index ], index, pScene->mRootNode, pScene, MeshArray); + createNodes(pModel, pModel->m_Objects[ index ], pScene->mRootNode, pScene, MeshArray); } // Create mesh pointer buffer for this scene @@ -195,7 +196,6 @@ 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, - unsigned int /*uiMeshIndex*/, aiNode *pParent, aiScene* pScene, std::vector &MeshArray ) { diff --git a/code/ObjFileImporter.h b/code/ObjFileImporter.h index 42e69a840..ca931088a 100644 --- a/code/ObjFileImporter.h +++ b/code/ObjFileImporter.h @@ -87,7 +87,7 @@ private: void CreateDataFromImport(const ObjFile::Model* pModel, aiScene* pScene); //! \brief Creates all nodes stored in imported content. - aiNode *createNodes(const ObjFile::Model* pModel, const ObjFile::Object* pData, unsigned int uiMeshIndex, + aiNode *createNodes(const ObjFile::Model* pModel, const ObjFile::Object* pData, aiNode *pParent, aiScene* pScene, std::vector &MeshArray); //! \brief Creates topology data like faces and meshes for the geometry. diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index e701ddc62..ef3deb20f 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -50,10 +50,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../include/assimp/types.h" #include "DefaultIOSystem.h" -namespace Assimp -{ +namespace Assimp { -// ------------------------------------------------------------------- const std::string ObjFileParser::DEFAULT_MATERIAL = AI_DEFAULT_MATERIAL_NAME; // ------------------------------------------------------------------- @@ -71,9 +69,10 @@ ObjFileParser::ObjFileParser(std::vector &Data,const std::string &strModel 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_MaterialLib.push_back( DEFAULT_MATERIAL ); m_pModel->m_MaterialMap[ DEFAULT_MATERIAL ] = m_pModel->m_pDefaultMaterial; // Start parsing the file @@ -84,9 +83,6 @@ ObjFileParser::ObjFileParser(std::vector &Data,const std::string &strModel // Destructor ObjFileParser::~ObjFileParser() { - /*delete m_pModel->m_pDefaultMaterial; - m_pModel->m_pDefaultMaterial = NULL;*/ - delete m_pModel; m_pModel = NULL; }