diff --git a/interface/src/MetavoxelSystem.cpp b/interface/src/MetavoxelSystem.cpp index da73bfb371..54cc3b4cdb 100644 --- a/interface/src/MetavoxelSystem.cpp +++ b/interface/src/MetavoxelSystem.cpp @@ -360,6 +360,10 @@ void StaticModelRenderer::render(float alpha) { _model->render(alpha); } +bool StaticModelRenderer::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const { + return _model->findRayIntersection(origin, direction, distance); +} + void StaticModelRenderer::applyTranslation(const glm::vec3& translation) { _model->setTranslation(translation); } diff --git a/interface/src/MetavoxelSystem.h b/interface/src/MetavoxelSystem.h index c605205244..2af3262d15 100644 --- a/interface/src/MetavoxelSystem.h +++ b/interface/src/MetavoxelSystem.h @@ -163,6 +163,7 @@ public: virtual void init(Spanner* spanner); virtual void simulate(float deltaTime); virtual void render(float alpha); + virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const; private slots: diff --git a/libraries/metavoxels/src/MetavoxelData.cpp b/libraries/metavoxels/src/MetavoxelData.cpp index 047faf5e71..d64cbc7d94 100644 --- a/libraries/metavoxels/src/MetavoxelData.cpp +++ b/libraries/metavoxels/src/MetavoxelData.cpp @@ -1177,9 +1177,9 @@ AttributeValue MetavoxelVisitation::getInheritedOutputValue(int index) const { const float DEFAULT_GRANULARITY = 0.01f; Spanner::Spanner() : + _renderer(NULL), _granularity(DEFAULT_GRANULARITY), - _lastVisit(0), - _renderer(NULL) { + _lastVisit(0) { } void Spanner::setBounds(const Box& bounds) { @@ -1247,6 +1247,10 @@ void SpannerRenderer::render(float alpha) { // nothing by default } +bool SpannerRenderer::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const { + return false; +} + Transformable::Transformable() : _scale(1.0f) { } @@ -1359,6 +1363,12 @@ void StaticModel::setURL(const QUrl& url) { } } +bool StaticModel::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const { + // delegate to renderer, if we have one + return _renderer ? _renderer->findRayIntersection(origin, direction, distance) : + Spanner::findRayIntersection(origin, direction, distance); +} + QByteArray StaticModel::getRendererClassName() const { return "StaticModelRenderer"; } diff --git a/libraries/metavoxels/src/MetavoxelData.h b/libraries/metavoxels/src/MetavoxelData.h index 80ff431172..c5ac570876 100644 --- a/libraries/metavoxels/src/MetavoxelData.h +++ b/libraries/metavoxels/src/MetavoxelData.h @@ -444,6 +444,8 @@ signals: protected: + SpannerRenderer* _renderer; + /// Returns the name of the class to instantiate in order to render this spanner. virtual QByteArray getRendererClassName() const; @@ -452,7 +454,6 @@ private: Box _bounds; float _granularity; int _lastVisit; ///< the identifier of the last visit - SpannerRenderer* _renderer; static int _visit; ///< the global visit counter }; @@ -468,6 +469,7 @@ public: virtual void init(Spanner* spanner); virtual void simulate(float deltaTime); virtual void render(float alpha); + virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const; }; /// An object with a 3D transform. @@ -550,6 +552,8 @@ public: void setURL(const QUrl& url); const QUrl& getURL() const { return _url; } + virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const; + signals: void urlChanged(const QUrl& url); diff --git a/libraries/shared/src/ResourceCache.cpp b/libraries/shared/src/ResourceCache.cpp index a7c0302a9c..9d7aa35c31 100644 --- a/libraries/shared/src/ResourceCache.cpp +++ b/libraries/shared/src/ResourceCache.cpp @@ -81,7 +81,7 @@ Resource::Resource(const QUrl& url, bool delayLoad) : _reply(NULL), _attempts(0) { - if (!url.isValid()) { + if (!(url.isValid() && ResourceCache::getNetworkAccessManager())) { _startedLoading = _failedToLoad = true; return; }