immediately fade out ignored avatars

This commit is contained in:
Stephen Birarda 2016-07-11 14:46:21 -07:00
parent d5af323057
commit 6b6513d5f9
6 changed files with 17 additions and 9 deletions

View file

@ -435,7 +435,7 @@ void AvatarMixer::handleKillAvatarPacket(QSharedPointer<ReceivedMessage> message
void AvatarMixer::handleNodeIgnoreRequestPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) {
// parse out the UUID being ignored from the packet
QUuid ignoredUUID = QUuid::fromRfc4122(packet->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
QUuid ignoredUUID = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
senderNode->addIgnoredNode(ignoredUUID);
}

View file

@ -441,6 +441,7 @@ bool setupEssentials(int& argc, char** argv) {
DependencyManager::set<FramebufferCache>();
DependencyManager::set<AnimationCache>();
DependencyManager::set<ModelBlender>();
DependencyManager::set<UsersScriptingInterface>();
DependencyManager::set<AvatarManager>();
DependencyManager::set<LODManager>();
DependencyManager::set<StandAloneJSConsole>();
@ -455,7 +456,6 @@ bool setupEssentials(int& argc, char** argv) {
DependencyManager::set<ResourceScriptingInterface>();
DependencyManager::set<ToolbarScriptingInterface>();
DependencyManager::set<UserActivityLoggerScriptingInterface>();
DependencyManager::set<UsersScriptingInterface>();
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
DependencyManager::set<SpeechRecognizer>();

View file

@ -29,6 +29,7 @@
#include <RegisteredMetaTypes.h>
#include <Rig.h>
#include <SettingHandle.h>
#include <UsersScriptingInterface.h>
#include <UUID.h>
#include "Application.h"
@ -73,6 +74,11 @@ AvatarManager::AvatarManager(QObject* parent) :
packetReceiver.registerListener(PacketType::BulkAvatarData, this, "processAvatarDataPacket");
packetReceiver.registerListener(PacketType::KillAvatar, this, "processKillAvatar");
packetReceiver.registerListener(PacketType::AvatarIdentity, this, "processAvatarIdentityPacket");
// when we hear that the user has ignored an avatar by session UUID
// immediately remove that avatar instead of waiting for the absence of packets from avatar mixer
auto usersScriptingInterface = DependencyManager::get<UsersScriptingInterface>();
connect(usersScriptingInterface.data(), &UsersScriptingInterface::ignoredNode, this, &AvatarManager::removeAvatar);
}
AvatarManager::~AvatarManager() {
@ -85,7 +91,8 @@ void AvatarManager::init() {
_avatarHash.insert(MY_AVATAR_KEY, _myAvatar);
}
connect(DependencyManager::get<SceneScriptingInterface>().data(), &SceneScriptingInterface::shouldRenderAvatarsChanged, this, &AvatarManager::updateAvatarRenderStatus, Qt::QueuedConnection);
connect(DependencyManager::get<SceneScriptingInterface>().data(), &SceneScriptingInterface::shouldRenderAvatarsChanged,
this, &AvatarManager::updateAvatarRenderStatus, Qt::QueuedConnection);
render::ScenePointer scene = qApp->getMain3DScene();
render::PendingChanges pendingChanges;

View file

@ -78,6 +78,9 @@ public slots:
void setShouldShowReceiveStats(bool shouldShowReceiveStats) { _shouldShowReceiveStats = shouldShowReceiveStats; }
void updateAvatarRenderStatus(bool shouldRenderAvatars);
private slots:
virtual void removeAvatar(const QUuid& sessionUUID) override;
private:
explicit AvatarManager(QObject* parent = 0);
explicit AvatarManager(const AvatarManager& other);
@ -88,7 +91,6 @@ private:
virtual AvatarSharedPointer newSharedAvatar() override;
virtual AvatarSharedPointer addAvatar(const QUuid& sessionUUID, const QWeakPointer<Node>& mixerWeakPointer) override;
virtual void removeAvatar(const QUuid& sessionUUID) override;
virtual void handleRemovedAvatar(const AvatarSharedPointer& removedAvatar) override;
QVector<AvatarSharedPointer> _avatarFades;

View file

@ -81,14 +81,14 @@ void Node::updateClockSkewUsec(qint64 clockSkewSample) {
}
void Node::addIgnoredNode(const QUuid& otherNodeID) {
if (otherNodeID != _uuid) {
if (!otherNodeID.isNull() && otherNodeID != _uuid) {
qCDebug(networking) << "Adding" << uuidStringWithoutCurlyBraces(otherNodeID) << "to ignore set for"
<< uuidStringWithoutCurlyBraces(_uuid);
// add the session UUID to the set of ignored ones for this listening node
_ignoredNodeIDSet.insert(otherNodeID);
} else {
qCWarning(networking) << "Node::addIgnoredNode called with ID of ignoring node - nodes cannot self-ignore.";
qCWarning(networking) << "Node::addIgnoredNode called with null ID or ID of ignoring node.";
}
}

View file

@ -20,7 +20,7 @@ void UsersScriptingInterface::ignore(const QUuid& nodeID) {
// enumerate the nodes to send a reliable ignore packet to each that can leverage it
auto nodeList = DependencyManager::get<NodeList>();
if (nodeList->getSessionUUID() != nodeID) {
if (!nodeID.isNull() && nodeList->getSessionUUID() != nodeID) {
nodeList->eachMatchingNode([&nodeID](const SharedNodePointer& node)->bool {
if (node->getType() == NodeType::AudioMixer || node->getType() == NodeType::AvatarMixer) {
return true;
@ -42,7 +42,6 @@ void UsersScriptingInterface::ignore(const QUuid& nodeID) {
emit ignoredNode(nodeID);
} else {
qWarning() << "UsersScriptingInterface was asked to ignore a node ID which matches the current session ID, "
<< "but self-ignore has no meaning.";
qWarning() << "UsersScriptingInterface::ignore called with an invalid ID or an ID which matches the current session ID.";
}
}