History

trying to fix entity editing bugs, needs testing

SamGondelman committed 9 years ago

Commit 0ad5f471 parent 6c066608 files · +45 −18Browse files

Showing the changes to assignment-client/src/entities/EntityTreeSendThread.cpp (1 of 8 files). Show all

Unified · Split

assignment-client/src/entities/EntityTreeSendThread.cpp+27−12
@@ -22,6 +22,7 @@ · 21 unmodified lines
22EntityTreeSendThread::EntityTreeSendThread(OctreeServer* myServer, const SharedNodePointer& node) :22EntityTreeSendThread::EntityTreeSendThread(OctreeServer* myServer, const SharedNodePointer& node) :
23 OctreeSendThread(myServer, node)23 OctreeSendThread(myServer, node)
24{24{
25 connect(std::static_pointer_cast<EntityTree>(myServer->getOctree()).get(), &EntityTree::editingEntityPointer, this, &EntityTreeSendThread::editingEntityPointer, Qt::QueuedConnection);
25 connect(std::static_pointer_cast<EntityTree>(myServer->getOctree()).get(), &EntityTree::deletingEntityPointer, this, &EntityTreeSendThread::deletingEntityPointer, Qt::QueuedConnection);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 // Re-add elements from previous traversal if they still need to be sent109 // Re-add elements from previous traversal if they still need to be sent
109 while (!prevSendQueue.empty()) {110 while (!prevSendQueue.empty()) {
110 EntityItemPointer entity = prevSendQueue.top().getEntity();111 EntityItemPointer entity = prevSendQueue.top().getEntity();
112 bool forceSend = prevSendQueue.top().shouldForceSend();
111 prevSendQueue.pop();113 prevSendQueue.pop();
112 if (entity) {114 if (entity) {
113 bool success = false;115 bool success = false;
114 AACube cube = entity->getQueryAACube(success);116 AACube cube = entity->getQueryAACube(success);
115 if (success) {117 if (success) {
116 if (_traversal.getCurrentView().cubeIntersectsKeyhole(cube)) {118 if (forceSend || _traversal.getCurrentView().cubeIntersectsKeyhole(cube)) {
117 float priority = _conicalView.computePriority(cube);119 float priority = _conicalView.computePriority(cube);
118 if (priority != PrioritizedEntity::DO_NOT_SEND) {120 if (forceSend || priority != PrioritizedEntity::DO_NOT_SEND) {
119 float renderAccuracy = calculateRenderAccuracy(_traversal.getCurrentView().getPosition(),121 float renderAccuracy = calculateRenderAccuracy(_traversal.getCurrentView().getPosition(),
120 cube,122 cube,
121 _traversal.getCurrentRootSizeScale(),123 _traversal.getCurrentRootSizeScale(),
122 lodLevelOffset);124 lodLevelOffset);
123 125
124 // Only send entities if they are large enough to see126 // Only send entities if they are large enough to see, or we need to update them to be out of view
125 if (renderAccuracy > 0.0f) {127 if (forceSend || renderAccuracy > 0.0f) {
126 _sendQueue.push(PrioritizedEntity(entity, priority));128 _sendQueue.push(PrioritizedEntity(entity, priority));
127 _entitiesInQueue.insert(entity.get());129 _entitiesInQueue.insert(entity.get());
128 }130 }
129 }131 }
130 }132 }
131 } else {133 } else {
132 const float WHEN_IN_DOUBT_PRIORITY = 1.0f;134 _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY));
133 _sendQueue.push(PrioritizedEntity(entity, WHEN_IN_DOUBT_PRIORITY));
134 _entitiesInQueue.insert(entity.get());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 } else {277 } else {
277 const float WHEN_IN_DOUBT_PRIORITY = 1.0f;278 _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY));
278 _sendQueue.push(PrioritizedEntity(entity, WHEN_IN_DOUBT_PRIORITY));
279 _entitiesInQueue.insert(entity.get());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 } else {312 } else {
313 const float WHEN_IN_DOUBT_PRIORITY = 1.0f;313 _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY));
314 _sendQueue.push(PrioritizedEntity(entity, WHEN_IN_DOUBT_PRIORITY));
315 _entitiesInQueue.insert(entity.get());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 } else {365 } else {
367 const float WHEN_IN_DOUBT_PRIORITY = 1.0f;366 _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY));
368 _sendQueue.push(PrioritizedEntity(entity, WHEN_IN_DOUBT_PRIORITY));
369 _entitiesInQueue.insert(entity.get());367 _entitiesInQueue.insert(entity.get());
370 }368 }
371 }369 }
@@ -454,6 +452,23 @@ bool EntityTreeSendThread::traverseTreeAndBuildNextPacketPayload(EncodeBitstream · 82 unmodified lines
454#endif // SEND_SORTED_ENTITIES452#endif // SEND_SORTED_ENTITIES
455}453}
456 454
455void 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
457void EntityTreeSendThread::deletingEntityPointer(EntityItem* entity) {472void EntityTreeSendThread::deletingEntityPointer(EntityItem* entity) {
458 _knownState.erase(entity);473 _knownState.erase(entity);
459}474}