mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:24:07 +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));
|
||||
|
||||
_skeletonModel = std::make_shared<SkeletonModel>(this, nullptr, rig);
|
||||
connect(_skeletonModel.get(), &Model::setURLFinished, this, &Avatar::setModelURLFinished);
|
||||
}
|
||||
|
||||
Avatar::~Avatar() {
|
||||
|
@ -298,7 +299,9 @@ void Avatar::simulate(float deltaTime) {
|
|||
{
|
||||
PerformanceTimer perfTimer("head");
|
||||
glm::vec3 headPosition = getPosition();
|
||||
_skeletonModel->getHeadPosition(headPosition);
|
||||
if (!_skeletonModel->getHeadPosition(headPosition)) {
|
||||
headPosition = getPosition();
|
||||
}
|
||||
Head* head = getHead();
|
||||
head->setPosition(headPosition);
|
||||
head->setScale(getUniformScale());
|
||||
|
@ -306,6 +309,7 @@ void Avatar::simulate(float deltaTime) {
|
|||
}
|
||||
} else {
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
static std::shared_ptr<Model> allocateAttachmentModel(bool isSoft, RigPointer rigOverride) {
|
||||
if (isSoft) {
|
||||
|
|
|
@ -184,6 +184,8 @@ public slots:
|
|||
glm::vec3 getRightPalmPosition() const;
|
||||
glm::quat getRightPalmRotation() const;
|
||||
|
||||
void setModelURLFinished(bool success);
|
||||
|
||||
protected:
|
||||
friend class AvatarManager;
|
||||
|
||||
|
|
|
@ -430,6 +430,7 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
|
||||
if (!_skeletonModel->hasSkeleton()) {
|
||||
// All the simulation that can be done has been done
|
||||
getHead()->setPosition(getPosition()); // so audio-position isn't 0,0,0
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -919,7 +919,9 @@ bool RenderableModelEntityItem::contains(const glm::vec3& point) const {
|
|||
bool RenderableModelEntityItem::shouldBePhysical() const {
|
||||
// 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 (_model && _model->didGeometryRequestFail()) {
|
||||
if (_model && getShapeType() == SHAPE_TYPE_COMPOUND && _model->didCollisionGeometryRequestFail()) {
|
||||
return false;
|
||||
} else if (_model && getShapeType() != SHAPE_TYPE_NONE && _model->didVisualGeometryRequestFail()) {
|
||||
return false;
|
||||
} else {
|
||||
return ModelEntityItem::shouldBePhysical();
|
||||
|
|
|
@ -403,9 +403,8 @@ void GeometryResourceWatcher::setResource(GeometryResource::Pointer resource) {
|
|||
void GeometryResourceWatcher::resourceFinished(bool success) {
|
||||
if (success) {
|
||||
_geometryRef = std::make_shared<Geometry>(*_resource);
|
||||
} else {
|
||||
emit resourceFailed();
|
||||
}
|
||||
emit finished(success);
|
||||
}
|
||||
|
||||
void GeometryResourceWatcher::resourceRefreshed() {
|
||||
|
|
|
@ -112,7 +112,7 @@ public:
|
|||
QUrl getURL() const { return (bool)_resource ? _resource->getURL() : QUrl(); }
|
||||
|
||||
signals:
|
||||
void resourceFailed();
|
||||
void finished(bool success);
|
||||
|
||||
private:
|
||||
void startWatching();
|
||||
|
|
|
@ -111,8 +111,8 @@ Model::Model(RigPointer rig, QObject* parent) :
|
|||
|
||||
setSnapModelToRegistrationPoint(true, glm::vec3(0.5f));
|
||||
|
||||
// handle download failure reported by the GeometryResourceWatcher
|
||||
connect(&_renderWatcher, &GeometryResourceWatcher::resourceFailed, this, &Model::handleGeometryResourceFailure);
|
||||
connect(&_renderWatcher, &GeometryResourceWatcher::finished, this, &Model::loadURLFinished);
|
||||
connect(&_collisionWatcher, &GeometryResourceWatcher::finished, this, &Model::loadCollisionModelURLFinished);
|
||||
}
|
||||
|
||||
Model::~Model() {
|
||||
|
@ -822,7 +822,7 @@ void Model::setURL(const QUrl& url) {
|
|||
_needsReload = true;
|
||||
_needsUpdateTextures = true;
|
||||
_meshGroupsKnown = false;
|
||||
_geometryRequestFailed = false;
|
||||
_visualGeometryRequestFailed = false;
|
||||
invalidCalculatedMeshBoxes();
|
||||
deleteGeometry();
|
||||
|
||||
|
@ -830,14 +830,30 @@ void Model::setURL(const QUrl& url) {
|
|||
onInvalidate();
|
||||
}
|
||||
|
||||
void Model::loadURLFinished(bool success) {
|
||||
if (!success) {
|
||||
_visualGeometryRequestFailed = true;
|
||||
}
|
||||
emit setURLFinished(success);
|
||||
}
|
||||
|
||||
void Model::setCollisionModelURL(const QUrl& url) {
|
||||
if (_collisionUrl == url && _collisionWatcher.getURL() == url) {
|
||||
return;
|
||||
}
|
||||
_collisionUrl = url;
|
||||
_collisionGeometryRequestFailed = false;
|
||||
_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 {
|
||||
return _rig->getJointPositionInWorldFrame(jointIndex, position, _translation, _rotation);
|
||||
}
|
||||
|
|
|
@ -148,8 +148,9 @@ public:
|
|||
const QUrl& getCollisionURL() const { return _collisionUrl; }
|
||||
|
||||
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);
|
||||
|
||||
|
@ -237,6 +238,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; }
|
||||
|
@ -394,10 +403,8 @@ protected:
|
|||
|
||||
uint32_t _deleteGeometryCounter { 0 };
|
||||
|
||||
bool _geometryRequestFailed { false };
|
||||
|
||||
private slots:
|
||||
void handleGeometryResourceFailure() { _geometryRequestFailed = true; }
|
||||
bool _visualGeometryRequestFailed { false };
|
||||
bool _collisionGeometryRequestFailed { false };
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(ModelPointer)
|
||||
|
|
|
@ -40,7 +40,7 @@ var DEFAULT_SOUND_DATA = {
|
|||
|
||||
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.
|
||||
Avatar.skeletonModelURL = "http://invalid-url";
|
||||
Avatar.skeletonModelURL = "http://hifi-content.s3.amazonaws.com/ozan/dev/avatars/invisible_avatar/invisible_avatar.fst";
|
||||
function ignore() {}
|
||||
function debug() { // Display the arguments not just [Object object].
|
||||
//print.apply(null, [].map.call(arguments, JSON.stringify));
|
||||
|
|
Loading…
Reference in a new issue