From 1a5bc5d11148185e67ca09a69a427ac7773796fa Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Thu, 3 Dec 2015 12:40:24 -0800 Subject: [PATCH] removing optional compression --- assignment-client/src/octree/OctreeQueryNode.cpp | 9 ++------- assignment-client/src/octree/OctreeQueryNode.h | 4 +--- assignment-client/src/octree/OctreeSendThread.cpp | 14 ++++---------- interface/src/Application.cpp | 1 - libraries/entities/src/EntityItemProperties.cpp | 4 +++- libraries/octree/src/OctreeHeadlessViewer.cpp | 1 - libraries/octree/src/OctreePacketData.cpp | 9 +++++---- libraries/octree/src/OctreePacketData.h | 6 +++--- libraries/octree/src/OctreeQuery.cpp | 2 -- libraries/octree/src/OctreeQuery.h | 5 +---- 10 files changed, 19 insertions(+), 36 deletions(-) diff --git a/assignment-client/src/octree/OctreeQueryNode.cpp b/assignment-client/src/octree/OctreeQueryNode.cpp index 06e9834804..cafba8c083 100644 --- a/assignment-client/src/octree/OctreeQueryNode.cpp +++ b/assignment-client/src/octree/OctreeQueryNode.cpp @@ -179,14 +179,9 @@ void OctreeQueryNode::resetOctreePacket() { // If we're moving, and the client asked for low res, then we force monochrome, otherwise, use // the clients requested color state. - _currentPacketIsCompressed = getWantCompression(); OCTREE_PACKET_FLAGS flags = 0; - if (_currentPacketIsColor) { - setAtBit(flags, PACKET_IS_COLOR_BIT); - } - if (_currentPacketIsCompressed) { - setAtBit(flags, PACKET_IS_COMPRESSED_BIT); - } + setAtBit(flags, PACKET_IS_COLOR_BIT); + setAtBit(flags, PACKET_IS_COMPRESSED_BIT); _octreePacket->reset(); diff --git a/assignment-client/src/octree/OctreeQueryNode.h b/assignment-client/src/octree/OctreeQueryNode.h index 4140d42a5f..67298296e9 100644 --- a/assignment-client/src/octree/OctreeQueryNode.h +++ b/assignment-client/src/octree/OctreeQueryNode.h @@ -77,9 +77,7 @@ public: bool getCurrentPacketIsColor() const { return _currentPacketIsColor; } bool getCurrentPacketIsCompressed() const { return _currentPacketIsCompressed; } - bool getCurrentPacketFormatMatches() { - return (getCurrentPacketIsCompressed() == getWantCompression()); - } + bool getCurrentPacketFormatMatches() { return (getCurrentPacketIsCompressed() == true); } // FIXME bool hasLodChanged() const { return _lodChanged; } diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index efc81d6a21..d01117dff6 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -321,7 +321,6 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus // If we're starting a fresh packet, then... // If we're moving, and the client asked for low res, then we force monochrome, otherwise, use // the clients requested color state. - bool wantCompression = nodeData->getWantCompression(); // If we have a packet waiting, and our desired want color, doesn't match the current waiting packets color // then let's just send that waiting packet. @@ -332,10 +331,8 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus nodeData->resetOctreePacket(); } int targetSize = MAX_OCTREE_PACKET_DATA_SIZE; - if (wantCompression) { - targetSize = nodeData->getAvailable() - sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE); - } - _packetData.changeSettings(wantCompression, targetSize); + targetSize = nodeData->getAvailable() - sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE); + _packetData.changeSettings(targetSize); } const ViewFrustum* lastViewFrustum = wantDelta ? &nodeData->getLastKnownViewFrustum() : NULL; @@ -551,10 +548,7 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus packetsSentThisInterval += handlePacketSend(nodeData, trueBytesSent, truePacketsSent); quint64 packetSendingEnd = usecTimestampNow(); packetSendingElapsedUsec = (float)(packetSendingEnd - packetSendingStart); - - if (wantCompression) { - targetSize = nodeData->getAvailable() - sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE); - } + targetSize = nodeData->getAvailable() - sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE); } else { // If we're in compressed mode, then we want to see if we have room for more in this wire packet. // but we've finalized the _packetData, so we want to start a new section, we will do that by @@ -564,7 +558,7 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus // a larger compressed size then uncompressed size targetSize = nodeData->getAvailable() - sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE) - COMPRESS_PADDING; } - _packetData.changeSettings(nodeData->getWantCompression(), targetSize); // will do reset + _packetData.changeSettings(targetSize); // will do reset } OctreeServer::trackTreeWaitTime(lockWaitElapsedUsec); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4b3775933d..053ef5b7a7 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3075,7 +3075,6 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node // These will be the same for all servers, so we can set them up once and then reuse for each server we send to. _octreeQuery.setWantLowResMoving(true); _octreeQuery.setWantDelta(true); - _octreeQuery.setWantCompression(true); _octreeQuery.setCameraPosition(_viewFrustum.getPosition()); _octreeQuery.setCameraOrientation(_viewFrustum.getOrientation()); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 78a4f3e8b6..30bee83482 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -790,7 +790,9 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue // bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItemID id, const EntityItemProperties& properties, QByteArray& buffer) { - OctreePacketData ourDataPacket(false, buffer.size()); // create a packetData object to add out packet details too. + + // FIXME - remove non-compressed OctreePacketData and handle compressed edit packets + OctreePacketData ourDataPacket(buffer.size(), false); // create a packetData object to add out packet details too. OctreePacketData* packetData = &ourDataPacket; // we want a pointer to this so we can use our APPEND_ENTITY_PROPERTY macro bool success = true; // assume the best diff --git a/libraries/octree/src/OctreeHeadlessViewer.cpp b/libraries/octree/src/OctreeHeadlessViewer.cpp index f1c2172d86..7b80d315f1 100644 --- a/libraries/octree/src/OctreeHeadlessViewer.cpp +++ b/libraries/octree/src/OctreeHeadlessViewer.cpp @@ -52,7 +52,6 @@ void OctreeHeadlessViewer::queryOctree() { // These will be the same for all servers, so we can set them up once and then reuse for each server we send to. _octreeQuery.setWantLowResMoving(true); _octreeQuery.setWantDelta(true); - _octreeQuery.setWantCompression(true); // TODO: should be on by default _octreeQuery.setCameraPosition(_viewFrustum.getPosition()); _octreeQuery.setCameraOrientation(_viewFrustum.getOrientation()); diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp index 811e96fcf4..f4fbf9bd97 100644 --- a/libraries/octree/src/OctreePacketData.cpp +++ b/libraries/octree/src/OctreePacketData.cpp @@ -23,12 +23,13 @@ AtomicUIntStat OctreePacketData::_totalBytesOfValues { 0 }; AtomicUIntStat OctreePacketData::_totalBytesOfPositions { 0 }; AtomicUIntStat OctreePacketData::_totalBytesOfRawData { 0 }; -OctreePacketData::OctreePacketData(bool enableCompression, int targetSize) { - changeSettings(enableCompression, targetSize); // does reset... +OctreePacketData::OctreePacketData(int targetSize, bool enableCompression) { + changeSettings(targetSize); // does reset... + _enableCompression = enableCompression; // FIXME } -void OctreePacketData::changeSettings(bool enableCompression, unsigned int targetSize) { - _enableCompression = enableCompression; +void OctreePacketData::changeSettings(unsigned int targetSize) { + _enableCompression = true; // FIXME _targetSize = std::min(MAX_OCTREE_UNCOMRESSED_PACKET_SIZE, targetSize); reset(); } diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index 2c86d518ad..fb53b3472f 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -83,11 +83,11 @@ private: /// Handles packing of the data portion of PacketType_OCTREE_DATA messages. class OctreePacketData { public: - OctreePacketData(bool enableCompression = false, int maxFinalizedSize = MAX_OCTREE_PACKET_DATA_SIZE); + OctreePacketData(int maxFinalizedSize = MAX_OCTREE_PACKET_DATA_SIZE, bool enableCompression = true); ~OctreePacketData(); /// change compression and target size settings - void changeSettings(bool enableCompression = false, unsigned int targetSize = MAX_OCTREE_PACKET_DATA_SIZE); + void changeSettings(unsigned int targetSize = MAX_OCTREE_PACKET_DATA_SIZE); /// reset completely, all data is discarded void reset(); @@ -262,7 +262,7 @@ private: bool append(unsigned char byte); unsigned int _targetSize; - bool _enableCompression; + bool _enableCompression { true }; // FIXME - these will always be compressed, so remove this option unsigned char _uncompressed[MAX_OCTREE_UNCOMRESSED_PACKET_SIZE]; int _bytesInUse; diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index c431d66bf2..8449e3083a 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -42,7 +42,6 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) { unsigned char bitItems = 0; if (_wantLowResMoving) { setAtBit(bitItems, WANT_LOW_RES_MOVING_BIT); } if (_wantDelta) { setAtBit(bitItems, WANT_DELTA_AT_BIT); } - if (_wantCompression) { setAtBit(bitItems, WANT_COMPRESSION); } *destinationBuffer++ = bitItems; @@ -83,7 +82,6 @@ int OctreeQuery::parseData(NLPacket& packet) { bitItems = (unsigned char)*sourceBuffer++; _wantLowResMoving = oneAtBit(bitItems, WANT_LOW_RES_MOVING_BIT); _wantDelta = oneAtBit(bitItems, WANT_DELTA_AT_BIT); - _wantCompression = oneAtBit(bitItems, WANT_COMPRESSION); // desired Max Octree PPS memcpy(&_maxQueryPPS, sourceBuffer, sizeof(_maxQueryPPS)); diff --git a/libraries/octree/src/OctreeQuery.h b/libraries/octree/src/OctreeQuery.h index 71c9361e68..962a8e1425 100644 --- a/libraries/octree/src/OctreeQuery.h +++ b/libraries/octree/src/OctreeQuery.h @@ -38,7 +38,7 @@ const int WANT_LOW_RES_MOVING_BIT = 0; const int UNUSED_BIT_1 = 1; // unused... available for new feature const int WANT_DELTA_AT_BIT = 2; const int UNUSED_BIT_3 = 3; // unused... available for new feature -const int WANT_COMPRESSION = 4; // 5th bit +const int UNUSED_BIT_4 = 4; // 5th bit, unused... available for new feature class OctreeQuery : public NodeData { Q_OBJECT @@ -73,7 +73,6 @@ public: // related to Octree Sending strategies bool getWantDelta() const { return _wantDelta; } bool getWantLowResMoving() const { return _wantLowResMoving; } - bool getWantCompression() const { return _wantCompression; } int getMaxQueryPacketsPerSecond() const { return _maxQueryPPS; } float getOctreeSizeScale() const { return _octreeElementSizeScale; } int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; } @@ -81,7 +80,6 @@ public: public slots: void setWantLowResMoving(bool wantLowResMoving) { _wantLowResMoving = wantLowResMoving; } void setWantDelta(bool wantDelta) { _wantDelta = wantDelta; } - void setWantCompression(bool wantCompression) { _wantCompression = wantCompression; } void setMaxQueryPacketsPerSecond(int maxQueryPPS) { _maxQueryPPS = maxQueryPPS; } void setOctreeSizeScale(float octreeSizeScale) { _octreeElementSizeScale = octreeSizeScale; } void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _boundaryLevelAdjust = boundaryLevelAdjust; } @@ -99,7 +97,6 @@ protected: // octree server sending items bool _wantDelta = true; bool _wantLowResMoving = true; - bool _wantCompression = false; int _maxQueryPPS = DEFAULT_MAX_OCTREE_PPS; float _octreeElementSizeScale = DEFAULT_OCTREE_SIZE_SCALE; /// used for LOD calculations int _boundaryLevelAdjust = 0; /// used for LOD calculations