Showing the changes to assignment-client/src/entities/EntityTreeSendThread.cpp (1 of 8 files). Show all
Unified · Split
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | EntityTreeSendThread::EntityTreeSendThread(OctreeServer* myServer, const SharedNodePointer& node) : |
| 23 | 23 | OctreeSendThread(myServer, node) |
| 24 | 24 | { |
| 25 | + connect(std::static_pointer_cast<EntityTree>(myServer->getOctree()).get(), &EntityTree::editingEntityPointer, this, &EntityTreeSendThread::editingEntityPointer, Qt::QueuedConnection); | |
| 25 | 26 | connect(std::static_pointer_cast<EntityTree>(myServer->getOctree()).get(), &EntityTree::deletingEntityPointer, this, &EntityTreeSendThread::deletingEntityPointer, Qt::QueuedConnection); |
| 26 | 27 | } |
| 27 | 28 | |
| @@ -108,29 +109,29 @@ void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O · 80 unmodified lines | ||
| 108 | 109 | // Re-add elements from previous traversal if they still need to be sent |
| 109 | 110 | while (!prevSendQueue.empty()) { |
| 110 | 111 | EntityItemPointer entity = prevSendQueue.top().getEntity(); |
| 112 | + bool forceSend = prevSendQueue.top().shouldForceSend(); | |
| 111 | 113 | prevSendQueue.pop(); |
| 112 | 114 | if (entity) { |
| 113 | 115 | bool success = false; |
| 114 | 116 | AACube cube = entity->getQueryAACube(success); |
| 115 | 117 | if (success) { |
| 116 | − if (_traversal.getCurrentView().cubeIntersectsKeyhole(cube)) { | |
| 118 | + if (forceSend || _traversal.getCurrentView().cubeIntersectsKeyhole(cube)) { | |
| 117 | 119 | float priority = _conicalView.computePriority(cube); |
| 118 | − if (priority != PrioritizedEntity::DO_NOT_SEND) { | |
| 120 | + if (forceSend || priority != PrioritizedEntity::DO_NOT_SEND) { | |
| 119 | 121 | float renderAccuracy = calculateRenderAccuracy(_traversal.getCurrentView().getPosition(), |
| 120 | 122 | cube, |
| 121 | 123 | _traversal.getCurrentRootSizeScale(), |
| 122 | 124 | lodLevelOffset); |
| 123 | 125 | |
| 124 | − // Only send entities if they are large enough to see | |
| 125 | − if (renderAccuracy > 0.0f) { | |
| 126 | + // Only send entities if they are large enough to see, or we need to update them to be out of view | |
| 127 | + if (forceSend || renderAccuracy > 0.0f) { | |
| 126 | 128 | _sendQueue.push(PrioritizedEntity(entity, priority)); |
| 127 | 129 | _entitiesInQueue.insert(entity.get()); |
| 128 | 130 | } |
| 129 | 131 | } |
| 130 | 132 | } |
| 131 | 133 | } else { |
| 132 | − const float WHEN_IN_DOUBT_PRIORITY = 1.0f; | |
| 133 | − _sendQueue.push(PrioritizedEntity(entity, WHEN_IN_DOUBT_PRIORITY)); | |
| 134 | + _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY)); | |
| 134 | 135 | _entitiesInQueue.insert(entity.get()); |
| 135 | 136 | } |
| 136 | 137 | } |
| @@ -274,8 +275,7 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree · 137 unmodified lines | ||
| 274 | 275 | } |
| 275 | 276 | } |
| 276 | 277 | } else { |
| 277 | − const float WHEN_IN_DOUBT_PRIORITY = 1.0f; | |
| 278 | − _sendQueue.push(PrioritizedEntity(entity, WHEN_IN_DOUBT_PRIORITY)); | |
| 278 | + _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY)); | |
| 279 | 279 | _entitiesInQueue.insert(entity.get()); |
| 280 | 280 | } |
| 281 | 281 | }); |
| @@ -310,8 +310,7 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree · 28 unmodified lines | ||
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | } else { |
| 313 | − const float WHEN_IN_DOUBT_PRIORITY = 1.0f; | |
| 314 | − _sendQueue.push(PrioritizedEntity(entity, WHEN_IN_DOUBT_PRIORITY)); | |
| 313 | + _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY)); | |
| 315 | 314 | _entitiesInQueue.insert(entity.get()); |
| 316 | 315 | } |
| 317 | 316 | } |
| @@ -364,8 +363,7 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree · 46 unmodified lines | ||
| 364 | 363 | } |
| 365 | 364 | } |
| 366 | 365 | } else { |
| 367 | − const float WHEN_IN_DOUBT_PRIORITY = 1.0f; | |
| 368 | − _sendQueue.push(PrioritizedEntity(entity, WHEN_IN_DOUBT_PRIORITY)); | |
| 366 | + _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY)); | |
| 369 | 367 | _entitiesInQueue.insert(entity.get()); |
| 370 | 368 | } |
| 371 | 369 | } |
| @@ -454,6 +452,23 @@ bool EntityTreeSendThread::traverseTreeAndBuildNextPacketPayload(EncodeBitstream · 82 unmodified lines | ||
| 454 | 452 | #endif // SEND_SORTED_ENTITIES |
| 455 | 453 | } |
| 456 | 454 | |
| 455 | +void EntityTreeSendThread::editingEntityPointer(const EntityItemPointer entity) { | |
| 456 | + if (entity) { | |
| 457 | + if (_entitiesInQueue.find(entity.get()) == _entitiesInQueue.end() && _knownState.find(entity.get()) != _knownState.end()) { | |
| 458 | + bool success = false; | |
| 459 | + AACube cube = entity->getQueryAACube(success); | |
| 460 | + if (success) { | |
| 461 | + float priority = _conicalView.computePriority(cube); | |
| 462 | + _sendQueue.push(PrioritizedEntity(entity, priority, true)); | |
| 463 | + _entitiesInQueue.insert(entity.get()); | |
| 464 | + } else { | |
| 465 | + _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY, true)); | |
| 466 | + _entitiesInQueue.insert(entity.get()); | |
| 467 | + } | |
| 468 | + } | |
| 469 | + } | |
| 470 | +} | |
| 471 | + | |
| 457 | 472 | void EntityTreeSendThread::deletingEntityPointer(EntityItem* entity) { |
| 458 | 473 | _knownState.erase(entity); |
| 459 | 474 | } |