MAINT-6044: Throttle positional updates to no more than two a second. Compare angle between avatar rotations if trivially small do not trigger update.

meow-7.2.2
Rider Linden 2016-01-11 18:16:28 -08:00
parent 59bf97529a
commit f91e287475
2 changed files with 19 additions and 12 deletions

View File

@ -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;
}

View File

@ -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;