mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:12:46 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi
This commit is contained in:
commit
08c810baad
22 changed files with 110 additions and 98 deletions
|
@ -1036,6 +1036,7 @@ function handeMenuEvent(menuItem) {
|
||||||
// This function tries to find a reasonable position to place a new entity based on the camera
|
// This function tries to find a reasonable position to place a new entity based on the camera
|
||||||
// position. If a reasonable position within the world bounds can't be found, `null` will
|
// position. If a reasonable position within the world bounds can't be found, `null` will
|
||||||
// be returned. The returned position will also take into account grid snapping settings.
|
// be returned. The returned position will also take into account grid snapping settings.
|
||||||
|
// FIXME - technically we should guard against very large positions too
|
||||||
function getPositionToCreateEntity() {
|
function getPositionToCreateEntity() {
|
||||||
var distance = cameraManager.enabled ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE;
|
var distance = cameraManager.enabled ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE;
|
||||||
var direction = Quat.getFront(Camera.orientation);
|
var direction = Quat.getFront(Camera.orientation);
|
||||||
|
@ -1043,17 +1044,21 @@ function getPositionToCreateEntity() {
|
||||||
var placementPosition = Vec3.sum(Camera.position, offset);
|
var placementPosition = Vec3.sum(Camera.position, offset);
|
||||||
|
|
||||||
var cameraPosition = Camera.position;
|
var cameraPosition = Camera.position;
|
||||||
|
|
||||||
|
var HALF_TREE_SCALE = 16384;
|
||||||
|
|
||||||
var cameraOutOfBounds = cameraPosition.x < 0 || cameraPosition.y < 0 || cameraPosition.z < 0;
|
var cameraOutOfBounds = cameraPosition.x < -HALF_TREE_SCALE || cameraPosition.y < -HALF_TREE_SCALE ||
|
||||||
var placementOutOfBounds = placementPosition.x < 0 || placementPosition.y < 0 || placementPosition.z < 0;
|
cameraPosition.z < -HALF_TREE_SCALE;
|
||||||
|
var placementOutOfBounds = placementPosition.x < -HALF_TREE_SCALE || placementPosition.y < -HALF_TREE_SCALE ||
|
||||||
|
placementPosition.z < -HALF_TREE_SCALE;
|
||||||
|
|
||||||
if (cameraOutOfBounds && placementOutOfBounds) {
|
if (cameraOutOfBounds && placementOutOfBounds) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
placementPosition.x = Math.max(0, placementPosition.x);
|
placementPosition.x = Math.max(-HALF_TREE_SCALE, placementPosition.x);
|
||||||
placementPosition.y = Math.max(0, placementPosition.y);
|
placementPosition.y = Math.max(-HALF_TREE_SCALE, placementPosition.y);
|
||||||
placementPosition.z = Math.max(0, placementPosition.z);
|
placementPosition.z = Math.max(-HALF_TREE_SCALE, placementPosition.z);
|
||||||
|
|
||||||
return placementPosition;
|
return placementPosition;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,8 +175,6 @@ public:
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// Starfield information
|
// Starfield information
|
||||||
static uint8_t THROTTLED_IDLE_TIMER_DELAY = 10;
|
|
||||||
|
|
||||||
const qint64 MAXIMUM_CACHE_SIZE = 10 * BYTES_PER_GIGABYTES; // 10GB
|
const qint64 MAXIMUM_CACHE_SIZE = 10 * BYTES_PER_GIGABYTES; // 10GB
|
||||||
|
|
||||||
static QTimer* locationUpdateTimer = NULL;
|
static QTimer* locationUpdateTimer = NULL;
|
||||||
|
@ -737,6 +735,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
_keyboardFocusHighlight->setVisible(false);
|
_keyboardFocusHighlight->setVisible(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(this, &Application::applicationStateChanged, this, &Application::activeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::aboutToQuit() {
|
void Application::aboutToQuit() {
|
||||||
|
@ -2108,8 +2108,11 @@ void Application::idle() {
|
||||||
// Once rendering is off on another thread we should be able to have Application::idle run at start(0) in
|
// Once rendering is off on another thread we should be able to have Application::idle run at start(0) in
|
||||||
// perpetuity and not expect events to get backed up.
|
// perpetuity and not expect events to get backed up.
|
||||||
|
|
||||||
|
bool isThrottled = getActiveDisplayPlugin()->isThrottled();
|
||||||
|
static const int THROTTLED_IDLE_TIMER_DELAY = MSECS_PER_SECOND / 15;
|
||||||
static const int IDLE_TIMER_DELAY_MS = 2;
|
static const int IDLE_TIMER_DELAY_MS = 2;
|
||||||
int desiredInterval = getActiveDisplayPlugin()->isThrottled() ? THROTTLED_IDLE_TIMER_DELAY : IDLE_TIMER_DELAY_MS;
|
int desiredInterval = isThrottled ? THROTTLED_IDLE_TIMER_DELAY : IDLE_TIMER_DELAY_MS;
|
||||||
|
//qDebug() << "isThrottled:" << isThrottled << "desiredInterval:" << desiredInterval;
|
||||||
|
|
||||||
if (idleTimer->interval() != desiredInterval) {
|
if (idleTimer->interval() != desiredInterval) {
|
||||||
idleTimer->start(desiredInterval);
|
idleTimer->start(desiredInterval);
|
||||||
|
@ -4612,6 +4615,24 @@ void Application::checkSkeleton() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Application::isForeground() {
|
||||||
|
return _isForeground && !getWindow()->isMinimized();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::activeChanged(Qt::ApplicationState state) {
|
||||||
|
switch (state) {
|
||||||
|
case Qt::ApplicationActive:
|
||||||
|
_isForeground = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::ApplicationSuspended:
|
||||||
|
case Qt::ApplicationHidden:
|
||||||
|
case Qt::ApplicationInactive:
|
||||||
|
default:
|
||||||
|
_isForeground = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
void Application::showFriendsWindow() {
|
void Application::showFriendsWindow() {
|
||||||
const QString FRIENDS_WINDOW_TITLE = "Add/Remove Friends";
|
const QString FRIENDS_WINDOW_TITLE = "Add/Remove Friends";
|
||||||
const QString FRIENDS_WINDOW_URL = "https://metaverse.highfidelity.com/user/friends";
|
const QString FRIENDS_WINDOW_URL = "https://metaverse.highfidelity.com/user/friends";
|
||||||
|
@ -4725,6 +4746,7 @@ static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool acti
|
||||||
}
|
}
|
||||||
|
|
||||||
static QVector<QPair<QString, QString>> _currentDisplayPluginActions;
|
static QVector<QPair<QString, QString>> _currentDisplayPluginActions;
|
||||||
|
static bool _activatingDisplayPlugin{false};
|
||||||
|
|
||||||
void Application::updateDisplayMode() {
|
void Application::updateDisplayMode() {
|
||||||
auto menu = Menu::getInstance();
|
auto menu = Menu::getInstance();
|
||||||
|
@ -4771,7 +4793,9 @@ void Application::updateDisplayMode() {
|
||||||
|
|
||||||
if (newDisplayPlugin) {
|
if (newDisplayPlugin) {
|
||||||
_offscreenContext->makeCurrent();
|
_offscreenContext->makeCurrent();
|
||||||
|
_activatingDisplayPlugin = true;
|
||||||
newDisplayPlugin->activate();
|
newDisplayPlugin->activate();
|
||||||
|
_activatingDisplayPlugin = false;
|
||||||
_offscreenContext->makeCurrent();
|
_offscreenContext->makeCurrent();
|
||||||
offscreenUi->resize(fromGlm(newDisplayPlugin->getRecommendedUiSize()));
|
offscreenUi->resize(fromGlm(newDisplayPlugin->getRecommendedUiSize()));
|
||||||
_offscreenContext->makeCurrent();
|
_offscreenContext->makeCurrent();
|
||||||
|
@ -4888,14 +4912,17 @@ void Application::removeMenu(const QString& menuName) {
|
||||||
void Application::addMenuItem(const QString& path, const QString& name, std::function<void(bool)> onClicked, bool checkable, bool checked, const QString& groupName) {
|
void Application::addMenuItem(const QString& path, const QString& name, std::function<void(bool)> onClicked, bool checkable, bool checked, const QString& groupName) {
|
||||||
auto menu = Menu::getInstance();
|
auto menu = Menu::getInstance();
|
||||||
MenuWrapper* parentItem = menu->getMenu(path);
|
MenuWrapper* parentItem = menu->getMenu(path);
|
||||||
QAction* action = parentItem->addAction(name);
|
QAction* action = menu->addActionToQMenuAndActionHash(parentItem, name);
|
||||||
connect(action, &QAction::triggered, [=] {
|
connect(action, &QAction::triggered, [=] {
|
||||||
onClicked(action->isChecked());
|
onClicked(action->isChecked());
|
||||||
});
|
});
|
||||||
action->setCheckable(checkable);
|
action->setCheckable(checkable);
|
||||||
action->setChecked(checked);
|
action->setChecked(checked);
|
||||||
_currentDisplayPluginActions.push_back({ path, name });
|
if (_activatingDisplayPlugin) {
|
||||||
_currentInputPluginActions.push_back({ path, name });
|
_currentDisplayPluginActions.push_back({ path, name });
|
||||||
|
} else {
|
||||||
|
_currentInputPluginActions.push_back({ path, name });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::removeMenuItem(const QString& menuName, const QString& menuItem) {
|
void Application::removeMenuItem(const QString& menuName, const QString& menuItem) {
|
||||||
|
|
|
@ -291,6 +291,7 @@ public:
|
||||||
virtual void unsetFullscreen(const QScreen* avoid) override;
|
virtual void unsetFullscreen(const QScreen* avoid) override;
|
||||||
virtual void showDisplayPluginsTools() override;
|
virtual void showDisplayPluginsTools() override;
|
||||||
virtual QGLWidget* getPrimarySurface() override;
|
virtual QGLWidget* getPrimarySurface() override;
|
||||||
|
virtual bool isForeground() override;
|
||||||
|
|
||||||
void setActiveDisplayPlugin(const QString& pluginName);
|
void setActiveDisplayPlugin(const QString& pluginName);
|
||||||
|
|
||||||
|
@ -476,6 +477,7 @@ private slots:
|
||||||
void faceTrackerMuteToggled();
|
void faceTrackerMuteToggled();
|
||||||
|
|
||||||
void setCursorVisible(bool visible);
|
void setCursorVisible(bool visible);
|
||||||
|
void activeChanged(Qt::ApplicationState state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetCameras(Camera& camera, const glm::uvec2& size);
|
void resetCameras(Camera& camera, const glm::uvec2& size);
|
||||||
|
@ -688,6 +690,7 @@ private:
|
||||||
SimpleMovingAverage _simsPerSecond{10};
|
SimpleMovingAverage _simsPerSecond{10};
|
||||||
int _simsPerSecondReport = 0;
|
int _simsPerSecondReport = 0;
|
||||||
quint64 _lastSimsPerSecondUpdate = 0;
|
quint64 _lastSimsPerSecondUpdate = 0;
|
||||||
|
bool _isForeground = true; // starts out assumed to be in foreground
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Application_h
|
#endif // hifi_Application_h
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
const int MSECS_PER_FRAME_WHEN_THROTTLED = 66;
|
|
||||||
|
|
||||||
static QGLFormat& getDesiredGLFormat() {
|
static QGLFormat& getDesiredGLFormat() {
|
||||||
// Specify an OpenGL 3.3 format using the Core profile.
|
// Specify an OpenGL 3.3 format using the Core profile.
|
||||||
// That is, no old-school fixed pipeline functionality
|
// That is, no old-school fixed pipeline functionality
|
||||||
|
@ -35,10 +33,7 @@ static QGLFormat& getDesiredGLFormat() {
|
||||||
return glFormat;
|
return glFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLCanvas::GLCanvas() : QGLWidget(getDesiredGLFormat()),
|
GLCanvas::GLCanvas() : QGLWidget(getDesiredGLFormat()) {
|
||||||
_throttleRendering(false),
|
|
||||||
_idleRenderInterval(MSECS_PER_FRAME_WHEN_THROTTLED)
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
// Cause GLCanvas::eventFilter to be called.
|
// Cause GLCanvas::eventFilter to be called.
|
||||||
// It wouldn't hurt to do this on Mac and PC too; but apparently it's only needed on linux.
|
// It wouldn't hurt to do this on Mac and PC too; but apparently it's only needed on linux.
|
||||||
|
@ -46,15 +41,6 @@ GLCanvas::GLCanvas() : QGLWidget(getDesiredGLFormat()),
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas::stopFrameTimer() {
|
|
||||||
_frameTimer.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GLCanvas::isThrottleRendering() const {
|
|
||||||
return (_throttleRendering
|
|
||||||
|| (Application::getInstance()->getWindow()->isMinimized() && Application::getInstance()->isThrottleFPSEnabled()));
|
|
||||||
}
|
|
||||||
|
|
||||||
int GLCanvas::getDeviceWidth() const {
|
int GLCanvas::getDeviceWidth() const {
|
||||||
return width() * (windowHandle() ? (float)windowHandle()->devicePixelRatio() : 1.0f);
|
return width() * (windowHandle() ? (float)windowHandle()->devicePixelRatio() : 1.0f);
|
||||||
}
|
}
|
||||||
|
@ -66,17 +52,17 @@ int GLCanvas::getDeviceHeight() const {
|
||||||
void GLCanvas::initializeGL() {
|
void GLCanvas::initializeGL() {
|
||||||
setAttribute(Qt::WA_AcceptTouchEvents);
|
setAttribute(Qt::WA_AcceptTouchEvents);
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
connect(Application::getInstance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(activeChanged(Qt::ApplicationState)));
|
|
||||||
connect(&_frameTimer, SIGNAL(timeout()), this, SLOT(throttleRender()));
|
|
||||||
|
|
||||||
// Note, we *DO NOT* want Qt to automatically swap buffers for us. This results in the "ringing" bug mentioned in WL#19514 when we're throttling the framerate.
|
// Note, we *DO NOT* want Qt to automatically swap buffers for us. This results in the "ringing" bug mentioned in WL#19514 when we're throttling the framerate.
|
||||||
setAutoBufferSwap(false);
|
setAutoBufferSwap(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas::paintGL() {
|
void GLCanvas::paintGL() {
|
||||||
PROFILE_RANGE(__FUNCTION__);
|
PROFILE_RANGE(__FUNCTION__);
|
||||||
if (!_throttleRendering &&
|
|
||||||
(!Application::getInstance()->getWindow()->isMinimized() || !Application::getInstance()->isThrottleFPSEnabled())) {
|
// FIXME - I'm not sure why this still remains, it appears as if this GLCanvas gets a single paintGL call near
|
||||||
|
// the beginning of the application starting up. I'm not sure if we really need to call Application::paintGL()
|
||||||
|
// in this case, since the display plugins eventually handle all the painting
|
||||||
|
if ((!Application::getInstance()->getWindow()->isMinimized() || !Application::getInstance()->isThrottleFPSEnabled())) {
|
||||||
Application::getInstance()->paintGL();
|
Application::getInstance()->paintGL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,39 +71,6 @@ void GLCanvas::resizeGL(int width, int height) {
|
||||||
Application::getInstance()->resizeGL();
|
Application::getInstance()->resizeGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas::activeChanged(Qt::ApplicationState state) {
|
|
||||||
switch (state) {
|
|
||||||
case Qt::ApplicationActive:
|
|
||||||
// If we're active, stop the frame timer and the throttle.
|
|
||||||
_frameTimer.stop();
|
|
||||||
_throttleRendering = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Qt::ApplicationSuspended:
|
|
||||||
case Qt::ApplicationHidden:
|
|
||||||
// If we're hidden or are about to suspend, don't render anything.
|
|
||||||
_throttleRendering = false;
|
|
||||||
_frameTimer.stop();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Otherwise, throttle.
|
|
||||||
if (!_throttleRendering && !Application::getInstance()->isAboutToQuit()
|
|
||||||
&& Application::getInstance()->isThrottleFPSEnabled()) {
|
|
||||||
_frameTimer.start(_idleRenderInterval);
|
|
||||||
_throttleRendering = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLCanvas::throttleRender() {
|
|
||||||
_frameTimer.start(_idleRenderInterval);
|
|
||||||
if (!Application::getInstance()->getWindow()->isMinimized()) {
|
|
||||||
Application::getInstance()->paintGL();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int updateTime = 0;
|
int updateTime = 0;
|
||||||
bool GLCanvas::event(QEvent* event) {
|
bool GLCanvas::event(QEvent* event) {
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
|
|
|
@ -23,28 +23,18 @@ class GLCanvas : public QGLWidget {
|
||||||
public:
|
public:
|
||||||
GLCanvas();
|
GLCanvas();
|
||||||
|
|
||||||
void stopFrameTimer();
|
|
||||||
|
|
||||||
bool isThrottleRendering() const;
|
|
||||||
|
|
||||||
int getDeviceWidth() const;
|
int getDeviceWidth() const;
|
||||||
int getDeviceHeight() const;
|
int getDeviceHeight() const;
|
||||||
QSize getDeviceSize() const { return QSize(getDeviceWidth(), getDeviceHeight()); }
|
QSize getDeviceSize() const { return QSize(getDeviceWidth(), getDeviceHeight()); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
QTimer _frameTimer;
|
|
||||||
bool _throttleRendering;
|
|
||||||
int _idleRenderInterval;
|
|
||||||
|
|
||||||
virtual void initializeGL();
|
virtual void initializeGL();
|
||||||
virtual void paintGL();
|
virtual void paintGL();
|
||||||
virtual void resizeGL(int width, int height);
|
virtual void resizeGL(int width, int height);
|
||||||
virtual bool event(QEvent* event);
|
virtual bool event(QEvent* event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void activeChanged(Qt::ApplicationState state);
|
|
||||||
void throttleRender();
|
|
||||||
bool eventFilter(QObject*, QEvent* event);
|
bool eventFilter(QObject*, QEvent* event);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -283,7 +283,7 @@ namespace MenuOption {
|
||||||
const QString TestPing = "Test Ping";
|
const QString TestPing = "Test Ping";
|
||||||
const QString ThirdPerson = "Third Person";
|
const QString ThirdPerson = "Third Person";
|
||||||
const QString ThreePointCalibration = "3 Point Calibration";
|
const QString ThreePointCalibration = "3 Point Calibration";
|
||||||
const QString ThrottleFPSIfNotFocus = "Throttle FPS If Not Focus";
|
const QString ThrottleFPSIfNotFocus = "Throttle FPS If Not Focus"; // FIXME - this value duplicated in Basic2DWindowOpenGLDisplayPlugin.cpp
|
||||||
const QString ToolWindow = "Tool Window";
|
const QString ToolWindow = "Tool Window";
|
||||||
const QString TransmitterDrive = "Transmitter Drive";
|
const QString TransmitterDrive = "Transmitter Drive";
|
||||||
const QString TurnWithHead = "Turn using Head";
|
const QString TurnWithHead = "Turn using Head";
|
||||||
|
|
|
@ -43,11 +43,13 @@ void renderWorldBox(gpu::Batch& batch) {
|
||||||
|
|
||||||
auto transform = Transform{};
|
auto transform = Transform{};
|
||||||
batch.setModelTransform(transform);
|
batch.setModelTransform(transform);
|
||||||
geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(TREE_SCALE, 0.0f, 0.0f), red);
|
|
||||||
geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, TREE_SCALE, 0.0f), green);
|
// TODO - consider alternate rendering for negative build-able space in the domain
|
||||||
geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, TREE_SCALE), blue);
|
geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(HALF_TREE_SCALE, 0.0f, 0.0f), red);
|
||||||
geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, TREE_SCALE), glm::vec3(TREE_SCALE, 0.0f, TREE_SCALE), grey);
|
geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, HALF_TREE_SCALE, 0.0f), green);
|
||||||
geometryCache->renderLine(batch, glm::vec3(TREE_SCALE, 0.0f, TREE_SCALE), glm::vec3(TREE_SCALE, 0.0f, 0.0f), grey);
|
geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, HALF_TREE_SCALE), blue);
|
||||||
|
geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, HALF_TREE_SCALE), glm::vec3(HALF_TREE_SCALE, 0.0f, HALF_TREE_SCALE), grey);
|
||||||
|
geometryCache->renderLine(batch, glm::vec3(HALF_TREE_SCALE, 0.0f, HALF_TREE_SCALE), glm::vec3(HALF_TREE_SCALE, 0.0f, 0.0f), grey);
|
||||||
|
|
||||||
// Draw meter markers along the 3 axis to help with measuring things
|
// Draw meter markers along the 3 axis to help with measuring things
|
||||||
const float MARKER_DISTANCE = 1.0f;
|
const float MARKER_DISTANCE = 1.0f;
|
||||||
|
|
|
@ -34,3 +34,24 @@ void Basic2DWindowOpenGLDisplayPlugin::deactivate() {
|
||||||
// container->removeMenu(MENU_PATH);
|
// container->removeMenu(MENU_PATH);
|
||||||
MainWindowOpenGLDisplayPlugin::deactivate();
|
MainWindowOpenGLDisplayPlugin::deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Basic2DWindowOpenGLDisplayPlugin::getDesiredInterval(bool isThrottled) const {
|
||||||
|
static const int THROTTLED_PAINT_TIMER_DELAY = MSECS_PER_SECOND / 15;
|
||||||
|
static const int PAINT_TIMER_DELAY_MS = 1;
|
||||||
|
|
||||||
|
return isThrottled ? THROTTLED_PAINT_TIMER_DELAY : PAINT_TIMER_DELAY_MS;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Basic2DWindowOpenGLDisplayPlugin::isThrottled() const {
|
||||||
|
static const QString ThrottleFPSIfNotFocus = "Throttle FPS If Not Focus"; // FIXME - this value duplicated in Menu.h
|
||||||
|
|
||||||
|
bool shouldThrottle = (!CONTAINER->isForeground() && CONTAINER->isOptionChecked(ThrottleFPSIfNotFocus));
|
||||||
|
|
||||||
|
if (_isThrottled != shouldThrottle) {
|
||||||
|
int desiredInterval = getDesiredInterval(shouldThrottle);
|
||||||
|
_timer.start(desiredInterval);
|
||||||
|
_isThrottled = shouldThrottle;
|
||||||
|
}
|
||||||
|
|
||||||
|
return shouldThrottle;
|
||||||
|
}
|
|
@ -18,6 +18,12 @@ public:
|
||||||
|
|
||||||
virtual const QString & getName() const override;
|
virtual const QString & getName() const override;
|
||||||
|
|
||||||
|
virtual bool isThrottled() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int getDesiredInterval(bool isThrottled) const;
|
||||||
|
mutable bool _isThrottled = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const QString NAME;
|
static const QString NAME;
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,8 +37,8 @@ protected:
|
||||||
virtual void doneCurrent() = 0;
|
virtual void doneCurrent() = 0;
|
||||||
virtual void swapBuffers() = 0;
|
virtual void swapBuffers() = 0;
|
||||||
|
|
||||||
QTimer _timer;
|
mutable QTimer _timer;
|
||||||
ProgramPtr _program;
|
ProgramPtr _program;
|
||||||
ShapeWrapperPtr _plane;
|
ShapeWrapperPtr _plane;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@ AddEntityOperator::AddEntityOperator(EntityTree* tree,
|
||||||
{
|
{
|
||||||
// caller must have verified existence of newEntity
|
// caller must have verified existence of newEntity
|
||||||
assert(_newEntity);
|
assert(_newEntity);
|
||||||
_newEntityBox = _newEntity->getMaximumAACube().clamp(0.0f, (float)TREE_SCALE);
|
|
||||||
|
_newEntityBox = _newEntity->getMaximumAACube().clamp((float)(-HALF_TREE_SCALE), (float)HALF_TREE_SCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddEntityOperator::preRecursion(OctreeElement* element) {
|
bool AddEntityOperator::preRecursion(OctreeElement* element) {
|
||||||
|
|
|
@ -253,7 +253,7 @@ void EntityItemPropertiesFromScriptValueHonorReadOnly(const QScriptValue &object
|
||||||
|
|
||||||
// define these inline here so the macros work
|
// define these inline here so the macros work
|
||||||
inline void EntityItemProperties::setPosition(const glm::vec3& value)
|
inline void EntityItemProperties::setPosition(const glm::vec3& value)
|
||||||
{ _position = glm::clamp(value, 0.0f, (float)TREE_SCALE); _positionChanged = true; }
|
{ _position = glm::clamp(value, (float)-HALF_TREE_SCALE, (float)HALF_TREE_SCALE); _positionChanged = true; }
|
||||||
|
|
||||||
inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) {
|
inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) {
|
||||||
debug << "EntityItemProperties[" << "\n";
|
debug << "EntityItemProperties[" << "\n";
|
||||||
|
|
|
@ -113,7 +113,7 @@ void EntitySimulation::sortEntitiesThatMoved() {
|
||||||
// External changes to entity position/shape are expected to be sorted outside of the EntitySimulation.
|
// External changes to entity position/shape are expected to be sorted outside of the EntitySimulation.
|
||||||
PerformanceTimer perfTimer("sortingEntities");
|
PerformanceTimer perfTimer("sortingEntities");
|
||||||
MovingEntitiesOperator moveOperator(_entityTree);
|
MovingEntitiesOperator moveOperator(_entityTree);
|
||||||
AACube domainBounds(glm::vec3(0.0f,0.0f,0.0f), (float)TREE_SCALE);
|
AACube domainBounds(glm::vec3((float)-HALF_TREE_SCALE), (float)TREE_SCALE);
|
||||||
SetOfEntities::iterator itemItr = _entitiesToSort.begin();
|
SetOfEntities::iterator itemItr = _entitiesToSort.begin();
|
||||||
while (itemItr != _entitiesToSort.end()) {
|
while (itemItr != _entitiesToSort.end()) {
|
||||||
EntityItemPointer entity = *itemItr;
|
EntityItemPointer entity = *itemItr;
|
||||||
|
@ -195,7 +195,7 @@ void EntitySimulation::changeEntity(EntityItemPointer entity) {
|
||||||
bool wasRemoved = false;
|
bool wasRemoved = false;
|
||||||
uint32_t dirtyFlags = entity->getDirtyFlags();
|
uint32_t dirtyFlags = entity->getDirtyFlags();
|
||||||
if (dirtyFlags & EntityItem::DIRTY_POSITION) {
|
if (dirtyFlags & EntityItem::DIRTY_POSITION) {
|
||||||
AACube domainBounds(glm::vec3(0.0f,0.0f,0.0f), (float)TREE_SCALE);
|
AACube domainBounds(glm::vec3((float)-HALF_TREE_SCALE), (float)TREE_SCALE);
|
||||||
AACube newCube = entity->getMaximumAACube();
|
AACube newCube = entity->getMaximumAACube();
|
||||||
if (!domainBounds.touches(newCube)) {
|
if (!domainBounds.touches(newCube)) {
|
||||||
qCDebug(entities) << "Entity " << entity->getEntityItemID() << " moved out of domain bounds.";
|
qCDebug(entities) << "Entity " << entity->getEntityItemID() << " moved out of domain bounds.";
|
||||||
|
|
|
@ -444,14 +444,14 @@ bool EntityTreeElement::bestFitBounds(const AABox& bounds) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityTreeElement::containsBounds(const glm::vec3& minPoint, const glm::vec3& maxPoint) const {
|
bool EntityTreeElement::containsBounds(const glm::vec3& minPoint, const glm::vec3& maxPoint) const {
|
||||||
glm::vec3 clampedMin = glm::clamp(minPoint, 0.0f, (float)TREE_SCALE);
|
glm::vec3 clampedMin = glm::clamp(minPoint, (float)-HALF_TREE_SCALE, (float)HALF_TREE_SCALE);
|
||||||
glm::vec3 clampedMax = glm::clamp(maxPoint, 0.0f, (float)TREE_SCALE);
|
glm::vec3 clampedMax = glm::clamp(maxPoint, (float)-HALF_TREE_SCALE, (float)HALF_TREE_SCALE);
|
||||||
return _cube.contains(clampedMin) && _cube.contains(clampedMax);
|
return _cube.contains(clampedMin) && _cube.contains(clampedMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityTreeElement::bestFitBounds(const glm::vec3& minPoint, const glm::vec3& maxPoint) const {
|
bool EntityTreeElement::bestFitBounds(const glm::vec3& minPoint, const glm::vec3& maxPoint) const {
|
||||||
glm::vec3 clampedMin = glm::clamp(minPoint, 0.0f, (float)TREE_SCALE);
|
glm::vec3 clampedMin = glm::clamp(minPoint, (float)-HALF_TREE_SCALE, (float)HALF_TREE_SCALE);
|
||||||
glm::vec3 clampedMax = glm::clamp(maxPoint, 0.0f, (float)TREE_SCALE);
|
glm::vec3 clampedMax = glm::clamp(maxPoint, (float)-HALF_TREE_SCALE, (float)HALF_TREE_SCALE);
|
||||||
|
|
||||||
if (_cube.contains(clampedMin) && _cube.contains(clampedMax)) {
|
if (_cube.contains(clampedMin) && _cube.contains(clampedMax)) {
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ MovingEntitiesOperator::~MovingEntitiesOperator() {
|
||||||
|
|
||||||
void MovingEntitiesOperator::addEntityToMoveList(EntityItemPointer entity, const AACube& newCube) {
|
void MovingEntitiesOperator::addEntityToMoveList(EntityItemPointer entity, const AACube& newCube) {
|
||||||
EntityTreeElement* oldContainingElement = _tree->getContainingElement(entity->getEntityItemID());
|
EntityTreeElement* oldContainingElement = _tree->getContainingElement(entity->getEntityItemID());
|
||||||
AABox newCubeClamped = newCube.clamp(0.0f, (float)TREE_SCALE);
|
AABox newCubeClamped = newCube.clamp((float)-HALF_TREE_SCALE, (float)HALF_TREE_SCALE);
|
||||||
|
|
||||||
if (_wantDebug) {
|
if (_wantDebug) {
|
||||||
qCDebug(entities) << "MovingEntitiesOperator::addEntityToMoveList() -----------------------------";
|
qCDebug(entities) << "MovingEntitiesOperator::addEntityToMoveList() -----------------------------";
|
||||||
|
|
|
@ -47,7 +47,7 @@ UpdateEntityOperator::UpdateEntityOperator(EntityTree* tree,
|
||||||
// which can handle all potential rotations?
|
// which can handle all potential rotations?
|
||||||
// the getMaximumAACube is the relaxed form.
|
// the getMaximumAACube is the relaxed form.
|
||||||
_oldEntityCube = _existingEntity->getMaximumAACube();
|
_oldEntityCube = _existingEntity->getMaximumAACube();
|
||||||
_oldEntityBox = _oldEntityCube.clamp(0.0f, (float)TREE_SCALE); // clamp to domain bounds
|
_oldEntityBox = _oldEntityCube.clamp((float)-HALF_TREE_SCALE, (float)HALF_TREE_SCALE); // clamp to domain bounds
|
||||||
|
|
||||||
// If the old properties doesn't contain the properties required to calculate a bounding box,
|
// If the old properties doesn't contain the properties required to calculate a bounding box,
|
||||||
// get them from the existing entity. Registration point is required to correctly calculate
|
// get them from the existing entity. Registration point is required to correctly calculate
|
||||||
|
@ -123,7 +123,7 @@ UpdateEntityOperator::UpdateEntityOperator(EntityTree* tree,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_newEntityBox = _newEntityCube.clamp(0.0f, (float)TREE_SCALE); // clamp to domain bounds
|
_newEntityBox = _newEntityCube.clamp((float)-HALF_TREE_SCALE, (float)HALF_TREE_SCALE); // clamp to domain bounds
|
||||||
|
|
||||||
|
|
||||||
if (_wantDebug) {
|
if (_wantDebug) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ PacketVersion versionForPacketType(PacketType::Value packetType) {
|
||||||
case EntityAdd:
|
case EntityAdd:
|
||||||
case EntityEdit:
|
case EntityEdit:
|
||||||
case EntityData:
|
case EntityData:
|
||||||
return VERSION_ENTITIES_POLYLINE;
|
return VERSION_OCTREE_CENTERED_ORIGIN;
|
||||||
case AvatarData:
|
case AvatarData:
|
||||||
return 12;
|
return 12;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -142,5 +142,6 @@ const PacketVersion VERSION_ENTITIES_HAVE_SIMULATION_OWNER_AND_ACTIONS_OVER_WIRE
|
||||||
const PacketVersion VERSION_ENTITIES_NEW_PROTOCOL_LAYER = 35;
|
const PacketVersion VERSION_ENTITIES_NEW_PROTOCOL_LAYER = 35;
|
||||||
const PacketVersion VERSION_POLYVOX_TEXTURES = 36;
|
const PacketVersion VERSION_POLYVOX_TEXTURES = 36;
|
||||||
const PacketVersion VERSION_ENTITIES_POLYLINE = 37;
|
const PacketVersion VERSION_ENTITIES_POLYLINE = 37;
|
||||||
|
const PacketVersion VERSION_OCTREE_CENTERED_ORIGIN = 38;
|
||||||
|
|
||||||
#endif // hifi_PacketHeaders_h
|
#endif // hifi_PacketHeaders_h
|
|
@ -17,7 +17,8 @@
|
||||||
|
|
||||||
const quint64 CHANGE_FUDGE = 1000 * 200; // useconds of fudge in determining if we want to resend changed voxels
|
const quint64 CHANGE_FUDGE = 1000 * 200; // useconds of fudge in determining if we want to resend changed voxels
|
||||||
|
|
||||||
const int TREE_SCALE = 16384; // ~10 miles.. This is the number of meters of the 0.0 to 1.0 voxel universe
|
const int TREE_SCALE = 32768; // ~20 miles.. This is the number of meters of the 0.0 to 1.0 voxel universe
|
||||||
|
const int HALF_TREE_SCALE = TREE_SCALE / 2;
|
||||||
|
|
||||||
// This controls the LOD. Larger number will make smaller voxels visible at greater distance.
|
// This controls the LOD. Larger number will make smaller voxels visible at greater distance.
|
||||||
const float DEFAULT_OCTREE_SIZE_SCALE = TREE_SCALE * 400.0f;
|
const float DEFAULT_OCTREE_SIZE_SCALE = TREE_SCALE * 400.0f;
|
||||||
|
|
|
@ -191,6 +191,7 @@ void OctreeElement::calculateAACube() {
|
||||||
// this tells you the "size" of the voxel
|
// this tells you the "size" of the voxel
|
||||||
float voxelScale = (float)TREE_SCALE / powf(2.0f, numberOfThreeBitSectionsInCode(getOctalCode()));
|
float voxelScale = (float)TREE_SCALE / powf(2.0f, numberOfThreeBitSectionsInCode(getOctalCode()));
|
||||||
corner *= (float)TREE_SCALE;
|
corner *= (float)TREE_SCALE;
|
||||||
|
corner -= (float)HALF_TREE_SCALE;
|
||||||
_cube.setBox(corner, voxelScale);
|
_cube.setBox(corner, voxelScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,8 +718,8 @@ int OctreeElement::getMyChildContaining(const AACube& cube) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine which of our children the minimum and maximum corners of the cube live in...
|
// Determine which of our children the minimum and maximum corners of the cube live in...
|
||||||
glm::vec3 cubeCornerMinimum = glm::clamp(cube.getCorner(), 0.0f, (float)TREE_SCALE);
|
glm::vec3 cubeCornerMinimum = glm::clamp(cube.getCorner(), (float)-HALF_TREE_SCALE, (float)HALF_TREE_SCALE);
|
||||||
glm::vec3 cubeCornerMaximum = glm::clamp(cube.calcTopFarLeft(), 0.0f, (float)TREE_SCALE);
|
glm::vec3 cubeCornerMaximum = glm::clamp(cube.calcTopFarLeft(), (float)-HALF_TREE_SCALE, (float)HALF_TREE_SCALE);
|
||||||
|
|
||||||
if (_cube.contains(cubeCornerMinimum) && _cube.contains(cubeCornerMaximum)) {
|
if (_cube.contains(cubeCornerMinimum) && _cube.contains(cubeCornerMaximum)) {
|
||||||
int childIndexCubeMinimum = getMyChildContainingPoint(cubeCornerMinimum);
|
int childIndexCubeMinimum = getMyChildContainingPoint(cubeCornerMinimum);
|
||||||
|
|
|
@ -31,7 +31,7 @@ const float DEFAULT_KEYHOLE_RADIUS = 3.0f;
|
||||||
const float DEFAULT_FIELD_OF_VIEW_DEGREES = 45.0f;
|
const float DEFAULT_FIELD_OF_VIEW_DEGREES = 45.0f;
|
||||||
const float DEFAULT_ASPECT_RATIO = 16.0f/9.0f;
|
const float DEFAULT_ASPECT_RATIO = 16.0f/9.0f;
|
||||||
const float DEFAULT_NEAR_CLIP = 0.08f;
|
const float DEFAULT_NEAR_CLIP = 0.08f;
|
||||||
const float DEFAULT_FAR_CLIP = (float)TREE_SCALE;
|
const float DEFAULT_FAR_CLIP = (float)HALF_TREE_SCALE;
|
||||||
|
|
||||||
class ViewFrustum {
|
class ViewFrustum {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -26,4 +26,5 @@ public:
|
||||||
virtual void unsetFullscreen(const QScreen* avoidScreen = nullptr) = 0;
|
virtual void unsetFullscreen(const QScreen* avoidScreen = nullptr) = 0;
|
||||||
virtual void showDisplayPluginsTools() = 0;
|
virtual void showDisplayPluginsTools() = 0;
|
||||||
virtual QGLWidget* getPrimarySurface() = 0;
|
virtual QGLWidget* getPrimarySurface() = 0;
|
||||||
|
virtual bool isForeground() = 0;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue