mirror of
https://github.com/overte-org/overte.git
synced 2025-06-19 06:20:02 +02:00
Merge branch 'master' of git://github.com/worklist/hifi into windows_build
This commit is contained in:
commit
a39c20e4d4
4 changed files with 61 additions and 18 deletions
|
@ -251,18 +251,16 @@ QSharedPointer<NetworkGeometry> GeometryCache::getGeometry(const QUrl& url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkGeometry::NetworkGeometry(const QUrl& url) :
|
NetworkGeometry::NetworkGeometry(const QUrl& url) :
|
||||||
|
_modelRequest(url),
|
||||||
_modelReply(NULL),
|
_modelReply(NULL),
|
||||||
_mappingReply(NULL)
|
_mappingReply(NULL),
|
||||||
|
_attempts(0)
|
||||||
{
|
{
|
||||||
if (!url.isValid()) {
|
if (!url.isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QNetworkRequest modelRequest(url);
|
_modelRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
|
||||||
modelRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
|
makeModelRequest();
|
||||||
_modelReply = Application::getInstance()->getNetworkAccessManager()->get(modelRequest);
|
|
||||||
|
|
||||||
connect(_modelReply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(maybeReadModelWithMapping()));
|
|
||||||
connect(_modelReply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleModelReplyError()));
|
|
||||||
|
|
||||||
QUrl mappingURL = url;
|
QUrl mappingURL = url;
|
||||||
QString path = url.path();
|
QString path = url.path();
|
||||||
|
@ -312,12 +310,30 @@ glm::vec4 NetworkGeometry::computeAverageColor() const {
|
||||||
return (totalTriangles == 0) ? glm::vec4(1.0f, 1.0f, 1.0f, 1.0f) : totalColor / totalTriangles;
|
return (totalTriangles == 0) ? glm::vec4(1.0f, 1.0f, 1.0f, 1.0f) : totalColor / totalTriangles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkGeometry::makeModelRequest() {
|
||||||
|
_modelReply = Application::getInstance()->getNetworkAccessManager()->get(_modelRequest);
|
||||||
|
|
||||||
|
connect(_modelReply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(maybeReadModelWithMapping()));
|
||||||
|
connect(_modelReply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleModelReplyError()));
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkGeometry::handleModelReplyError() {
|
void NetworkGeometry::handleModelReplyError() {
|
||||||
qDebug() << _modelReply->errorString() << "\n";
|
QDebug debug = qDebug() << _modelReply->errorString();
|
||||||
|
|
||||||
_modelReply->disconnect(this);
|
_modelReply->disconnect(this);
|
||||||
_modelReply->deleteLater();
|
_modelReply->deleteLater();
|
||||||
_modelReply = NULL;
|
_modelReply = NULL;
|
||||||
|
|
||||||
|
// retry with increasing delays
|
||||||
|
const int MAX_ATTEMPTS = 8;
|
||||||
|
const int BASE_DELAY_MS = 1000;
|
||||||
|
if (++_attempts < MAX_ATTEMPTS) {
|
||||||
|
QTimer::singleShot(BASE_DELAY_MS * (int)pow(2.0, _attempts), this, SLOT(makeModelRequest()));
|
||||||
|
debug << " -- retrying...\n";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
debug << "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkGeometry::handleMappingReplyError() {
|
void NetworkGeometry::handleMappingReplyError() {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#define __interface__GeometryCache__
|
#define __interface__GeometryCache__
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QNetworkRequest>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QWeakPointer>
|
#include <QWeakPointer>
|
||||||
|
@ -67,15 +68,18 @@ public:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
void makeModelRequest();
|
||||||
void handleModelReplyError();
|
void handleModelReplyError();
|
||||||
void handleMappingReplyError();
|
void handleMappingReplyError();
|
||||||
void maybeReadModelWithMapping();
|
void maybeReadModelWithMapping();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
QNetworkRequest _modelRequest;
|
||||||
QNetworkReply* _modelReply;
|
QNetworkReply* _modelReply;
|
||||||
QNetworkReply* _mappingReply;
|
QNetworkReply* _mappingReply;
|
||||||
|
|
||||||
|
int _attempts;
|
||||||
FBXGeometry _geometry;
|
FBXGeometry _geometry;
|
||||||
QVector<NetworkMesh> _meshes;
|
QVector<NetworkMesh> _meshes;
|
||||||
};
|
};
|
||||||
|
|
|
@ -252,16 +252,17 @@ Texture::~Texture() {
|
||||||
glDeleteTextures(1, &_id);
|
glDeleteTextures(1, &_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkTexture::NetworkTexture(const QUrl& url, bool normalMap) : _reply(NULL), _averageColor(1.0f, 1.0f, 1.0f, 1.0f) {
|
NetworkTexture::NetworkTexture(const QUrl& url, bool normalMap) :
|
||||||
|
_request(url),
|
||||||
|
_reply(NULL),
|
||||||
|
_attempts(0),
|
||||||
|
_averageColor(1.0f, 1.0f, 1.0f, 1.0f) {
|
||||||
|
|
||||||
if (!url.isValid()) {
|
if (!url.isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QNetworkRequest request(url);
|
_request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
|
||||||
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
|
makeRequest();
|
||||||
_reply = Application::getInstance()->getNetworkAccessManager()->get(request);
|
|
||||||
|
|
||||||
connect(_reply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(handleDownloadProgress(qint64,qint64)));
|
|
||||||
connect(_reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleReplyError()));
|
|
||||||
|
|
||||||
// default to white/blue
|
// default to white/blue
|
||||||
glBindTexture(GL_TEXTURE_2D, getID());
|
glBindTexture(GL_TEXTURE_2D, getID());
|
||||||
|
@ -279,6 +280,13 @@ void NetworkTexture::imageLoaded(const QImage& image) {
|
||||||
// nothing by default
|
// nothing by default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkTexture::makeRequest() {
|
||||||
|
_reply = Application::getInstance()->getNetworkAccessManager()->get(_request);
|
||||||
|
|
||||||
|
connect(_reply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(handleDownloadProgress(qint64,qint64)));
|
||||||
|
connect(_reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleReplyError()));
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkTexture::handleDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
|
void NetworkTexture::handleDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
|
||||||
if (bytesReceived < bytesTotal && !_reply->isFinished()) {
|
if (bytesReceived < bytesTotal && !_reply->isFinished()) {
|
||||||
return;
|
return;
|
||||||
|
@ -314,11 +322,22 @@ void NetworkTexture::handleDownloadProgress(qint64 bytesReceived, qint64 bytesTo
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkTexture::handleReplyError() {
|
void NetworkTexture::handleReplyError() {
|
||||||
qDebug() << _reply->errorString() << "\n";
|
QDebug debug = qDebug() << _reply->errorString();
|
||||||
|
|
||||||
_reply->disconnect(this);
|
_reply->disconnect(this);
|
||||||
_reply->deleteLater();
|
_reply->deleteLater();
|
||||||
_reply = NULL;
|
_reply = NULL;
|
||||||
|
|
||||||
|
// retry with increasing delays
|
||||||
|
const int MAX_ATTEMPTS = 8;
|
||||||
|
const int BASE_DELAY_MS = 1000;
|
||||||
|
if (++_attempts < MAX_ATTEMPTS) {
|
||||||
|
QTimer::singleShot(BASE_DELAY_MS * (int)pow(2.0, _attempts), this, SLOT(makeRequest()));
|
||||||
|
debug << " -- retrying...\n";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
debug << "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DilatableNetworkTexture::DilatableNetworkTexture(const QUrl& url, bool normalMap) :
|
DilatableNetworkTexture::DilatableNetworkTexture(const QUrl& url, bool normalMap) :
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QNetworkRequest>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QWeakPointer>
|
#include <QWeakPointer>
|
||||||
|
@ -126,12 +127,15 @@ protected:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
void makeRequest();
|
||||||
void handleDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
void handleDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
||||||
void handleReplyError();
|
void handleReplyError();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
QNetworkRequest _request;
|
||||||
QNetworkReply* _reply;
|
QNetworkReply* _reply;
|
||||||
|
int _attempts;
|
||||||
glm::vec4 _averageColor;
|
glm::vec4 _averageColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue