mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
21d2a5d9f4
8 changed files with 69 additions and 27 deletions
|
@ -1121,7 +1121,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_isHoverVoxel) {
|
if (_isHoverVoxel) {
|
||||||
_myAvatar.orbit(glm::vec3(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z) * (float)TREE_SCALE, deltaX, deltaY);
|
_myAvatar.orbit(getMouseVoxelWorldCoordinates(_hoverVoxel), deltaX, deltaY);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1618,10 +1618,9 @@ void Application::makeVoxel(glm::vec3 position,
|
||||||
isDestructive);
|
isDestructive);
|
||||||
}
|
}
|
||||||
|
|
||||||
const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) {
|
glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel) {
|
||||||
return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE,
|
return glm::vec3((mouseVoxel.x + mouseVoxel.s / 2.f) * TREE_SCALE, (mouseVoxel.y + mouseVoxel.s / 2.f) * TREE_SCALE,
|
||||||
(_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE,
|
(mouseVoxel.z + mouseVoxel.s / 2.f) * TREE_SCALE);
|
||||||
(_mouseVoxel.z + _mouseVoxel.s / 2.f) * TREE_SCALE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const float NUDGE_PRECISION_MIN = 1 / pow(2.0, 12.0);
|
const float NUDGE_PRECISION_MIN = 1 / pow(2.0, 12.0);
|
||||||
|
|
|
@ -142,7 +142,7 @@ public:
|
||||||
|
|
||||||
void removeVoxel(glm::vec3 position, float scale);
|
void removeVoxel(glm::vec3 position, float scale);
|
||||||
|
|
||||||
const glm::vec3 getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel);
|
glm::vec3 getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel);
|
||||||
|
|
||||||
QGLWidget* getGLWidget() { return _glWidget; }
|
QGLWidget* getGLWidget() { return _glWidget; }
|
||||||
MyAvatar* getAvatar() { return &_myAvatar; }
|
MyAvatar* getAvatar() { return &_myAvatar; }
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -301,8 +301,8 @@ void MetavoxelNode::clearChildren(const AttributePointer& attribute) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int MetavoxelPath::operator[](int index) const {
|
int MetavoxelPath::operator[](int index) const {
|
||||||
return _array.at(index * BITS_PER_ELEMENT) | (_array.at(index * BITS_PER_ELEMENT + 1) << 1) |
|
return (int)_array.at(index * BITS_PER_ELEMENT) | ((int)_array.at(index * BITS_PER_ELEMENT + 1) << 1) |
|
||||||
(_array.at(index * BITS_PER_ELEMENT + 2) << 2);
|
((int)_array.at(index * BITS_PER_ELEMENT + 2) << 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetavoxelPath& MetavoxelPath::operator+=(int element) {
|
MetavoxelPath& MetavoxelPath::operator+=(int element) {
|
||||||
|
|
|
@ -92,4 +92,4 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* defined(__hifi__VoxelTreeElement__) */
|
#endif /* defined(__hifi__VoxelTreeElement__) */
|
||||||
|
|
Loading…
Reference in a new issue