mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
more cleanup use kens 1 byte audio gain
This commit is contained in:
parent
5b76eaaf52
commit
407ad633e0
2 changed files with 6 additions and 39 deletions
|
@ -35,6 +35,7 @@
|
|||
#include <UUID.h>
|
||||
#include <shared/JSONHelpers.h>
|
||||
#include <ShapeInfo.h>
|
||||
#include <AudioHelpers.h>
|
||||
|
||||
#include "AvatarLogging.h"
|
||||
|
||||
|
@ -314,14 +315,6 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
|
|||
|
||||
if (hasAvatarOrientation) {
|
||||
auto localOrientation = getLocalOrientation();
|
||||
/*
|
||||
auto data = reinterpret_cast<AvatarDataPacket::AvatarOrientation*>(destinationBuffer);
|
||||
glm::vec3 bodyEulerAngles = glm::degrees(safeEulerAngles(localOrientation));
|
||||
packFloatAngleToTwoByte((uint8_t*)(data->localOrientation + 0), bodyEulerAngles.y);
|
||||
packFloatAngleToTwoByte((uint8_t*)(data->localOrientation + 1), bodyEulerAngles.x);
|
||||
packFloatAngleToTwoByte((uint8_t*)(data->localOrientation + 2), bodyEulerAngles.z);
|
||||
destinationBuffer += sizeof(AvatarDataPacket::AvatarOrientation);
|
||||
*/
|
||||
destinationBuffer += packOrientationQuatToSixBytes(destinationBuffer, localOrientation);
|
||||
}
|
||||
|
||||
|
@ -343,8 +336,7 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
|
|||
|
||||
if (hasAudioLoudness) {
|
||||
auto data = reinterpret_cast<AvatarDataPacket::AudioLoudness*>(destinationBuffer);
|
||||
auto audioLoudness = glm::min(_headData->getAudioLoudness(), MAX_AUDIO_LOUDNESS);
|
||||
packFloatScalarToSignedTwoByteFixed((uint8_t*)&data->audioLoudness, audioLoudness, AUDIO_LOUDNESS_RADIX);
|
||||
data->audioLoudness = packFloatGainToByte(_headData->getAudioLoudness());
|
||||
destinationBuffer += sizeof(AvatarDataPacket::AudioLoudness);
|
||||
}
|
||||
|
||||
|
@ -705,29 +697,9 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
|||
|
||||
if (hasAvatarOrientation) {
|
||||
auto startSection = sourceBuffer;
|
||||
|
||||
PACKET_READ_CHECK(AvatarOrientation, sizeof(AvatarDataPacket::AvatarOrientation));
|
||||
|
||||
/*
|
||||
auto data = reinterpret_cast<const AvatarDataPacket::AvatarOrientation*>(sourceBuffer);
|
||||
float pitch, yaw, roll;
|
||||
unpackFloatAngleFromTwoByte(data->localOrientation + 0, &yaw);
|
||||
unpackFloatAngleFromTwoByte(data->localOrientation + 1, &pitch);
|
||||
unpackFloatAngleFromTwoByte(data->localOrientation + 2, &roll);
|
||||
if (isNaN(yaw) || isNaN(pitch) || isNaN(roll)) {
|
||||
if (shouldLogError(now)) {
|
||||
qCWarning(avatars) << "Discard AvatarData packet: localOriention is NaN, uuid " << getSessionUUID();
|
||||
}
|
||||
return buffer.size();
|
||||
}
|
||||
glm::vec3 newEulerAngles(pitch, yaw, roll);
|
||||
glm::quat newOrientation = glm::quat(glm::radians(newEulerAngles));
|
||||
sourceBuffer += sizeof(AvatarDataPacket::AvatarOrientation);
|
||||
*/
|
||||
|
||||
glm::quat newOrientation;
|
||||
sourceBuffer += unpackOrientationQuatFromSixBytes(sourceBuffer, newOrientation);
|
||||
|
||||
glm::quat currentOrientation = getLocalOrientation();
|
||||
if (currentOrientation != newOrientation) {
|
||||
_hasNewJointRotations = true;
|
||||
|
@ -779,8 +751,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
|||
|
||||
PACKET_READ_CHECK(AudioLoudness, sizeof(AvatarDataPacket::AudioLoudness));
|
||||
auto data = reinterpret_cast<const AvatarDataPacket::AudioLoudness*>(sourceBuffer);
|
||||
float audioLoudness;
|
||||
unpackFloatScalarFromSignedTwoByteFixed((int16_t*)&data->audioLoudness, &audioLoudness, AUDIO_LOUDNESS_RADIX);
|
||||
float audioLoudness = unpackFloatGainFromByte(data->audioLoudness);
|
||||
|
||||
if (isNaN(audioLoudness)) {
|
||||
if (shouldLogError(now)) {
|
||||
|
|
|
@ -179,16 +179,12 @@ namespace AvatarDataPacket {
|
|||
|
||||
using SixByteQuat = uint8_t[6];
|
||||
PACKED_BEGIN struct AvatarOrientation {
|
||||
//smallFloat localOrientation[3]; // avatar's local euler angles (degrees, compressed) relative to the
|
||||
// thing it's attached to, or world relative if not attached
|
||||
|
||||
SixByteQuat avatarOrientation; // encodeded and compressed by packOrientationQuatToSixBytes()
|
||||
|
||||
} PACKED_END;
|
||||
const size_t AVATAR_ORIENTATION_SIZE = 6;
|
||||
|
||||
PACKED_BEGIN struct AvatarScale {
|
||||
smallFloat scale; // avatar's scale, (compressed) 'ratio' encoding uses sign bit as flag.
|
||||
smallFloat scale; // avatar's scale, compressed by packFloatRatioToTwoByte()
|
||||
} PACKED_END;
|
||||
const size_t AVATAR_SCALE_SIZE = 2;
|
||||
|
||||
|
@ -204,9 +200,9 @@ namespace AvatarDataPacket {
|
|||
const size_t LOOK_AT_POSITION_SIZE = 12;
|
||||
|
||||
PACKED_BEGIN struct AudioLoudness {
|
||||
smallFloat audioLoudness; // current loudness of microphone, (compressed)
|
||||
uint8_t audioLoudness; // current loudness of microphone, compressed by packFloatGainToByte()
|
||||
} PACKED_END;
|
||||
const size_t AUDIO_LOUDNESS_SIZE = 2;
|
||||
const size_t AUDIO_LOUDNESS_SIZE = 1;
|
||||
|
||||
PACKED_BEGIN struct SensorToWorldMatrix {
|
||||
// FIXME - these 20 bytes are only used by viewers if my avatar has "attachments"
|
||||
|
|
Loading…
Reference in a new issue