remove compression at the per avatar data buffer for now, since it gave no benefit

This commit is contained in:
Brad Hefta-Gaub 2016-12-15 14:13:38 -08:00
parent 439434b300
commit ed19b4b592
5 changed files with 6 additions and 53 deletions
assignment-client/src/avatars
interface/src/avatar
libraries/avatars/src

View file

@ -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());

View file

@ -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() {

View file

@ -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;

View file

@ -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<const unsigned char*>(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<const unsigned char*>(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;
}

View file

@ -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