Fixed OBJ reader not reading materials which start with a leading space

This commit is contained in:
Jan Möbius
2021-09-24 11:10:47 +02:00
parent fad00c8eb9
commit d74c7aa020
4 changed files with 84 additions and 5 deletions

View File

@@ -188,23 +188,24 @@ read_material(std::fstream& _in)
stream >> keyWrd;
if( ( isspace(line[0]) && line[0] != '\t' ) || line[0] == '#' )
if (keyWrd == "newmtl") // begin new material definition
{
// If we are in a material definition (Already reading a material)
// And a material name has been set
// And the current material definition is valid
// Then Store the current material in our lookup table
if (indef && !key.empty() && mat.is_valid())
{
materials_[key] = mat;
mat.cleanup();
}
}
else if (keyWrd == "newmtl") // begin new material definition
{
stream >> key;
indef = true;
}
else if (keyWrd == "Kd") // diffuse color
{
{
stream >> f1; stream >> f2; stream >> f3;
if( !stream.fail() )