src/document.cpp

changeset 250
2837b549e616
parent 245
a41ccc6924e3
equal deleted inserted replaced
249:37d3c819cafa 250:2837b549e616
26 #include "circularprimitive.h" 26 #include "circularprimitive.h"
27 27
28 // Make mapbox::earcut work with glm::vec3 28 // Make mapbox::earcut work with glm::vec3
29 template<> struct mapbox::util::nth<0, glm::vec3> 29 template<> struct mapbox::util::nth<0, glm::vec3>
30 { 30 {
31 static constexpr float get(const glm::vec3& t) { return t.x; }; 31 static constexpr float get(const glm::vec3& t) { return t.x; }
32 }; 32 };
33 33
34 template<> struct mapbox::util::nth<1, glm::vec3> 34 template<> struct mapbox::util::nth<1, glm::vec3>
35 { 35 {
36 static constexpr float get(const glm::vec3& t) { return t.y; }; 36 static constexpr float get(const glm::vec3& t) { return t.y; }
37 }; 37 };
38 38
39 EditTools::EditTools(QObject* parent) : 39 EditTools::EditTools(QObject* parent) :
40 QObject{parent}, 40 QObject{parent},
41 RenderLayer{} 41 RenderLayer{}
44 44
45 EditTools::~EditTools() 45 EditTools::~EditTools()
46 { 46 {
47 } 47 }
48 48
49 void EditTools::setEditMode(EditingMode mode) 49 void EditTools::setEditMode(EditingMode newMode)
50 { 50 {
51 this->mode = mode; 51 this->mode = newMode;
52 } 52 }
53 53
54 void EditTools::setGridMatrix(const glm::mat4& gridMatrix) 54 void EditTools::setGridMatrix(const glm::mat4& newGridMatrix)
55 { 55 {
56 this->gridMatrix = gridMatrix; 56 this->gridMatrix = newGridMatrix;
57 this->gridPlane = planeFromTriangle({ 57 this->gridPlane = planeFromTriangle({
58 this->gridMatrix * glm::vec4{0, 0, 0, 1}, 58 this->gridMatrix * glm::vec4{0, 0, 0, 1},
59 this->gridMatrix * glm::vec4{1, 0, 0, 1}, 59 this->gridMatrix * glm::vec4{1, 0, 0, 1},
60 this->gridMatrix * glm::vec4{0, 1, 0, 1}, 60 this->gridMatrix * glm::vec4{0, 1, 0, 1},
61 }); 61 });
99 static QVector<QPointF> convertWorldPointsToScreenPoints( 99 static QVector<QPointF> convertWorldPointsToScreenPoints(
100 const std::vector<glm::vec3> &worldPoints, 100 const std::vector<glm::vec3> &worldPoints,
101 const PartRenderer* renderer) 101 const PartRenderer* renderer)
102 { 102 {
103 QVector<QPointF> points2d; 103 QVector<QPointF> points2d;
104 points2d.reserve(worldPoints.size()); 104 points2d.reserve(static_cast<int>(worldPoints.size()));
105 for (const glm::vec3& point : worldPoints) 105 for (const glm::vec3& point : worldPoints)
106 { 106 {
107 points2d.push_back(renderer->modelToScreenCoordinates(point)); 107 points2d.push_back(renderer->modelToScreenCoordinates(point));
108 } 108 }
109 return points2d; 109 return points2d;
328 using indextype = std::uint16_t; 328 using indextype = std::uint16_t;
329 using indexpair = std::pair<indextype, indextype>; 329 using indexpair = std::pair<indextype, indextype>;
330 struct boundaryinfo { indextype third; std::size_t triangleid; }; 330 struct boundaryinfo { indextype third; std::size_t triangleid; };
331 std::map<indexpair, boundaryinfo> boundaries; 331 std::map<indexpair, boundaryinfo> boundaries;
332 for (std::size_t i = 0; i < indices.size(); i += 3) { 332 for (std::size_t i = 0; i < indices.size(); i += 3) {
333 const auto add = [&](int o1, int o2, int o3){ 333 const auto add = [&](const std::size_t o1, const std::size_t o2, const std::size_t o3){
334 const auto key = std::make_pair(indices[i + o1], indices[i + o2]); 334 const auto key = std::make_pair(indices[i + o1], indices[i + o2]);
335 boundaries[key] = {indices[i + o3], i}; 335 boundaries[key] = {indices[i + o3], i};
336 }; 336 };
337 add(0, 1, 2); 337 add(0, 1, 2);
338 add(1, 2, 0); 338 add(1, 2, 0);

mercurial