diff --git a/libraries/voxel-server-library/src/VoxelNodeData.cpp b/libraries/voxel-server-library/src/VoxelNodeData.cpp index 705ea8b2e7..57e42b634a 100644 --- a/libraries/voxel-server-library/src/VoxelNodeData.cpp +++ b/libraries/voxel-server-library/src/VoxelNodeData.cpp @@ -23,7 +23,10 @@ VoxelNodeData::VoxelNodeData(Node* owningNode) : _viewFrustumChanging(false), _viewFrustumJustStoppedChanging(true), _currentPacketIsColor(true), - _voxelSendThread(NULL) + _voxelSendThread(NULL), + _lastClientBoundaryLevelAdjust(0), + _lastClientVoxelSizeScale(DEFAULT_VOXEL_SIZE_SCALE), + _lodChanged(false) { _voxelPacket = new unsigned char[MAX_VOXEL_PACKET_SIZE]; _voxelPacketAt = _voxelPacket; @@ -140,6 +143,17 @@ bool VoxelNodeData::updateCurrentViewFrustum() { currentViewFrustumChanged = true; } + // Also check for LOD changes from the client + if (_lastClientBoundaryLevelAdjust != getBoundaryLevelAdjust()) { + _lastClientBoundaryLevelAdjust = getBoundaryLevelAdjust(); + _lodChanged = true; + } + if (_lastClientVoxelSizeScale != getVoxelSizeScale()) { + _lastClientVoxelSizeScale = getVoxelSizeScale(); + _lodChanged = true; + } + + // When we first detect that the view stopped changing, we record this. // but we don't change it back to false until we've completely sent this // scene. @@ -154,6 +168,7 @@ void VoxelNodeData::setViewSent(bool viewSent) { _viewSent = viewSent; if (viewSent) { _viewFrustumJustStoppedChanging = false; + _lodChanged = false; } } diff --git a/libraries/voxel-server-library/src/VoxelNodeData.h b/libraries/voxel-server-library/src/VoxelNodeData.h index 4049cdda36..ef5b32a894 100644 --- a/libraries/voxel-server-library/src/VoxelNodeData.h +++ b/libraries/voxel-server-library/src/VoxelNodeData.h @@ -48,25 +48,27 @@ public: VoxelNodeBag nodeBag; CoverageMap map; - ViewFrustum& getCurrentViewFrustum() { return _currentViewFrustum; }; - ViewFrustum& getLastKnownViewFrustum() { return _lastKnownViewFrustum; }; + ViewFrustum& getCurrentViewFrustum() { return _currentViewFrustum; }; + ViewFrustum& getLastKnownViewFrustum() { return _lastKnownViewFrustum; }; // These are not classic setters because they are calculating and maintaining state // which is set asynchronously through the network receive bool updateCurrentViewFrustum(); void updateLastKnownViewFrustum(); - bool getViewSent() const { return _viewSent; }; + bool getViewSent() const { return _viewSent; }; void setViewSent(bool viewSent); - bool getViewFrustumChanging() const { return _viewFrustumChanging; }; + bool getViewFrustumChanging() const { return _viewFrustumChanging; }; bool getViewFrustumJustStoppedChanging() const { return _viewFrustumJustStoppedChanging; }; - uint64_t getLastTimeBagEmpty() const { return _lastTimeBagEmpty; }; - void setLastTimeBagEmpty(uint64_t lastTimeBagEmpty) { _lastTimeBagEmpty = lastTimeBagEmpty; }; + uint64_t getLastTimeBagEmpty() const { return _lastTimeBagEmpty; }; + void setLastTimeBagEmpty(uint64_t lastTimeBagEmpty) { _lastTimeBagEmpty = lastTimeBagEmpty; }; bool getCurrentPacketIsColor() const { return _currentPacketIsColor; }; + + bool hasLodChanged() const { return _lodChanged; }; VoxelSceneStats stats; @@ -98,6 +100,11 @@ private: bool _currentPacketIsColor; VoxelSendThread* _voxelSendThread; + + // watch for LOD changes + int _lastClientBoundaryLevelAdjust; + float _lastClientVoxelSizeScale; + bool _lodChanged; }; #endif /* defined(__hifi__VoxelNodeData__) */ diff --git a/libraries/voxel-server-library/src/VoxelSendThread.cpp b/libraries/voxel-server-library/src/VoxelSendThread.cpp index e3705643b7..2cfb72a246 100644 --- a/libraries/voxel-server-library/src/VoxelSendThread.cpp +++ b/libraries/voxel-server-library/src/VoxelSendThread.cpp @@ -194,7 +194,8 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no } // start tracking our stats - bool isFullScene = (!viewFrustumChanged || !nodeData->getWantDelta()) && nodeData->getViewFrustumJustStoppedChanging(); + bool isFullScene = ((!viewFrustumChanged || !nodeData->getWantDelta()) + && nodeData->getViewFrustumJustStoppedChanging()) || nodeData->hasLodChanged(); // If we're starting a full scene, then definitely we want to empty the nodeBag if (isFullScene) { @@ -258,11 +259,8 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no ? LOW_RES_MOVING_ADJUST : NO_BOUNDARY_ADJUST); - printf("packetLoop() voxelSizeScale=%f boundaryLevelAdjustClient=%d boundaryLevelAdjust=%d\n", - voxelSizeScale, boundaryLevelAdjustClient, boundaryLevelAdjust); - - bool isFullScene = (!viewFrustumChanged || !nodeData->getWantDelta()) && - nodeData->getViewFrustumJustStoppedChanging(); + bool isFullScene = ((!viewFrustumChanged || !nodeData->getWantDelta()) && + nodeData->getViewFrustumJustStoppedChanging()) || nodeData->hasLodChanged(); EncodeBitstreamParams params(INT_MAX, &nodeData->getCurrentViewFrustum(), wantColor, WANT_EXISTS_BITS, DONT_CHOP, wantDelta, lastViewFrustum,