From d7babe6fbfb74d25ec7ac565286a0db80fc078d1 Mon Sep 17 00:00:00 2001 From: Anthony Thibault Date: Mon, 22 Apr 2019 16:16:55 -0700 Subject: [PATCH] Added data rates for new hand controller section --- libraries/avatars/src/AvatarData.cpp | 29 +++++++++++----------------- libraries/avatars/src/AvatarData.h | 3 +++ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 74f36e858e..4de3d9bb4e 100755 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -594,13 +594,8 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent } } - // AJT: hand controller section IF_AVATAR_SPACE(PACKET_HAS_HAND_CONTROLLERS, AvatarDataPacket::HAND_CONTROLLERS_SIZE) { - - qDebug() << "AJT: sending hand controllers!"; - - // AJT: TODO - //auto startSection = destinationBuffer; + auto startSection = destinationBuffer; Transform controllerLeftHandTransform = Transform(getControllerLeftHandMatrix()); destinationBuffer += packOrientationQuatToSixBytes(destinationBuffer, controllerLeftHandTransform.getRotation()); @@ -610,12 +605,10 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent destinationBuffer += packOrientationQuatToSixBytes(destinationBuffer, controllerRightHandTransform.getRotation()); destinationBuffer += packFloatVec3ToSignedTwoByteFixed(destinationBuffer, controllerRightHandTransform.getTranslation(), HAND_CONTROLLER_COMPRESSION_RADIX); - /* AJT: TODO int numBytes = destinationBuffer - startSection; if (outboundDataRateOut) { outboundDataRateOut->handControllersRate.increment(numBytes); } - */ } const auto& blendshapeCoefficients = _headData->getBlendshapeCoefficients(); @@ -1244,21 +1237,15 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) { _localPositionUpdateRate.increment(); } - // AJT: hand controller section if (hasHandControllers) { - - qDebug() << "AJT: received hand controllers!"; - - // AJT: TODO - // auto startSection = sourceBuffer; + auto startSection = sourceBuffer; sourceBuffer = unpackHandController(sourceBuffer, _controllerLeftHandMatrixCache); sourceBuffer = unpackHandController(sourceBuffer, _controllerRightHandMatrixCache); - // AJT: TODO - // int numBytesRead = sourceBuffer - startSection; - // _handControllerUpdateRate.increment(numBytesRead); - // _handControllerUpdateRate.increment(); + int numBytesRead = sourceBuffer - startSection; + _handControllersRate.increment(numBytesRead); + _handControllersUpdateRate.increment(); } else { _controllerLeftHandMatrixCache.invalidate(); _controllerRightHandMatrixCache.invalidate(); @@ -1465,6 +1452,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) { * * "globalPosition"Incoming global position. * "localPosition"Incoming local position. + * "handControllers"Incoming hand controllers. * "avatarBoundingBox"Incoming avatar bounding box. * "avatarOrientation"Incoming avatar orientation. * "avatarScale"Incoming avatar scale. @@ -1503,6 +1491,8 @@ float AvatarData::getDataRate(const QString& rateName) const { return _globalPositionRate.rate() / BYTES_PER_KILOBIT; } else if (rateName == "localPosition") { return _localPositionRate.rate() / BYTES_PER_KILOBIT; + } else if (rateName == "handControllers") { + return _handControllersRate.rate() / BYTES_PER_KILOBIT; } else if (rateName == "avatarBoundingBox") { return _avatarBoundingBoxRate.rate() / BYTES_PER_KILOBIT; } else if (rateName == "avatarOrientation") { @@ -1567,6 +1557,7 @@ float AvatarData::getDataRate(const QString& rateName) const { * * "globalPosition"Global position. * "localPosition"Local position. + * "handControllers"Hand controller positions and orientations. * "avatarBoundingBox"Avatar bounding box. * "avatarOrientation"Avatar orientation. * "avatarScale"Avatar scale. @@ -1591,6 +1582,8 @@ float AvatarData::getUpdateRate(const QString& rateName) const { return _globalPositionUpdateRate.rate(); } else if (rateName == "localPosition") { return _localPositionUpdateRate.rate(); + } else if (rateName == "handControllers") { + return _handControllersUpdateRate.rate(); } else if (rateName == "avatarBoundingBox") { return _avatarBoundingBoxUpdateRate.rate(); } else if (rateName == "avatarOrientation") { diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index ccb5423c78..56885e31fc 100755 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -413,6 +413,7 @@ class AvatarDataRate { public: RateCounter<> globalPositionRate; RateCounter<> localPositionRate; + RateCounter<> handControllersRate; RateCounter<> avatarBoundingBoxRate; RateCounter<> avatarOrientationRate; RateCounter<> avatarScaleRate; @@ -1680,6 +1681,7 @@ protected: RateCounter<> _parseBufferRate; RateCounter<> _globalPositionRate; RateCounter<> _localPositionRate; + RateCounter<> _handControllersRate; RateCounter<> _avatarBoundingBoxRate; RateCounter<> _avatarOrientationRate; RateCounter<> _avatarScaleRate; @@ -1697,6 +1699,7 @@ protected: RateCounter<> _parseBufferUpdateRate; RateCounter<> _globalPositionUpdateRate; RateCounter<> _localPositionUpdateRate; + RateCounter<> _handControllersUpdateRate; RateCounter<> _avatarBoundingBoxUpdateRate; RateCounter<> _avatarOrientationUpdateRate; RateCounter<> _avatarScaleUpdateRate;