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
2222 EntityTreeSendThread::EntityTreeSendThread(OctreeServer* myServer, const SharedNodePointer& node) :
2323 OctreeSendThread(myServer, node)
2424 {
25+ connect(std::static_pointer_cast<EntityTree>(myServer->getOctree()).get(), &EntityTree::editingEntityPointer, this, &EntityTreeSendThread::editingEntityPointer, Qt::QueuedConnection);
2526 connect(std::static_pointer_cast<EntityTree>(myServer->getOctree()).get(), &EntityTree::deletingEntityPointer, this, &EntityTreeSendThread::deletingEntityPointer, Qt::QueuedConnection);
2627 }
2728
@@ -108,29 +109,29 @@ void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O · 80 unmodified lines
108109 // Re-add elements from previous traversal if they still need to be sent
109110 while (!prevSendQueue.empty()) {
110111 EntityItemPointer entity = prevSendQueue.top().getEntity();
112+ bool forceSend = prevSendQueue.top().shouldForceSend();
111113 prevSendQueue.pop();
112114 if (entity) {
113115 bool success = false;
114116 AACube cube = entity->getQueryAACube(success);
115117 if (success) {
116− if (_traversal.getCurrentView().cubeIntersectsKeyhole(cube)) {
118+ if (forceSend || _traversal.getCurrentView().cubeIntersectsKeyhole(cube)) {
117119 float priority = _conicalView.computePriority(cube);
118− if (priority != PrioritizedEntity::DO_NOT_SEND) {
120+ if (forceSend || priority != PrioritizedEntity::DO_NOT_SEND) {
119121 float renderAccuracy = calculateRenderAccuracy(_traversal.getCurrentView().getPosition(),
120122 cube,
121123 _traversal.getCurrentRootSizeScale(),
122124 lodLevelOffset);
123125
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) {
126128 _sendQueue.push(PrioritizedEntity(entity, priority));
127129 _entitiesInQueue.insert(entity.get());
128130 }
129131 }
130132 }
131133 } 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));
134135 _entitiesInQueue.insert(entity.get());
135136 }
136137 }
@@ -274,8 +275,7 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree · 137 unmodified lines
274275 }
275276 }
276277 } 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));
279279 _entitiesInQueue.insert(entity.get());
280280 }
281281 });
@@ -310,8 +310,7 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree · 28 unmodified lines
310310 }
311311 }
312312 } 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));
315314 _entitiesInQueue.insert(entity.get());
316315 }
317316 }
@@ -364,8 +363,7 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree · 46 unmodified lines
364363 }
365364 }
366365 } 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));
369367 _entitiesInQueue.insert(entity.get());
370368 }
371369 }
@@ -454,6 +452,23 @@ bool EntityTreeSendThread::traverseTreeAndBuildNextPacketPayload(EncodeBitstream · 82 unmodified lines
454452 #endif // SEND_SORTED_ENTITIES
455453 }
456454
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+
457472 void EntityTreeSendThread::deletingEntityPointer(EntityItem* entity) {
458473 _knownState.erase(entity);
459474 }