mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into metavoxels
This commit is contained in:
commit
1c822542c1
8 changed files with 105 additions and 162 deletions
|
@ -510,7 +510,7 @@ void Application::paintGL() {
|
|||
_myCamera.setDistance(0.0f);
|
||||
_myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing
|
||||
_myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition());
|
||||
_myCamera.setTargetRotation(_myAvatar->getHead()->getOrientation());
|
||||
_myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation());
|
||||
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
||||
_myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay
|
||||
|
|
|
@ -1260,20 +1260,22 @@ void Menu::autoAdjustLOD(float currentFPS) {
|
|||
|
||||
quint64 now = usecTimestampNow();
|
||||
|
||||
const float ADJUST_AVATAR_LOD_DOWN_FPS = 30.0f;
|
||||
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) {
|
||||
// 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();
|
||||
const float MAXIMUM_MULTIPLIER_SCALE = 2.0f;
|
||||
_avatarLODDistanceMultiplier *= (averageFps < EPSILON) ? MAXIMUM_MULTIPLIER_SCALE :
|
||||
qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps);
|
||||
const float MAXIMUM_DISTANCE_MULTIPLIER = 15.0f;
|
||||
_avatarLODDistanceMultiplier = qMin(MAXIMUM_DISTANCE_MULTIPLIER, _avatarLODDistanceMultiplier *
|
||||
(averageFps < EPSILON ? MAXIMUM_MULTIPLIER_SCALE : qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps)));
|
||||
_lastAvatarDetailDrop = now;
|
||||
}
|
||||
} else if (_fastFPSAverage.getAverage() > ADJUST_LOD_UP_FPS) {
|
||||
// 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;
|
||||
_avatarLODDistanceMultiplier = qMax(MINIMUM_DISTANCE_MULTIPLIER,
|
||||
_avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "Head.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
#include "devices/OculusManager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -198,6 +199,9 @@ glm::quat Head::getFinalOrientation() const {
|
|||
}
|
||||
|
||||
glm::quat Head::getCameraOrientation () const {
|
||||
if (OculusManager::isConnected()) {
|
||||
return getOrientation();
|
||||
}
|
||||
Avatar* owningAvatar = static_cast<Avatar*>(_owningAvatar);
|
||||
return owningAvatar->getWorldAlignedOrientation() * glm::quat(glm::radians(glm::vec3(_basePitch, 0.f, 0.0f)));
|
||||
}
|
||||
|
|
|
@ -169,9 +169,6 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
// Collect thrust forces from keyboard and devices
|
||||
updateThrust(deltaTime);
|
||||
|
||||
// copy velocity so we can use it later for acceleration
|
||||
glm::vec3 oldVelocity = getVelocity();
|
||||
|
||||
// calculate speed
|
||||
_speed = glm::length(_velocity);
|
||||
|
||||
|
@ -231,29 +228,6 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
// update the euler angles
|
||||
setOrientation(orientation);
|
||||
|
||||
// Compute instantaneous acceleration
|
||||
float forwardAcceleration = glm::length(glm::dot(getBodyFrontDirection(), getVelocity() - oldVelocity)) / deltaTime;
|
||||
const float OCULUS_ACCELERATION_PULL_THRESHOLD = 1.0f;
|
||||
const int OCULUS_YAW_OFFSET_THRESHOLD = 10;
|
||||
|
||||
if (!Application::getInstance()->getFaceshift()->isActive() && OculusManager::isConnected() &&
|
||||
fabsf(forwardAcceleration) > OCULUS_ACCELERATION_PULL_THRESHOLD &&
|
||||
fabs(getHead()->getBaseYaw()) > OCULUS_YAW_OFFSET_THRESHOLD) {
|
||||
|
||||
// if we're wearing the oculus
|
||||
// and this acceleration is above the pull threshold
|
||||
// and the head yaw if off the body by more than OCULUS_YAW_OFFSET_THRESHOLD
|
||||
|
||||
// match the body yaw to the oculus yaw
|
||||
_bodyYaw = getAbsoluteHeadYaw();
|
||||
|
||||
// set the head yaw to zero for this draw
|
||||
getHead()->setBaseYaw(0);
|
||||
|
||||
// correct the oculus yaw offset
|
||||
OculusManager::updateYawOffset();
|
||||
}
|
||||
|
||||
const float WALKING_SPEED_THRESHOLD = 0.2f;
|
||||
// use speed and angular velocity to determine walking vs. standing
|
||||
if (_speed + fabs(_bodyYawDelta) > WALKING_SPEED_THRESHOLD) {
|
||||
|
@ -308,7 +282,7 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
head->simulate(deltaTime, true);
|
||||
|
||||
// Zero thrust out now that we've added it to velocity in this frame
|
||||
_thrust = glm::vec3(0, 0, 0);
|
||||
_thrust = glm::vec3(0.f);
|
||||
|
||||
// now that we're done stepping the avatar forward in time, compute new collisions
|
||||
if (_collisionFlags != 0) {
|
||||
|
|
|
@ -8,11 +8,10 @@
|
|||
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QEventLoop>
|
||||
#include <QGridLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QMessageBox>
|
||||
#include <QStringListModel>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QUrl>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
|
@ -33,27 +32,42 @@ static const QString KEY_NAME = "Key";
|
|||
static const QString LOADING_MSG = "Loading...";
|
||||
static const QString ERROR_MSG = "Error loading files";
|
||||
|
||||
static const QString DO_NOT_MODIFY_TAG = "DoNotModify";
|
||||
|
||||
enum ModelMetaData {
|
||||
NAME,
|
||||
CREATOR,
|
||||
UPLOAD_DATE,
|
||||
TYPE,
|
||||
GENDER,
|
||||
DATE_ADDED,
|
||||
TOTAL_SIZE,
|
||||
POLY_NUM,
|
||||
TAGS,
|
||||
|
||||
MODEL_METADATA_COUNT
|
||||
};
|
||||
static const QString propertiesNames[MODEL_METADATA_COUNT] = {
|
||||
"Name",
|
||||
"Creator",
|
||||
"Upload Date",
|
||||
"Type",
|
||||
"Gender"
|
||||
"Date Added",
|
||||
"Total Size",
|
||||
"Poly#",
|
||||
"Tags"
|
||||
};
|
||||
static const QString propertiesIds[MODEL_METADATA_COUNT] = {
|
||||
DO_NOT_MODIFY_TAG,
|
||||
"Creator",
|
||||
"Date-Added",
|
||||
"Total-Size",
|
||||
"Poly-Num",
|
||||
"Tags"
|
||||
};
|
||||
|
||||
ModelsBrowser::ModelsBrowser(ModelType modelsType, QWidget* parent) :
|
||||
QWidget(parent),
|
||||
_handler(new ModelHandler(modelsType))
|
||||
{
|
||||
connect(_handler, SIGNAL(doneDownloading()), SLOT(resizeView()));
|
||||
connect(_handler, SIGNAL(updated()), SLOT(resizeView()));
|
||||
|
||||
// Connect handler
|
||||
_handler->connect(this, SIGNAL(startDownloading()), SLOT(download()));
|
||||
_handler->connect(_handler, SIGNAL(doneDownloading()), SLOT(update()));
|
||||
|
@ -86,7 +100,7 @@ void ModelsBrowser::applyFilter(const QString &filter) {
|
|||
for (int k = 0; k < filters.count(); ++k) {
|
||||
match = false;
|
||||
for (int j = 0; j < MODEL_METADATA_COUNT; ++j) {
|
||||
if (model->item(i, j)->text().contains(filters.at(k))) {
|
||||
if (model->item(i, j)->text().contains(filters.at(k), Qt::CaseInsensitive)) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
|
@ -106,6 +120,12 @@ void ModelsBrowser::applyFilter(const QString &filter) {
|
|||
_handler->unlockModel();
|
||||
}
|
||||
|
||||
void ModelsBrowser::resizeView() {
|
||||
for (int i = 0; i < MODEL_METADATA_COUNT; ++i) {
|
||||
_view.resizeColumnToContents(i);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelsBrowser::browse() {
|
||||
QDialog dialog;
|
||||
dialog.setWindowTitle("Browse models");
|
||||
|
@ -145,8 +165,6 @@ ModelHandler::ModelHandler(ModelType modelsType, QWidget* parent) :
|
|||
_initiateExit(false),
|
||||
_type(modelsType)
|
||||
{
|
||||
connect(&_downloader, SIGNAL(done(QNetworkReply::NetworkError)), SLOT(downloadFinished()));
|
||||
|
||||
// set headers data
|
||||
QStringList headerData;
|
||||
for (int i = 0; i < MODEL_METADATA_COUNT; ++i) {
|
||||
|
@ -156,9 +174,6 @@ ModelHandler::ModelHandler(ModelType modelsType, QWidget* parent) :
|
|||
}
|
||||
|
||||
void ModelHandler::download() {
|
||||
// Query models list
|
||||
queryNewFiles();
|
||||
|
||||
_lock.lockForWrite();
|
||||
if (_initiateExit) {
|
||||
_lock.unlock();
|
||||
|
@ -169,10 +184,25 @@ void ModelHandler::download() {
|
|||
loadingItem->setEnabled(false);
|
||||
_model.appendRow(loadingItem);
|
||||
_lock.unlock();
|
||||
|
||||
// Query models list
|
||||
queryNewFiles();
|
||||
}
|
||||
|
||||
void ModelHandler::update() {
|
||||
// Will be implemented in my next PR
|
||||
_lock.lockForWrite();
|
||||
if (_initiateExit) {
|
||||
_lock.unlock();
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < _model.rowCount(); ++i) {
|
||||
QUrl url(_model.item(i,0)->data(Qt::UserRole).toString());
|
||||
QNetworkAccessManager* accessManager = new QNetworkAccessManager(this);
|
||||
QNetworkRequest request(url);
|
||||
accessManager->head(request);
|
||||
connect(accessManager, SIGNAL(finished(QNetworkReply*)), SLOT(downloadFinished(QNetworkReply*)));
|
||||
}
|
||||
_lock.unlock();
|
||||
}
|
||||
|
||||
void ModelHandler::exit() {
|
||||
|
@ -180,7 +210,6 @@ void ModelHandler::exit() {
|
|||
_initiateExit = true;
|
||||
|
||||
// Disconnect everything
|
||||
_downloader.disconnect();
|
||||
disconnect();
|
||||
thread()->disconnect();
|
||||
|
||||
|
@ -191,12 +220,16 @@ void ModelHandler::exit() {
|
|||
_lock.unlock();
|
||||
}
|
||||
|
||||
void ModelHandler::downloadFinished() {
|
||||
if (_downloader.getData().startsWith("<?xml")) {
|
||||
parseXML(_downloader.getData());
|
||||
void ModelHandler::downloadFinished(QNetworkReply* reply) {
|
||||
QByteArray data = reply->readAll();
|
||||
|
||||
if (!data.isEmpty()) {
|
||||
parseXML(data);
|
||||
} else {
|
||||
qDebug() << _downloader.getData();
|
||||
parseHeaders(reply);
|
||||
}
|
||||
reply->deleteLater();
|
||||
sender()->deleteLater();
|
||||
}
|
||||
|
||||
void ModelHandler::queryNewFiles(QString marker) {
|
||||
|
@ -219,7 +252,11 @@ void ModelHandler::queryNewFiles(QString marker) {
|
|||
|
||||
// Download
|
||||
url.setQuery(query);
|
||||
_downloader.download(url);
|
||||
QNetworkAccessManager* accessManager = new QNetworkAccessManager(this);
|
||||
QNetworkRequest request(url);
|
||||
accessManager->get(request);
|
||||
connect(accessManager, SIGNAL(finished(QNetworkReply*)), SLOT(downloadFinished(QNetworkReply*)));
|
||||
|
||||
}
|
||||
|
||||
bool ModelHandler::parseXML(QByteArray xmlFile) {
|
||||
|
@ -266,18 +303,9 @@ bool ModelHandler::parseXML(QByteArray xmlFile) {
|
|||
QList<QStandardItem*> model;
|
||||
model << new QStandardItem(QFileInfo(xml.text().toString()).baseName());
|
||||
model.first()->setData(PUBLIC_URL + "/" + xml.text().toString(), Qt::UserRole);
|
||||
|
||||
// Rand properties for now (Will be taken out in the next PR)
|
||||
static QString creator[] = {"Ryan", "Philip", "Andzrej"};
|
||||
static QString type[] = {"human", "beast", "pet", "elfe"};
|
||||
static QString gender[] = {"male", "female", "none"};
|
||||
model << new QStandardItem(creator[randIntInRange(0, 2)]);
|
||||
model << new QStandardItem(QDate(randIntInRange(2013, 2014),
|
||||
randIntInRange(1, 12),
|
||||
randIntInRange(1, 30)).toString());
|
||||
model << new QStandardItem(type[randIntInRange(0, 3)]);
|
||||
model << new QStandardItem(gender[randIntInRange(0, 2)]);
|
||||
////////////////////////////////////////////////////////////
|
||||
for (int i = 1; i < MODEL_METADATA_COUNT; ++i) {
|
||||
model << new QStandardItem();
|
||||
}
|
||||
|
||||
_model.appendRow(model);
|
||||
}
|
||||
|
@ -312,9 +340,32 @@ bool ModelHandler::parseXML(QByteArray xmlFile) {
|
|||
_lock.unlock();
|
||||
|
||||
if (!truncated) {
|
||||
qDebug() << "Emitting...";
|
||||
emit doneDownloading();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool ModelHandler::parseHeaders(QNetworkReply* reply) {
|
||||
_lock.lockForWrite();
|
||||
|
||||
QList<QStandardItem*> items = _model.findItems(QFileInfo(reply->url().toString()).baseName());
|
||||
if (items.isEmpty() || items.first()->text() == DO_NOT_MODIFY_TAG) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < MODEL_METADATA_COUNT; ++i) {
|
||||
for (int k = 1; k < reply->rawHeaderPairs().count(); ++k) {
|
||||
QString key = reply->rawHeaderPairs().at(k).first.data();
|
||||
QString item = reply->rawHeaderPairs().at(k).second.data();
|
||||
if (key == propertiesIds[i]) {
|
||||
_model.item(_model.indexFromItem(items.first()).row(), i)->setText(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
_lock.unlock();
|
||||
|
||||
emit updated();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,13 +9,10 @@
|
|||
#ifndef __hifi__ModelsBrowser__
|
||||
#define __hifi__ModelsBrowser__
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QStandardItem>
|
||||
#include <QTreeView>
|
||||
#include <QVector>
|
||||
#include <QReadWriteLock>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTreeView>
|
||||
|
||||
#include "FileDownloader.h"
|
||||
|
||||
enum ModelType {
|
||||
Head,
|
||||
|
@ -33,7 +30,7 @@ public:
|
|||
|
||||
signals:
|
||||
void doneDownloading();
|
||||
void doneUpdating();
|
||||
void updated();
|
||||
|
||||
public slots:
|
||||
void download();
|
||||
|
@ -41,17 +38,17 @@ public slots:
|
|||
void exit();
|
||||
|
||||
private slots:
|
||||
void downloadFinished();
|
||||
void downloadFinished(QNetworkReply* reply);
|
||||
|
||||
private:
|
||||
bool _initiateExit;
|
||||
ModelType _type;
|
||||
FileDownloader _downloader;
|
||||
QReadWriteLock _lock;
|
||||
QStandardItemModel _model;
|
||||
|
||||
void queryNewFiles(QString marker = QString());
|
||||
bool parseXML(QByteArray xmlFile);
|
||||
bool parseHeaders(QNetworkReply* reply);
|
||||
};
|
||||
|
||||
|
||||
|
@ -71,6 +68,7 @@ public slots:
|
|||
|
||||
private slots:
|
||||
void applyFilter(const QString& filter);
|
||||
void resizeView();
|
||||
|
||||
private:
|
||||
ModelHandler* _handler;
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
//
|
||||
// FileDownloader.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Clement Brisset on 3/14/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
//
|
||||
|
||||
#include <QUrl>
|
||||
#include <QNetworkRequest>
|
||||
#include <QEventLoop>
|
||||
#include <QTimer>
|
||||
|
||||
#include "FileDownloader.h"
|
||||
|
||||
FileDownloader::FileDownloader(QObject* parent) : QObject(parent) {
|
||||
connect(&_networkAccessManager, SIGNAL(finished(QNetworkReply*)), SLOT(processReply(QNetworkReply*)));
|
||||
}
|
||||
|
||||
void FileDownloader::download(const QUrl& dataURL, QNetworkAccessManager::Operation operation) {
|
||||
QNetworkRequest request(dataURL);
|
||||
|
||||
_downloadedData.clear();
|
||||
switch (operation) {
|
||||
case QNetworkAccessManager::GetOperation:
|
||||
_networkAccessManager.get(request);
|
||||
break;
|
||||
case QNetworkAccessManager::HeadOperation:
|
||||
_networkAccessManager.head(request);
|
||||
break;
|
||||
default:
|
||||
emit done(QNetworkReply::ProtocolInvalidOperationError);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FileDownloader::processReply(QNetworkReply *reply) {
|
||||
if (reply->error() == QNetworkReply::NoError) {
|
||||
_downloadedData = reply->readAll();
|
||||
}
|
||||
|
||||
reply->deleteLater();
|
||||
emit done(reply->error());
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
//
|
||||
// FileDownloader.h
|
||||
// hifi
|
||||
//
|
||||
// Created by Clement Brisset on 3/14/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef __hifi__FileDownloader__
|
||||
#define __hifi__FileDownloader__
|
||||
|
||||
#include <QObject>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QThread>
|
||||
|
||||
class FileDownloader : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FileDownloader(QObject* parent = NULL);
|
||||
QByteArray getData() const { return _downloadedData; }
|
||||
|
||||
|
||||
signals:
|
||||
void done(QNetworkReply::NetworkError error);
|
||||
|
||||
public slots:
|
||||
void download(const QUrl& dataURL, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation);
|
||||
|
||||
private slots:
|
||||
void processReply(QNetworkReply* reply);
|
||||
|
||||
private:
|
||||
QNetworkAccessManager _networkAccessManager;
|
||||
QByteArray _downloadedData;
|
||||
};
|
||||
|
||||
|
||||
#endif /* defined(__hifi__FileDownloader__) */
|
Loading…
Reference in a new issue