src/glcompiler.cpp

changeset 1440
265b2e95a8e8
parent 1436
241d3e452b32
equal deleted inserted replaced
1436:241d3e452b32 1440:265b2e95a8e8
254 } 254 }
255 255
256 /* 256 /*
257 * Stages the given object for compilation. 257 * Stages the given object for compilation.
258 */ 258 */
259 void gl::Compiler::stageForCompilation(const QModelIndex& index) 259 void gl::Compiler::stageForCompilation(const Uuid& index)
260 { 260 {
261 m_staged.insert(index); 261 m_staged.insert(index);
262 } 262 }
263 263
264 /* 264 /*
265 * Removes an object from the set of objects to be compiled. 265 * Removes an object from the set of objects to be compiled.
266 */ 266 */
267 void gl::Compiler::unstage(const QModelIndex& index) 267 void gl::Compiler::unstage(const Uuid& index)
268 { 268 {
269 m_staged.remove(index); 269 m_staged.remove(index);
270 } 270 }
271 271
272 /* 272 /*
322 } 322 }
323 323
324 /* 324 /*
325 * Removes the data related to the given object. 325 * Removes the data related to the given object.
326 */ 326 */
327 void gl::Compiler::dropObjectInfo(const QModelIndex& index) 327 void gl::Compiler::dropObjectInfo(const Uuid& index)
328 { 328 {
329 if (m_objectInfo.contains(index)) 329 if (m_objectInfo.contains(index))
330 { 330 {
331 // If we have data relating to this object, remove it. 331 // If we have data relating to this object, remove it.
332 // The VBOs have changed now and need to be merged. 332 // The VBOs have changed now and need to be merged.
337 } 337 }
338 338
339 /* 339 /*
340 * Makes the compiler forget about the given object completely. 340 * Makes the compiler forget about the given object completely.
341 */ 341 */
342 void gl::Compiler::forgetObject(QModelIndex index) 342 void gl::Compiler::forgetObject(const Uuid& index)
343 { 343 {
344 dropObjectInfo(index); 344 dropObjectInfo(index);
345 unstage(index); 345 unstage(index);
346 } 346 }
347 347
348 /* 348 /*
349 * Compiles a single object. 349 * Compiles a single object.
350 */ 350 */
351 void gl::Compiler::compileObject(const QModelIndex& index) 351 void gl::Compiler::compileObject(const Uuid& id)
352 { 352 {
353 LDObject* object = m_renderer->model()->lookup(index); 353 LDObject* object = m_renderer->model()->lookup(id);
354 354
355 if (object == nullptr) 355 if (object == nullptr)
356 return; 356 return;
357 357
358 ObjectVboData info; 358 ObjectVboData info;
359 dropObjectInfo(index); 359 dropObjectInfo(id);
360 360
361 switch (object->type()) 361 switch (object->type())
362 { 362 {
363 // Note: We cannot split quads into triangles here, it would mess up the 363 // Note: We cannot split quads into triangles here, it would mess up the
364 // wireframe view. Quads must go into separate vbos. 364 // wireframe view. Quads must go into separate vbos.
495 495
496 // If the bounding box is invalid, rebuild it now. 496 // If the bounding box is invalid, rebuild it now.
497 if (this->needBoundingBoxRebuild) 497 if (this->needBoundingBoxRebuild)
498 { 498 {
499 this->boundingBox = {}; 499 this->boundingBox = {};
500 QMapIterator<QPersistentModelIndex, ObjectVboData> iterator {m_objectInfo}; 500 QMapIterator<Uuid, ObjectVboData> iterator {m_objectInfo};
501 501
502 while (iterator.hasNext()) 502 while (iterator.hasNext())
503 { 503 {
504 iterator.next(); 504 iterator.next();
505 505
644 void gl::Compiler::clearSelectionModel() 644 void gl::Compiler::clearSelectionModel()
645 { 645 {
646 this->setSelectionModel(nullptr); 646 this->setSelectionModel(nullptr);
647 emit sceneChanged(); 647 emit sceneChanged();
648 } 648 }
649
650 void gl::Compiler::objectRemoved(const Uuid& id)
651 {
652 this->m_objectInfo.remove(id);
653 }

mercurial