Removed leans/Changed Head rotation in avatardata packets

This commit is contained in:
Atlante45 2015-01-09 11:16:49 -08:00
parent 16e1fc8c3a
commit f2b7cb005a

View file

@ -158,15 +158,18 @@ QByteArray AvatarData::toByteArray() {
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _targetScale); destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _targetScale);
// Head rotation (NOTE: This needs to become a quaternion to save two bytes) // Head rotation (NOTE: This needs to become a quaternion to save two bytes)
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalYaw()); glm::vec3 pitchYawRoll = glm::vec3(_headData->getFinalPitch(),
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalPitch()); _headData->getFinalYaw(),
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalRoll()); _headData->getFinalRoll());
if (this->isMyAvatar()) {
// Head lean X,Z (head lateral and fwd/back motion relative to torso) glm::vec3 lean = glm::radians(glm::vec3(_headData->getFinalLeanForward(),
memcpy(destinationBuffer, &_headData->_leanSideways, sizeof(_headData->_leanSideways)); _headData->getTorsoTwist(),
destinationBuffer += sizeof(_headData->_leanSideways); _headData->getFinalLeanSideways()));
memcpy(destinationBuffer, &_headData->_leanForward, sizeof(_headData->_leanForward)); pitchYawRoll -= lean;
destinationBuffer += sizeof(_headData->_leanForward); }
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.x);
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.y);
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, pitchYawRoll.z);
// Lookat Position // Lookat Position
memcpy(destinationBuffer, &_headData->_lookAtPosition, sizeof(_headData->_lookAtPosition)); memcpy(destinationBuffer, &_headData->_lookAtPosition, sizeof(_headData->_lookAtPosition));
@ -287,18 +290,16 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
// bodyPitch = 2 (compressed float) // bodyPitch = 2 (compressed float)
// bodyRoll = 2 (compressed float) // bodyRoll = 2 (compressed float)
// targetScale = 2 (compressed float) // targetScale = 2 (compressed float)
// headYaw = 2 (compressed float)
// headPitch = 2 (compressed float) // headPitch = 2 (compressed float)
// headYaw = 2 (compressed float)
// headRoll = 2 (compressed float) // headRoll = 2 (compressed float)
// leanSideways = 4
// leanForward = 4
// lookAt = 12 // lookAt = 12
// audioLoudness = 4 // audioLoudness = 4
// } // }
// + 1 byte for pupilSize // + 1 byte for pupilSize
// + 1 byte for numJoints (0) // + 1 byte for numJoints (0)
// = 53 bytes // = 45 bytes
int minPossibleSize = 52; int minPossibleSize = 45;
int maxAvailableSize = packet.size() - offset; int maxAvailableSize = packet.size() - offset;
if (minPossibleSize > maxAvailableSize) { if (minPossibleSize > maxAvailableSize) {
@ -356,8 +357,8 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
{ // Head rotation { // Head rotation
//(NOTE: This needs to become a quaternion to save two bytes) //(NOTE: This needs to become a quaternion to save two bytes)
float headYaw, headPitch, headRoll; float headYaw, headPitch, headRoll;
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headPitch); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headPitch);
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headRoll); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headRoll);
if (glm::isnan(headYaw) || glm::isnan(headPitch) || glm::isnan(headRoll)) { if (glm::isnan(headYaw) || glm::isnan(headPitch) || glm::isnan(headRoll)) {
if (shouldLogError(now)) { if (shouldLogError(now)) {
@ -365,27 +366,10 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
} }
return maxAvailableSize; return maxAvailableSize;
} }
_headData->setBaseYaw(headYaw);
_headData->setBasePitch(headPitch); _headData->setBasePitch(headPitch);
_headData->setBaseYaw(headYaw);
_headData->setBaseRoll(headRoll); _headData->setBaseRoll(headRoll);
} // 6 bytes } // 6 bytes
// Head lean (relative to pelvis)
{
float leanSideways, leanForward;
memcpy(&leanSideways, sourceBuffer, sizeof(float));
sourceBuffer += sizeof(float);
memcpy(&leanForward, sourceBuffer, sizeof(float));
sourceBuffer += sizeof(float);
if (glm::isnan(leanSideways) || glm::isnan(leanForward)) {
if (shouldLogError(now)) {
qDebug() << "Discard nan AvatarData::leanSideways,leanForward; displayName = '" << _displayName << "'";
}
return maxAvailableSize;
}
_headData->_leanSideways = leanSideways;
_headData->_leanForward = leanForward;
} // 8 bytes
{ // Lookat Position { // Lookat Position
glm::vec3 lookAt; glm::vec3 lookAt;