src/linetypes/cylinder.cpp

changeset 1394
8d9d0532b3df
parent 1391
5fa4bf1fc781
equal deleted inserted replaced
1393:f0fe7ea82b81 1394:8d9d0532b3df
75 } 75 }
76 76
77 QVector<LDPolygon> LDCylinder::rasterizePolygons(DocumentManager* context, Winding winding) 77 QVector<LDPolygon> LDCylinder::rasterizePolygons(DocumentManager* context, Winding winding)
78 { 78 {
79 Model cylinderBody {context}; 79 Model cylinderBody {context};
80 buildPrimitiveBody(cylinderBody, winding); 80 buildPrimitiveBody(cylinderBody);
81 QVector<LDPolygon> result; 81 QVector<LDPolygon> result;
82 bool cachedShouldInvert = shouldInvert(winding, context);
82 83
83 for (LDObject* object : cylinderBody.objects()) 84 for (LDObject* object : cylinderBody.objects())
84 { 85 {
85 for (int i = 0; i < object->numVertices(); i += 1) 86 for (int i = 0; i < object->numVertices(); i += 1)
86 { 87 {
91 92
92 LDPolygon* polygon = object->getPolygon(); 93 LDPolygon* polygon = object->getPolygon();
93 94
94 if (polygon) 95 if (polygon)
95 { 96 {
96 if (shouldInvert(winding, context)) 97 if (cachedShouldInvert)
97 invertPolygon(*polygon); 98 invertPolygon(*polygon);
98 99
99 result.append(*polygon); 100 result.append(*polygon);
100 } 101 }
101 102
103 } 104 }
104 105
105 return result; 106 return result;
106 } 107 }
107 108
108 void LDCylinder::buildPrimitiveBody(Model& model, Winding winding) const 109 void LDCylinder::buildPrimitiveBody(Model& model) const
109 { 110 {
110 PrimitiveModel primitive; 111 PrimitiveModel primitive;
111 primitive.type = PrimitiveModel::Cylinder; 112 primitive.type = PrimitiveModel::Cylinder;
112 primitive.segments = m_segments; 113 primitive.segments = m_segments;
113 primitive.divisions = m_divisions; 114 primitive.divisions = m_divisions;
114 primitive.ringNumber = 0; 115 primitive.ringNumber = 0;
115 primitive.generateCylinder(model, winding); 116 primitive.generateCylinder(model);
116 } 117 }
117 118
118 QString LDCylinder::objectListText() const 119 QString LDCylinder::objectListText() const
119 { 120 {
120 QString result = format("Cylinder %1 %2, (", m_segments / m_divisions, position().toString(true)); 121 QString result = format("Cylinder %1 %2, (", m_segments / m_divisions, position().toString(true));

mercurial