From 23ec92092a1c04fd5d5dbde3687a86718b4e1f41 Mon Sep 17 00:00:00 2001 From: cgmelt Date: Mon, 22 Sep 2008 08:22:36 +0000 Subject: [PATCH] git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@160 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/ObjFileParser.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index def3612c6..e248c771c 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -45,6 +45,9 @@ ObjFileParser::ObjFileParser(std::vector &Data, ObjFileParser::~ObjFileParser() { // empty + if(m_pModel->m_pDefaultMaterial) delete m_pModel->m_pDefaultMaterial; + if(m_pModel) delete m_pModel; + } // ------------------------------------------------------------------- @@ -223,6 +226,9 @@ void ObjFileParser::getFace() std::vector *pIndices = new std::vector; std::vector *pTexID = new std::vector; std::vector *pNormalID = new std::vector; + bool hasNormal = false; + + bool vt = (!m_pModel->m_TextureCoord.empty()); bool vn = (!m_pModel->m_Normals.empty()); int iStep = 0, iPos = 0; @@ -273,6 +279,7 @@ void ObjFileParser::getFace() else if ( 2 == iPos ) { pNormalID->push_back( iVal-1 ); + hasNormal = true; } else { @@ -310,7 +317,9 @@ void ObjFileParser::getFace() 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_hasNormals = true; + } // Skip the rest of the line m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); } @@ -330,7 +339,7 @@ void ObjFileParser::getMaterialDesc() // Get name std::string strName(pStart, &(*m_DataIt)); - if ( strName.empty() ) + if ( strName.empty()) return; // Search for material