From f02ffa92fdb03b8a6afd85e95761c62843b113f9 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 15 Jun 2016 18:00:08 -0700 Subject: [PATCH] undo debugging --- libraries/avatars/src/AvatarData.cpp | 33 ++++++++++++++-------------- libraries/avatars/src/AvatarData.h | 2 +- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 0ae58ca1de..c98fec0d7d 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -261,7 +261,7 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) { unsigned char validity = 0; int validityBit = 0; - #if 1 + #ifdef WANT_DEBUG int rotationSentCount = 0; unsigned char* beforeRotations = destinationBuffer; #endif @@ -276,7 +276,7 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) { fabsf(glm::dot(data.rotation, _lastSentJointData[i].rotation)) <= AVATAR_MIN_ROTATION_DOT) { if (data.rotationSet) { validity |= (1 << validityBit); - #if 1 + #ifdef WANT_DEBUG rotationSentCount++; #endif } @@ -310,7 +310,7 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) { validity = 0; validityBit = 0; - #if 1 + #ifdef WANT_DEBUG int translationSentCount = 0; unsigned char* beforeTranslations = destinationBuffer; #endif @@ -324,7 +324,7 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) { glm::distance(data.translation, _lastSentJointData[i].translation) > AVATAR_MIN_TRANSLATION) { if (data.translationSet) { validity |= (1 << validityBit); - #if 1 + #ifdef WANT_DEBUG translationSentCount++; #endif maxTranslationDimension = glm::max(fabsf(data.translation.x), maxTranslationDimension); @@ -359,7 +359,7 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) { } } - #if 1 + #ifdef WANT_DEBUG if (sendAll) { qDebug() << "AvatarData::toByteArray" << cullSmallChanges << sendAll << "rotations:" << rotationSentCount << "translations:" << translationSentCount @@ -575,6 +575,14 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) { } } + // If all the rotations were sent, this is a full packet + bool fullPacket = numValidJointRotations == numJoints; + + if (fullPacket) { + _hasNewJointRotations = true; + _hasNewJointTranslations = true; + } + // each joint rotation is stored in 6 bytes. const int COMPRESSED_QUATERNION_SIZE = 6; PACKET_READ_CHECK(JointRotations, numValidJointRotations * COMPRESSED_QUATERNION_SIZE); @@ -584,9 +592,6 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) { sourceBuffer += unpackOrientationQuatFromSixBytes(sourceBuffer, data.rotation); _hasNewJointRotations = true; data.rotationSet = true; - } else if (numValidJointRotations == numJoints) { - _hasNewJointRotations = true; - data.rotationSet = false; } } @@ -623,13 +628,10 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) { sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, data.translation, TRANSLATION_COMPRESSION_RADIX); _hasNewJointTranslations = true; data.translationSet = true; - } else if (numValidJointRotations == numJoints) { - _hasNewJointTranslations = true; - data.translationSet = false; } } - #if 1 + #ifdef WANT_DEBUG if (numValidJointRotations > 15) { qDebug() << "RECEIVING -- rotations:" << numValidJointRotations << "translations:" << numValidJointTranslations @@ -1058,20 +1060,17 @@ void AvatarData::setJointMappingsFromNetworkReply() { _jointIndices.insert(_jointNames.at(i), i + 1); } - //sendIdentityPacket(); - //sendAvatarDataPacket(true); qDebug() << "set joint mapping froms network reply, num joints: " << _jointIndices.size(); networkReply->deleteLater(); } -void AvatarData::sendAvatarDataPacket(bool sendFull) { +void AvatarData::sendAvatarDataPacket() { auto nodeList = DependencyManager::get(); // about 2% of the time, we send a full update (meaning, we transmit all the joint data), even if nothing has changed. // this is to guard against a joint moving once, the packet getting lost, and the joint never moving again. - bool sendFullUpdate = sendFull || (randFloat() < AVATAR_SEND_FULL_UPDATE_RATIO); - if (sendFullUpdate) qDebug() << sendFullUpdate; + bool sendFullUpdate = randFloat() < AVATAR_SEND_FULL_UPDATE_RATIO; QByteArray avatarByteArray = toByteArray(true, sendFullUpdate); doneEncoding(true); diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 7fe339c2b9..61ee649273 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -352,7 +352,7 @@ public: AvatarEntityIDs getAndClearRecentlyDetachedIDs(); public slots: - void sendAvatarDataPacket(bool sendFull = false); + void sendAvatarDataPacket(); void sendIdentityPacket(); void setJointMappingsFromNetworkReply();