src/parser.cpp

changeset 77
028798a72591
parent 35
98906a94732f
child 105
6ca6e8c647d4
equal deleted inserted replaced
76:7c4a63a02632 77:028798a72591
261 { 261 {
262 editor.invertObject(id); 262 editor.invertObject(id);
263 } 263 }
264 invertNext = false; 264 invertNext = false;
265 } 265 }
266 // Test quadrilateral splitting by splitting all the quadrilaterals
267 QVector<ldraw::quadrilateralid_t> quadrilateral_ids;
268 for (int i = 0; i < editor.model().size(); i += 1)
269 {
270 const ldraw::id_t id = editor.model().resolve(editor.model().index(i));
271 const ldraw::quadrilateralid_t quad_id = editor.model().checkType<ldraw::Quadrilateral>(id);
272 if (not(quad_id == ldraw::NULL_ID))
273 {
274 quadrilateral_ids.push_back(quad_id);
275 }
276 }
277 for (const ldraw::quadrilateralid_t id : quadrilateral_ids)
278 {
279 ldraw::splitQuadrilateral(editor, id);
280 }
266 } 281 }
267 282
268 static ldraw::Color colorFromString(const QString& colorString) 283 static ldraw::Color colorFromString(const QString& colorString)
269 { 284 {
270 bool colorSucceeded; 285 bool colorSucceeded;
374 if (tokens.size() != 2 + 3 * NumVertices) 389 if (tokens.size() != 2 + 3 * NumVertices)
375 { 390 {
376 throw BodyParseError{"wrong amount of tokens"}; 391 throw BodyParseError{"wrong amount of tokens"};
377 } 392 }
378 const ldraw::Color color = colorFromString(tokens[colorPosition]); 393 const ldraw::Color color = colorFromString(tokens[colorPosition]);
379 QVector<glm::vec3> vertices; 394 std::array<glm::vec3, NumVertices> vertices;
380 vertices.reserve(NumVertices);
381 for (int i = 0; i < NumVertices; i += 1) 395 for (int i = 0; i < NumVertices; i += 1)
382 { 396 {
383 vertices.append(vertexFromStrings(tokens, vertexPosition(i))); 397 vertices[unsigned_cast(i)] = vertexFromStrings(tokens, vertexPosition(i));
384 } 398 }
385 return std::make_unique<T>(vertices, color); 399 return std::make_unique<T>(vertices, color);
386 } 400 }
387 401
388 std::unique_ptr<ldraw::Object> Parser::parseFromString(QString line) 402 std::unique_ptr<ldraw::Object> Parser::parseFromString(QString line)

mercurial