undo debugging

This commit is contained in:
SamGondelman 2016-06-15 18:00:08 -07:00
parent 59b785a33b
commit f02ffa92fd
2 changed files with 17 additions and 18 deletions

View file

@ -261,7 +261,7 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) {
unsigned char validity = 0; unsigned char validity = 0;
int validityBit = 0; int validityBit = 0;
#if 1 #ifdef WANT_DEBUG
int rotationSentCount = 0; int rotationSentCount = 0;
unsigned char* beforeRotations = destinationBuffer; unsigned char* beforeRotations = destinationBuffer;
#endif #endif
@ -276,7 +276,7 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) {
fabsf(glm::dot(data.rotation, _lastSentJointData[i].rotation)) <= AVATAR_MIN_ROTATION_DOT) { fabsf(glm::dot(data.rotation, _lastSentJointData[i].rotation)) <= AVATAR_MIN_ROTATION_DOT) {
if (data.rotationSet) { if (data.rotationSet) {
validity |= (1 << validityBit); validity |= (1 << validityBit);
#if 1 #ifdef WANT_DEBUG
rotationSentCount++; rotationSentCount++;
#endif #endif
} }
@ -310,7 +310,7 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) {
validity = 0; validity = 0;
validityBit = 0; validityBit = 0;
#if 1 #ifdef WANT_DEBUG
int translationSentCount = 0; int translationSentCount = 0;
unsigned char* beforeTranslations = destinationBuffer; unsigned char* beforeTranslations = destinationBuffer;
#endif #endif
@ -324,7 +324,7 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) {
glm::distance(data.translation, _lastSentJointData[i].translation) > AVATAR_MIN_TRANSLATION) { glm::distance(data.translation, _lastSentJointData[i].translation) > AVATAR_MIN_TRANSLATION) {
if (data.translationSet) { if (data.translationSet) {
validity |= (1 << validityBit); validity |= (1 << validityBit);
#if 1 #ifdef WANT_DEBUG
translationSentCount++; translationSentCount++;
#endif #endif
maxTranslationDimension = glm::max(fabsf(data.translation.x), maxTranslationDimension); 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) { if (sendAll) {
qDebug() << "AvatarData::toByteArray" << cullSmallChanges << sendAll qDebug() << "AvatarData::toByteArray" << cullSmallChanges << sendAll
<< "rotations:" << rotationSentCount << "translations:" << translationSentCount << "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. // each joint rotation is stored in 6 bytes.
const int COMPRESSED_QUATERNION_SIZE = 6; const int COMPRESSED_QUATERNION_SIZE = 6;
PACKET_READ_CHECK(JointRotations, numValidJointRotations * COMPRESSED_QUATERNION_SIZE); PACKET_READ_CHECK(JointRotations, numValidJointRotations * COMPRESSED_QUATERNION_SIZE);
@ -584,9 +592,6 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
sourceBuffer += unpackOrientationQuatFromSixBytes(sourceBuffer, data.rotation); sourceBuffer += unpackOrientationQuatFromSixBytes(sourceBuffer, data.rotation);
_hasNewJointRotations = true; _hasNewJointRotations = true;
data.rotationSet = 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); sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, data.translation, TRANSLATION_COMPRESSION_RADIX);
_hasNewJointTranslations = true; _hasNewJointTranslations = true;
data.translationSet = true; data.translationSet = true;
} else if (numValidJointRotations == numJoints) {
_hasNewJointTranslations = true;
data.translationSet = false;
} }
} }
#if 1 #ifdef WANT_DEBUG
if (numValidJointRotations > 15) { if (numValidJointRotations > 15) {
qDebug() << "RECEIVING -- rotations:" << numValidJointRotations qDebug() << "RECEIVING -- rotations:" << numValidJointRotations
<< "translations:" << numValidJointTranslations << "translations:" << numValidJointTranslations
@ -1058,20 +1060,17 @@ void AvatarData::setJointMappingsFromNetworkReply() {
_jointIndices.insert(_jointNames.at(i), i + 1); _jointIndices.insert(_jointNames.at(i), i + 1);
} }
//sendIdentityPacket();
//sendAvatarDataPacket(true);
qDebug() << "set joint mapping froms network reply, num joints: " << _jointIndices.size(); qDebug() << "set joint mapping froms network reply, num joints: " << _jointIndices.size();
networkReply->deleteLater(); networkReply->deleteLater();
} }
void AvatarData::sendAvatarDataPacket(bool sendFull) { void AvatarData::sendAvatarDataPacket() {
auto nodeList = DependencyManager::get<NodeList>(); auto nodeList = DependencyManager::get<NodeList>();
// about 2% of the time, we send a full update (meaning, we transmit all the joint data), even if nothing has changed. // 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. // 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); bool sendFullUpdate = randFloat() < AVATAR_SEND_FULL_UPDATE_RATIO;
if (sendFullUpdate) qDebug() << sendFullUpdate;
QByteArray avatarByteArray = toByteArray(true, sendFullUpdate); QByteArray avatarByteArray = toByteArray(true, sendFullUpdate);
doneEncoding(true); doneEncoding(true);

View file

@ -352,7 +352,7 @@ public:
AvatarEntityIDs getAndClearRecentlyDetachedIDs(); AvatarEntityIDs getAndClearRecentlyDetachedIDs();
public slots: public slots:
void sendAvatarDataPacket(bool sendFull = false); void sendAvatarDataPacket();
void sendIdentityPacket(); void sendIdentityPacket();
void setJointMappingsFromNetworkReply(); void setJointMappingsFromNetworkReply();