summaryrefslogtreecommitdiff
path: root/indra/newview/llvoicevivox.cpp
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2016-01-11 18:16:28 -0800
committerRider Linden <rider@lindenlab.com>2016-01-11 18:16:28 -0800
commitf91e28747594ec0c4ba7dfa527ca3b82687ff2f0 (patch)
tree8b1814bee472360c182763a023eeaa8bdb35134e /indra/newview/llvoicevivox.cpp
parent59bf97529a47913f78ada9544ff9c0fae0870dfc (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/llvoicevivox.cpp')
-rwxr-xr-xindra/newview/llvoicevivox.cpp27
1 files changed, 17 insertions, 10 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;
}