mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:38:02 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into undo_redo_system
This commit is contained in:
commit
a0e70d0d2a
4 changed files with 57 additions and 27 deletions
|
@ -63,7 +63,7 @@
|
||||||
#include <UUID.h>
|
#include <UUID.h>
|
||||||
#include <OctreeSceneStats.h>
|
#include <OctreeSceneStats.h>
|
||||||
#include <LocalVoxelsList.h>
|
#include <LocalVoxelsList.h>
|
||||||
#include <FstReader.h>
|
#include <ModelUploader.h>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "InterfaceVersion.h"
|
#include "InterfaceVersion.h"
|
||||||
|
@ -3244,9 +3244,9 @@ void Application::toggleRunningScriptsWidget()
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::uploadFST(bool isHead) {
|
void Application::uploadFST(bool isHead) {
|
||||||
FstReader reader(isHead);
|
ModelUploader* uploader = new ModelUploader(isHead);
|
||||||
if (reader.zip()) {
|
if (uploader->zip()) {
|
||||||
reader.send();
|
uploader->send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1303,20 +1303,22 @@ void Menu::autoAdjustLOD(float currentFPS) {
|
||||||
|
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
|
|
||||||
|
const float ADJUST_AVATAR_LOD_DOWN_FPS = 30.0f;
|
||||||
const quint64 ADJUST_AVATAR_LOD_DOWN_DELAY = 1000 * 1000;
|
const quint64 ADJUST_AVATAR_LOD_DOWN_DELAY = 1000 * 1000;
|
||||||
if (_fastFPSAverage.getAverage() < ADJUST_LOD_DOWN_FPS) {
|
if (_fastFPSAverage.getAverage() < ADJUST_AVATAR_LOD_DOWN_FPS) {
|
||||||
if (now - _lastAvatarDetailDrop > ADJUST_AVATAR_LOD_DOWN_DELAY) {
|
if (now - _lastAvatarDetailDrop > ADJUST_AVATAR_LOD_DOWN_DELAY) {
|
||||||
// attempt to lower the detail in proportion to the fps difference
|
// attempt to lower the detail in proportion to the fps difference
|
||||||
float targetFps = (ADJUST_LOD_DOWN_FPS + ADJUST_LOD_UP_FPS) * 0.5f;
|
float targetFps = (ADJUST_AVATAR_LOD_DOWN_FPS + ADJUST_LOD_UP_FPS) * 0.5f;
|
||||||
float averageFps = _fastFPSAverage.getAverage();
|
float averageFps = _fastFPSAverage.getAverage();
|
||||||
const float MAXIMUM_MULTIPLIER_SCALE = 2.0f;
|
const float MAXIMUM_MULTIPLIER_SCALE = 2.0f;
|
||||||
_avatarLODDistanceMultiplier *= (averageFps < EPSILON) ? MAXIMUM_MULTIPLIER_SCALE :
|
const float MAXIMUM_DISTANCE_MULTIPLIER = 15.0f;
|
||||||
qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps);
|
_avatarLODDistanceMultiplier = qMin(MAXIMUM_DISTANCE_MULTIPLIER, _avatarLODDistanceMultiplier *
|
||||||
|
(averageFps < EPSILON ? MAXIMUM_MULTIPLIER_SCALE : qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps)));
|
||||||
_lastAvatarDetailDrop = now;
|
_lastAvatarDetailDrop = now;
|
||||||
}
|
}
|
||||||
} else if (_fastFPSAverage.getAverage() > ADJUST_LOD_UP_FPS) {
|
} else if (_fastFPSAverage.getAverage() > ADJUST_LOD_UP_FPS) {
|
||||||
// let the detail level creep slowly upwards
|
// let the detail level creep slowly upwards
|
||||||
const float DISTANCE_DECREASE_RATE = 0.02f;
|
const float DISTANCE_DECREASE_RATE = 0.05f;
|
||||||
const float MINIMUM_DISTANCE_MULTIPLIER = 0.1f;
|
const float MINIMUM_DISTANCE_MULTIPLIER = 0.1f;
|
||||||
_avatarLODDistanceMultiplier = qMax(MINIMUM_DISTANCE_MULTIPLIER,
|
_avatarLODDistanceMultiplier = qMax(MINIMUM_DISTANCE_MULTIPLIER,
|
||||||
_avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE);
|
_avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// FstReader.cpp
|
// ModelUploader.cpp
|
||||||
// hifi
|
// hifi
|
||||||
//
|
//
|
||||||
// Created by Clément Brisset on 3/4/14.
|
// Created by Clément Brisset on 3/4/14.
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "AccountManager.h"
|
#include "AccountManager.h"
|
||||||
#include "FstReader.h"
|
#include "ModelUploader.h"
|
||||||
|
|
||||||
|
|
||||||
static const QString NAME_FIELD = "name";
|
static const QString NAME_FIELD = "name";
|
||||||
|
@ -38,7 +38,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
FstReader::FstReader(bool isHead) :
|
ModelUploader::ModelUploader(bool isHead) :
|
||||||
_zipDir(new TemporaryDir()),
|
_zipDir(new TemporaryDir()),
|
||||||
_lodCount(-1),
|
_lodCount(-1),
|
||||||
_texturesCount(-1),
|
_texturesCount(-1),
|
||||||
|
@ -51,11 +51,11 @@ FstReader::FstReader(bool isHead) :
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FstReader::~FstReader() {
|
ModelUploader::~ModelUploader() {
|
||||||
delete _dataMultiPart;
|
delete _dataMultiPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FstReader::zip() {
|
bool ModelUploader::zip() {
|
||||||
// File Dialog
|
// File Dialog
|
||||||
QString filename = QFileDialog::getOpenFileName(NULL,
|
QString filename = QFileDialog::getOpenFileName(NULL,
|
||||||
"Select your .fst file ...",
|
"Select your .fst file ...",
|
||||||
|
@ -167,20 +167,41 @@ bool FstReader::zip() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FstReader::send() {
|
bool ModelUploader::send() {
|
||||||
if (!_readyToSend) {
|
if (!_readyToSend) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountManager::getInstance().authenticatedRequest(MODEL_URL, QNetworkAccessManager::PostOperation, JSONCallbackParameters(), QByteArray(), _dataMultiPart);
|
JSONCallbackParameters callbackParams;
|
||||||
|
callbackParams.jsonCallbackReceiver = this;
|
||||||
|
callbackParams.jsonCallbackMethod = "uploadSuccess";
|
||||||
|
callbackParams.errorCallbackReceiver = this;
|
||||||
|
callbackParams.errorCallbackMethod = "uploadFailed";
|
||||||
|
|
||||||
|
AccountManager::getInstance().authenticatedRequest(MODEL_URL, QNetworkAccessManager::PostOperation, callbackParams, QByteArray(), _dataMultiPart);
|
||||||
_zipDir = NULL;
|
_zipDir = NULL;
|
||||||
_dataMultiPart = NULL;
|
_dataMultiPart = NULL;
|
||||||
qDebug() << "Model sent.";
|
qDebug() << "Sending model...";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FstReader::addTextures(const QFileInfo& texdir) {
|
void ModelUploader::uploadSuccess(const QJsonObject& jsonResponse) {
|
||||||
|
qDebug() << "Model sent with success to the data server.";
|
||||||
|
qDebug() << "It might take a few minute for it to appear in your model browser.";
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelUploader::uploadFailed(QNetworkReply::NetworkError errorCode, const QString& errorString) {
|
||||||
|
QMessageBox::warning(NULL,
|
||||||
|
QString("ModelUploader::uploadFailed()"),
|
||||||
|
QString("Model could not be sent to the data server."),
|
||||||
|
QMessageBox::Ok);
|
||||||
|
qDebug() << "Model upload failed (" << errorCode << "): " << errorString;
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ModelUploader::addTextures(const QFileInfo& texdir) {
|
||||||
QStringList filter;
|
QStringList filter;
|
||||||
filter << "*.png" << "*.tif" << "*.jpg" << "*.jpeg";
|
filter << "*.png" << "*.tif" << "*.jpg" << "*.jpeg";
|
||||||
|
|
||||||
|
@ -209,7 +230,7 @@ bool FstReader::addTextures(const QFileInfo& texdir) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FstReader::compressFile(const QString &inFileName, const QString &outFileName) {
|
bool ModelUploader::compressFile(const QString &inFileName, const QString &outFileName) {
|
||||||
QFile inFile(inFileName);
|
QFile inFile(inFileName);
|
||||||
inFile.open(QIODevice::ReadOnly);
|
inFile.open(QIODevice::ReadOnly);
|
||||||
QByteArray buffer = inFile.readAll();
|
QByteArray buffer = inFile.readAll();
|
||||||
|
@ -233,7 +254,7 @@ bool FstReader::compressFile(const QString &inFileName, const QString &outFileNa
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FstReader::addPart(const QString &path, const QString& name) {
|
bool ModelUploader::addPart(const QString &path, const QString& name) {
|
||||||
QFile* file = new QFile(path);
|
QFile* file = new QFile(path);
|
||||||
if (!file->open(QIODevice::ReadOnly)) {
|
if (!file->open(QIODevice::ReadOnly)) {
|
||||||
QMessageBox::warning(NULL,
|
QMessageBox::warning(NULL,
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// FstReader.h
|
// ModelUploader.h
|
||||||
// hifi
|
// hifi
|
||||||
//
|
//
|
||||||
// Created by Clément Brisset on 3/4/14.
|
// Created by Clément Brisset on 3/4/14.
|
||||||
|
@ -7,20 +7,27 @@
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef __hifi__FstReader__
|
#ifndef __hifi__ModelUploader__
|
||||||
#define __hifi__FstReader__
|
#define __hifi__ModelUploader__
|
||||||
|
|
||||||
class TemporaryDir;
|
class TemporaryDir;
|
||||||
class QHttpMultiPart;
|
class QHttpMultiPart;
|
||||||
|
class QFileInfo;
|
||||||
|
|
||||||
class FstReader : public QObject {
|
class ModelUploader : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FstReader(bool isHead);
|
ModelUploader(bool isHead);
|
||||||
~FstReader();
|
~ModelUploader();
|
||||||
|
|
||||||
bool zip();
|
bool zip();
|
||||||
bool send();
|
bool send();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void uploadSuccess(const QJsonObject& jsonResponse);
|
||||||
|
void uploadFailed(QNetworkReply::NetworkError errorCode, const QString& errorString);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TemporaryDir* _zipDir;
|
TemporaryDir* _zipDir;
|
||||||
int _lodCount;
|
int _lodCount;
|
||||||
|
@ -37,4 +44,4 @@ private:
|
||||||
bool addPart(const QString& path, const QString& name);
|
bool addPart(const QString& path, const QString& name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__FstReader__) */
|
#endif /* defined(__hifi__ModelUploader__) */
|
Loading…
Reference in a new issue