diff options
author | Rider Linden <rider@lindenlab.com> | 2016-01-11 18:16:28 -0800 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2016-01-11 18:16:28 -0800 |
commit | f91e28747594ec0c4ba7dfa527ca3b82687ff2f0 (patch) | |
tree | 8b1814bee472360c182763a023eeaa8bdb35134e /indra/newview | |
parent | 59bf97529a47913f78ada9544ff9c0fae0870dfc (diff) |
MAINT-6044: Throttle positional updates to no more than two a second. Compare angle between avatar rotations if trivially small do not trigger update.
Diffstat (limited to 'indra/newview')
-rwxr-xr-x | indra/newview/llvoicevivox.cpp | 27 | ||||
-rwxr-xr-x | indra/newview/llvoicevivox.h | 4 |
2 files changed, 19 insertions, 12 deletions
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index ba374a0e11..e2bb212a52 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -89,11 +89,14 @@ static const std::string VOICE_SERVER_TYPE = "Vivox"; const F32 CONNECT_THROTTLE_SECONDS = 1.0f; // Don't send positional updates more frequently than this: -const F32 UPDATE_THROTTLE_SECONDS = 0.1f; +const F32 UPDATE_THROTTLE_SECONDS = 0.5f; const F32 LOGIN_RETRY_SECONDS = 10.0f; const int MAX_LOGIN_RETRIES = 12; +// Cosine of a "trivially" small angle +const F32 MINUSCULE_ANGLE_COS = 0.999f; + // Defines the maximum number of times(in a row) "stateJoiningSession" case for spatial channel is reached in stateMachine() // which is treated as normal. The is the number of frames to wait for a channel join before giving up. This was changed // from the original count of 50 for two reason. Modern PCs have higher frame rates and sometimes the SLVoice process @@ -2397,10 +2400,12 @@ void LLVivoxVoiceClient::sendPositionalUpdate(void) stream << "<SpeakerPosition>"; + LLMatrix3 avatarRot = mAvatarRot.getMatrix3(); + // LL_DEBUGS("Voice") << "Sending speaker position " << mAvatarPosition << LL_ENDL; - l = mAvatarRot.getLeftRow(); - u = mAvatarRot.getUpRow(); - a = mAvatarRot.getFwdRow(); + l = avatarRot.getLeftRow(); + u = avatarRot.getUpRow(); + a = avatarRot.getFwdRow(); pos = mAvatarPosition; vel = mAvatarVelocity; @@ -2464,7 +2469,7 @@ void LLVivoxVoiceClient::sendPositionalUpdate(void) case earLocAvatar: earPosition = mAvatarPosition; earVelocity = mAvatarVelocity; - earRot = mAvatarRot; + earRot = avatarRot; break; case earLocMixed: @@ -4518,6 +4523,7 @@ void LLVivoxVoiceClient::updatePosition(void) { LLMatrix3 rot; LLVector3d pos; + LLQuaternion qrot; // TODO: If camera and avatar velocity are actually used by the voice system, we could compute them here... // They're currently always set to zero. @@ -4532,7 +4538,7 @@ void LLVivoxVoiceClient::updatePosition(void) rot); // rotation matrix // Send the current avatar position to the voice code - rot = gAgentAvatarp->getRootJoint()->getWorldRotation().getMatrix3(); + qrot = gAgentAvatarp->getRootJoint()->getWorldRotation(); pos = gAgentAvatarp->getPositionGlobal(); // TODO: Can we get the head offset from outside the LLVOAvatar? @@ -4542,7 +4548,7 @@ void LLVivoxVoiceClient::updatePosition(void) LLVivoxVoiceClient::getInstance()->setAvatarPosition( pos, // position LLVector3::zero, // velocity - rot); // rotation matrix + qrot); // rotation matrix } } @@ -4563,7 +4569,7 @@ void LLVivoxVoiceClient::setCameraPosition(const LLVector3d &position, const LLV } } -void LLVivoxVoiceClient::setAvatarPosition(const LLVector3d &position, const LLVector3 &velocity, const LLMatrix3 &rot) +void LLVivoxVoiceClient::setAvatarPosition(const LLVector3d &position, const LLVector3 &velocity, const LLQuaternion &rot) { if(dist_vec_squared(mAvatarPosition, position) > 0.01) { @@ -4577,8 +4583,9 @@ void LLVivoxVoiceClient::setAvatarPosition(const LLVector3d &position, const LLV mSpatialCoordsDirty = true; } - if(mAvatarRot != rot) - { + if ((mAvatarRot != rot) && (llabs(dot(mAvatarRot, rot)) > MINUSCULE_ANGLE_COS)) + { // if the two rotations are not exactly equal test their dot product + // to get the cos of the angle between them. If it is minuscule don't update. mAvatarRot = rot; mSpatialCoordsDirty = true; } diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index 83911f91f8..0054c7cca4 100755 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -446,7 +446,7 @@ protected: // Sending updates of current state void updatePosition(void); void setCameraPosition(const LLVector3d &position, const LLVector3 &velocity, const LLMatrix3 &rot); - void setAvatarPosition(const LLVector3d &position, const LLVector3 &velocity, const LLMatrix3 &rot); + void setAvatarPosition(const LLVector3d &position, const LLVector3 &velocity, const LLQuaternion &rot); bool channelFromRegion(LLViewerRegion *region, std::string &name); void setEarLocation(S32 loc); @@ -735,7 +735,7 @@ private: LLVector3d mAvatarPosition; LLVector3 mAvatarVelocity; - LLMatrix3 mAvatarRot; + LLQuaternion mAvatarRot; bool mMuteMic; bool mMuteMicDirty; |