mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 16:55:07 +02:00
Merge pull request #8353 from birarda/fake-atp-url
fix for disabled physics with unloadable entity
This commit is contained in:
commit
754eae98c2
6 changed files with 30 additions and 2 deletions
|
@ -916,6 +916,16 @@ bool RenderableModelEntityItem::contains(const glm::vec3& point) const {
|
|||
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 {
|
||||
if (_model) {
|
||||
glm::quat result;
|
||||
|
|
|
@ -65,6 +65,8 @@ public:
|
|||
|
||||
virtual bool contains(const glm::vec3& point) const override;
|
||||
|
||||
virtual bool shouldBePhysical() const override;
|
||||
|
||||
// these are in the frame of this object (model space)
|
||||
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override;
|
||||
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override;
|
||||
|
|
|
@ -403,6 +403,8 @@ void GeometryResourceWatcher::setResource(GeometryResource::Pointer resource) {
|
|||
void GeometryResourceWatcher::resourceFinished(bool success) {
|
||||
if (success) {
|
||||
_geometryRef = std::make_shared<Geometry>(*_resource);
|
||||
} else {
|
||||
emit resourceFailed();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -111,6 +111,9 @@ public:
|
|||
|
||||
QUrl getURL() const { return (bool)_resource ? _resource->getURL() : QUrl(); }
|
||||
|
||||
signals:
|
||||
void resourceFailed();
|
||||
|
||||
private:
|
||||
void startWatching();
|
||||
void stopWatching();
|
||||
|
|
|
@ -102,13 +102,17 @@ Model::Model(RigPointer rig, QObject* parent) :
|
|||
_calculatedMeshTrianglesValid(false),
|
||||
_meshGroupsKnown(false),
|
||||
_isWireframe(false),
|
||||
_rig(rig) {
|
||||
_rig(rig)
|
||||
{
|
||||
// we may have been created in the network thread, but we live in the main thread
|
||||
if (_viewState) {
|
||||
moveToThread(_viewState->getMainThread());
|
||||
}
|
||||
|
||||
setSnapModelToRegistrationPoint(true, glm::vec3(0.5f));
|
||||
|
||||
// handle download failure reported by the GeometryResourceWatcher
|
||||
connect(&_renderWatcher, &GeometryResourceWatcher::resourceFailed, this, &Model::handleGeometryResourceFailure);
|
||||
}
|
||||
|
||||
Model::~Model() {
|
||||
|
@ -818,6 +822,7 @@ void Model::setURL(const QUrl& url) {
|
|||
_needsReload = true;
|
||||
_needsUpdateTextures = true;
|
||||
_meshGroupsKnown = false;
|
||||
_geometryRequestFailed = false;
|
||||
invalidCalculatedMeshBoxes();
|
||||
deleteGeometry();
|
||||
|
||||
|
|
|
@ -147,8 +147,9 @@ public:
|
|||
Q_INVOKABLE void setCollisionModelURL(const QUrl& url);
|
||||
const QUrl& getCollisionURL() const { return _collisionUrl; }
|
||||
|
||||
|
||||
bool isActive() const { return isLoaded(); }
|
||||
|
||||
bool didGeometryRequestFail() const { return _geometryRequestFailed; }
|
||||
|
||||
bool convexHullContains(glm::vec3 point);
|
||||
|
||||
|
@ -392,6 +393,11 @@ protected:
|
|||
RigPointer _rig;
|
||||
|
||||
uint32_t _deleteGeometryCounter { 0 };
|
||||
|
||||
bool _geometryRequestFailed { false };
|
||||
|
||||
private slots:
|
||||
void handleGeometryResourceFailure() { _geometryRequestFailed = true; }
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(ModelPointer)
|
||||
|
|
Loading…
Reference in a new issue