--- a/src/primitives.cpp Sun Jun 10 16:04:38 2018 +0300 +++ b/src/primitives.cpp Sun Jun 10 16:50:14 2018 +0300 @@ -325,12 +325,41 @@ } } +/* + * Builds a circle primitive. + */ +void PrimitiveModel::generateCircle(Model& model) const +{ + QVector<QLineF> circle = makeCircle(segments, divisions, 1); + + for (int i = 0; i < segments; ++i) + { + double x0 = circle[i].x1(); + double x1 = circle[i].x2(); + double z0 = circle[i].y1(); + double z1 = circle[i].y2(); + + LDEdgeLine* line = model.emplace<LDEdgeLine>(); + line->setVertex(0, Vertex {x0, 0.0f, z0}); + line->setVertex(1, Vertex {x1, 0.0f, z1}); + line->setColor(EdgeColor); + } +} + void PrimitiveModel::generateBody(Model& model) const { - if (this->type == Cylinder) + switch (type) { - this->generateCylinder(model); + case Cylinder: + generateCylinder(model); return; + + case Circle: + generateCircle(model); + return; + + default: + break; } QVector<int> conditionalLineSegments; @@ -345,15 +374,6 @@ switch (type) { - case Circle: - { - LDEdgeLine* line = model.emplace<LDEdgeLine>(); - line->setVertex(0, Vertex {x0, 0.0f, z0}); - line->setVertex(1, Vertex {x1, 0.0f, z1}); - line->setColor(EdgeColor); - } - break; - case Ring: case Cone: { @@ -421,6 +441,7 @@ } break; + case Circle: case Cylinder: break; }