From ed19b4b592914c061d22f2ad4e42bd277fd9d24a Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Thu, 15 Dec 2016 14:13:38 -0800 Subject: [PATCH] remove compression at the per avatar data buffer for now, since it gave no benefit --- assignment-client/src/avatars/AvatarMixer.cpp | 1 - interface/src/avatar/MyAvatar.cpp | 6 +-- interface/src/avatar/MyAvatar.h | 2 +- libraries/avatars/src/AvatarData.cpp | 46 +------------------ libraries/avatars/src/AvatarData.h | 4 +- 5 files changed, 6 insertions(+), 53 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index b394673702..90a8f65c9c 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -358,7 +358,6 @@ void AvatarMixer::broadcastAvatarData() { // determine if avatar is in view, to determine how much data to include... glm::vec3 otherNodeBoxScale = (otherNodeData->getPosition() - otherNodeData->getGlobalBoundingBoxCorner()) * 2.0f; AABox otherNodeBox(otherNodeData->getGlobalBoundingBoxCorner(), otherNodeBoxScale); - bool sendMinimumForOutOfView = !nodeData->otherAvatarInView(otherNodeBox); numAvatarDataBytes += avatarPacketList->write(otherNode->getUUID().toRfc4122()); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 50517b706c..1b1bd9f30d 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -227,7 +227,7 @@ void MyAvatar::simulateAttachments(float deltaTime) { // don't update attachments here, do it in harvestResultsFromPhysicsSimulation() } -QByteArray MyAvatar::toByteArray(bool cullSmallChanges, bool sendAll, bool sendMinimum, bool compressed) { +QByteArray MyAvatar::toByteArray(bool cullSmallChanges, bool sendAll, bool sendMinimum) { CameraMode mode = qApp->getCamera()->getMode(); _globalPosition = getPosition(); _globalBoundingBoxCorner.x = _characterController.getCapsuleRadius(); @@ -238,12 +238,12 @@ QByteArray MyAvatar::toByteArray(bool cullSmallChanges, bool sendAll, bool sendM // fake the avatar position that is sent up to the AvatarMixer glm::vec3 oldPosition = getPosition(); setPosition(getSkeletonPosition()); - QByteArray array = AvatarData::toByteArray(cullSmallChanges, sendAll, sendMinimum, compressed); + QByteArray array = AvatarData::toByteArray(cullSmallChanges, sendAll, sendMinimum); // copy the correct position back setPosition(oldPosition); return array; } - return AvatarData::toByteArray(cullSmallChanges, sendAll, sendMinimum, compressed); + return AvatarData::toByteArray(cullSmallChanges, sendAll, sendMinimum); } void MyAvatar::centerBody() { diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 609e93f616..14770fa14f 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -333,7 +333,7 @@ private: glm::vec3 getWorldBodyPosition() const; glm::quat getWorldBodyOrientation() const; - QByteArray toByteArray(bool cullSmallChanges, bool sendAll, bool sendMinimum, bool compressed) override; + QByteArray toByteArray(bool cullSmallChanges, bool sendAll, bool sendMinimum) override; void simulate(float deltaTime); void updateFromTrackers(float deltaTime); virtual void render(RenderArgs* renderArgs, const glm::vec3& cameraPositio) override; diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 3f61c5f8aa..135cf48fa3 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -181,7 +181,7 @@ void AvatarData::setHandPosition(const glm::vec3& handPosition) { _handPosition = glm::inverse(getOrientation()) * (handPosition - getPosition()); } -QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll, bool sendMinimum, bool compressed) { +QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll, bool sendMinimum) { // TODO: DRY this up to a shared method // that can pack any type given the number of bytes // and return the number of bytes to push the pointer @@ -205,11 +205,6 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll, bool sen setAtBit(packetStateFlags, AVATARDATA_FLAGS_MINIMUM); } - // do we need this, or do we just always compress it? - if (compressed) { - setAtBit(packetStateFlags, AVATARDATA_FLAGS_COMPRESSED); - } - memcpy(destinationBuffer, &packetStateFlags, sizeof(packetStateFlags)); destinationBuffer += sizeof(packetStateFlags); @@ -423,25 +418,6 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll, bool sen #endif } - // NOTE: first byte of array should always be uncompressed - - if (compressed) { - static const int SKIP_PACKET_FLAGS = 1; - static const int COMPRESSION_LEVEL = 9; - QByteArray uncompressedPortion = avatarDataByteArray.mid(SKIP_PACKET_FLAGS, - (destinationBuffer - startPosition) - SKIP_PACKET_FLAGS); - - QByteArray compressedPortion = qCompress(uncompressedPortion, COMPRESSION_LEVEL); - QByteArray flagsAndCompressed; - flagsAndCompressed.append(packetStateFlags); - flagsAndCompressed.append(compressedPortion); - - //qDebug() << __FUNCTION__ << "compressing data was:" << (uncompressedPortion.size() + SKIP_PACKET_FLAGS) << "now:" << flagsAndCompressed.size(); - - return flagsAndCompressed; - } - - // entire buffer is uncompressed return avatarDataByteArray.left(destinationBuffer - startPosition); } @@ -517,34 +493,17 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) { uint8_t packetStateFlags = buffer.at(0); bool minimumSent = oneAtBit(packetStateFlags, AVATARDATA_FLAGS_MINIMUM); - bool packetIsCompressed = oneAtBit(packetStateFlags, AVATARDATA_FLAGS_COMPRESSED); - //qDebug() << __FUNCTION__ << "NOT minimum... expecting actual content!!"; - - QByteArray uncompressBuffer; const unsigned char* startPosition = reinterpret_cast(buffer.data()); const unsigned char* endPosition = startPosition + buffer.size(); const unsigned char* sourceBuffer = startPosition + sizeof(packetStateFlags); // skip the flags!! - if (packetIsCompressed) { - uncompressBuffer = qUncompress(buffer.right(buffer.size() - sizeof(packetStateFlags))); - startPosition = reinterpret_cast(uncompressBuffer.data()); - endPosition = startPosition + uncompressBuffer.size(); - sourceBuffer = startPosition; - //qDebug() << __FUNCTION__ << "uncompressing compressed data was:" << buffer.size() << "now:" << uncompressBuffer.size(); - } - // if this is the minimum, then it only includes the flags if (minimumSent) { - //qDebug() << __FUNCTION__ << "minimum... not expecting actual content!!"; - memcpy(&_globalPosition, sourceBuffer, sizeof(_globalPosition)); sourceBuffer += sizeof(_globalPosition); int numBytesRead = (sourceBuffer - startPosition); _averageBytesReceived.updateAverage(numBytesRead); - - //qDebug() << __FUNCTION__ << "minimum... included global position!! numBytesRead:" << numBytesRead; - return numBytesRead; } @@ -760,9 +719,6 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) { sourceBuffer = unpackFauxJoint(sourceBuffer, _controllerRightHandMatrixCache); int numBytesRead = sourceBuffer - startPosition; - if (packetIsCompressed) { - numBytesRead += sizeof(packetStateFlags); - } _averageBytesReceived.updateAverage(numBytesRead); return numBytesRead; } diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index c985559913..dd23d5c86d 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -109,8 +109,6 @@ const char IS_FINGER_POINTING_FLAG = 4; // AvatarData state flags - we store the details about the packet encoding in the first byte, // before the "header" structure const char AVATARDATA_FLAGS_MINIMUM = 0; -const char AVATARDATA_FLAGS_COMPRESSED = 1; - static const float MAX_AVATAR_SCALE = 1000.0f; @@ -208,7 +206,7 @@ public: glm::vec3 getHandPosition() const; void setHandPosition(const glm::vec3& handPosition); - virtual QByteArray toByteArray(bool cullSmallChanges, bool sendAll, bool sendMinimum = false, bool compressed = false); + virtual QByteArray toByteArray(bool cullSmallChanges, bool sendAll, bool sendMinimum = false); virtual void doneEncoding(bool cullSmallChanges); /// \return true if an error should be logged