Fixed bug where hex digit in Face is assigned as a material

This commit is contained in:
2017-05-06 15:25:47 -07:00
parent 98c2ec2a20
commit 111cdc6339

View File

@ -125,27 +125,25 @@ vector<struct TFace> parse_face(ifstream &f) {
// then it qualifies as an illegal line. // then it qualifies as an illegal line.
} else if (4 < i && i < 8) { } else if (4 < i && i < 8) {
x.m_Indices.push_back(stoi(fdata)); x.m_Indices.push_back(stoi(fdata));
} else if (i == 8) { } else if (8 <= i) {
// field #8 may either be the unidentified hex digit if (!hex && fdata.length() > 1) {
// i.e there are 3 indices only, if (SECONDCH(fdata) == 'x') {
// or it could be another index.
if (fdata.length() > 1 && SECONDCH(fdata) == 'x') {
// this is the unidentified hex digit. // this is the unidentified hex digit.
// just it signify the texture at the end. // just it signify the texture at the end.
hex = true; hex = true;
} else { }
} else if (!hex) {
x.m_Indices.push_back(stoi(fdata)); x.m_Indices.push_back(stoi(fdata));
} } else if (hex) {
} else if ((i == 9 && hex) || i == 10) {
// it is a texture if it is field #9
// and the hex digit is already encountered
// or it is field #10.
x.m_Material = fdata; x.m_Material = fdata;
} else {
;
}
} }
i++; i++;
} // end, per field iteration } // end, per field iteration
output.push_back(x); output.push_back(x);
} } // end else case, if line did not contain other keywords
pos = f.tellg(); pos = f.tellg();
} // end, per line iteration } // end, per line iteration
// the odd case when the map file ends with a face indent. // the odd case when the map file ends with a face indent.