mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 03:03:35 +02:00
Fetch avatars' fst files
This commit is contained in:
parent
facf8a9305
commit
e4f6f2cb14
3 changed files with 75 additions and 3 deletions
|
@ -183,6 +183,7 @@ void AvatarMixerClientData::processSetTraitsMessage(ReceivedMessage& message,
|
||||||
if (traitType == AvatarTraits::SkeletonModelURL) {
|
if (traitType == AvatarTraits::SkeletonModelURL) {
|
||||||
// special handling for skeleton model URL, since we need to make sure it is in the whitelist
|
// special handling for skeleton model URL, since we need to make sure it is in the whitelist
|
||||||
checkSkeletonURLAgainstWhitelist(slaveSharedData, sendingNode, packetTraitVersion);
|
checkSkeletonURLAgainstWhitelist(slaveSharedData, sendingNode, packetTraitVersion);
|
||||||
|
_avatar->fetchAvatarFST();
|
||||||
}
|
}
|
||||||
|
|
||||||
anyTraitsChanged = true;
|
anyTraitsChanged = true;
|
||||||
|
|
59
assignment-client/src/avatars/MixerAvatar.cpp
Normal file
59
assignment-client/src/avatars/MixerAvatar.cpp
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
//
|
||||||
|
// MixerAvatar.cpp
|
||||||
|
// assignment-client/src/avatars
|
||||||
|
//
|
||||||
|
// Created by Simon Walton April 2019
|
||||||
|
//
|
||||||
|
// Copyright 2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <ResourceManager.h>
|
||||||
|
|
||||||
|
#include "MixerAvatar.h"
|
||||||
|
#include "AvatarLogging.h"
|
||||||
|
|
||||||
|
void MixerAvatar::fetchAvatarFST() {
|
||||||
|
_avatarFSTValid = false;
|
||||||
|
auto resourceManager = DependencyManager::get<ResourceManager>();
|
||||||
|
QUrl avatarURL = getSkeletonModelURL();
|
||||||
|
if (avatarURL.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_avatarURLString = avatarURL.toDisplayString();
|
||||||
|
|
||||||
|
ResourceRequest * fstRequest = resourceManager->createResourceRequest(this, avatarURL);
|
||||||
|
if (fstRequest) {
|
||||||
|
QMutexLocker certifyLocker(&_avatarCertifyLock);
|
||||||
|
|
||||||
|
if (_avatarRequest) {
|
||||||
|
_avatarRequest->deleteLater();
|
||||||
|
}
|
||||||
|
_avatarRequest = fstRequest;
|
||||||
|
connect(fstRequest, &ResourceRequest::finished, this, &MixerAvatar::fstRequestComplete);
|
||||||
|
fstRequest->send();
|
||||||
|
} else {
|
||||||
|
qCDebug(avatars) << "Couldn't create FST request for" << avatarURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MixerAvatar::fstRequestComplete() {
|
||||||
|
ResourceRequest* fstRequest = static_cast<ResourceRequest*>(QObject::sender());
|
||||||
|
QMutexLocker certifyLocker(&_avatarCertifyLock);
|
||||||
|
if (fstRequest == _avatarRequest) {
|
||||||
|
auto result = fstRequest->getResult();
|
||||||
|
if (result != ResourceRequest::Success) {
|
||||||
|
qCDebug(avatars) << "FST request for" << fstRequest->getUrl() << "failed:" << result;
|
||||||
|
} else {
|
||||||
|
_avatarFSTContents = fstRequest->getData();
|
||||||
|
_avatarFSTValid = true;
|
||||||
|
}
|
||||||
|
_avatarRequest->deleteLater();
|
||||||
|
_avatarRequest = nullptr;
|
||||||
|
} else {
|
||||||
|
qCDebug(avatars) << "Incorrect request for" << getDisplayName();
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,14 +17,26 @@
|
||||||
|
|
||||||
#include <AvatarData.h>
|
#include <AvatarData.h>
|
||||||
|
|
||||||
|
class ResourceRequest;
|
||||||
|
|
||||||
class MixerAvatar : public AvatarData {
|
class MixerAvatar : public AvatarData {
|
||||||
public:
|
public:
|
||||||
bool getNeedsHeroCheck() const { return _needsHeroCheck; }
|
bool getNeedsHeroCheck() const { return _needsHeroCheck; }
|
||||||
void setNeedsHeroCheck(bool needsHeroCheck = true)
|
void setNeedsHeroCheck(bool needsHeroCheck = true) { _needsHeroCheck = needsHeroCheck; }
|
||||||
{ _needsHeroCheck = needsHeroCheck; }
|
|
||||||
|
void fetchAvatarFST();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _needsHeroCheck { false };
|
bool _needsHeroCheck{ false };
|
||||||
|
|
||||||
|
QMutex _avatarCertifyLock;
|
||||||
|
ResourceRequest* _avatarRequest{ nullptr };
|
||||||
|
QString _avatarURLString;
|
||||||
|
QByteArray _avatarFSTContents;
|
||||||
|
bool _avatarFSTValid { false };
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void fstRequestComplete();
|
||||||
};
|
};
|
||||||
|
|
||||||
using MixerAvatarSharedPointer = std::shared_ptr<MixerAvatar>;
|
using MixerAvatarSharedPointer = std::shared_ptr<MixerAvatar>;
|
||||||
|
|
Loading…
Reference in a new issue