mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 16:18:05 +02:00
clean up some uneedded nullptr checks, make them asserts
This commit is contained in:
parent
8cb8d686ec
commit
1e91f74ce7
1 changed files with 65 additions and 68 deletions
|
@ -171,6 +171,10 @@ void AvatarMixerSlave::broadcastAvatarData(const SharedNodePointer& node) {
|
||||||
int listItem = 0;
|
int listItem = 0;
|
||||||
std::for_each(_begin, _end, [&](const SharedNodePointer& otherNode) {
|
std::for_each(_begin, _end, [&](const SharedNodePointer& otherNode) {
|
||||||
const AvatarMixerClientData* otherNodeData = reinterpret_cast<const AvatarMixerClientData*>(otherNode->getLinkedData());
|
const AvatarMixerClientData* otherNodeData = reinterpret_cast<const AvatarMixerClientData*>(otherNode->getLinkedData());
|
||||||
|
|
||||||
|
// theoretically it's possible for a Node to be in the NodeList (and therefore end up here),
|
||||||
|
// but not have yet sent data that's linked to the node. Check for that case and don't
|
||||||
|
// consider those nodes.
|
||||||
if (otherNodeData) {
|
if (otherNodeData) {
|
||||||
listItem++;
|
listItem++;
|
||||||
AvatarSharedPointer otherAvatar = otherNodeData->getAvatarSharedPointer();
|
AvatarSharedPointer otherAvatar = otherNodeData->getAvatarSharedPointer();
|
||||||
|
@ -186,10 +190,8 @@ void AvatarMixerSlave::broadcastAvatarData(const SharedNodePointer& node) {
|
||||||
|
|
||||||
[&](AvatarSharedPointer avatar)->uint64_t{
|
[&](AvatarSharedPointer avatar)->uint64_t{
|
||||||
auto avatarNode = avatarDataToNodes[avatar];
|
auto avatarNode = avatarDataToNodes[avatar];
|
||||||
if (avatarNode) {
|
assert(avatarNode); // we can't have gotten here without the avatarData being a valid key in the map
|
||||||
return nodeData->getLastBroadcastTime(avatarNode->getUUID());
|
return nodeData->getLastBroadcastTime(avatarNode->getUUID());
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
[&](AvatarSharedPointer avatar)->float{
|
[&](AvatarSharedPointer avatar)->float{
|
||||||
|
@ -210,72 +212,72 @@ void AvatarMixerSlave::broadcastAvatarData(const SharedNodePointer& node) {
|
||||||
// happen if for example the avatar is connected on a desktop and sending
|
// happen if for example the avatar is connected on a desktop and sending
|
||||||
// updates at ~30hz. So every 3 frames we skip a frame.
|
// updates at ~30hz. So every 3 frames we skip a frame.
|
||||||
auto avatarNode = avatarDataToNodes[avatar];
|
auto avatarNode = avatarDataToNodes[avatar];
|
||||||
if (avatarNode) {
|
|
||||||
const AvatarMixerClientData* avatarNodeData = reinterpret_cast<const AvatarMixerClientData*>(avatarNode->getLinkedData());
|
|
||||||
if (avatarNodeData) {
|
|
||||||
quint64 startIgnoreCalculation = usecTimestampNow();
|
|
||||||
|
|
||||||
// make sure we have data for this avatar, that it isn't the same node,
|
assert(avatarNode); // we can't have gotten here without the avatarData being a valid key in the map
|
||||||
// and isn't an avatar that the viewing node has ignored
|
|
||||||
// or that has ignored the viewing node
|
|
||||||
if (!avatarNode->getLinkedData()
|
|
||||||
|| avatarNode->getUUID() == node->getUUID()
|
|
||||||
|| (node->isIgnoringNodeWithID(avatarNode->getUUID()) && !getsIgnoredByMe)
|
|
||||||
|| (avatarNode->isIgnoringNodeWithID(node->getUUID()) && !getsAnyIgnored)) {
|
|
||||||
shouldIgnore = true;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Check to see if the space bubble is enabled
|
const AvatarMixerClientData* avatarNodeData = reinterpret_cast<const AvatarMixerClientData*>(avatarNode->getLinkedData());
|
||||||
if (node->isIgnoreRadiusEnabled() || avatarNode->isIgnoreRadiusEnabled()) {
|
assert(avatarNodeData); // we can't have gotten here without avatarNode having valid data
|
||||||
|
quint64 startIgnoreCalculation = usecTimestampNow();
|
||||||
|
|
||||||
// Define the scale of the box for the current other node
|
// make sure we have data for this avatar, that it isn't the same node,
|
||||||
glm::vec3 otherNodeBoxScale = (avatarNodeData->getPosition() - avatarNodeData->getGlobalBoundingBoxCorner()) * 2.0f;
|
// and isn't an avatar that the viewing node has ignored
|
||||||
// Set up the bounding box for the current other node
|
// or that has ignored the viewing node
|
||||||
AABox otherNodeBox(avatarNodeData->getGlobalBoundingBoxCorner(), otherNodeBoxScale);
|
if (!avatarNode->getLinkedData()
|
||||||
// Clamp the size of the bounding box to a minimum scale
|
|| avatarNode->getUUID() == node->getUUID()
|
||||||
if (glm::any(glm::lessThan(otherNodeBoxScale, minBubbleSize))) {
|
|| (node->isIgnoringNodeWithID(avatarNode->getUUID()) && !getsIgnoredByMe)
|
||||||
otherNodeBox.setScaleStayCentered(minBubbleSize);
|
|| (avatarNode->isIgnoringNodeWithID(node->getUUID()) && !getsAnyIgnored)) {
|
||||||
}
|
shouldIgnore = true;
|
||||||
// Quadruple the scale of both bounding boxes
|
} else {
|
||||||
otherNodeBox.embiggen(4.0f);
|
|
||||||
|
|
||||||
// Perform the collision check between the two bounding boxes
|
// Check to see if the space bubble is enabled
|
||||||
if (nodeBox.touches(otherNodeBox)) {
|
if (node->isIgnoreRadiusEnabled() || avatarNode->isIgnoreRadiusEnabled()) {
|
||||||
nodeData->ignoreOther(node, avatarNode);
|
|
||||||
shouldIgnore = !getsAnyIgnored;
|
// Define the scale of the box for the current other node
|
||||||
}
|
glm::vec3 otherNodeBoxScale = (avatarNodeData->getPosition() - avatarNodeData->getGlobalBoundingBoxCorner()) * 2.0f;
|
||||||
}
|
// Set up the bounding box for the current other node
|
||||||
// Not close enough to ignore
|
AABox otherNodeBox(avatarNodeData->getGlobalBoundingBoxCorner(), otherNodeBoxScale);
|
||||||
if (!shouldIgnore) {
|
// Clamp the size of the bounding box to a minimum scale
|
||||||
nodeData->removeFromRadiusIgnoringSet(node, avatarNode->getUUID());
|
if (glm::any(glm::lessThan(otherNodeBoxScale, minBubbleSize))) {
|
||||||
}
|
otherNodeBox.setScaleStayCentered(minBubbleSize);
|
||||||
}
|
}
|
||||||
quint64 endIgnoreCalculation = usecTimestampNow();
|
// Quadruple the scale of both bounding boxes
|
||||||
_stats.ignoreCalculationElapsedTime += (endIgnoreCalculation - startIgnoreCalculation);
|
otherNodeBox.embiggen(4.0f);
|
||||||
|
|
||||||
if (!shouldIgnore) {
|
// Perform the collision check between the two bounding boxes
|
||||||
AvatarDataSequenceNumber lastSeqToReceiver = nodeData->getLastBroadcastSequenceNumber(avatarNode->getUUID());
|
if (nodeBox.touches(otherNodeBox)) {
|
||||||
AvatarDataSequenceNumber lastSeqFromSender = avatarNodeData->getLastReceivedSequenceNumber();
|
nodeData->ignoreOther(node, avatarNode);
|
||||||
|
shouldIgnore = !getsAnyIgnored;
|
||||||
// FIXME - This code does appear to be working. But it seems brittle.
|
|
||||||
// It supports determining if the frame of data for this "other"
|
|
||||||
// avatar has already been sent to the reciever. This has been
|
|
||||||
// verified to work on a desktop display that renders at 60hz and
|
|
||||||
// therefore sends to mixer at 30hz. Each second you'd expect to
|
|
||||||
// have 15 (45hz-30hz) duplicate frames. In this case, the stat
|
|
||||||
// avg_other_av_skips_per_second does report 15.
|
|
||||||
//
|
|
||||||
// make sure we haven't already sent this data from this sender to this receiver
|
|
||||||
// or that somehow we haven't sent
|
|
||||||
if (lastSeqToReceiver == lastSeqFromSender && lastSeqToReceiver != 0) {
|
|
||||||
++numAvatarsHeldBack;
|
|
||||||
shouldIgnore = true;
|
|
||||||
} else if (lastSeqFromSender - lastSeqToReceiver > 1) {
|
|
||||||
// this is a skip - we still send the packet but capture the presence of the skip so we see it happening
|
|
||||||
++numAvatarsWithSkippedFrames;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Not close enough to ignore
|
||||||
|
if (!shouldIgnore) {
|
||||||
|
nodeData->removeFromRadiusIgnoringSet(node, avatarNode->getUUID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
quint64 endIgnoreCalculation = usecTimestampNow();
|
||||||
|
_stats.ignoreCalculationElapsedTime += (endIgnoreCalculation - startIgnoreCalculation);
|
||||||
|
|
||||||
|
if (!shouldIgnore) {
|
||||||
|
AvatarDataSequenceNumber lastSeqToReceiver = nodeData->getLastBroadcastSequenceNumber(avatarNode->getUUID());
|
||||||
|
AvatarDataSequenceNumber lastSeqFromSender = avatarNodeData->getLastReceivedSequenceNumber();
|
||||||
|
|
||||||
|
// FIXME - This code does appear to be working. But it seems brittle.
|
||||||
|
// It supports determining if the frame of data for this "other"
|
||||||
|
// avatar has already been sent to the reciever. This has been
|
||||||
|
// verified to work on a desktop display that renders at 60hz and
|
||||||
|
// therefore sends to mixer at 30hz. Each second you'd expect to
|
||||||
|
// have 15 (45hz-30hz) duplicate frames. In this case, the stat
|
||||||
|
// avg_other_av_skips_per_second does report 15.
|
||||||
|
//
|
||||||
|
// make sure we haven't already sent this data from this sender to this receiver
|
||||||
|
// or that somehow we haven't sent
|
||||||
|
if (lastSeqToReceiver == lastSeqFromSender && lastSeqToReceiver != 0) {
|
||||||
|
++numAvatarsHeldBack;
|
||||||
|
shouldIgnore = true;
|
||||||
|
} else if (lastSeqFromSender - lastSeqToReceiver > 1) {
|
||||||
|
// this is a skip - we still send the packet but capture the presence of the skip so we see it happening
|
||||||
|
++numAvatarsWithSkippedFrames;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return shouldIgnore;
|
return shouldIgnore;
|
||||||
});
|
});
|
||||||
|
@ -284,7 +286,6 @@ void AvatarMixerSlave::broadcastAvatarData(const SharedNodePointer& node) {
|
||||||
int avatarRank = 0;
|
int avatarRank = 0;
|
||||||
|
|
||||||
// this is overly conservative, because it includes some avatars we might not consider
|
// this is overly conservative, because it includes some avatars we might not consider
|
||||||
// FIXME - move the ignore logic up into the sorting list so we get a better estimate
|
|
||||||
int remainingAvatars = (int)sortedAvatars.size();
|
int remainingAvatars = (int)sortedAvatars.size();
|
||||||
|
|
||||||
while (!sortedAvatars.empty()) {
|
while (!sortedAvatars.empty()) {
|
||||||
|
@ -295,11 +296,7 @@ void AvatarMixerSlave::broadcastAvatarData(const SharedNodePointer& node) {
|
||||||
remainingAvatars--;
|
remainingAvatars--;
|
||||||
|
|
||||||
auto otherNode = avatarDataToNodes[avatarData];
|
auto otherNode = avatarDataToNodes[avatarData];
|
||||||
|
assert(otherNode); // we can't have gotten here without the avatarData being a valid key in the map
|
||||||
// FIXME - should't this be an assert?
|
|
||||||
if (!otherNode) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: Here's where we determine if we are over budget and drop to bare minimum data
|
// NOTE: Here's where we determine if we are over budget and drop to bare minimum data
|
||||||
int minimRemainingAvatarBytes = minimumBytesPerAvatar * remainingAvatars;
|
int minimRemainingAvatarBytes = minimumBytesPerAvatar * remainingAvatars;
|
||||||
|
|
Loading…
Reference in a new issue