mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 18:38:24 +02:00
send minimum data for out of view avatars
This commit is contained in:
parent
2443b2d6d9
commit
c8fb467579
2 changed files with 30 additions and 23 deletions
|
@ -276,19 +276,6 @@ void AvatarMixer::broadcastAvatarData() {
|
||||||
}
|
}
|
||||||
// Not close enough to ignore
|
// Not close enough to ignore
|
||||||
nodeData->removeFromRadiusIgnoringSet(otherNode->getUUID());
|
nodeData->removeFromRadiusIgnoringSet(otherNode->getUUID());
|
||||||
|
|
||||||
|
|
||||||
// Also check to see if the other node is in our view
|
|
||||||
glm::vec3 otherNodeBoxScale = (otherData->getPosition() - otherData->getGlobalBoundingBoxCorner()) * 2.0f;
|
|
||||||
AABox otherNodeBox(otherData->getGlobalBoundingBoxCorner(), otherNodeBoxScale);
|
|
||||||
|
|
||||||
if (!nodeData->otherAvatarInView(otherNodeBox)) {
|
|
||||||
//qDebug() << "Avatar out of view!";
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
//qDebug() << "Avatar in view!";
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -368,9 +355,15 @@ void AvatarMixer::broadcastAvatarData() {
|
||||||
// start a new segment in the PacketList for this avatar
|
// start a new segment in the PacketList for this avatar
|
||||||
avatarPacketList->startSegment();
|
avatarPacketList->startSegment();
|
||||||
|
|
||||||
|
// determine if avatar is in view, to determine how much data to include...
|
||||||
|
glm::vec3 otherNodeBoxScale = (otherNodeData->getPosition() - otherNodeData->getGlobalBoundingBoxCorner()) * 2.0f;
|
||||||
|
AABox otherNodeBox(otherNodeData->getGlobalBoundingBoxCorner(), otherNodeBoxScale);
|
||||||
|
|
||||||
|
bool sendMinimumForOutOfView = !nodeData->otherAvatarInView(otherNodeBox);
|
||||||
|
|
||||||
numAvatarDataBytes += avatarPacketList->write(otherNode->getUUID().toRfc4122());
|
numAvatarDataBytes += avatarPacketList->write(otherNode->getUUID().toRfc4122());
|
||||||
numAvatarDataBytes +=
|
numAvatarDataBytes +=
|
||||||
avatarPacketList->write(otherAvatar.toByteArray(false, distribution(generator) < AVATAR_SEND_FULL_UPDATE_RATIO));
|
avatarPacketList->write(otherAvatar.toByteArray(false, distribution(generator) < AVATAR_SEND_FULL_UPDATE_RATIO), sendMinimumForOutOfView);
|
||||||
|
|
||||||
avatarPacketList->endSegment();
|
avatarPacketList->endSegment();
|
||||||
});
|
});
|
||||||
|
|
|
@ -213,7 +213,12 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll, bool sen
|
||||||
memcpy(destinationBuffer, &packetStateFlags, sizeof(packetStateFlags));
|
memcpy(destinationBuffer, &packetStateFlags, sizeof(packetStateFlags));
|
||||||
destinationBuffer += sizeof(packetStateFlags);
|
destinationBuffer += sizeof(packetStateFlags);
|
||||||
|
|
||||||
if (!sendMinimum) {
|
if (sendMinimum) {
|
||||||
|
memcpy(destinationBuffer, &_globalPosition, sizeof(_globalPosition));
|
||||||
|
destinationBuffer += sizeof(_globalPosition);
|
||||||
|
qDebug() << __FUNCTION__ << "minimum... included global position!!";
|
||||||
|
}
|
||||||
|
else {
|
||||||
//qDebug() << __FUNCTION__ << "not minimum... sending actual content!!";
|
//qDebug() << __FUNCTION__ << "not minimum... sending actual content!!";
|
||||||
|
|
||||||
auto header = reinterpret_cast<AvatarDataPacket::Header*>(destinationBuffer);
|
auto header = reinterpret_cast<AvatarDataPacket::Header*>(destinationBuffer);
|
||||||
|
@ -515,14 +520,6 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
bool minimumSent = oneAtBit(packetStateFlags, AVATARDATA_FLAGS_MINIMUM);
|
bool minimumSent = oneAtBit(packetStateFlags, AVATARDATA_FLAGS_MINIMUM);
|
||||||
bool packetIsCompressed = oneAtBit(packetStateFlags, AVATARDATA_FLAGS_COMPRESSED);
|
bool packetIsCompressed = oneAtBit(packetStateFlags, AVATARDATA_FLAGS_COMPRESSED);
|
||||||
|
|
||||||
// if this is the minimum, then it only includes the flags
|
|
||||||
if (minimumSent) {
|
|
||||||
//qDebug() << __FUNCTION__ << "minimum... not expecting actual content!!";
|
|
||||||
|
|
||||||
int numBytesRead = sizeof(packetStateFlags);
|
|
||||||
_averageBytesReceived.updateAverage(numBytesRead);
|
|
||||||
return numBytesRead;
|
|
||||||
}
|
|
||||||
//qDebug() << __FUNCTION__ << "NOT minimum... expecting actual content!!";
|
//qDebug() << __FUNCTION__ << "NOT minimum... expecting actual content!!";
|
||||||
|
|
||||||
QByteArray uncompressBuffer;
|
QByteArray uncompressBuffer;
|
||||||
|
@ -538,6 +535,20 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
//qDebug() << __FUNCTION__ << "uncompressing compressed data was:" << buffer.size() << "now:" << uncompressBuffer.size();
|
//qDebug() << __FUNCTION__ << "uncompressing compressed data was:" << buffer.size() << "now:" << uncompressBuffer.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if this is the minimum, then it only includes the flags
|
||||||
|
if (minimumSent) {
|
||||||
|
//qDebug() << __FUNCTION__ << "minimum... not expecting actual content!!";
|
||||||
|
|
||||||
|
memcpy(&_globalPosition, sourceBuffer, sizeof(_globalPosition));
|
||||||
|
sourceBuffer += sizeof(_globalPosition);
|
||||||
|
int numBytesRead = (sourceBuffer - startPosition) + sizeof(packetStateFlags);
|
||||||
|
_averageBytesReceived.updateAverage(numBytesRead);
|
||||||
|
|
||||||
|
qDebug() << __FUNCTION__ << "minimum... included global position!! numBytesRead:" << numBytesRead;
|
||||||
|
|
||||||
|
return numBytesRead;
|
||||||
|
}
|
||||||
|
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
|
|
||||||
PACKET_READ_CHECK(Header, sizeof(AvatarDataPacket::Header));
|
PACKET_READ_CHECK(Header, sizeof(AvatarDataPacket::Header));
|
||||||
|
@ -750,6 +761,9 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
sourceBuffer = unpackFauxJoint(sourceBuffer, _controllerRightHandMatrixCache);
|
sourceBuffer = unpackFauxJoint(sourceBuffer, _controllerRightHandMatrixCache);
|
||||||
|
|
||||||
int numBytesRead = sourceBuffer - startPosition;
|
int numBytesRead = sourceBuffer - startPosition;
|
||||||
|
if (packetIsCompressed) {
|
||||||
|
numBytesRead += sizeof(packetStateFlags);
|
||||||
|
}
|
||||||
_averageBytesReceived.updateAverage(numBytesRead);
|
_averageBytesReceived.updateAverage(numBytesRead);
|
||||||
return numBytesRead;
|
return numBytesRead;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue