mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +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;
|
||||
}
|
||||
if (_isHoverVoxel) {
|
||||
_myAvatar.orbit(glm::vec3(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z) * (float)TREE_SCALE, deltaX, deltaY);
|
||||
_myAvatar.orbit(getMouseVoxelWorldCoordinates(_hoverVoxel), deltaX, deltaY);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1618,10 +1618,9 @@ void Application::makeVoxel(glm::vec3 position,
|
|||
isDestructive);
|
||||
}
|
||||
|
||||
const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) {
|
||||
return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE,
|
||||
(_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE,
|
||||
(_mouseVoxel.z + _mouseVoxel.s / 2.f) * TREE_SCALE);
|
||||
glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel) {
|
||||
return glm::vec3((mouseVoxel.x + mouseVoxel.s / 2.f) * TREE_SCALE, (mouseVoxel.y + 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);
|
||||
|
|
|
@ -142,7 +142,7 @@ public:
|
|||
|
||||
void removeVoxel(glm::vec3 position, float scale);
|
||||
|
||||
const glm::vec3 getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel);
|
||||
glm::vec3 getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel);
|
||||
|
||||
QGLWidget* getGLWidget() { return _glWidget; }
|
||||
MyAvatar* getAvatar() { return &_myAvatar; }
|
||||
|
|
|
@ -251,18 +251,16 @@ QSharedPointer<NetworkGeometry> GeometryCache::getGeometry(const QUrl& url) {
|
|||
}
|
||||
|
||||
NetworkGeometry::NetworkGeometry(const QUrl& url) :
|
||||
_modelRequest(url),
|
||||
_modelReply(NULL),
|
||||
_mappingReply(NULL)
|
||||
_mappingReply(NULL),
|
||||
_attempts(0)
|
||||
{
|
||||
if (!url.isValid()) {
|
||||
return;
|
||||
}
|
||||
QNetworkRequest modelRequest(url);
|
||||
modelRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
|
||||
_modelReply = Application::getInstance()->getNetworkAccessManager()->get(modelRequest);
|
||||
|
||||
connect(_modelReply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(maybeReadModelWithMapping()));
|
||||
connect(_modelReply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleModelReplyError()));
|
||||
_modelRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
|
||||
makeModelRequest();
|
||||
|
||||
QUrl mappingURL = url;
|
||||
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;
|
||||
}
|
||||
|
||||
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() {
|
||||
qDebug() << _modelReply->errorString() << "\n";
|
||||
QDebug debug = qDebug() << _modelReply->errorString();
|
||||
|
||||
_modelReply->disconnect(this);
|
||||
_modelReply->deleteLater();
|
||||
_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() {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define __interface__GeometryCache__
|
||||
|
||||
#include <QHash>
|
||||
#include <QNetworkRequest>
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QWeakPointer>
|
||||
|
@ -67,15 +68,18 @@ public:
|
|||
|
||||
private slots:
|
||||
|
||||
void makeModelRequest();
|
||||
void handleModelReplyError();
|
||||
void handleMappingReplyError();
|
||||
void maybeReadModelWithMapping();
|
||||
|
||||
private:
|
||||
|
||||
QNetworkRequest _modelRequest;
|
||||
QNetworkReply* _modelReply;
|
||||
QNetworkReply* _mappingReply;
|
||||
|
||||
int _attempts;
|
||||
FBXGeometry _geometry;
|
||||
QVector<NetworkMesh> _meshes;
|
||||
};
|
||||
|
|
|
@ -252,16 +252,17 @@ Texture::~Texture() {
|
|||
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()) {
|
||||
return;
|
||||
}
|
||||
QNetworkRequest request(url);
|
||||
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
|
||||
_reply = Application::getInstance()->getNetworkAccessManager()->get(request);
|
||||
|
||||
connect(_reply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(handleDownloadProgress(qint64,qint64)));
|
||||
connect(_reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleReplyError()));
|
||||
_request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
|
||||
makeRequest();
|
||||
|
||||
// default to white/blue
|
||||
glBindTexture(GL_TEXTURE_2D, getID());
|
||||
|
@ -279,6 +280,13 @@ void NetworkTexture::imageLoaded(const QImage& image) {
|
|||
// 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) {
|
||||
if (bytesReceived < bytesTotal && !_reply->isFinished()) {
|
||||
return;
|
||||
|
@ -314,11 +322,22 @@ void NetworkTexture::handleDownloadProgress(qint64 bytesReceived, qint64 bytesTo
|
|||
}
|
||||
|
||||
void NetworkTexture::handleReplyError() {
|
||||
qDebug() << _reply->errorString() << "\n";
|
||||
QDebug debug = qDebug() << _reply->errorString();
|
||||
|
||||
_reply->disconnect(this);
|
||||
_reply->deleteLater();
|
||||
_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) :
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <QHash>
|
||||
#include <QImage>
|
||||
#include <QMap>
|
||||
#include <QNetworkRequest>
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QWeakPointer>
|
||||
|
@ -126,12 +127,15 @@ protected:
|
|||
|
||||
private slots:
|
||||
|
||||
void makeRequest();
|
||||
void handleDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
||||
void handleReplyError();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
QNetworkRequest _request;
|
||||
QNetworkReply* _reply;
|
||||
int _attempts;
|
||||
glm::vec4 _averageColor;
|
||||
};
|
||||
|
||||
|
|
|
@ -301,8 +301,8 @@ void MetavoxelNode::clearChildren(const AttributePointer& attribute) {
|
|||
}
|
||||
|
||||
int MetavoxelPath::operator[](int index) const {
|
||||
return _array.at(index * BITS_PER_ELEMENT) | (_array.at(index * BITS_PER_ELEMENT + 1) << 1) |
|
||||
(_array.at(index * BITS_PER_ELEMENT + 2) << 2);
|
||||
return (int)_array.at(index * BITS_PER_ELEMENT) | ((int)_array.at(index * BITS_PER_ELEMENT + 1) << 1) |
|
||||
((int)_array.at(index * BITS_PER_ELEMENT + 2) << 2);
|
||||
}
|
||||
|
||||
MetavoxelPath& MetavoxelPath::operator+=(int element) {
|
||||
|
|
|
@ -92,4 +92,4 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
#endif /* defined(__hifi__VoxelTreeElement__) */
|
||||
#endif /* defined(__hifi__VoxelTreeElement__) */
|
||||
|
|
Loading…
Reference in a new issue