src/polygoncache.cpp

Sun, 03 Jul 2022 21:49:15 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sun, 03 Jul 2022 21:49:15 +0300
changeset 325
64ddcd77639f
parent 318
216f02b50b0a
child 333
07e65a4c6611
permissions
-rw-r--r--

minor fix in main

264
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 250
diff changeset
1 #include "src/circularprimitive.h"
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 250
diff changeset
2 #include "src/documentmanager.h"
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 250
diff changeset
3 #include "src/invert.h"
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 250
diff changeset
4 #include "src/polygoncache.h"
150
b6cbba6e29a1 extract polygon cache out of Model
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5
200
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 193
diff changeset
6 Model* resolve(const QString& name, const ModelId callingModelId, DocumentManager* documents)
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 193
diff changeset
7 {
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 193
diff changeset
8 return documents->findDependencyByName(callingModelId, name);
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 193
diff changeset
9 }
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 193
diff changeset
10
210
232e7634cc8a more refactoring, dosn't build yet
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 205
diff changeset
11 static PolygonElement transformed(
232e7634cc8a more refactoring, dosn't build yet
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 205
diff changeset
12 PolygonElement element,
232e7634cc8a more refactoring, dosn't build yet
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 205
diff changeset
13 const glm::mat4& transform)
200
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 193
diff changeset
14 {
211
b27b90fb993f Now builds again
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 210
diff changeset
15 visitPoints([&transform](glm::vec3& p) {
210
232e7634cc8a more refactoring, dosn't build yet
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 205
diff changeset
16 p = transform * glm::vec4{p, 1};
211
b27b90fb993f Now builds again
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 210
diff changeset
17 }, element);
210
232e7634cc8a more refactoring, dosn't build yet
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 205
diff changeset
18 return element;
232e7634cc8a more refactoring, dosn't build yet
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 205
diff changeset
19 }
232e7634cc8a more refactoring, dosn't build yet
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 205
diff changeset
20
211
b27b90fb993f Now builds again
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 210
diff changeset
21 PolygonCache* findPolygonCacheForModel(Model* model, DocumentManager* context)
b27b90fb993f Now builds again
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 210
diff changeset
22 {
b27b90fb993f Now builds again
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 210
diff changeset
23 std::optional<ModelId> modelId = context->findIdForModel(model);
b27b90fb993f Now builds again
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 210
diff changeset
24 if (modelId.has_value()) {
b27b90fb993f Now builds again
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 210
diff changeset
25 return context->getPolygonCacheForModel(modelId.value());
b27b90fb993f Now builds again
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 210
diff changeset
26 }
b27b90fb993f Now builds again
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 210
diff changeset
27 else {
b27b90fb993f Now builds again
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 210
diff changeset
28 return nullptr;
b27b90fb993f Now builds again
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 210
diff changeset
29 }
b27b90fb993f Now builds again
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 210
diff changeset
30 }
b27b90fb993f Now builds again
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 210
diff changeset
31
318
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
32 constexpr bool n_xor(bool a)
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
33 {
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
34 return a;
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
35 }
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
36
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
37 template<typename... Args>
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
38 constexpr bool n_xor(bool a, Args&&... rest)
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
39 {
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
40 return a xor n_xor(rest...);
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
41 }
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
42
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
43 template<typename Fn, typename Fn2>
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
44 static void inlineSubfileReference(
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
45 const PolygonCache::vector_type& polygons,
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
46 const Colored<SubfileReference>& ref,
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
47 Fn&& add,
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
48 Fn2&& reserve)
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
49 {
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
50 const bool needInverting = 0
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
51 ^ (glm::determinant(ref.transformation) < 0)
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
52 ^ (ref.inverted);
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
53 reserve(polygons.size());
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
54 for (const PolygonElement& cacheElement : polygons) {
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
55 PolygonElement polygon = transformed(cacheElement, ref.transformation);
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
56 if (needInverting) {
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
57 gl::invert(polygon);
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
58 }
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
59 if (polygon.color == MAIN_COLOR) {
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
60 polygon.color = ref.color;
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
61 }
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
62 add(polygon);
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
63 }
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
64 }
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
65
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
66 Model* findDependency(const SubfileReference& ref, GetPolygonsContext* context)
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
67 {
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
68 return context->documents->findDependencyByName(context->modelId, ref.name);
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
69 }
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
70
305
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
71 template<typename Fn, typename Fn2>
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
72 static void collectPolygons(
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
73 const ModelElement& element,
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
74 Winding& winding,
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
75 GetPolygonsContext* context,
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
76 Fn&& add,
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
77 Fn2&& reserve)
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
78 {
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
79 std::visit<void>(overloaded{
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
80 [&](const Colored<LineSegment>& edge) {
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
81 add({edge, edge.color});
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
82 },
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
83 [&](const Colored<Triangle>& triangle) {
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
84 add({triangle, triangle.color});
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
85 },
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
86 [&](const Colored<Quadrilateral>& quad) {
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
87 add({quad, quad.color});
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
88 },
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
89 [&](const Colored<ConditionalEdge>& cedge) {
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
90 add({cedge, cedge.color});
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
91 },
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
92 [&add, context, &reserve](const Colored<SubfileReference>& ref) {
318
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
93 Model* const dependency = findDependency(ref, context);
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
94 if (PolygonCache* cache = (dependency != nullptr)
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
95 ? findPolygonCacheForModel(dependency, context->documents)
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
96 : nullptr
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
97 ) {
305
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
98 recacheIfNeeded(cache, dependency, context->documents);
318
216f02b50b0a Reduce indent level
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
99 inlineSubfileReference(cache->polygons, ref, add, reserve);
305
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
100 }
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
101 },
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
102 [&add](const Colored<CircularPrimitive>& circ) {
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
103 rasterize(circ, [&](const PlainPolygonElement& polygon, ColorIndex color){
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
104 if (color == MAIN_COLOR) {
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
105 color = circ.color;
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
106 }
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
107 add(PolygonElement{polygon, color});
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
108 });
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
109 },
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
110 [&winding](const Comment& comment) {
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
111 if (comment.text == QStringLiteral("BFC CERTIFY CW")) {
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
112 winding = Clockwise;
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
113 }
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
114 else if (comment.text == QStringLiteral("BFC CERTIFY CCW")) {
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
115 winding = Anticlockwise;
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
116 }
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
117 else if (comment.text == QStringLiteral("BFC NOCERTIFY")) {
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
118 winding = NoWinding;
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
119 }
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
120 },
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
121 [](const ModelElement&) {}
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
122 }, element);
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
123 }
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
124
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
125 static std::vector<WithId<PolygonElement>> inlinePolygons(
210
232e7634cc8a more refactoring, dosn't build yet
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 205
diff changeset
126 const Model* model,
232e7634cc8a more refactoring, dosn't build yet
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 205
diff changeset
127 GetPolygonsContext* context)
232e7634cc8a more refactoring, dosn't build yet
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 205
diff changeset
128 {
305
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
129 Winding winding = NoWinding;
210
232e7634cc8a more refactoring, dosn't build yet
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 205
diff changeset
130 std::vector<WithId<PolygonElement>> result;
250
2837b549e616 I felt that the compiler was too kind to me, so I enabled a big pile of warnings
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 232
diff changeset
131 for (std::size_t i = 0; i < model->size(); i += 1)
200
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 193
diff changeset
132 {
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 193
diff changeset
133 const ModelElement& element = (*model)[i];
309
d862721d19a3 Fixed ModelId being used to identify both models and elements, added ElementId to identify elements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 305
diff changeset
134 const ElementId id = model->idAt(i);
305
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
135 collectPolygons(element, winding, context,
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
136 [&result, winding, id](const PolygonElement& poly){
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
137 result.push_back({poly, id});
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
138 if (winding == Winding::Clockwise) {
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
139 gl::invert(result.back());
200
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 193
diff changeset
140 }
305
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
141 }, [&result](std::size_t incomingsize){
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
142 reserveMore(result, incomingsize);
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
143 });
200
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 193
diff changeset
144 }
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 193
diff changeset
145 return result;
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 193
diff changeset
146 }
150
b6cbba6e29a1 extract polygon cache out of Model
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
147
305
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
148 void recacheIfNeeded(PolygonCache *cache, Model *model, DocumentManager *documents)
150
b6cbba6e29a1 extract polygon cache out of Model
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
149 {
193
b4beff48bb7a Simplify PolygonCache
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
150 if (cache->needRecache)
150
b6cbba6e29a1 extract polygon cache out of Model
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
151 {
305
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
152 cache->polygons.clear();
193
b4beff48bb7a Simplify PolygonCache
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
153 const std::optional<ModelId> modelId = documents->findIdForModel(model);
150
b6cbba6e29a1 extract polygon cache out of Model
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
154 if (modelId.has_value())
b6cbba6e29a1 extract polygon cache out of Model
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
155 {
200
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 193
diff changeset
156 GetPolygonsContext context{modelId.value(), documents};
305
d891da20abca Add support for BFC CERTIFY statements
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
157 cache->polygons = inlinePolygons(model, &context);
150
b6cbba6e29a1 extract polygon cache out of Model
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
158 }
193
b4beff48bb7a Simplify PolygonCache
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
159 cache->needRecache = false;
150
b6cbba6e29a1 extract polygon cache out of Model
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
160 }
b6cbba6e29a1 extract polygon cache out of Model
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
161 }

mercurial