diff -r 767592024ec5 -r 4c41bfe2ec6e src/parser.cpp --- a/src/parser.cpp Sun Jan 26 01:06:27 2020 +0200 +++ b/src/parser.cpp Sun Jan 26 14:29:30 2020 +0200 @@ -92,7 +92,7 @@ if (partTypeString.startsWith("Unofficial_")) partTypeString = partTypeString.mid(strlen("Unofficial_")); header.type = typeStrings.value(partTypeString, LDHeader::Part); - header.qualfiers = 0; + header.qualfiers = {}; if (tokens.contains("Alias")) header.qualfiers |= LDHeader::Alias; if (tokens.contains("Physical_Color")) @@ -279,7 +279,7 @@ } } -static Point3D vertexFromStrings( +static glm::vec3 vertexFromStrings( const QStringList& tokens, const int startingPosition) { @@ -296,9 +296,9 @@ return {x, y, z}; } -static Matrix3x3 matrixFromStrings(const QStringList& tokens, const int startingPosition) +static glm::mat4 matrixFromStrings(const QStringList& tokens, const int startingPosition, const int positionStartingIndex) { - Matrix3x3 result; + glm::mat4 result = glm::mat4{1}; for (int i = 0; i < 9; i += 1) { const int row = i / 3; @@ -309,7 +309,18 @@ throw BodyParseError{"too few tokens available"}; } bool ok; - result(row, column) = tokens[index].toFloat(&ok); + // note that glm::mat4 is column-major + result[column][row] = tokens[index].toFloat(&ok); + if (not ok) + { + throw BodyParseError{"non-numeric values for matrix"}; + } + } + for (int i = 0; i < 3; i += 1) + { + bool ok; + const auto value = tokens[i + positionStartingIndex].toFloat(&ok); + result[3][i] = value; if (not ok) { throw BodyParseError{"non-numeric values for matrix"}; @@ -347,10 +358,9 @@ throw BodyParseError{"wrong amount of tokens in a type-1 line"}; } const Color color = colorFromString(tokens[colorPosition]); - const Point3D position = vertexFromStrings(tokens, positionPosition); - const Matrix3x3 transform = matrixFromStrings(tokens, transformPosition); + const glm::mat4 transform = matrixFromStrings(tokens, transformPosition, positionPosition); const QString& name = tokens[namePosition]; - return std::make_unique(combine(transform, position), name, color); + return std::make_unique(transform, name, color); } template @@ -366,7 +376,7 @@ throw BodyParseError{"wrong amount of tokens"}; } const Color color = colorFromString(tokens[colorPosition]); - QVector vertices; + QVector vertices; vertices.reserve(NumVertices); for (int i = 0; i < NumVertices; i += 1) {