From b724ac5c2c9aa2ca4a704d05fbd118bb45350363 Mon Sep 17 00:00:00 2001 From: kimmi Date: Tue, 20 Mar 2012 20:31:14 +0000 Subject: [PATCH] =?UTF-8?q?-=20Bugfix=20:=20Fix=20build=20of=20Obj-FileImp?= =?UTF-8?q?orter=20(=20this=20is=20currently=20only=20a=20work-around,=20l?= =?UTF-8?q?oader=20is=20leaking=20memory,=20I=20am=20working=20on=20it=20)?= =?UTF-8?q?.=20-=20Update=20:=20Merge=20fixes=20from=20GitHub,=20thanks=20?= =?UTF-8?q?to=20Riku=20Palom=C3=A4ki=20(=20more=20fixes=20will=20merged=20?= =?UTF-8?q?soon=20).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1213 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/BaseImporter.cpp | 11 +++++++++-- code/BaseImporter.h | 4 ++-- code/ObjFileData.h | 11 ++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/code/BaseImporter.cpp b/code/BaseImporter.cpp index c4ec68565..1c4f4bbcc 100644 --- a/code/BaseImporter.cpp +++ b/code/BaseImporter.cpp @@ -110,7 +110,8 @@ void BaseImporter::SetupProperties(const Importer* /*pImp*/) const std::string& pFile, const char** tokens, unsigned int numTokens, - unsigned int searchBytes /* = 200 */) + unsigned int searchBytes /* = 200 */, + bool tokensSol /* false */) { ai_assert(NULL != tokens && 0 != numTokens && 0 != searchBytes); if (!pIOHandler) @@ -142,7 +143,13 @@ void BaseImporter::SetupProperties(const Importer* /*pImp*/) for (unsigned int i = 0; i < numTokens;++i) { ai_assert(NULL != tokens[i]); - if (::strstr(buffer,tokens[i])) { + + const char* r = strstr(buffer,tokens[i]); + if (!r) + continue; + // We got a match, either we don't care where it is, or it happens to + // be in the beginning of the file / line + if (!tokensSol || r == buffer || r[-1] == '\r' || r[-1] == '\n') { DefaultLogger::get()->debug(std::string("Found positive match for header keyword: ") + tokens[i]); return true; } diff --git a/code/BaseImporter.h b/code/BaseImporter.h index 9511629dd..e701bca0d 100644 --- a/code/BaseImporter.h +++ b/code/BaseImporter.h @@ -271,8 +271,8 @@ public: // static utilities const std::string& file, const char** tokens, unsigned int numTokens, - unsigned int searchBytes = 200); - + unsigned int searchBytes = 200, + bool tokensSol = false); // ------------------------------------------------------------------- /** @brief Check whether a file has a specific file extension diff --git a/code/ObjFileData.h b/code/ObjFileData.h index c2c092cee..0075fd58f 100644 --- a/code/ObjFileData.h +++ b/code/ObjFileData.h @@ -58,7 +58,7 @@ struct Material; // ------------------------------------------------------------------------------------------------ //! \struct Face -//! \brief Datastructure for a simple obj-face, descripes discredisation and materials +//! \brief Data structure for a simple obj-face, describes discredit,l.ation and materials struct Face { typedef std::vector IndexArray; @@ -96,8 +96,10 @@ struct Face { delete m_pVertices; m_pVertices = NULL; + delete m_pNormals; m_pNormals = NULL; + delete m_pTexturCoords; m_pTexturCoords = NULL; } @@ -162,7 +164,7 @@ struct Material aiColor3D ambient; //! Diffuse color aiColor3D diffuse; - //! Speculao color + //! Specular color aiColor3D specular; //! Alpha value float alpha; @@ -228,7 +230,6 @@ struct Mesh { delete *it; } - } }; @@ -259,7 +260,7 @@ struct Model std::vector m_Vertices; //! vector with all generated normals std::vector m_Normals; - //! Groupmap + //! Group map GroupMap m_Groups; //! Group to face id assignment std::vector *m_pGroupFaceIDs; @@ -309,7 +310,7 @@ struct Model m_Groups.clear(); for ( std::map::iterator it = m_MaterialMap.begin(); it != m_MaterialMap.end(); ++it ) { - delete it->second; +// delete it->second; } } };