Showing the changes to assignment-client/src/entities/EntityTreeSendThread.cpp (1 of 1 file). Show all
Unified · Split
| @@ -25,9 +25,9 @@ void PrioritizedEntity::updatePriority(const ViewFrustum& view) { · 24 unmodified lines | ||
| 25 | 25 | bool success; |
| 26 | 26 | AACube cube = entity->getQueryAACube(success); |
| 27 | 27 | if (success) { |
| 28 | − glm::vec3 center = cube.calcCenter() - view.getPosition(); | |
| 28 | + glm::vec3 offset = cube.calcCenter() - view.getPosition(); | |
| 29 | 29 | const float MIN_DISTANCE = 0.001f; |
| 30 | − float distanceToCenter = glm::length(center) + MIN_DISTANCE; | |
| 30 | + float distanceToCenter = glm::length(offset) + MIN_DISTANCE; | |
| 31 | 31 | float distance = distanceToCenter; //- 0.5f * cube.getScale(); |
| 32 | 32 | if (distance < MIN_DISTANCE) { |
| 33 | 33 | // this object's bounding box overlaps the camera --> give it a big priority |
| @@ -35,8 +35,8 @@ void PrioritizedEntity::updatePriority(const ViewFrustum& view) { · 1 unmodified line | ||
| 35 | 35 | } else { |
| 36 | 36 | // NOTE: we assume view.aspectRatio < 1.0 (view width greater than height) |
| 37 | 37 | // so we only check against the larger (horizontal) view angle |
| 38 | − float front = glm::dot(center, view.getDirection()) / distanceToCenter; | |
| 39 | − if (front > cosf(view.getFieldOfView()) || distance < view.getCenterRadius()) { | |
| 38 | + float front = glm::dot(offset, view.getDirection()) / distanceToCenter; | |
| 39 | + if (front > cosf(glm::radians(view.getFieldOfView())) || distance < view.getCenterRadius()) { | |
| 40 | 40 | _priority = cube.getScale() / distance; // + front; |
| 41 | 41 | } else { |
| 42 | 42 | _priority = INVALID_ENTITY_SEND_PRIORITY; |
| @@ -84,15 +84,8 @@ EntityTreeElementPointer TreeTraversalPath::Fork::getNextElementAgain(const View · 41 unmodified lines | ||
| 84 | 84 | ++_nextIndex; |
| 85 | 85 | EntityTreeElementPointer element = _weakElement.lock(); |
| 86 | 86 | assert(element); // should never lose root element |
| 87 | − if (element->getLastChanged() < oldTime) { | |
| 88 | − _nextIndex = NUMBER_OF_CHILDREN; | |
| 89 | − return EntityTreeElementPointer(); | |
| 90 | − } | |
| 91 | − if (element->getLastChanged() > oldTime) { | |
| 92 | − return element; | |
| 93 | − } | |
| 94 | − } | |
| 95 | − if (_nextIndex < NUMBER_OF_CHILDREN) { | |
| 87 | + return element; | |
| 88 | + } else if (_nextIndex < NUMBER_OF_CHILDREN) { | |
| 96 | 89 | EntityTreeElementPointer element = _weakElement.lock(); |
| 97 | 90 | if (element) { |
| 98 | 91 | while (_nextIndex < NUMBER_OF_CHILDREN) { |
| @@ -115,10 +108,6 @@ EntityTreeElementPointer TreeTraversalPath::Fork::getNextElementDelta(const View · 16 unmodified lines | ||
| 115 | 108 | ++_nextIndex; |
| 116 | 109 | EntityTreeElementPointer element = _weakElement.lock(); |
| 117 | 110 | assert(element); // should never lose root element |
| 118 | − if (element->getLastChanged() < oldTime) { | |
| 119 | − _nextIndex = NUMBER_OF_CHILDREN; | |
| 120 | − return EntityTreeElementPointer(); | |
| 121 | − } | |
| 122 | 111 | return element; |
| 123 | 112 | } else if (_nextIndex < NUMBER_OF_CHILDREN) { |
| 124 | 113 | EntityTreeElementPointer element = _weakElement.lock(); |
| @@ -282,13 +271,14 @@ static size_t adebug = 0; · 157 unmodified lines | ||
| 282 | 271 | |
| 283 | 272 | void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, OctreeQueryNode* nodeData, |
| 284 | 273 | bool viewFrustumChanged, bool isFullScene) { |
| 285 | − if (viewFrustumChanged) { | |
| 274 | + static int foo=0;++foo;bool verbose=(0==(foo%800)); // adebug | |
| 275 | + if (viewFrustumChanged || verbose) { | |
| 286 | 276 | ViewFrustum view; |
| 287 | 277 | nodeData->copyCurrentViewFrustum(view); |
| 278 | + std::cout << "adebug reset view" << std::endl; // adebug | |
| 288 | 279 | EntityTreeElementPointer root = std::dynamic_pointer_cast<EntityTreeElement>(_myServer->getOctree()->getRoot()); |
| 289 | 280 | _path.startNewTraversal(view, root); |
| 290 | 281 | |
| 291 | − std::cout << "adebug reset view" << std::endl; // adebug | |
| 292 | 282 | adebug = 0; |
| 293 | 283 | } |
| 294 | 284 | if (!_path.empty()) { |
| @@ -321,6 +311,7 @@ void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O · 26 unmodified lines | ||
| 321 | 311 | std::cout << "adebug traverseTreeAndSendContents totalEntities = " << adebug |
| 322 | 312 | << " numElements = " << numElements |
| 323 | 313 | << " numEntities = " << entities.size() |
| 314 | + << " queueSize = " << _sendQueue.size() | |
| 324 | 315 | << " dt = " << dt1 << std::endl; // adebug |
| 325 | 316 | } else if (!_sendQueue.empty()) { |
| 326 | 317 | while (!_sendQueue.empty()) { |