From dec41f67cc53d6c8b2a6dd58220198179d42dbba Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Fri, 6 Jan 2017 13:58:23 -0800 Subject: [PATCH] Fix bugs and generally fix behavior --- assignment-client/src/audio/AudioMixer.cpp | 15 +++++++++++++++ assignment-client/src/audio/AudioMixer.h | 1 + .../src/audio/AudioMixerClientData.h | 3 +++ assignment-client/src/audio/AudioMixerSlave.cpp | 11 ++++++++--- assignment-client/src/avatars/AvatarMixer.cpp | 2 +- interface/src/avatar/Avatar.cpp | 5 +++-- interface/src/avatar/AvatarManager.cpp | 2 ++ libraries/networking/src/NodeList.cpp | 4 ++-- 8 files changed, 35 insertions(+), 8 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 01715497b1..19ebd4ea87 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -68,6 +68,7 @@ AudioMixer::AudioMixer(ReceivedMessage& message) : packetReceiver.registerListener(PacketType::KillAvatar, this, "handleKillAvatarPacket"); packetReceiver.registerListener(PacketType::NodeMuteRequest, this, "handleNodeMuteRequestPacket"); packetReceiver.registerListener(PacketType::RadiusIgnoreRequest, this, "handleRadiusIgnoreRequestPacket"); + packetReceiver.registerListener(PacketType::RequestsDomainListData, this, "handleRequestsDomainListDataPacket"); connect(nodeList.data(), &NodeList::nodeKilled, this, &AudioMixer::handleNodeKilled); } @@ -221,6 +222,20 @@ void AudioMixer::handleKillAvatarPacket(QSharedPointer packet, } } +void AudioMixer::handleRequestsDomainListDataPacket(QSharedPointer message, SharedNodePointer senderNode) { + auto nodeList = DependencyManager::get(); + nodeList->getOrCreateLinkedData(senderNode); + + if (senderNode->getLinkedData()) { + AudioMixerClientData* nodeData = dynamic_cast(senderNode->getLinkedData()); + if (nodeData != nullptr) { + bool isRequesting; + message->readPrimitive(&isRequesting); + nodeData->setRequestsDomainListData(isRequesting); + } + } +} + void AudioMixer::handleNodeIgnoreRequestPacket(QSharedPointer packet, SharedNodePointer sendingNode) { sendingNode->parseIgnoreRequestMessage(packet); } diff --git a/assignment-client/src/audio/AudioMixer.h b/assignment-client/src/audio/AudioMixer.h index 59cdec7732..d9759653fb 100644 --- a/assignment-client/src/audio/AudioMixer.h +++ b/assignment-client/src/audio/AudioMixer.h @@ -61,6 +61,7 @@ private slots: void handleMuteEnvironmentPacket(QSharedPointer packet, SharedNodePointer sendingNode); void handleNegotiateAudioFormat(QSharedPointer message, SharedNodePointer sendingNode); void handleNodeKilled(SharedNodePointer killedNode); + void handleRequestsDomainListDataPacket(QSharedPointer message, SharedNodePointer senderNode); void handleNodeIgnoreRequestPacket(QSharedPointer packet, SharedNodePointer sendingNode); void handleRadiusIgnoreRequestPacket(QSharedPointer packet, SharedNodePointer sendingNode); void handleKillAvatarPacket(QSharedPointer packet, SharedNodePointer sendingNode); diff --git a/assignment-client/src/audio/AudioMixerClientData.h b/assignment-client/src/audio/AudioMixerClientData.h index 07e98c044b..e637fd0409 100644 --- a/assignment-client/src/audio/AudioMixerClientData.h +++ b/assignment-client/src/audio/AudioMixerClientData.h @@ -92,6 +92,8 @@ public: glm::vec3 getPosition() { return getAvatarAudioStream() ? getAvatarAudioStream()->getPosition() : glm::vec3(0); } glm::vec3 getAvatarBoundingBoxCorner() { return getAvatarAudioStream() ? getAvatarAudioStream()->getAvatarBoundingBoxCorner() : glm::vec3(0); } glm::vec3 getAvatarBoundingBoxScale() { return getAvatarAudioStream() ? getAvatarAudioStream()->getAvatarBoundingBoxScale() : glm::vec3(0); } + bool getRequestsDomainListData() { return _requestsDomainListData; } + void setRequestsDomainListData(bool requesting) { _requestsDomainListData = requesting; } signals: void injectorStreamFinished(const QUuid& streamIdentifier); @@ -122,6 +124,7 @@ private: bool _shouldFlushEncoder { false }; bool _shouldMuteClient { false }; + bool _requestsDomainListData { false }; }; #endif // hifi_AudioMixerClientData_h diff --git a/assignment-client/src/audio/AudioMixerSlave.cpp b/assignment-client/src/audio/AudioMixerSlave.cpp index 42e8c5bdef..9958d95aa4 100644 --- a/assignment-client/src/audio/AudioMixerSlave.cpp +++ b/assignment-client/src/audio/AudioMixerSlave.cpp @@ -209,8 +209,13 @@ bool AudioMixerSlave::prepareMix(const SharedNodePointer& node) { // and that it isn't being ignored by our listening node // and that it isn't ignoring our listening node AudioMixerClientData* otherData = static_cast(otherNode->getLinkedData()); + + // When this is true, the AudioMixer will send Audio data to a client about avatars that have ignored them + bool getsAnyIgnored = nodeData->getRequestsDomainListData() && node->getCanKick(); + if (otherData - && !node->isIgnoringNodeWithID(otherNode->getUUID()) && !otherNode->isIgnoringNodeWithID(node->getUUID())) { + && !node->isIgnoringNodeWithID(otherNode->getUUID()) + && (!otherNode->isIgnoringNodeWithID(node->getUUID()) || getsAnyIgnored)) { // check to see if we're ignoring in radius bool insideIgnoreRadius = false; @@ -219,7 +224,7 @@ bool AudioMixerSlave::prepareMix(const SharedNodePointer& node) { // We'll always be inside the radius in that case. insideIgnoreRadius = true; // Check to see if the space bubble is enabled - } else if ((node->isIgnoreRadiusEnabled() || otherNode->isIgnoreRadiusEnabled()) && (*otherNode != *node)) { + } else if ((node->isIgnoreRadiusEnabled() || otherNode->isIgnoreRadiusEnabled())) { // Define the minimum bubble size static const glm::vec3 minBubbleSize = glm::vec3(0.3f, 1.3f, 0.3f); AudioMixerClientData* nodeData = reinterpret_cast(node->getLinkedData()); @@ -251,7 +256,7 @@ bool AudioMixerSlave::prepareMix(const SharedNodePointer& node) { auto otherNodeStream = streamPair.second; bool isSelfWithEcho = ((*otherNode == *node) && (otherNodeStream->shouldLoopbackForNode())); // Add all audio streams that should be added to the mix - if (isSelfWithEcho || (!isSelfWithEcho && !insideIgnoreRadius)) { + if (isSelfWithEcho || (!isSelfWithEcho && !insideIgnoreRadius && getsAnyIgnored)) { addStreamToMix(*nodeData, otherNode->getUUID(), *nodeAudioStream, *otherNodeStream); } } diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index ddecd1b50f..11cbd73970 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -326,7 +326,7 @@ void AvatarMixer::broadcastAvatarData() { // Perform the collision check between the two bounding boxes if (nodeBox.touches(otherNodeBox)) { nodeData->ignoreOther(node, otherNode); - return getsIgnoredByMe || getsAnyIgnored; + return getsAnyIgnored; } } // Not close enough to ignore diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 659a96afa0..81eee6b3a7 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -1339,9 +1339,10 @@ void Avatar::addToScene(AvatarSharedPointer myHandle) { render::ScenePointer scene = qApp->getMain3DScene(); if (scene) { render::PendingChanges pendingChanges; + auto nodelist = DependencyManager::get(); if (DependencyManager::get()->shouldRenderAvatars() - && !DependencyManager::get()->isIgnoringNode(getSessionUUID()) - && !DependencyManager::get()->isRadiusIgnoringNode(getSessionUUID())) { + && !nodelist->isIgnoringNode(getSessionUUID()) + && !nodelist->isRadiusIgnoringNode(getSessionUUID())) { addToScene(myHandle, scene, pendingChanges); } scene->enqueuePendingChanges(pendingChanges); diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index e955f94597..1f5726acba 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -257,6 +257,8 @@ void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar if (removalReason == KillAvatarReason::TheirAvatarEnteredYourBubble) { emit DependencyManager::get()->enteredIgnoreRadius(); + } + if (removalReason == KillAvatarReason::TheirAvatarEnteredYourBubble || removalReason == YourAvatarEnteredTheirBubble) { DependencyManager::get()->radiusIgnoreNodeBySessionID(avatar->getSessionUUID(), true); } _avatarFades.push_back(removedAvatar); diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index c587037911..d890431a45 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -1040,12 +1040,12 @@ void NodeList::processUsernameFromIDReply(QSharedPointer messag } void NodeList::setRequestsDomainListData(bool isRequesting) { - // Tell the avatar mixer whether I want to receive any additional data to which I might be entitled + // Tell the avatar mixer and audio mixer whether I want to receive any additional data to which I might be entitled if (_requestsDomainListData == isRequesting) { return; } eachMatchingNode([](const SharedNodePointer& node)->bool { - return node->getType() == NodeType::AvatarMixer; + return (node->getType() == NodeType::AudioMixer || node->getType() == NodeType::AvatarMixer); }, [this, isRequesting](const SharedNodePointer& destinationNode) { auto packet = NLPacket::create(PacketType::RequestsDomainListData, sizeof(bool), true); // reliable packet->writePrimitive(isRequesting);