when an avatar URL fails, switch to the default

This commit is contained in:
Seth Alves 2016-08-01 18:12:30 -07:00
parent f71a59276c
commit b953e6f0ff
6 changed files with 36 additions and 1 deletions

View file

@ -98,6 +98,7 @@ Avatar::Avatar(RigPointer rig) :
_headData = static_cast<HeadData*>(new Head(this));
_skeletonModel = std::make_shared<SkeletonModel>(this, nullptr, rig);
connect(_skeletonModel.get(), &Model::setURLFinished, this, &Avatar::setModelURLFinished);
}
Avatar::~Avatar() {
@ -916,6 +917,15 @@ void Avatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
}
}
void Avatar::setModelURLFinished(bool success) {
if (!success && _skeletonModelURL != AvatarData::defaultFullAvatarModelUrl()) {
qDebug() << "Using default after failing to load Avatar model: " << _skeletonModelURL;
QMetaObject::invokeMethod(this, "setSkeletonModelURL",
Qt::QueuedConnection, Q_ARG(QUrl, AvatarData::defaultFullAvatarModelUrl()));
}
}
// create new model, can return an instance of a SoftAttachmentModel rather then Model
static std::shared_ptr<Model> allocateAttachmentModel(bool isSoft, RigPointer rigOverride) {
if (isSoft) {

View file

@ -115,7 +115,7 @@ public:
virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) override { return false; }
virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) override { return false; }
virtual void setSkeletonModelURL(const QUrl& skeletonModelURL) override;
Q_INVOKABLE virtual void setSkeletonModelURL(const QUrl& skeletonModelURL) override;
virtual void setAttachmentData(const QVector<AttachmentData>& attachmentData) override;
void setShowDisplayName(bool showDisplayName);
@ -184,6 +184,8 @@ public slots:
glm::vec3 getRightPalmPosition() const;
glm::quat getRightPalmRotation() const;
void setModelURLFinished(bool success);
protected:
friend class AvatarManager;

View file

@ -404,6 +404,7 @@ void GeometryResourceWatcher::resourceFinished(bool success) {
if (success) {
_geometryRef = std::make_shared<Geometry>(*_resource);
}
emit finished(success);
}
void GeometryResourceWatcher::resourceRefreshed() {

View file

@ -111,6 +111,9 @@ public:
QUrl getURL() const { return (bool)_resource ? _resource->getURL() : QUrl(); }
signals:
void finished(bool success);
private:
void startWatching();
void stopWatching();

View file

@ -109,6 +109,9 @@ Model::Model(RigPointer rig, QObject* parent) :
}
setSnapModelToRegistrationPoint(true, glm::vec3(0.5f));
connect(&_renderWatcher, &GeometryResourceWatcher::finished, this, &Model::loadURLFinished);
connect(&_collisionWatcher, &GeometryResourceWatcher::finished, this, &Model::loadURLFinished);
}
Model::~Model() {
@ -825,6 +828,10 @@ void Model::setURL(const QUrl& url) {
onInvalidate();
}
void Model::loadURLFinished(bool success) {
emit setURLFinished(success);
}
void Model::setCollisionModelURL(const QUrl& url) {
if (_collisionUrl == url && _collisionWatcher.getURL() == url) {
return;
@ -833,6 +840,10 @@ void Model::setCollisionModelURL(const QUrl& url) {
_collisionWatcher.setResource(DependencyManager::get<ModelCache>()->getGeometryResource(url));
}
void Model::loadCollisionModelURLFinished(bool success) {
emit setCollisionModelURLFinished(success);
}
bool Model::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position) const {
return _rig->getJointPositionInWorldFrame(jointIndex, position, _translation, _rotation);
}

View file

@ -236,6 +236,14 @@ public:
// returns 'true' if needs fullUpdate after geometry change
bool updateGeometry();
public slots:
void loadURLFinished(bool success);
void loadCollisionModelURLFinished(bool success);
signals:
void setURLFinished(bool success);
void setCollisionModelURLFinished(bool success);
protected:
void setPupilDilation(float dilation) { _pupilDilation = dilation; }