From 6f4f55038b3cb2c39dbe76c19ec1c4fde6d71cb7 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 25 Mar 2014 15:31:53 -0700 Subject: [PATCH] add back selective inclusion of Avatars based on distance --- assignment-client/src/avatars/AvatarMixer.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 9df66d0362..b9bc87ecf2 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -134,8 +134,14 @@ void AvatarMixer::broadcastAvatarData() { AvatarData& otherAvatar = otherNodeData->getAvatar(); glm::vec3 otherPosition = otherAvatar.getPosition(); - // Decide whether to send this avatar's data based on current performance throttling - if (_performanceThrottlingRatio == 0 || randFloat() < (1.0f - _performanceThrottlingRatio)) { + float distanceToAvatar = glm::length(myPosition - otherPosition); + // The full rate distance is the distance at which EVERY update will be sent for this avatar + // at a distance of twice the full rate distance, there will be a 50% chance of sending this avatar's update + const float FULL_RATE_DISTANCE = 2.f; + + // Decide whether to send this avatar's data based on it's distance from us + if ((_performanceThrottlingRatio == 0 || randFloat() < (1.0f - _performanceThrottlingRatio)) + && (distanceToAvatar == 0.f || randFloat() < FULL_RATE_DISTANCE / distanceToAvatar)) { QByteArray avatarByteArray; avatarByteArray.append(otherNode->getUUID().toRfc4122()); avatarByteArray.append(otherAvatar.toByteArray());