Fixed bug that added an extra index for a 3 vertex face.
This commit is contained in:
parent
9eb48c8ff8
commit
64c5032c93
@ -92,6 +92,7 @@ vector<Eigen::Vector3f> parse_vertices(ifstream &f) {
|
||||
|
||||
vector<struct TFace> parse_face(ifstream &f) {
|
||||
#define FIRSTCH(x) x[0]
|
||||
#define SECONDCH(x) x[1]
|
||||
// it is possible for the next line to be unrelated to faces
|
||||
// so it is needed to reset the stream prior to reading
|
||||
// the new label, e.g '\tbrush'.
|
||||
@ -102,7 +103,8 @@ vector<struct TFace> parse_face(ifstream &f) {
|
||||
if (line.find(KEYWORD_VERTICES) != string::npos ||
|
||||
line.find(KEYWORD_BRUSH) != string::npos ||
|
||||
line.find(KEYWORD_ENTITY) != string::npos ||
|
||||
line.find(KEYWORD_PREFAB) != string::npos) {
|
||||
line.find(KEYWORD_PREFAB) != string::npos ||
|
||||
line.find(KEYWORD_GLOBAL) != string::npos) {
|
||||
f.seekg(pos);
|
||||
return output;
|
||||
} else {
|
||||
@ -110,6 +112,7 @@ vector<struct TFace> parse_face(ifstream &f) {
|
||||
float *f = &x.m_fXOffset;;
|
||||
stringstream ss(line);
|
||||
string fdata;
|
||||
bool hex = false;
|
||||
unsigned int i = 0;
|
||||
while (ss >> fdata) {
|
||||
if (i < 5) {
|
||||
@ -120,14 +123,24 @@ vector<struct TFace> parse_face(ifstream &f) {
|
||||
}
|
||||
// note: if there is a non-digit in the first 5 fields
|
||||
// then it qualifies as an illegal line.
|
||||
} else if (i == 9) {
|
||||
;
|
||||
} else {
|
||||
if (isdigit(FIRSTCH(fdata)) || FIRSTCH(fdata) == '-') {
|
||||
} else if (4 < i && i < 8) {
|
||||
x.m_Indices.push_back(stoi(fdata));
|
||||
} else if (i == 8) {
|
||||
// field #8 may either be the unidentified hex digit
|
||||
// i.e there are 3 indices only,
|
||||
// or it could be another index.
|
||||
if (fdata.length() > 1 && SECONDCH(fdata) == 'x') {
|
||||
// this is the unidentified hex digit.
|
||||
// just it signify the texture at the end.
|
||||
hex = true;
|
||||
} else {
|
||||
x.m_Material = fdata;
|
||||
x.m_Indices.push_back(stoi(fdata));
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
i++;
|
||||
} // end, per field iteration
|
||||
@ -186,7 +199,6 @@ bool convertmap(const char * const infile,
|
||||
<< "\"classname\" \"worldspawn\"" << endl;
|
||||
string line;
|
||||
while (getline(fin, line)) {
|
||||
cout << line << endl;
|
||||
if (line.find(KEYWORD_PREFAB) != string::npos ||
|
||||
line.find(KEYWORD_GLOBAL) != string::npos) {
|
||||
parse_prefab(fin, fout, brushdef);
|
||||
|
Loading…
Reference in New Issue
Block a user