Update XFileParser.cpp

pull/2254/head
Kim Kulling 2018-12-03 22:03:50 +01:00 committed by GitHub
parent 831cbcf699
commit 54be5fdb7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 7 deletions

View File

@ -583,22 +583,31 @@ void XFileParser::ParseDataObjectMeshNormals( Mesh* pMesh)
pMesh->mNormals.resize( numNormals);
// read normal vectors
for( unsigned int a = 0; a < numNormals; a++)
for( unsigned int a = 0; a < numNormals; ++a) {
pMesh->mNormals[a] = ReadVector3();
}
// read normal indices
unsigned int numFaces = ReadInt();
if( numFaces != pMesh->mPosFaces.size())
if( numFaces != pMesh->mPosFaces.size()) {
ThrowException( "Normal face count does not match vertex face count.");
}
for( unsigned int a = 0; a < numFaces; a++)
{
// do not crah when no face definitions are there
if (numFaces == 0) {
TestForSeparator();
CheckForClosingBrace();
return;
// normal face creation
pMesh->mNormFaces.resize( pMesh->mNormFaces.size() + numFaces );
for( unsigned int a = 0; a < numFaces; ++a ) {
unsigned int numIndices = ReadInt();
pMesh->mNormFaces.push_back( Face() );
Face& face = pMesh->mNormFaces.back();
for( unsigned int b = 0; b < numIndices; b++)
for( unsigned int b = 0; b < numIndices; ++b ) {
face.mIndices.push_back( ReadInt());
}
TestForSeparator();
}