Merge pull request #8353 from birarda/fake-atp-url

fix for disabled physics with unloadable entity
This commit is contained in:
Brad Hefta-Gaub 2016-08-03 09:10:41 -07:00 committed by GitHub
commit 754eae98c2
6 changed files with 30 additions and 2 deletions

View file

@ -916,6 +916,16 @@ bool RenderableModelEntityItem::contains(const glm::vec3& point) const {
return false; return false;
} }
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()) {
return false;
} else {
return ModelEntityItem::shouldBePhysical();
}
}
glm::quat RenderableModelEntityItem::getAbsoluteJointRotationInObjectFrame(int index) const { glm::quat RenderableModelEntityItem::getAbsoluteJointRotationInObjectFrame(int index) const {
if (_model) { if (_model) {
glm::quat result; glm::quat result;

View file

@ -65,6 +65,8 @@ public:
virtual bool contains(const glm::vec3& point) const override; virtual bool contains(const glm::vec3& point) const override;
virtual bool shouldBePhysical() const override;
// these are in the frame of this object (model space) // these are in the frame of this object (model space)
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override; virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override;
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override; virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override;

View file

@ -403,6 +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();
} }
} }

View file

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

View file

@ -102,13 +102,17 @@ Model::Model(RigPointer rig, QObject* parent) :
_calculatedMeshTrianglesValid(false), _calculatedMeshTrianglesValid(false),
_meshGroupsKnown(false), _meshGroupsKnown(false),
_isWireframe(false), _isWireframe(false),
_rig(rig) { _rig(rig)
{
// we may have been created in the network thread, but we live in the main thread // we may have been created in the network thread, but we live in the main thread
if (_viewState) { if (_viewState) {
moveToThread(_viewState->getMainThread()); moveToThread(_viewState->getMainThread());
} }
setSnapModelToRegistrationPoint(true, glm::vec3(0.5f)); setSnapModelToRegistrationPoint(true, glm::vec3(0.5f));
// handle download failure reported by the GeometryResourceWatcher
connect(&_renderWatcher, &GeometryResourceWatcher::resourceFailed, this, &Model::handleGeometryResourceFailure);
} }
Model::~Model() { Model::~Model() {
@ -818,6 +822,7 @@ void Model::setURL(const QUrl& url) {
_needsReload = true; _needsReload = true;
_needsUpdateTextures = true; _needsUpdateTextures = true;
_meshGroupsKnown = false; _meshGroupsKnown = false;
_geometryRequestFailed = false;
invalidCalculatedMeshBoxes(); invalidCalculatedMeshBoxes();
deleteGeometry(); deleteGeometry();

View file

@ -147,8 +147,9 @@ public:
Q_INVOKABLE void setCollisionModelURL(const QUrl& url); Q_INVOKABLE void setCollisionModelURL(const QUrl& url);
const QUrl& getCollisionURL() const { return _collisionUrl; } const QUrl& getCollisionURL() const { return _collisionUrl; }
bool isActive() const { return isLoaded(); } bool isActive() const { return isLoaded(); }
bool didGeometryRequestFail() const { return _geometryRequestFailed; }
bool convexHullContains(glm::vec3 point); bool convexHullContains(glm::vec3 point);
@ -392,6 +393,11 @@ protected:
RigPointer _rig; RigPointer _rig;
uint32_t _deleteGeometryCounter { 0 }; uint32_t _deleteGeometryCounter { 0 };
bool _geometryRequestFailed { false };
private slots:
void handleGeometryResourceFailure() { _geometryRequestFailed = true; }
}; };
Q_DECLARE_METATYPE(ModelPointer) Q_DECLARE_METATYPE(ModelPointer)