mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-26 06:55:16 +02:00
Merge pull request #8346 from sethalves/default-when-av-fails
use default avatar when avatar-url is bogus
This commit is contained in:
commit
1e2d77a99b
9 changed files with 57 additions and 15 deletions
|
@ -98,6 +98,7 @@ Avatar::Avatar(RigPointer rig) :
|
||||||
_headData = static_cast<HeadData*>(new Head(this));
|
_headData = static_cast<HeadData*>(new Head(this));
|
||||||
|
|
||||||
_skeletonModel = std::make_shared<SkeletonModel>(this, nullptr, rig);
|
_skeletonModel = std::make_shared<SkeletonModel>(this, nullptr, rig);
|
||||||
|
connect(_skeletonModel.get(), &Model::setURLFinished, this, &Avatar::setModelURLFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
Avatar::~Avatar() {
|
Avatar::~Avatar() {
|
||||||
|
@ -298,7 +299,9 @@ void Avatar::simulate(float deltaTime) {
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("head");
|
PerformanceTimer perfTimer("head");
|
||||||
glm::vec3 headPosition = getPosition();
|
glm::vec3 headPosition = getPosition();
|
||||||
_skeletonModel->getHeadPosition(headPosition);
|
if (!_skeletonModel->getHeadPosition(headPosition)) {
|
||||||
|
headPosition = getPosition();
|
||||||
|
}
|
||||||
Head* head = getHead();
|
Head* head = getHead();
|
||||||
head->setPosition(headPosition);
|
head->setPosition(headPosition);
|
||||||
head->setScale(getUniformScale());
|
head->setScale(getUniformScale());
|
||||||
|
@ -306,6 +309,7 @@ void Avatar::simulate(float deltaTime) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// a non-full update is still required so that the position, rotation, scale and bounds of the skeletonModel are updated.
|
// a non-full update is still required so that the position, rotation, scale and bounds of the skeletonModel are updated.
|
||||||
|
getHead()->setPosition(getPosition());
|
||||||
_skeletonModel->simulate(deltaTime, false);
|
_skeletonModel->simulate(deltaTime, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -916,6 +920,17 @@ 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;
|
||||||
|
// call _skeletonModel.setURL, but leave our copy of _skeletonModelURL alone. This is so that
|
||||||
|
// we don't redo this every time we receive an identity packet from the avatar with the bad url.
|
||||||
|
QMetaObject::invokeMethod(_skeletonModel.get(), "setURL",
|
||||||
|
Qt::QueuedConnection, Q_ARG(QUrl, AvatarData::defaultFullAvatarModelUrl()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// create new model, can return an instance of a SoftAttachmentModel rather then Model
|
// create new model, can return an instance of a SoftAttachmentModel rather then Model
|
||||||
static std::shared_ptr<Model> allocateAttachmentModel(bool isSoft, RigPointer rigOverride) {
|
static std::shared_ptr<Model> allocateAttachmentModel(bool isSoft, RigPointer rigOverride) {
|
||||||
if (isSoft) {
|
if (isSoft) {
|
||||||
|
|
|
@ -184,6 +184,8 @@ public slots:
|
||||||
glm::vec3 getRightPalmPosition() const;
|
glm::vec3 getRightPalmPosition() const;
|
||||||
glm::quat getRightPalmRotation() const;
|
glm::quat getRightPalmRotation() const;
|
||||||
|
|
||||||
|
void setModelURLFinished(bool success);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class AvatarManager;
|
friend class AvatarManager;
|
||||||
|
|
||||||
|
|
|
@ -430,6 +430,7 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
|
|
||||||
if (!_skeletonModel->hasSkeleton()) {
|
if (!_skeletonModel->hasSkeleton()) {
|
||||||
// All the simulation that can be done has been done
|
// All the simulation that can be done has been done
|
||||||
|
getHead()->setPosition(getPosition()); // so audio-position isn't 0,0,0
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -919,7 +919,9 @@ bool RenderableModelEntityItem::contains(const glm::vec3& point) const {
|
||||||
bool RenderableModelEntityItem::shouldBePhysical() const {
|
bool RenderableModelEntityItem::shouldBePhysical() const {
|
||||||
// If we have a model, make sure it hasn't failed to download.
|
// If we have a model, make sure it hasn't failed to download.
|
||||||
// If it has, we'll report back that we shouldn't be physical so that physics aren't held waiting for us to be ready.
|
// If it has, we'll report back that we shouldn't be physical so that physics aren't held waiting for us to be ready.
|
||||||
if (_model && _model->didGeometryRequestFail()) {
|
if (_model && getShapeType() == SHAPE_TYPE_COMPOUND && _model->didCollisionGeometryRequestFail()) {
|
||||||
|
return false;
|
||||||
|
} else if (_model && getShapeType() != SHAPE_TYPE_NONE && _model->didVisualGeometryRequestFail()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return ModelEntityItem::shouldBePhysical();
|
return ModelEntityItem::shouldBePhysical();
|
||||||
|
|
|
@ -403,9 +403,8 @@ void GeometryResourceWatcher::setResource(GeometryResource::Pointer resource) {
|
||||||
void GeometryResourceWatcher::resourceFinished(bool success) {
|
void GeometryResourceWatcher::resourceFinished(bool success) {
|
||||||
if (success) {
|
if (success) {
|
||||||
_geometryRef = std::make_shared<Geometry>(*_resource);
|
_geometryRef = std::make_shared<Geometry>(*_resource);
|
||||||
} else {
|
|
||||||
emit resourceFailed();
|
|
||||||
}
|
}
|
||||||
|
emit finished(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryResourceWatcher::resourceRefreshed() {
|
void GeometryResourceWatcher::resourceRefreshed() {
|
||||||
|
|
|
@ -112,7 +112,7 @@ public:
|
||||||
QUrl getURL() const { return (bool)_resource ? _resource->getURL() : QUrl(); }
|
QUrl getURL() const { return (bool)_resource ? _resource->getURL() : QUrl(); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void resourceFailed();
|
void finished(bool success);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void startWatching();
|
void startWatching();
|
||||||
|
|
|
@ -111,8 +111,8 @@ Model::Model(RigPointer rig, QObject* parent) :
|
||||||
|
|
||||||
setSnapModelToRegistrationPoint(true, glm::vec3(0.5f));
|
setSnapModelToRegistrationPoint(true, glm::vec3(0.5f));
|
||||||
|
|
||||||
// handle download failure reported by the GeometryResourceWatcher
|
connect(&_renderWatcher, &GeometryResourceWatcher::finished, this, &Model::loadURLFinished);
|
||||||
connect(&_renderWatcher, &GeometryResourceWatcher::resourceFailed, this, &Model::handleGeometryResourceFailure);
|
connect(&_collisionWatcher, &GeometryResourceWatcher::finished, this, &Model::loadCollisionModelURLFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
Model::~Model() {
|
Model::~Model() {
|
||||||
|
@ -822,7 +822,7 @@ void Model::setURL(const QUrl& url) {
|
||||||
_needsReload = true;
|
_needsReload = true;
|
||||||
_needsUpdateTextures = true;
|
_needsUpdateTextures = true;
|
||||||
_meshGroupsKnown = false;
|
_meshGroupsKnown = false;
|
||||||
_geometryRequestFailed = false;
|
_visualGeometryRequestFailed = false;
|
||||||
invalidCalculatedMeshBoxes();
|
invalidCalculatedMeshBoxes();
|
||||||
deleteGeometry();
|
deleteGeometry();
|
||||||
|
|
||||||
|
@ -830,14 +830,30 @@ void Model::setURL(const QUrl& url) {
|
||||||
onInvalidate();
|
onInvalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Model::loadURLFinished(bool success) {
|
||||||
|
if (!success) {
|
||||||
|
_visualGeometryRequestFailed = true;
|
||||||
|
}
|
||||||
|
emit setURLFinished(success);
|
||||||
|
}
|
||||||
|
|
||||||
void Model::setCollisionModelURL(const QUrl& url) {
|
void Model::setCollisionModelURL(const QUrl& url) {
|
||||||
if (_collisionUrl == url && _collisionWatcher.getURL() == url) {
|
if (_collisionUrl == url && _collisionWatcher.getURL() == url) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_collisionUrl = url;
|
_collisionUrl = url;
|
||||||
|
_collisionGeometryRequestFailed = false;
|
||||||
_collisionWatcher.setResource(DependencyManager::get<ModelCache>()->getGeometryResource(url));
|
_collisionWatcher.setResource(DependencyManager::get<ModelCache>()->getGeometryResource(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Model::loadCollisionModelURLFinished(bool success) {
|
||||||
|
if (!success) {
|
||||||
|
_collisionGeometryRequestFailed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit setCollisionModelURLFinished(success);
|
||||||
|
}
|
||||||
|
|
||||||
bool Model::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position) const {
|
bool Model::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position) const {
|
||||||
return _rig->getJointPositionInWorldFrame(jointIndex, position, _translation, _rotation);
|
return _rig->getJointPositionInWorldFrame(jointIndex, position, _translation, _rotation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,8 @@ public:
|
||||||
|
|
||||||
bool isActive() const { return isLoaded(); }
|
bool isActive() const { return isLoaded(); }
|
||||||
|
|
||||||
bool didGeometryRequestFail() const { return _geometryRequestFailed; }
|
bool didVisualGeometryRequestFail() const { return _visualGeometryRequestFailed; }
|
||||||
|
bool didCollisionGeometryRequestFail() const { return _collisionGeometryRequestFailed; }
|
||||||
|
|
||||||
bool convexHullContains(glm::vec3 point);
|
bool convexHullContains(glm::vec3 point);
|
||||||
|
|
||||||
|
@ -237,6 +238,14 @@ public:
|
||||||
// returns 'true' if needs fullUpdate after geometry change
|
// returns 'true' if needs fullUpdate after geometry change
|
||||||
bool updateGeometry();
|
bool updateGeometry();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void loadURLFinished(bool success);
|
||||||
|
void loadCollisionModelURLFinished(bool success);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void setURLFinished(bool success);
|
||||||
|
void setCollisionModelURLFinished(bool success);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void setPupilDilation(float dilation) { _pupilDilation = dilation; }
|
void setPupilDilation(float dilation) { _pupilDilation = dilation; }
|
||||||
|
@ -394,10 +403,8 @@ protected:
|
||||||
|
|
||||||
uint32_t _deleteGeometryCounter { 0 };
|
uint32_t _deleteGeometryCounter { 0 };
|
||||||
|
|
||||||
bool _geometryRequestFailed { false };
|
bool _visualGeometryRequestFailed { false };
|
||||||
|
bool _collisionGeometryRequestFailed { false };
|
||||||
private slots:
|
|
||||||
void handleGeometryResourceFailure() { _geometryRequestFailed = true; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(ModelPointer)
|
Q_DECLARE_METATYPE(ModelPointer)
|
||||||
|
|
|
@ -40,7 +40,7 @@ var DEFAULT_SOUND_DATA = {
|
||||||
|
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
Agent.isAvatar = true; // This puts a robot at 0,0,0, but is currently necessary in order to use AvatarList.
|
Agent.isAvatar = true; // This puts a robot at 0,0,0, but is currently necessary in order to use AvatarList.
|
||||||
Avatar.skeletonModelURL = "http://invalid-url";
|
Avatar.skeletonModelURL = "http://hifi-content.s3.amazonaws.com/ozan/dev/avatars/invisible_avatar/invisible_avatar.fst";
|
||||||
function ignore() {}
|
function ignore() {}
|
||||||
function debug() { // Display the arguments not just [Object object].
|
function debug() { // Display the arguments not just [Object object].
|
||||||
//print.apply(null, [].map.call(arguments, JSON.stringify));
|
//print.apply(null, [].map.call(arguments, JSON.stringify));
|
||||||
|
|
Loading…
Reference in a new issue