mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 00:03:39 +02:00
Ray intersections for models, don't load resources if there's no network
manager installed.
This commit is contained in:
parent
78957e42be
commit
ae6a59ef78
5 changed files with 23 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue