| 220 [](const ConditionalEdge&) { return gl::ArrayClass::ConditionalLines; }, |
220 [](const ConditionalEdge&) { return gl::ArrayClass::ConditionalLines; }, |
| 221 element); |
221 element); |
| 222 } |
222 } |
| 223 |
223 |
| 224 template<typename Fn> |
224 template<typename Fn> |
| 225 void iterateModelPolygons(Model* model, DocumentManager* context, Fn&& fn) |
225 void iterateModelPolygons(QTextDocument* model, DocumentManager* context, Fn&& fn) |
| 226 { |
226 { |
| 227 PolygonCache* const cache = findPolygonCacheForModel(model, context); |
227 PolygonCache* const cache = findPolygonCacheForModel(model, context); |
| 228 if (cache != nullptr) { |
228 if (cache != nullptr) { |
| 229 recacheIfNeeded(cache, model, context); |
229 recacheIfNeeded(cache, model, context); |
| 230 for (const WithId<PolygonElement>& polygon : cache->polygons) { |
230 for (const WithId<PolygonElement>& polygon : cache->polygons) { |
| 258 } |
258 } |
| 259 |
259 |
| 260 /** |
260 /** |
| 261 * @brief Computes the minimum bounding box for a model |
261 * @brief Computes the minimum bounding box for a model |
| 262 */ |
262 */ |
| 263 BoundingBox gl::boundingBoxForModel(Model* model, DocumentManager* context) |
263 BoundingBox gl::boundingBoxForModel(QTextDocument* model, DocumentManager* context) |
| 264 { |
264 { |
| 265 BoundingBox result = emptyBoundingBox; |
265 BoundingBox result = emptyBoundingBox; |
| 266 iterateModelPolygons(model, context, [&](const PolygonElement& polygon) |
266 iterateModelPolygons(model, context, [&](const PolygonElement& polygon) |
| 267 { |
267 { |
| 268 visitPoints([&result](const glm::vec3& p) { |
268 visitPoints([&result](const glm::vec3& p) { |
| 275 /** |
275 /** |
| 276 * @brief gl::build Creates GL vertices for objects in the model and buffers them to shaders. |
276 * @brief gl::build Creates GL vertices for objects in the model and buffers them to shaders. |
| 277 */ |
277 */ |
| 278 void gl::build( |
278 void gl::build( |
| 279 gl::ModelShaders* shaders, |
279 gl::ModelShaders* shaders, |
| 280 Model* model, |
280 QTextDocument* model, |
| 281 const ColorTable& colorTable, |
281 const ColorTable& colorTable, |
| 282 DocumentManager* context, |
282 DocumentManager* context, |
| 283 const gl::RenderPreferences& preferences) |
283 const gl::RenderPreferences& preferences) |
| 284 { |
284 { |
| 285 for (gl::ModelShaders::ShaderObject& shader : shaders->shaderObjects) { |
285 for (gl::ModelShaders::ShaderObject& shader : shaders->shaderObjects) { |