mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:48:44 +02:00
Merge pull request #3973 from Atlante45/applications_diet
Move GLWidget to DM
This commit is contained in:
commit
0b3796ccfe
49 changed files with 271 additions and 258 deletions
|
@ -64,6 +64,7 @@
|
||||||
#include <HFBackEvent.h>
|
#include <HFBackEvent.h>
|
||||||
#include <LocalVoxelsList.h>
|
#include <LocalVoxelsList.h>
|
||||||
#include <LogHandler.h>
|
#include <LogHandler.h>
|
||||||
|
#include <MainWindow.h>
|
||||||
#include <NetworkAccessManager.h>
|
#include <NetworkAccessManager.h>
|
||||||
#include <OctalCode.h>
|
#include <OctalCode.h>
|
||||||
#include <OctreeSceneStats.h>
|
#include <OctreeSceneStats.h>
|
||||||
|
@ -142,7 +143,6 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt
|
||||||
Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
QApplication(argc, argv),
|
QApplication(argc, argv),
|
||||||
_window(new MainWindow(desktop())),
|
_window(new MainWindow(desktop())),
|
||||||
_glWidget(new GLCanvas()),
|
|
||||||
_toolWindow(NULL),
|
_toolWindow(NULL),
|
||||||
_nodeThread(new QThread(this)),
|
_nodeThread(new QThread(this)),
|
||||||
_datagramProcessor(),
|
_datagramProcessor(),
|
||||||
|
@ -191,6 +191,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
_isVSyncOn(true),
|
_isVSyncOn(true),
|
||||||
_aboutToQuit(false)
|
_aboutToQuit(false)
|
||||||
{
|
{
|
||||||
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
Model::setViewStateInterface(this); // The model class will sometimes need to know view state details from us
|
Model::setViewStateInterface(this); // The model class will sometimes need to know view state details from us
|
||||||
|
|
||||||
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
||||||
|
@ -362,16 +363,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
|
|
||||||
ResourceCache::setRequestLimit(3);
|
ResourceCache::setRequestLimit(3);
|
||||||
|
|
||||||
_window->setCentralWidget(_glWidget);
|
_window->setCentralWidget(glCanvas.data());
|
||||||
|
|
||||||
restoreSizeAndPosition();
|
restoreSizeAndPosition();
|
||||||
|
|
||||||
_window->setVisible(true);
|
_window->setVisible(true);
|
||||||
_glWidget->setFocusPolicy(Qt::StrongFocus);
|
glCanvas->setFocusPolicy(Qt::StrongFocus);
|
||||||
_glWidget->setFocus();
|
glCanvas->setFocus();
|
||||||
|
|
||||||
// enable mouse tracking; otherwise, we only get drag events
|
// enable mouse tracking; otherwise, we only get drag events
|
||||||
_glWidget->setMouseTracking(true);
|
glCanvas->setMouseTracking(true);
|
||||||
|
|
||||||
_toolWindow = new ToolWindow();
|
_toolWindow = new ToolWindow();
|
||||||
_toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint);
|
_toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint);
|
||||||
|
@ -390,7 +391,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
|
|
||||||
checkVersion();
|
checkVersion();
|
||||||
|
|
||||||
_overlays.init(_glWidget); // do this before scripts load
|
_overlays.init(glCanvas.data()); // do this before scripts load
|
||||||
|
|
||||||
LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());
|
LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());
|
||||||
LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);
|
LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);
|
||||||
|
@ -439,6 +440,7 @@ void Application::aboutToQuit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application() {
|
Application::~Application() {
|
||||||
|
|
||||||
_entities.getTree()->setSimulation(NULL);
|
_entities.getTree()->setSimulation(NULL);
|
||||||
qInstallMessageHandler(NULL);
|
qInstallMessageHandler(NULL);
|
||||||
|
|
||||||
|
@ -480,8 +482,6 @@ Application::~Application() {
|
||||||
Menu::getInstance()->deleteLater();
|
Menu::getInstance()->deleteLater();
|
||||||
|
|
||||||
_myAvatar = NULL;
|
_myAvatar = NULL;
|
||||||
|
|
||||||
delete _glWidget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::saveSettings() {
|
void Application::saveSettings() {
|
||||||
|
@ -621,7 +621,7 @@ void Application::paintGL() {
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected()) {
|
||||||
DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize());
|
DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize());
|
||||||
} else {
|
} else {
|
||||||
QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
|
QSize fbSize = DependencyManager::get<GLCanvas>()->getDeviceSize() * getRenderResolutionScale();
|
||||||
DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize);
|
DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1045,7 +1045,8 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
if (isShifted) {
|
if (isShifted) {
|
||||||
_viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f);
|
_viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f);
|
||||||
if (TV3DManager::isConnected()) {
|
if (TV3DManager::isConnected()) {
|
||||||
TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
|
TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0));
|
_myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0));
|
||||||
|
@ -1057,7 +1058,8 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
if (isShifted) {
|
if (isShifted) {
|
||||||
_viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f);
|
_viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f);
|
||||||
if (TV3DManager::isConnected()) {
|
if (TV3DManager::isConnected()) {
|
||||||
TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
|
TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1503,7 +1505,7 @@ void Application::idle() {
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("updateGL");
|
PerformanceTimer perfTimer("updateGL");
|
||||||
PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()");
|
PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()");
|
||||||
_glWidget->updateGL();
|
DependencyManager::get<GLCanvas>()->updateGL();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("rest");
|
PerformanceTimer perfTimer("rest");
|
||||||
|
@ -1529,13 +1531,14 @@ void Application::idle() {
|
||||||
|
|
||||||
void Application::checkBandwidthMeterClick() {
|
void Application::checkBandwidthMeterClick() {
|
||||||
// ... to be called upon button release
|
// ... to be called upon button release
|
||||||
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) &&
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) &&
|
||||||
Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
|
Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
|
||||||
Menu::getInstance()->isOptionChecked(MenuOption::UserInterface) &&
|
Menu::getInstance()->isOptionChecked(MenuOption::UserInterface) &&
|
||||||
glm::compMax(glm::abs(glm::ivec2(getMouseX() - getMouseDragStartedX(),
|
glm::compMax(glm::abs(glm::ivec2(getMouseX() - getMouseDragStartedX(),
|
||||||
getMouseY() - getMouseDragStartedY())))
|
getMouseY() - getMouseDragStartedY())))
|
||||||
<= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH
|
<= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH
|
||||||
&& _bandwidthMeter.isWithinArea(getMouseX(), getMouseY(), _glWidget->width(), _glWidget->height())) {
|
&& _bandwidthMeter.isWithinArea(getMouseX(), getMouseY(), glCanvas->width(), glCanvas->height())) {
|
||||||
|
|
||||||
// The bandwidth meter is visible, the click didn't get dragged too far and
|
// The bandwidth meter is visible, the click didn't get dragged too far and
|
||||||
// we actually hit the bandwidth meter
|
// we actually hit the bandwidth meter
|
||||||
|
@ -1564,7 +1567,8 @@ void Application::setFullscreen(bool fullscreen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setEnable3DTVMode(bool enable3DTVMode) {
|
void Application::setEnable3DTVMode(bool enable3DTVMode) {
|
||||||
resizeGL(_glWidget->getDeviceWidth(),_glWidget->getDeviceHeight());
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
|
resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setEnableVRMode(bool enableVRMode) {
|
void Application::setEnableVRMode(bool enableVRMode) {
|
||||||
|
@ -1589,7 +1593,8 @@ void Application::setEnableVRMode(bool enableVRMode) {
|
||||||
_myCamera.setHmdRotation(glm::quat());
|
_myCamera.setHmdRotation(glm::quat());
|
||||||
}
|
}
|
||||||
|
|
||||||
resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
|
resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setRenderVoxels(bool voxelRender) {
|
void Application::setRenderVoxels(bool voxelRender) {
|
||||||
|
@ -1651,8 +1656,9 @@ glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVox
|
||||||
|
|
||||||
bool Application::mouseOnScreen() const {
|
bool Application::mouseOnScreen() const {
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected()) {
|
||||||
return getMouseX() >= 0 && getMouseX() <= _glWidget->getDeviceWidth() &&
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
getMouseY() >= 0 && getMouseY() <= _glWidget->getDeviceHeight();
|
return getMouseX() >= 0 && getMouseX() <= glCanvas->getDeviceWidth() &&
|
||||||
|
getMouseY() >= 0 && getMouseY() <= glCanvas->getDeviceHeight();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1692,13 +1698,13 @@ int Application::getMouseDragStartedY() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
FaceTracker* Application::getActiveFaceTracker() {
|
FaceTracker* Application::getActiveFaceTracker() {
|
||||||
Faceshift* faceshift = DependencyManager::get<Faceshift>();
|
Faceshift::SharedPointer faceshift = DependencyManager::get<Faceshift>();
|
||||||
Visage* visage = DependencyManager::get<Visage>();
|
Visage::SharedPointer visage = DependencyManager::get<Visage>();
|
||||||
DdeFaceTracker* dde = DependencyManager::get<DdeFaceTracker>();
|
DdeFaceTracker::SharedPointer dde = DependencyManager::get<DdeFaceTracker>();
|
||||||
|
|
||||||
return (dde->isActive() ? static_cast<FaceTracker*>(dde) :
|
return (dde->isActive() ? static_cast<FaceTracker*>(dde.data()) :
|
||||||
(faceshift->isActive() ? static_cast<FaceTracker*>(faceshift) :
|
(faceshift->isActive() ? static_cast<FaceTracker*>(faceshift.data()) :
|
||||||
(visage->isActive() ? static_cast<FaceTracker*>(visage) : NULL)));
|
(visage->isActive() ? static_cast<FaceTracker*>(visage.data()) : NULL)));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SendVoxelsOperationArgs {
|
struct SendVoxelsOperationArgs {
|
||||||
|
@ -1771,7 +1777,8 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) {
|
||||||
QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
||||||
QString suggestedName = desktopLocation.append("/voxels.svo");
|
QString suggestedName = desktopLocation.append("/voxels.svo");
|
||||||
|
|
||||||
QString fileNameString = QFileDialog::getSaveFileName(_glWidget, tr("Export Voxels"), suggestedName,
|
QString fileNameString = QFileDialog::getSaveFileName(DependencyManager::get<GLCanvas>().data(),
|
||||||
|
tr("Export Voxels"), suggestedName,
|
||||||
tr("Sparse Voxel Octree Files (*.svo)"));
|
tr("Sparse Voxel Octree Files (*.svo)"));
|
||||||
QByteArray fileNameAscii = fileNameString.toLocal8Bit();
|
QByteArray fileNameAscii = fileNameString.toLocal8Bit();
|
||||||
const char* fileName = fileNameAscii.data();
|
const char* fileName = fileNameAscii.data();
|
||||||
|
@ -2025,9 +2032,9 @@ void Application::init() {
|
||||||
|
|
||||||
_metavoxels.init();
|
_metavoxels.init();
|
||||||
|
|
||||||
_audio.init(_glWidget);
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
|
_audio.init(glCanvas.data());
|
||||||
_rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings);
|
_rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect, _settings);
|
||||||
|
|
||||||
connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
|
connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
|
||||||
connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
|
connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
|
||||||
|
@ -2041,10 +2048,11 @@ void Application::init() {
|
||||||
connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
|
connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
|
||||||
|
|
||||||
// make sure our texture cache knows about window size changes
|
// make sure our texture cache knows about window size changes
|
||||||
DependencyManager::get<TextureCache>()->associateWithWidget(getGLWidget());
|
DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data());
|
||||||
|
|
||||||
// initialize the GlowEffect with our widget
|
// initialize the GlowEffect with our widget
|
||||||
DependencyManager::get<GlowEffect>()->init(getGLWidget(), Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect));
|
DependencyManager::get<GlowEffect>()->init(glCanvas.data(),
|
||||||
|
Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::closeMirrorView() {
|
void Application::closeMirrorView() {
|
||||||
|
@ -2112,7 +2120,7 @@ void Application::updateMouseRay() {
|
||||||
void Application::updateFaceshift() {
|
void Application::updateFaceshift() {
|
||||||
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||||
PerformanceWarning warn(showWarnings, "Application::updateFaceshift()");
|
PerformanceWarning warn(showWarnings, "Application::updateFaceshift()");
|
||||||
Faceshift* faceshift = DependencyManager::get<Faceshift>();
|
Faceshift::SharedPointer faceshift = DependencyManager::get<Faceshift>();
|
||||||
// Update faceshift
|
// Update faceshift
|
||||||
faceshift->update();
|
faceshift->update();
|
||||||
|
|
||||||
|
@ -2916,7 +2924,8 @@ void Application::updateShadowMap() {
|
||||||
|
|
||||||
fbo->release();
|
fbo->release();
|
||||||
|
|
||||||
glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
|
glViewport(0, 0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f };
|
const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f };
|
||||||
|
@ -2950,7 +2959,9 @@ QImage Application::renderAvatarBillboard() {
|
||||||
Glower glower;
|
Glower glower;
|
||||||
|
|
||||||
const int BILLBOARD_SIZE = 64;
|
const int BILLBOARD_SIZE = 64;
|
||||||
renderRearViewMirror(QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true);
|
renderRearViewMirror(QRect(0, DependencyManager::get<GLCanvas>()->getDeviceHeight() - BILLBOARD_SIZE,
|
||||||
|
BILLBOARD_SIZE, BILLBOARD_SIZE),
|
||||||
|
true);
|
||||||
|
|
||||||
QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
|
QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
|
||||||
glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
|
glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
|
||||||
|
@ -3253,8 +3264,9 @@ bool Application::getCascadeShadowsEnabled() {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
|
glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
|
||||||
float horizontalScale = _glWidget->getDeviceWidth() / 2.0f;
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
float verticalScale = _glWidget->getDeviceHeight() / 2.0f;
|
float horizontalScale = glCanvas->getDeviceWidth() / 2.0f;
|
||||||
|
float verticalScale = glCanvas->getDeviceHeight() / 2.0f;
|
||||||
|
|
||||||
// -1,-1 is 0,windowHeight
|
// -1,-1 is 0,windowHeight
|
||||||
// 1,1 is windowWidth,0
|
// 1,1 is windowWidth,0
|
||||||
|
@ -3273,7 +3285,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
|
||||||
// -1,-1 1,-1
|
// -1,-1 1,-1
|
||||||
|
|
||||||
glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale,
|
glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale,
|
||||||
((projectedPoint.y + 1.0) * -verticalScale) + _glWidget->getDeviceHeight());
|
((projectedPoint.y + 1.0) * -verticalScale) + glCanvas->getDeviceHeight());
|
||||||
|
|
||||||
return screenPoint;
|
return screenPoint;
|
||||||
}
|
}
|
||||||
|
@ -3584,7 +3596,7 @@ void Application::resetSensors() {
|
||||||
QScreen* currentScreen = _window->windowHandle()->screen();
|
QScreen* currentScreen = _window->windowHandle()->screen();
|
||||||
QWindow* mainWindow = _window->windowHandle();
|
QWindow* mainWindow = _window->windowHandle();
|
||||||
QPoint windowCenter = mainWindow->geometry().center();
|
QPoint windowCenter = mainWindow->geometry().center();
|
||||||
_glWidget->cursor().setPos(currentScreen, windowCenter);
|
DependencyManager::get<GLCanvas>()->cursor().setPos(currentScreen, windowCenter);
|
||||||
|
|
||||||
_myAvatar->reset();
|
_myAvatar->reset();
|
||||||
|
|
||||||
|
@ -4020,7 +4032,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
||||||
scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
|
||||||
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
|
||||||
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
||||||
scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>());
|
scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
|
||||||
scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());
|
scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());
|
||||||
scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
|
||||||
scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
|
scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
|
||||||
|
@ -4265,7 +4277,8 @@ void Application::setPreviousScriptLocation(const QString& previousScriptLocatio
|
||||||
|
|
||||||
void Application::loadDialog() {
|
void Application::loadDialog() {
|
||||||
|
|
||||||
QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"),
|
QString fileNameString = QFileDialog::getOpenFileName(DependencyManager::get<GLCanvas>().data(),
|
||||||
|
tr("Open Script"),
|
||||||
getPreviousScriptLocation(),
|
getPreviousScriptLocation(),
|
||||||
tr("JavaScript Files (*.js)"));
|
tr("JavaScript Files (*.js)"));
|
||||||
if (!fileNameString.isEmpty()) {
|
if (!fileNameString.isEmpty()) {
|
||||||
|
@ -4301,7 +4314,7 @@ void Application::loadScriptURLDialog() {
|
||||||
|
|
||||||
void Application::toggleLogDialog() {
|
void Application::toggleLogDialog() {
|
||||||
if (! _logDialog) {
|
if (! _logDialog) {
|
||||||
_logDialog = new LogDialog(_glWidget, getLogger());
|
_logDialog = new LogDialog(DependencyManager::get<GLCanvas>().data(), getLogger());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_logDialog->isVisible()) {
|
if (_logDialog->isVisible()) {
|
||||||
|
@ -4361,7 +4374,7 @@ void Application::parseVersionXml() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) {
|
if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) {
|
||||||
new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadUrl);
|
new UpdateDialog(DependencyManager::get<GLCanvas>().data(), releaseNotes, latestVersion, downloadUrl);
|
||||||
}
|
}
|
||||||
sender->deleteLater();
|
sender->deleteLater();
|
||||||
}
|
}
|
||||||
|
@ -4394,7 +4407,7 @@ void Application::takeSnapshot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_snapshotShareDialog) {
|
if (!_snapshotShareDialog) {
|
||||||
_snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget);
|
_snapshotShareDialog = new SnapshotShareDialog(fileName, DependencyManager::get<GLCanvas>().data());
|
||||||
}
|
}
|
||||||
_snapshotShareDialog->show();
|
_snapshotShareDialog->show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,25 +12,16 @@
|
||||||
#ifndef hifi_Application_h
|
#ifndef hifi_Application_h
|
||||||
#define hifi_Application_h
|
#define hifi_Application_h
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <gpu/GPUConfig.h>
|
#include <gpu/GPUConfig.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QAction>
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QList>
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QHash>
|
|
||||||
#include <QTouchEvent>
|
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
#include <QSystemTrayIcon>
|
|
||||||
|
|
||||||
#include <EntityCollisionSystem.h>
|
#include <EntityCollisionSystem.h>
|
||||||
#include <EntityEditPacketSender.h>
|
#include <EntityEditPacketSender.h>
|
||||||
|
@ -45,7 +36,6 @@
|
||||||
#include <ViewStateInterface.h>
|
#include <ViewStateInterface.h>
|
||||||
#include <VoxelEditPacketSender.h>
|
#include <VoxelEditPacketSender.h>
|
||||||
|
|
||||||
#include "MainWindow.h"
|
|
||||||
#include "Audio.h"
|
#include "Audio.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "DatagramProcessor.h"
|
#include "DatagramProcessor.h"
|
||||||
|
@ -89,17 +79,19 @@
|
||||||
#include "UndoStackScriptingInterface.h"
|
#include "UndoStackScriptingInterface.h"
|
||||||
|
|
||||||
|
|
||||||
class QAction;
|
|
||||||
class QActionGroup;
|
|
||||||
class QGLWidget;
|
class QGLWidget;
|
||||||
class QKeyEvent;
|
class QKeyEvent;
|
||||||
class QMouseEvent;
|
class QMouseEvent;
|
||||||
class QSettings;
|
class QSettings;
|
||||||
|
class QSystemTrayIcon;
|
||||||
|
class QTouchEvent;
|
||||||
class QWheelEvent;
|
class QWheelEvent;
|
||||||
|
|
||||||
class FaceTracker;
|
class FaceTracker;
|
||||||
|
class MainWindow;
|
||||||
class Node;
|
class Node;
|
||||||
class ProgramObject;
|
class ProgramObject;
|
||||||
|
class ScriptEngine;
|
||||||
|
|
||||||
static const float NODE_ADDED_RED = 0.0f;
|
static const float NODE_ADDED_RED = 0.0f;
|
||||||
static const float NODE_ADDED_GREEN = 1.0f;
|
static const float NODE_ADDED_GREEN = 1.0f;
|
||||||
|
@ -182,46 +174,49 @@ public:
|
||||||
void removeVoxel(glm::vec3 position, float scale);
|
void removeVoxel(glm::vec3 position, float scale);
|
||||||
|
|
||||||
glm::vec3 getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel);
|
glm::vec3 getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel);
|
||||||
|
bool isThrottleRendering() const { return DependencyManager::get<GLCanvas>()->isThrottleRendering(); }
|
||||||
|
|
||||||
GLCanvas* getGLWidget() { return _glWidget; }
|
|
||||||
bool isThrottleRendering() const { return _glWidget->isThrottleRendering(); }
|
|
||||||
MyAvatar* getAvatar() { return _myAvatar; }
|
MyAvatar* getAvatar() { return _myAvatar; }
|
||||||
Audio* getAudio() { return &_audio; }
|
Audio* getAudio() { return &_audio; }
|
||||||
Camera* getCamera() { return &_myCamera; }
|
Camera* getCamera() { return &_myCamera; }
|
||||||
ViewFrustum* getViewFrustum() { return &_viewFrustum; }
|
ViewFrustum* getViewFrustum() { return &_viewFrustum; }
|
||||||
ViewFrustum* getDisplayViewFrustum() { return &_displayViewFrustum; }
|
ViewFrustum* getDisplayViewFrustum() { return &_displayViewFrustum; }
|
||||||
ViewFrustum* getShadowViewFrustum() { return &_shadowViewFrustum; }
|
ViewFrustum* getShadowViewFrustum() { return &_shadowViewFrustum; }
|
||||||
VoxelImporter* getVoxelImporter() { return &_voxelImporter; }
|
|
||||||
VoxelSystem* getVoxels() { return &_voxels; }
|
VoxelSystem* getVoxels() { return &_voxels; }
|
||||||
VoxelTree* getVoxelTree() { return _voxels.getTree(); }
|
|
||||||
const OctreePacketProcessor& getOctreePacketProcessor() const { return _octreeProcessor; }
|
const OctreePacketProcessor& getOctreePacketProcessor() const { return _octreeProcessor; }
|
||||||
MetavoxelSystem* getMetavoxels() { return &_metavoxels; }
|
MetavoxelSystem* getMetavoxels() { return &_metavoxels; }
|
||||||
EntityTreeRenderer* getEntities() { return &_entities; }
|
EntityTreeRenderer* getEntities() { return &_entities; }
|
||||||
bool getImportSucceded() { return _importSucceded; }
|
|
||||||
VoxelSystem* getSharedVoxelSystem() { return &_sharedVoxelSystem; }
|
VoxelSystem* getSharedVoxelSystem() { return &_sharedVoxelSystem; }
|
||||||
|
Environment* getEnvironment() { return &_environment; }
|
||||||
|
PrioVR* getPrioVR() { return &_prioVR; }
|
||||||
|
QUndoStack* getUndoStack() { return &_undoStack; }
|
||||||
|
MainWindow* getWindow() { return _window; }
|
||||||
|
|
||||||
|
VoxelImporter* getVoxelImporter() { return &_voxelImporter; }
|
||||||
VoxelTree* getClipboard() { return &_clipboard; }
|
VoxelTree* getClipboard() { return &_clipboard; }
|
||||||
EntityTree* getEntityClipboard() { return &_entityClipboard; }
|
EntityTree* getEntityClipboard() { return &_entityClipboard; }
|
||||||
EntityTreeRenderer* getEntityClipboardRenderer() { return &_entityClipboardRenderer; }
|
EntityTreeRenderer* getEntityClipboardRenderer() { return &_entityClipboardRenderer; }
|
||||||
Environment* getEnvironment() { return &_environment; }
|
VoxelTree* getVoxelTree() { return _voxels.getTree(); }
|
||||||
|
bool getImportSucceded() { return _importSucceded; }
|
||||||
|
|
||||||
bool isMousePressed() const { return _mousePressed; }
|
bool isMousePressed() const { return _mousePressed; }
|
||||||
bool isMouseHidden() const { return _glWidget->cursor().shape() == Qt::BlankCursor; }
|
bool isMouseHidden() const { return DependencyManager::get<GLCanvas>()->cursor().shape() == Qt::BlankCursor; }
|
||||||
void setCursorVisible(bool visible);
|
void setCursorVisible(bool visible);
|
||||||
const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; }
|
const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; }
|
||||||
const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; }
|
const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; }
|
||||||
bool mouseOnScreen() const;
|
bool mouseOnScreen() const;
|
||||||
int getMouseX() const;
|
int getMouseX() const;
|
||||||
int getMouseY() const;
|
int getMouseY() const;
|
||||||
int getTrueMouseX() const { return _glWidget->mapFromGlobal(QCursor::pos()).x(); }
|
int getTrueMouseX() const { return DependencyManager::get<GLCanvas>()->mapFromGlobal(QCursor::pos()).x(); }
|
||||||
int getTrueMouseY() const { return _glWidget->mapFromGlobal(QCursor::pos()).y(); }
|
int getTrueMouseY() const { return DependencyManager::get<GLCanvas>()->mapFromGlobal(QCursor::pos()).y(); }
|
||||||
int getMouseDragStartedX() const;
|
int getMouseDragStartedX() const;
|
||||||
int getMouseDragStartedY() const;
|
int getMouseDragStartedY() const;
|
||||||
int getTrueMouseDragStartedX() const { return _mouseDragStartedX; }
|
int getTrueMouseDragStartedX() const { return _mouseDragStartedX; }
|
||||||
int getTrueMouseDragStartedY() const { return _mouseDragStartedY; }
|
int getTrueMouseDragStartedY() const { return _mouseDragStartedY; }
|
||||||
bool getLastMouseMoveWasSimulated() const { return _lastMouseMoveWasSimulated; }
|
bool getLastMouseMoveWasSimulated() const { return _lastMouseMoveWasSimulated; }
|
||||||
|
|
||||||
FaceTracker* getActiveFaceTracker();
|
FaceTracker* getActiveFaceTracker();
|
||||||
PrioVR* getPrioVR() { return &_prioVR; }
|
|
||||||
BandwidthMeter* getBandwidthMeter() { return &_bandwidthMeter; }
|
BandwidthMeter* getBandwidthMeter() { return &_bandwidthMeter; }
|
||||||
QUndoStack* getUndoStack() { return &_undoStack; }
|
|
||||||
QSystemTrayIcon* getTrayIcon() { return _trayIcon; }
|
QSystemTrayIcon* getTrayIcon() { return _trayIcon; }
|
||||||
ApplicationOverlay& getApplicationOverlay() { return _applicationOverlay; }
|
ApplicationOverlay& getApplicationOverlay() { return _applicationOverlay; }
|
||||||
Overlays& getOverlays() { return _overlays; }
|
Overlays& getOverlays() { return _overlays; }
|
||||||
|
@ -241,7 +236,6 @@ public:
|
||||||
|
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|
||||||
MainWindow* getWindow() { return _window; }
|
|
||||||
NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; }
|
NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; }
|
||||||
void lockOctreeSceneStats() { _octreeSceneStatsLock.lockForRead(); }
|
void lockOctreeSceneStats() { _octreeSceneStatsLock.lockForRead(); }
|
||||||
void unlockOctreeSceneStats() { _octreeSceneStatsLock.unlock(); }
|
void unlockOctreeSceneStats() { _octreeSceneStatsLock.unlock(); }
|
||||||
|
@ -290,7 +284,8 @@ public:
|
||||||
|
|
||||||
FileLogger* getLogger() { return _logger; }
|
FileLogger* getLogger() { return _logger; }
|
||||||
|
|
||||||
glm::vec2 getViewportDimensions() const { return glm::vec2(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); }
|
glm::vec2 getViewportDimensions() const { return glm::vec2(DependencyManager::get<GLCanvas>()->getDeviceWidth(),
|
||||||
|
DependencyManager::get<GLCanvas>()->getDeviceHeight()); }
|
||||||
NodeToJurisdictionMap& getVoxelServerJurisdictions() { return _voxelServerJurisdictions; }
|
NodeToJurisdictionMap& getVoxelServerJurisdictions() { return _voxelServerJurisdictions; }
|
||||||
NodeToJurisdictionMap& getEntityServerJurisdictions() { return _entityServerJurisdictions; }
|
NodeToJurisdictionMap& getEntityServerJurisdictions() { return _entityServerJurisdictions; }
|
||||||
void pasteVoxelsToOctalCode(const unsigned char* octalCodeDestination);
|
void pasteVoxelsToOctalCode(const unsigned char* octalCodeDestination);
|
||||||
|
@ -468,7 +463,6 @@ private:
|
||||||
int sendNackPackets();
|
int sendNackPackets();
|
||||||
|
|
||||||
MainWindow* _window;
|
MainWindow* _window;
|
||||||
GLCanvas* _glWidget; // our GLCanvas has a couple extra features
|
|
||||||
|
|
||||||
ToolWindow* _toolWindow;
|
ToolWindow* _toolWindow;
|
||||||
|
|
||||||
|
|
|
@ -95,10 +95,8 @@ void Camera::setFarClip(float f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PickRay Camera::computePickRay(float x, float y) {
|
PickRay Camera::computePickRay(float x, float y) {
|
||||||
float screenWidth = Application::getInstance()->getGLWidget()->width();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
float screenHeight = Application::getInstance()->getGLWidget()->height();
|
return computeViewPickRay(x / glCanvas->width(), y / glCanvas->height());
|
||||||
|
|
||||||
return computeViewPickRay(x / screenWidth, y / screenHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PickRay Camera::computeViewPickRay(float xRatio, float yRatio) {
|
PickRay Camera::computeViewPickRay(float xRatio, float yRatio) {
|
||||||
|
|
|
@ -9,13 +9,13 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "GLCanvas.h"
|
#include "GLCanvas.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
#include "devices/OculusManager.h"
|
#include "devices/OculusManager.h"
|
||||||
|
|
||||||
const int MSECS_PER_FRAME_WHEN_THROTTLED = 66;
|
const int MSECS_PER_FRAME_WHEN_THROTTLED = 66;
|
||||||
|
|
|
@ -15,11 +15,14 @@
|
||||||
#include <QGLWidget>
|
#include <QGLWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <DependencyManager.h>
|
||||||
|
|
||||||
/// customized canvas that simply forwards requests/events to the singleton application
|
/// customized canvas that simply forwards requests/events to the singleton application
|
||||||
class GLCanvas : public QGLWidget {
|
class GLCanvas : public QGLWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
SINGLETON_DEPENDENCY(GLCanvas)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GLCanvas();
|
|
||||||
bool isThrottleRendering() const;
|
bool isThrottleRendering() const;
|
||||||
|
|
||||||
int getDeviceWidth() const;
|
int getDeviceWidth() const;
|
||||||
|
@ -56,6 +59,12 @@ private slots:
|
||||||
void activeChanged(Qt::ApplicationState state);
|
void activeChanged(Qt::ApplicationState state);
|
||||||
void throttleRender();
|
void throttleRender();
|
||||||
bool eventFilter(QObject*, QEvent* event);
|
bool eventFilter(QObject*, QEvent* event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
GLCanvas();
|
||||||
|
~GLCanvas() {
|
||||||
|
qDebug() << "Deleting GLCanvas";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_GLCanvas_h
|
#endif // hifi_GLCanvas_h
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <AccountManager.h>
|
#include <AccountManager.h>
|
||||||
#include <AddressManager.h>
|
#include <AddressManager.h>
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
|
#include <MainWindow.h>
|
||||||
#include <GlowEffect.h>
|
#include <GlowEffect.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
#include <UUID.h>
|
#include <UUID.h>
|
||||||
|
@ -426,7 +427,7 @@ Menu::Menu() :
|
||||||
appInstance,
|
appInstance,
|
||||||
SLOT(setRenderVoxels(bool)));
|
SLOT(setRenderVoxels(bool)));
|
||||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::EnableGlowEffect, 0, true,
|
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::EnableGlowEffect, 0, true,
|
||||||
DependencyManager::get<GlowEffect>(), SLOT(toggleGlowEffect(bool)));
|
DependencyManager::get<GlowEffect>().data(), SLOT(toggleGlowEffect(bool)));
|
||||||
|
|
||||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Wireframe, Qt::ALT | Qt::Key_W, false);
|
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Wireframe, Qt::ALT | Qt::Key_W, false);
|
||||||
addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools()));
|
addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools()));
|
||||||
|
@ -437,12 +438,12 @@ Menu::Menu() :
|
||||||
MenuOption::Faceshift,
|
MenuOption::Faceshift,
|
||||||
0,
|
0,
|
||||||
true,
|
true,
|
||||||
DependencyManager::get<Faceshift>(),
|
DependencyManager::get<Faceshift>().data(),
|
||||||
SLOT(setTCPEnabled(bool)));
|
SLOT(setTCPEnabled(bool)));
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_VISAGE
|
#ifdef HAVE_VISAGE
|
||||||
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::Visage, 0, false,
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::Visage, 0, false,
|
||||||
DependencyManager::get<Visage>(), SLOT(updateEnabled()));
|
DependencyManager::get<Visage>().data(), SLOT(updateEnabled()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderSkeletonCollisionShapes);
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderSkeletonCollisionShapes);
|
||||||
|
@ -1051,11 +1052,11 @@ void Menu::bumpSettings() {
|
||||||
|
|
||||||
void sendFakeEnterEvent() {
|
void sendFakeEnterEvent() {
|
||||||
QPoint lastCursorPosition = QCursor::pos();
|
QPoint lastCursorPosition = QCursor::pos();
|
||||||
QGLWidget* glWidget = Application::getInstance()->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
|
|
||||||
QPoint windowPosition = glWidget->mapFromGlobal(lastCursorPosition);
|
QPoint windowPosition = glCanvas->mapFromGlobal(lastCursorPosition);
|
||||||
QEnterEvent enterEvent = QEnterEvent(windowPosition, windowPosition, lastCursorPosition);
|
QEnterEvent enterEvent = QEnterEvent(windowPosition, windowPosition, lastCursorPosition);
|
||||||
QCoreApplication::sendEvent(glWidget, &enterEvent);
|
QCoreApplication::sendEvent(glCanvas.data(), &enterEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
const float DIALOG_RATIO_OF_WINDOW = 0.30f;
|
const float DIALOG_RATIO_OF_WINDOW = 0.30f;
|
||||||
|
@ -1303,7 +1304,7 @@ void Menu::toggleLoginMenuItem() {
|
||||||
|
|
||||||
void Menu::bandwidthDetails() {
|
void Menu::bandwidthDetails() {
|
||||||
if (! _bandwidthDialog) {
|
if (! _bandwidthDialog) {
|
||||||
_bandwidthDialog = new BandwidthDialog(Application::getInstance()->getGLWidget(),
|
_bandwidthDialog = new BandwidthDialog(DependencyManager::get<GLCanvas>().data(),
|
||||||
Application::getInstance()->getBandwidthMeter());
|
Application::getInstance()->getBandwidthMeter());
|
||||||
connect(_bandwidthDialog, SIGNAL(closed()), SLOT(bandwidthDetailsClosed()));
|
connect(_bandwidthDialog, SIGNAL(closed()), SLOT(bandwidthDetailsClosed()));
|
||||||
|
|
||||||
|
@ -1414,7 +1415,7 @@ void Menu::bandwidthDetailsClosed() {
|
||||||
|
|
||||||
void Menu::octreeStatsDetails() {
|
void Menu::octreeStatsDetails() {
|
||||||
if (!_octreeStatsDialog) {
|
if (!_octreeStatsDialog) {
|
||||||
_octreeStatsDialog = new OctreeStatsDialog(Application::getInstance()->getGLWidget(),
|
_octreeStatsDialog = new OctreeStatsDialog(DependencyManager::get<GLCanvas>().data(),
|
||||||
Application::getInstance()->getOcteeSceneStats());
|
Application::getInstance()->getOcteeSceneStats());
|
||||||
connect(_octreeStatsDialog, SIGNAL(closed()), SLOT(octreeStatsDetailsClosed()));
|
connect(_octreeStatsDialog, SIGNAL(closed()), SLOT(octreeStatsDetailsClosed()));
|
||||||
_octreeStatsDialog->show();
|
_octreeStatsDialog->show();
|
||||||
|
@ -1598,7 +1599,7 @@ bool Menu::shouldRenderMesh(float largestDimension, float distanceToCamera) {
|
||||||
|
|
||||||
void Menu::lodTools() {
|
void Menu::lodTools() {
|
||||||
if (!_lodToolsDialog) {
|
if (!_lodToolsDialog) {
|
||||||
_lodToolsDialog = new LodToolsDialog(Application::getInstance()->getGLWidget());
|
_lodToolsDialog = new LodToolsDialog(DependencyManager::get<GLCanvas>().data());
|
||||||
connect(_lodToolsDialog, SIGNAL(closed()), SLOT(lodToolsClosed()));
|
connect(_lodToolsDialog, SIGNAL(closed()), SLOT(lodToolsClosed()));
|
||||||
_lodToolsDialog->show();
|
_lodToolsDialog->show();
|
||||||
if (_hmdToolsDialog) {
|
if (_hmdToolsDialog) {
|
||||||
|
@ -1618,7 +1619,7 @@ void Menu::lodToolsClosed() {
|
||||||
void Menu::hmdTools(bool showTools) {
|
void Menu::hmdTools(bool showTools) {
|
||||||
if (showTools) {
|
if (showTools) {
|
||||||
if (!_hmdToolsDialog) {
|
if (!_hmdToolsDialog) {
|
||||||
_hmdToolsDialog = new HMDToolsDialog(Application::getInstance()->getGLWidget());
|
_hmdToolsDialog = new HMDToolsDialog(DependencyManager::get<GLCanvas>().data());
|
||||||
connect(_hmdToolsDialog, SIGNAL(closed()), SLOT(hmdToolsClosed()));
|
connect(_hmdToolsDialog, SIGNAL(closed()), SLOT(hmdToolsClosed()));
|
||||||
}
|
}
|
||||||
_hmdToolsDialog->show();
|
_hmdToolsDialog->show();
|
||||||
|
|
|
@ -1178,7 +1178,7 @@ void VoxelBuffer::render(bool cursor) {
|
||||||
|
|
||||||
if (!_materials.isEmpty()) {
|
if (!_materials.isEmpty()) {
|
||||||
_networkTextures.resize(_materials.size());
|
_networkTextures.resize(_materials.size());
|
||||||
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
TextureCache::SharedPointer textureCache = DependencyManager::get<TextureCache>();
|
||||||
for (int i = 0; i < _materials.size(); i++) {
|
for (int i = 0; i < _materials.size(); i++) {
|
||||||
const SharedObjectPointer material = _materials.at(i);
|
const SharedObjectPointer material = _materials.at(i);
|
||||||
if (material) {
|
if (material) {
|
||||||
|
@ -2233,7 +2233,7 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g
|
||||||
|
|
||||||
const QVector<SharedObjectPointer>& materials = node->getMaterial()->getMaterials();
|
const QVector<SharedObjectPointer>& materials = node->getMaterial()->getMaterials();
|
||||||
_networkTextures.resize(materials.size());
|
_networkTextures.resize(materials.size());
|
||||||
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
TextureCache::SharedPointer textureCache = DependencyManager::get<TextureCache>();
|
||||||
for (int i = 0; i < materials.size(); i++) {
|
for (int i = 0; i < materials.size(); i++) {
|
||||||
const SharedObjectPointer& material = materials.at(i);
|
const SharedObjectPointer& material = materials.at(i);
|
||||||
if (material) {
|
if (material) {
|
||||||
|
|
|
@ -472,7 +472,7 @@ void ModelUploader::processCheck() {
|
||||||
QString("Your model is now available in the browser."),
|
QString("Your model is now available in the browser."),
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
DependencyManager::get<GeometryCache>()->refresh(_url);
|
DependencyManager::get<GeometryCache>()->refresh(_url);
|
||||||
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
TextureCache::SharedPointer textureCache = DependencyManager::get<TextureCache>();
|
||||||
foreach (const QByteArray& filename, _textureFilenames) {
|
foreach (const QByteArray& filename, _textureFilenames) {
|
||||||
textureCache->refresh(_textureBase + filename);
|
textureCache->refresh(_textureBase + filename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ void renderWorldBox() {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(MARKER_DISTANCE, 0, 0);
|
glTranslatef(MARKER_DISTANCE, 0, 0);
|
||||||
glColor3fv(red);
|
glColor3fv(red);
|
||||||
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
|
GeometryCache::SharedPointer geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
|
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
|
@ -72,20 +72,19 @@ void Head::reset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
||||||
|
|
||||||
if (isMine) {
|
if (isMine) {
|
||||||
MyAvatar* myAvatar = static_cast<MyAvatar*>(_owningAvatar);
|
MyAvatar* myAvatar = static_cast<MyAvatar*>(_owningAvatar);
|
||||||
|
|
||||||
// Only use face trackers when not playing back a recording.
|
// Only use face trackers when not playing back a recording.
|
||||||
if (!myAvatar->isPlaying()) {
|
if (!myAvatar->isPlaying()) {
|
||||||
FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker();
|
FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker();
|
||||||
DdeFaceTracker* dde = DependencyManager::get<DdeFaceTracker>();
|
DdeFaceTracker::SharedPointer dde = DependencyManager::get<DdeFaceTracker>();
|
||||||
Faceshift* faceshift = DependencyManager::get<Faceshift>();
|
Faceshift::SharedPointer faceshift = DependencyManager::get<Faceshift>();
|
||||||
|
|
||||||
if ((_isFaceshiftConnected = (faceshift == faceTracker))) {
|
if ((_isFaceshiftConnected = (faceshift == faceTracker))) {
|
||||||
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
||||||
} else if (dde->isActive()) {
|
} else if (dde->isActive()) {
|
||||||
faceTracker = dde;
|
faceTracker = dde.data();
|
||||||
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,7 +422,7 @@ void MyAvatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bo
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::renderHeadMouse(int screenWidth, int screenHeight) const {
|
void MyAvatar::renderHeadMouse(int screenWidth, int screenHeight) const {
|
||||||
Faceshift* faceshift = DependencyManager::get<Faceshift>();
|
Faceshift::SharedPointer faceshift = DependencyManager::get<Faceshift>();
|
||||||
|
|
||||||
float pixelsPerDegree = screenHeight / Menu::getInstance()->getFieldOfView();
|
float pixelsPerDegree = screenHeight / Menu::getInstance()->getFieldOfView();
|
||||||
|
|
||||||
|
|
|
@ -554,7 +554,7 @@ void SkeletonModel::renderRagdoll() {
|
||||||
float radius1 = 0.008f;
|
float radius1 = 0.008f;
|
||||||
float radius2 = 0.01f;
|
float radius2 = 0.01f;
|
||||||
glm::vec3 simulationTranslation = _ragdoll->getTranslationInSimulationFrame();
|
glm::vec3 simulationTranslation = _ragdoll->getTranslationInSimulationFrame();
|
||||||
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
|
GeometryCache::SharedPointer geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
for (int i = 0; i < numPoints; ++i) {
|
for (int i = 0; i < numPoints; ++i) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
// NOTE: ragdollPoints are in simulation-frame but we want them to be model-relative
|
// NOTE: ragdollPoints are in simulation-frame but we want them to be model-relative
|
||||||
|
@ -914,7 +914,7 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
|
||||||
endPoint = endPoint - _translation;
|
endPoint = endPoint - _translation;
|
||||||
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
|
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
|
||||||
glColor4f(0.6f, 0.6f, 0.8f, alpha);
|
glColor4f(0.6f, 0.6f, 0.8f, alpha);
|
||||||
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
|
GeometryCache::SharedPointer geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
|
||||||
|
|
||||||
// draw a yellow sphere at the capsule startpoint
|
// draw a yellow sphere at the capsule startpoint
|
||||||
|
@ -950,7 +950,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
|
GeometryCache::SharedPointer geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
// shapes are stored in simulation-frame but we want position to be model-relative
|
// shapes are stored in simulation-frame but we want position to be model-relative
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
|
|
||||||
#include "FaceTracker.h"
|
#include "FaceTracker.h"
|
||||||
|
|
||||||
class DdeFaceTracker : public FaceTracker, public DependencyManager::Dependency {
|
class DdeFaceTracker : public FaceTracker {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
SINGLETON_DEPENDENCY(DdeFaceTracker)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//initialization
|
//initialization
|
||||||
|
@ -58,7 +59,6 @@ private:
|
||||||
DdeFaceTracker();
|
DdeFaceTracker();
|
||||||
DdeFaceTracker(const QHostAddress& host, quint16 port);
|
DdeFaceTracker(const QHostAddress& host, quint16 port);
|
||||||
~DdeFaceTracker();
|
~DdeFaceTracker();
|
||||||
friend DependencyManager;
|
|
||||||
|
|
||||||
float getBlendshapeCoefficient(int index) const;
|
float getBlendshapeCoefficient(int index) const;
|
||||||
void decodePacket(const QByteArray& buffer);
|
void decodePacket(const QByteArray& buffer);
|
||||||
|
|
|
@ -24,8 +24,9 @@
|
||||||
#include "FaceTracker.h"
|
#include "FaceTracker.h"
|
||||||
|
|
||||||
/// Handles interaction with the Faceshift software, which provides head position/orientation and facial features.
|
/// Handles interaction with the Faceshift software, which provides head position/orientation and facial features.
|
||||||
class Faceshift : public FaceTracker, public DependencyManager::Dependency {
|
class Faceshift : public FaceTracker {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
SINGLETON_DEPENDENCY(Faceshift)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void init();
|
void init();
|
||||||
|
@ -89,7 +90,6 @@ private slots:
|
||||||
private:
|
private:
|
||||||
Faceshift();
|
Faceshift();
|
||||||
virtual ~Faceshift() {}
|
virtual ~Faceshift() {}
|
||||||
friend DependencyManager;
|
|
||||||
|
|
||||||
float getBlendshapeCoefficient(int index) const;
|
float getBlendshapeCoefficient(int index) const;
|
||||||
|
|
||||||
|
|
|
@ -562,8 +562,8 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore our normal viewport
|
// restore our normal viewport
|
||||||
glViewport(0, 0, Application::getInstance()->getGLWidget()->getDeviceWidth(),
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
Application::getInstance()->getGLWidget()->getDeviceHeight());
|
glViewport(0, 0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
@ -581,8 +581,8 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
|
||||||
void OculusManager::renderDistortionMesh(ovrPosef eyeRenderPose[ovrEye_Count]) {
|
void OculusManager::renderDistortionMesh(ovrPosef eyeRenderPose[ovrEye_Count]) {
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluOrtho2D(0, Application::getInstance()->getGLWidget()->getDeviceWidth(), 0,
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
Application::getInstance()->getGLWidget()->getDeviceHeight());
|
gluOrtho2D(0, glCanvas->getDeviceWidth(), 0, glCanvas->getDeviceHeight());
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
|
|
@ -215,8 +215,9 @@ void PrioVR::renderCalibrationCountdown() {
|
||||||
static TextRenderer* textRenderer = TextRenderer::getInstance(MONO_FONT_FAMILY, 18, QFont::Bold,
|
static TextRenderer* textRenderer = TextRenderer::getInstance(MONO_FONT_FAMILY, 18, QFont::Bold,
|
||||||
false, TextRenderer::OUTLINE_EFFECT, 2);
|
false, TextRenderer::OUTLINE_EFFECT, 2);
|
||||||
QByteArray text = "Assume T-Pose in " + QByteArray::number(secondsRemaining) + "...";
|
QByteArray text = "Assume T-Pose in " + QByteArray::number(secondsRemaining) + "...";
|
||||||
textRenderer->draw((Application::getInstance()->getGLWidget()->width() -
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
textRenderer->computeWidth(text.constData())) / 2, Application::getInstance()->getGLWidget()->height() / 2,
|
textRenderer->draw((glCanvas->width() - textRenderer->computeWidth(text.constData())) / 2,
|
||||||
text);
|
glCanvas->height() / 2,
|
||||||
|
text);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -461,7 +461,7 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers)
|
||||||
void SixenseManager::emulateMouse(PalmData* palm, int index) {
|
void SixenseManager::emulateMouse(PalmData* palm, int index) {
|
||||||
Application* application = Application::getInstance();
|
Application* application = Application::getInstance();
|
||||||
MyAvatar* avatar = application->getAvatar();
|
MyAvatar* avatar = application->getAvatar();
|
||||||
GLCanvas* widget = application->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
QPoint pos;
|
QPoint pos;
|
||||||
|
|
||||||
Qt::MouseButton bumperButton;
|
Qt::MouseButton bumperButton;
|
||||||
|
@ -489,10 +489,10 @@ void SixenseManager::emulateMouse(PalmData* palm, int index) {
|
||||||
float yAngle = 0.5f - ((atan2(direction.z, direction.y) + M_PI_2));
|
float yAngle = 0.5f - ((atan2(direction.z, direction.y) + M_PI_2));
|
||||||
|
|
||||||
// Get the pixel range over which the xAngle and yAngle are scaled
|
// Get the pixel range over which the xAngle and yAngle are scaled
|
||||||
float cursorRange = widget->width() * getCursorPixelRangeMult();
|
float cursorRange = glCanvas->width() * getCursorPixelRangeMult();
|
||||||
|
|
||||||
pos.setX(widget->width() / 2.0f + cursorRange * xAngle);
|
pos.setX(glCanvas->width() / 2.0f + cursorRange * xAngle);
|
||||||
pos.setY(widget->height() / 2.0f + cursorRange * yAngle);
|
pos.setY(glCanvas->height() / 2.0f + cursorRange * yAngle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,10 @@ bool TV3DManager::isConnected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TV3DManager::connect() {
|
void TV3DManager::connect() {
|
||||||
Application* app = Application::getInstance();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
int width = app->getGLWidget()->getDeviceWidth();
|
int width = glCanvas->getDeviceWidth();
|
||||||
int height = app->getGLWidget()->getDeviceHeight();
|
int height = glCanvas->getDeviceHeight();
|
||||||
Camera& camera = *app->getCamera();
|
Camera& camera = *Application::getInstance()->getCamera();
|
||||||
|
|
||||||
configureCamera(camera, width, height);
|
configureCamera(camera, width, height);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,8 @@ void TV3DManager::display(Camera& whichCamera) {
|
||||||
// left eye portal
|
// left eye portal
|
||||||
int portalX = 0;
|
int portalX = 0;
|
||||||
int portalY = 0;
|
int portalY = 0;
|
||||||
QSize deviceSize = Application::getInstance()->getGLWidget()->getDeviceSize() *
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
|
QSize deviceSize = glCanvas->getDeviceSize() *
|
||||||
Application::getInstance()->getRenderResolutionScale();
|
Application::getInstance()->getRenderResolutionScale();
|
||||||
int portalW = deviceSize.width() / 2;
|
int portalW = deviceSize.width() / 2;
|
||||||
int portalH = deviceSize.height();
|
int portalH = deviceSize.height();
|
||||||
|
|
|
@ -122,7 +122,7 @@ static const QMultiHash<QByteArray, QPair<int, float> >& getActionUnitNameMap()
|
||||||
const float TRANSLATION_SCALE = 20.0f;
|
const float TRANSLATION_SCALE = 20.0f;
|
||||||
|
|
||||||
void Visage::init() {
|
void Visage::init() {
|
||||||
connect(DependencyManager::get<Faceshift>(), SIGNAL(connectionStateChanged()), SLOT(updateEnabled()));
|
connect(DependencyManager::get<Faceshift>().data(), SIGNAL(connectionStateChanged()), SLOT(updateEnabled()));
|
||||||
updateEnabled();
|
updateEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,9 @@ namespace VisageSDK {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles input from the Visage webcam feature tracking software.
|
/// Handles input from the Visage webcam feature tracking software.
|
||||||
class Visage : public FaceTracker, public DependencyManager::Dependency {
|
class Visage : public FaceTracker {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
SINGLETON_DEPENDENCY(Visage)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void init();
|
void init();
|
||||||
|
@ -44,7 +45,6 @@ public slots:
|
||||||
private:
|
private:
|
||||||
Visage();
|
Visage();
|
||||||
virtual ~Visage();
|
virtual ~Visage();
|
||||||
friend DependencyManager;
|
|
||||||
|
|
||||||
#ifdef HAVE_VISAGE
|
#ifdef HAVE_VISAGE
|
||||||
VisageSDK::VisageTracker2* _tracker;
|
VisageSDK::VisageTracker2* _tracker;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include <EntityTree.h>
|
#include <EntityTree.h>
|
||||||
#include <EntityScriptingInterface.h> // for RayToEntityIntersectionResult
|
#include <EntityScriptingInterface.h> // for RayToEntityIntersectionResult
|
||||||
|
#include <MouseEvent.h>
|
||||||
#include <Model.h>
|
#include <Model.h>
|
||||||
#include <Octree.h>
|
#include <Octree.h>
|
||||||
#include <OctreePacketData.h>
|
#include <OctreePacketData.h>
|
||||||
|
@ -27,6 +28,8 @@
|
||||||
#include <ViewFrustum.h>
|
#include <ViewFrustum.h>
|
||||||
|
|
||||||
|
|
||||||
|
class ScriptEngine;
|
||||||
|
|
||||||
class EntityScriptDetails {
|
class EntityScriptDetails {
|
||||||
public:
|
public:
|
||||||
QString scriptText;
|
QString scriptText;
|
||||||
|
|
|
@ -268,8 +268,8 @@ void ControllerScriptingInterface::releaseJoystick(int joystickIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 ControllerScriptingInterface::getViewportDimensions() const {
|
glm::vec2 ControllerScriptingInterface::getViewportDimensions() const {
|
||||||
GLCanvas* widget = Application::getInstance()->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
return glm::vec2(widget->width(), widget->height());
|
return glm::vec2(glCanvas->width(), glCanvas->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractInputController* ControllerScriptingInterface::createInputController(const QString& deviceName, const QString& tracker) {
|
AbstractInputController* ControllerScriptingInterface::createInputController(const QString& deviceName, const QString& tracker) {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <QScriptValue>
|
#include <QScriptValue>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "ui/ModelsBrowser.h"
|
#include "ui/ModelsBrowser.h"
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ WebWindowClass* WindowScriptingInterface::doCreateWebWindow(const QString& title
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue WindowScriptingInterface::hasFocus() {
|
QScriptValue WindowScriptingInterface::hasFocus() {
|
||||||
return Application::getInstance()->getGLWidget()->hasFocus();
|
return DependencyManager::get<GLCanvas>()->hasFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowScriptingInterface::setCursorVisible(bool visible) {
|
void WindowScriptingInterface::setCursorVisible(bool visible) {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "AddressBarDialog.h"
|
#include "AddressBarDialog.h"
|
||||||
#include "AddressManager.h"
|
#include "AddressManager.h"
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
|
|
||||||
const QString ADDRESSBAR_GO_BUTTON_ICON = "images/address-bar-submit.svg";
|
const QString ADDRESSBAR_GO_BUTTON_ICON = "images/address-bar-submit.svg";
|
||||||
const QString ADDRESSBAR_GO_BUTTON_ACTIVE_ICON = "images/address-bar-submit-active.svg";
|
const QString ADDRESSBAR_GO_BUTTON_ACTIVE_ICON = "images/address-bar-submit-active.svg";
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include "AnimationsDialog.h"
|
#include "AnimationsDialog.h"
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
|
|
||||||
AnimationsDialog::AnimationsDialog() :
|
AnimationsDialog::AnimationsDialog() :
|
||||||
QDialog(Application::getInstance()->getWindow()) {
|
QDialog(Application::getInstance()->getWindow()) {
|
||||||
|
|
|
@ -147,11 +147,11 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) {
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()");
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()");
|
||||||
Application* application = Application::getInstance();
|
Application* application = Application::getInstance();
|
||||||
Overlays& overlays = application->getOverlays();
|
Overlays& overlays = application->getOverlays();
|
||||||
GLCanvas* glWidget = application->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
MyAvatar* myAvatar = application->getAvatar();
|
MyAvatar* myAvatar = application->getAvatar();
|
||||||
|
|
||||||
_textureFov = glm::radians(Menu::getInstance()->getOculusUIAngularSize());
|
_textureFov = glm::radians(Menu::getInstance()->getOculusUIAngularSize());
|
||||||
_textureAspectRatio = (float)application->getGLWidget()->getDeviceWidth() / (float)application->getGLWidget()->getDeviceHeight();
|
_textureAspectRatio = (float)glCanvas->getDeviceWidth() / (float)glCanvas->getDeviceHeight();
|
||||||
|
|
||||||
//Handle fading and deactivation/activation of UI
|
//Handle fading and deactivation/activation of UI
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) {
|
||||||
|
@ -180,12 +180,12 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) {
|
||||||
|
|
||||||
glPushMatrix(); {
|
glPushMatrix(); {
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluOrtho2D(0, glWidget->width(), glWidget->height(), 0);
|
gluOrtho2D(0, glCanvas->width(), glCanvas->height(), 0);
|
||||||
|
|
||||||
renderAudioMeter();
|
renderAudioMeter();
|
||||||
|
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)) {
|
||||||
myAvatar->renderHeadMouse(glWidget->width(), glWidget->height());
|
myAvatar->renderHeadMouse(glCanvas->width(), glCanvas->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
renderStatsAndLogs();
|
renderStatsAndLogs();
|
||||||
|
@ -215,7 +215,7 @@ void ApplicationOverlay::displayOverlayTexture() {
|
||||||
if (_alpha == 0.0f) {
|
if (_alpha == 0.0f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GLCanvas* glWidget = Application::getInstance()->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
@ -224,16 +224,16 @@ void ApplicationOverlay::displayOverlayTexture() {
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPushMatrix(); {
|
glPushMatrix(); {
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluOrtho2D(0, glWidget->getDeviceWidth(), glWidget->getDeviceHeight(), 0);
|
gluOrtho2D(0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight(), 0);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
glBegin(GL_QUADS); {
|
glBegin(GL_QUADS); {
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, _alpha);
|
glColor4f(1.0f, 1.0f, 1.0f, _alpha);
|
||||||
glTexCoord2f(0, 0); glVertex2i(0, glWidget->getDeviceHeight());
|
glTexCoord2f(0, 0); glVertex2i(0, glCanvas->getDeviceHeight());
|
||||||
glTexCoord2f(1, 0); glVertex2i(glWidget->getDeviceWidth(), glWidget->getDeviceHeight());
|
glTexCoord2f(1, 0); glVertex2i(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
|
||||||
glTexCoord2f(1, 1); glVertex2i(glWidget->getDeviceWidth(), 0);
|
glTexCoord2f(1, 1); glVertex2i(glCanvas->getDeviceWidth(), 0);
|
||||||
glTexCoord2f(0, 1); glVertex2i(0, 0);
|
glTexCoord2f(0, 1); glVertex2i(0, 0);
|
||||||
} glEnd();
|
} glEnd();
|
||||||
} glPopMatrix();
|
} glPopMatrix();
|
||||||
|
@ -380,18 +380,19 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
if (_crosshairTexture == 0) {
|
if (_crosshairTexture == 0) {
|
||||||
_crosshairTexture = Application::getInstance()->getGLWidget()->bindTexture(QImage(PathUtils::resourcesPath() + "images/sixense-reticle.png"));
|
_crosshairTexture = glCanvas->bindTexture(QImage(PathUtils::resourcesPath() + "images/sixense-reticle.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw the mouse pointer
|
//draw the mouse pointer
|
||||||
glBindTexture(GL_TEXTURE_2D, _crosshairTexture);
|
glBindTexture(GL_TEXTURE_2D, _crosshairTexture);
|
||||||
|
|
||||||
const float reticleSize = 40.0f / application->getGLWidget()->width() * quadWidth;
|
const float reticleSize = 40.0f / glCanvas->width() * quadWidth;
|
||||||
x -= reticleSize / 2.0f;
|
x -= reticleSize / 2.0f;
|
||||||
y += reticleSize / 2.0f;
|
y += reticleSize / 2.0f;
|
||||||
const float mouseX = (application->getMouseX() / (float)application->getGLWidget()->width()) * quadWidth;
|
const float mouseX = (application->getMouseX() / (float)glCanvas->width()) * quadWidth;
|
||||||
const float mouseY = (1.0 - (application->getMouseY() / (float)application->getGLWidget()->height())) * quadHeight;
|
const float mouseY = (1.0 - (application->getMouseY() / (float)glCanvas->height())) * quadHeight;
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
|
@ -433,7 +434,7 @@ void ApplicationOverlay::computeOculusPickRay(float x, float y, glm::vec3& origi
|
||||||
//Caculate the click location using one of the sixense controllers. Scale is not applied
|
//Caculate the click location using one of the sixense controllers. Scale is not applied
|
||||||
QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const {
|
QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const {
|
||||||
Application* application = Application::getInstance();
|
Application* application = Application::getInstance();
|
||||||
GLCanvas* glWidget = application->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
MyAvatar* myAvatar = application->getAvatar();
|
MyAvatar* myAvatar = application->getAvatar();
|
||||||
|
|
||||||
glm::vec3 tip = myAvatar->getLaserPointerTipPosition(palm);
|
glm::vec3 tip = myAvatar->getLaserPointerTipPosition(palm);
|
||||||
|
@ -464,8 +465,8 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const {
|
||||||
float u = asin(collisionPos.x) / (_textureFov)+0.5f;
|
float u = asin(collisionPos.x) / (_textureFov)+0.5f;
|
||||||
float v = 1.0 - (asin(collisionPos.y) / (_textureFov)+0.5f);
|
float v = 1.0 - (asin(collisionPos.y) / (_textureFov)+0.5f);
|
||||||
|
|
||||||
rv.setX(u * glWidget->width());
|
rv.setX(u * glCanvas->width());
|
||||||
rv.setY(v * glWidget->height());
|
rv.setY(v * glCanvas->height());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//if they did not click on the overlay, just set the coords to INT_MAX
|
//if they did not click on the overlay, just set the coords to INT_MAX
|
||||||
|
@ -482,8 +483,8 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const {
|
||||||
ndcSpacePos = glm::vec3(clipSpacePos) / clipSpacePos.w;
|
ndcSpacePos = glm::vec3(clipSpacePos) / clipSpacePos.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv.setX(((ndcSpacePos.x + 1.0) / 2.0) * glWidget->width());
|
rv.setX(((ndcSpacePos.x + 1.0) / 2.0) * glCanvas->width());
|
||||||
rv.setY((1.0 - ((ndcSpacePos.y + 1.0) / 2.0)) * glWidget->height());
|
rv.setY((1.0 - ((ndcSpacePos.y + 1.0) / 2.0)) * glCanvas->height());
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -512,10 +513,11 @@ bool ApplicationOverlay::calculateRayUICollisionPoint(const glm::vec3& position,
|
||||||
//Renders optional pointers
|
//Renders optional pointers
|
||||||
void ApplicationOverlay::renderPointers() {
|
void ApplicationOverlay::renderPointers() {
|
||||||
Application* application = Application::getInstance();
|
Application* application = Application::getInstance();
|
||||||
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
|
|
||||||
//lazily load crosshair texture
|
//lazily load crosshair texture
|
||||||
if (_crosshairTexture == 0) {
|
if (_crosshairTexture == 0) {
|
||||||
_crosshairTexture = Application::getInstance()->getGLWidget()->bindTexture(QImage(PathUtils::resourcesPath() + "images/sixense-reticle.png"));
|
_crosshairTexture = glCanvas->bindTexture(QImage(PathUtils::resourcesPath() + "images/sixense-reticle.png"));
|
||||||
}
|
}
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
@ -538,7 +540,7 @@ void ApplicationOverlay::renderPointers() {
|
||||||
glm::vec2 screenPos = sphericalToScreen(glm::vec2(yaw, -pitch));
|
glm::vec2 screenPos = sphericalToScreen(glm::vec2(yaw, -pitch));
|
||||||
|
|
||||||
position = QPoint(screenPos.x, screenPos.y);
|
position = QPoint(screenPos.x, screenPos.y);
|
||||||
application->getGLWidget()->cursor().setPos(application->getGLWidget()->mapToGlobal(position));
|
glCanvas->cursor().setPos(glCanvas->mapToGlobal(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
_reticlePosition[MOUSE] = position;
|
_reticlePosition[MOUSE] = position;
|
||||||
|
@ -559,7 +561,7 @@ void ApplicationOverlay::renderPointers() {
|
||||||
|
|
||||||
void ApplicationOverlay::renderControllerPointers() {
|
void ApplicationOverlay::renderControllerPointers() {
|
||||||
Application* application = Application::getInstance();
|
Application* application = Application::getInstance();
|
||||||
GLCanvas* glWidget = application->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
MyAvatar* myAvatar = application->getAvatar();
|
MyAvatar* myAvatar = application->getAvatar();
|
||||||
|
|
||||||
//Static variables used for storing controller state
|
//Static variables used for storing controller state
|
||||||
|
@ -637,14 +639,14 @@ void ApplicationOverlay::renderControllerPointers() {
|
||||||
float yAngle = 0.5f - ((atan2(direction.z, direction.y) + M_PI_2));
|
float yAngle = 0.5f - ((atan2(direction.z, direction.y) + M_PI_2));
|
||||||
|
|
||||||
// Get the pixel range over which the xAngle and yAngle are scaled
|
// Get the pixel range over which the xAngle and yAngle are scaled
|
||||||
float cursorRange = glWidget->width() * SixenseManager::getInstance().getCursorPixelRangeMult();
|
float cursorRange = glCanvas->width() * SixenseManager::getInstance().getCursorPixelRangeMult();
|
||||||
|
|
||||||
mouseX = (glWidget->width() / 2.0f + cursorRange * xAngle);
|
mouseX = (glCanvas->width() / 2.0f + cursorRange * xAngle);
|
||||||
mouseY = (glWidget->height() / 2.0f + cursorRange * yAngle);
|
mouseY = (glCanvas->height() / 2.0f + cursorRange * yAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//If the cursor is out of the screen then don't render it
|
//If the cursor is out of the screen then don't render it
|
||||||
if (mouseX < 0 || mouseX >= glWidget->width() || mouseY < 0 || mouseY >= glWidget->height()) {
|
if (mouseX < 0 || mouseX >= glCanvas->width() || mouseY < 0 || mouseY >= glCanvas->height()) {
|
||||||
_reticleActive[index] = false;
|
_reticleActive[index] = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -704,11 +706,10 @@ void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) {
|
||||||
|
|
||||||
//Renders a small magnification of the currently bound texture at the coordinates
|
//Renders a small magnification of the currently bound texture at the coordinates
|
||||||
void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool showBorder) const {
|
void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool showBorder) const {
|
||||||
Application* application = Application::getInstance();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
GLCanvas* glWidget = application->getGLWidget();
|
|
||||||
|
|
||||||
const int widgetWidth = glWidget->width();
|
const int widgetWidth = glCanvas->width();
|
||||||
const int widgetHeight = glWidget->height();
|
const int widgetHeight = glCanvas->height();
|
||||||
|
|
||||||
const float halfWidth = (MAGNIFY_WIDTH / _textureAspectRatio) * sizeMult / 2.0f;
|
const float halfWidth = (MAGNIFY_WIDTH / _textureAspectRatio) * sizeMult / 2.0f;
|
||||||
const float halfHeight = MAGNIFY_HEIGHT * sizeMult / 2.0f;
|
const float halfHeight = MAGNIFY_HEIGHT * sizeMult / 2.0f;
|
||||||
|
@ -763,7 +764,7 @@ void ApplicationOverlay::renderAudioMeter() {
|
||||||
|
|
||||||
Application* application = Application::getInstance();
|
Application* application = Application::getInstance();
|
||||||
|
|
||||||
GLCanvas* glWidget = application->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
Audio* audio = application->getAudio();
|
Audio* audio = application->getAudio();
|
||||||
|
|
||||||
// Display a single screen-size quad to create an alpha blended 'collision' flash
|
// Display a single screen-size quad to create an alpha blended 'collision' flash
|
||||||
|
@ -771,7 +772,7 @@ void ApplicationOverlay::renderAudioMeter() {
|
||||||
float collisionSoundMagnitude = audio->getCollisionSoundMagnitude();
|
float collisionSoundMagnitude = audio->getCollisionSoundMagnitude();
|
||||||
const float VISIBLE_COLLISION_SOUND_MAGNITUDE = 0.5f;
|
const float VISIBLE_COLLISION_SOUND_MAGNITUDE = 0.5f;
|
||||||
if (collisionSoundMagnitude > VISIBLE_COLLISION_SOUND_MAGNITUDE) {
|
if (collisionSoundMagnitude > VISIBLE_COLLISION_SOUND_MAGNITUDE) {
|
||||||
renderCollisionOverlay(glWidget->width(), glWidget->height(),
|
renderCollisionOverlay(glCanvas->width(), glCanvas->height(),
|
||||||
audio->getCollisionSoundMagnitude());
|
audio->getCollisionSoundMagnitude());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -825,14 +826,14 @@ void ApplicationOverlay::renderAudioMeter() {
|
||||||
if ((audio->getTimeSinceLastClip() > 0.0f) && (audio->getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) {
|
if ((audio->getTimeSinceLastClip() > 0.0f) && (audio->getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) {
|
||||||
const float MAX_MAGNITUDE = 0.7f;
|
const float MAX_MAGNITUDE = 0.7f;
|
||||||
float magnitude = MAX_MAGNITUDE * (1 - audio->getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME);
|
float magnitude = MAX_MAGNITUDE * (1 - audio->getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME);
|
||||||
renderCollisionOverlay(glWidget->width(), glWidget->height(), magnitude, 1.0f);
|
renderCollisionOverlay(glCanvas->width(), glCanvas->height(), magnitude, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
audio->renderToolBox(MIRROR_VIEW_LEFT_PADDING + AUDIO_METER_GAP, audioMeterY, boxed);
|
audio->renderToolBox(MIRROR_VIEW_LEFT_PADDING + AUDIO_METER_GAP, audioMeterY, boxed);
|
||||||
|
|
||||||
audio->renderScope(glWidget->width(), glWidget->height());
|
audio->renderScope(glCanvas->width(), glCanvas->height());
|
||||||
|
|
||||||
audio->renderStats(WHITE_TEXT, glWidget->width(), glWidget->height());
|
audio->renderStats(WHITE_TEXT, glCanvas->width(), glCanvas->height());
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
if (isClipping) {
|
if (isClipping) {
|
||||||
|
@ -894,7 +895,7 @@ void ApplicationOverlay::renderStatsAndLogs() {
|
||||||
|
|
||||||
Application* application = Application::getInstance();
|
Application* application = Application::getInstance();
|
||||||
|
|
||||||
GLCanvas* glWidget = application->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
const OctreePacketProcessor& octreePacketProcessor = application->getOctreePacketProcessor();
|
const OctreePacketProcessor& octreePacketProcessor = application->getOctreePacketProcessor();
|
||||||
BandwidthMeter* bandwidthMeter = application->getBandwidthMeter();
|
BandwidthMeter* bandwidthMeter = application->getBandwidthMeter();
|
||||||
NodeBounds& nodeBoundsDisplay = application->getNodeBoundsDisplay();
|
NodeBounds& nodeBoundsDisplay = application->getNodeBoundsDisplay();
|
||||||
|
@ -912,8 +913,8 @@ void ApplicationOverlay::renderStatsAndLogs() {
|
||||||
application->getPacketsPerSecond(), application->getBytesPerSecond(), voxelPacketsToProcess);
|
application->getPacketsPerSecond(), application->getBytesPerSecond(), voxelPacketsToProcess);
|
||||||
// Bandwidth meter
|
// Bandwidth meter
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) {
|
||||||
Stats::drawBackground(0x33333399, glWidget->width() - 296, glWidget->height() - 68, 296, 68);
|
Stats::drawBackground(0x33333399, glCanvas->width() - 296, glCanvas->height() - 68, 296, 68);
|
||||||
bandwidthMeter->render(glWidget->width(), glWidget->height());
|
bandwidthMeter->render(glCanvas->width(), glCanvas->height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -926,7 +927,7 @@ void ApplicationOverlay::renderStatsAndLogs() {
|
||||||
(Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
|
(Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
|
||||||
Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth))
|
Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth))
|
||||||
? 80 : 20;
|
? 80 : 20;
|
||||||
drawText(glWidget->width() - 100, glWidget->height() - timerBottom,
|
drawText(glCanvas->width() - 100, glCanvas->height() - timerBottom,
|
||||||
0.30f, 0.0f, 0, frameTimer, WHITE_TEXT);
|
0.30f, 0.0f, 0, frameTimer, WHITE_TEXT);
|
||||||
}
|
}
|
||||||
nodeBoundsDisplay.drawOverlay();
|
nodeBoundsDisplay.drawOverlay();
|
||||||
|
@ -936,9 +937,9 @@ void ApplicationOverlay::renderDomainConnectionStatusBorder() {
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
if (nodeList && !nodeList->getDomainHandler().isConnected()) {
|
if (nodeList && !nodeList->getDomainHandler().isConnected()) {
|
||||||
GLCanvas* glWidget = Application::getInstance()->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
int right = glWidget->width();
|
int right = glCanvas->width();
|
||||||
int bottom = glWidget->height();
|
int bottom = glCanvas->height();
|
||||||
|
|
||||||
glColor3f(CONNECTION_STATUS_BORDER_COLOR[0],
|
glColor3f(CONNECTION_STATUS_BORDER_COLOR[0],
|
||||||
CONNECTION_STATUS_BORDER_COLOR[1],
|
CONNECTION_STATUS_BORDER_COLOR[1],
|
||||||
|
@ -1073,7 +1074,7 @@ void ApplicationOverlay::TexturedHemisphere::cleanupVBO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() {
|
void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() {
|
||||||
QSize size = Application::getInstance()->getGLWidget()->getDeviceSize();
|
QSize size = DependencyManager::get<GLCanvas>()->getDeviceSize();
|
||||||
if (_framebufferObject != NULL && size == _framebufferObject->size()) {
|
if (_framebufferObject != NULL && size == _framebufferObject->size()) {
|
||||||
// Already build
|
// Already build
|
||||||
return;
|
return;
|
||||||
|
@ -1124,7 +1125,7 @@ void ApplicationOverlay::TexturedHemisphere::render() {
|
||||||
|
|
||||||
|
|
||||||
glm::vec2 ApplicationOverlay::screenToSpherical(glm::vec2 screenPos) const {
|
glm::vec2 ApplicationOverlay::screenToSpherical(glm::vec2 screenPos) const {
|
||||||
QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize();
|
QSize screenSize = DependencyManager::get<GLCanvas>()->getDeviceSize();
|
||||||
float yaw = -(screenPos.x / screenSize.width() - 0.5f) * MOUSE_YAW_RANGE;
|
float yaw = -(screenPos.x / screenSize.width() - 0.5f) * MOUSE_YAW_RANGE;
|
||||||
float pitch = (screenPos.y / screenSize.height() - 0.5f) * MOUSE_PITCH_RANGE;
|
float pitch = (screenPos.y / screenSize.height() - 0.5f) * MOUSE_PITCH_RANGE;
|
||||||
|
|
||||||
|
@ -1132,7 +1133,7 @@ glm::vec2 ApplicationOverlay::screenToSpherical(glm::vec2 screenPos) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 ApplicationOverlay::sphericalToScreen(glm::vec2 sphericalPos) const {
|
glm::vec2 ApplicationOverlay::sphericalToScreen(glm::vec2 sphericalPos) const {
|
||||||
QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize();
|
QSize screenSize = DependencyManager::get<GLCanvas>()->getDeviceSize();
|
||||||
float x = (-sphericalPos.x / MOUSE_YAW_RANGE + 0.5f) * screenSize.width();
|
float x = (-sphericalPos.x / MOUSE_YAW_RANGE + 0.5f) * screenSize.width();
|
||||||
float y = (sphericalPos.y / MOUSE_PITCH_RANGE + 0.5f) * screenSize.height();
|
float y = (sphericalPos.y / MOUSE_PITCH_RANGE + 0.5f) * screenSize.height();
|
||||||
|
|
||||||
|
@ -1140,7 +1141,7 @@ glm::vec2 ApplicationOverlay::sphericalToScreen(glm::vec2 sphericalPos) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 ApplicationOverlay::sphericalToOverlay(glm::vec2 sphericalPos) const {
|
glm::vec2 ApplicationOverlay::sphericalToOverlay(glm::vec2 sphericalPos) const {
|
||||||
QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize();
|
QSize screenSize = DependencyManager::get<GLCanvas>()->getDeviceSize();
|
||||||
float x = (-sphericalPos.x / (_textureFov * _textureAspectRatio) + 0.5f) * screenSize.width();
|
float x = (-sphericalPos.x / (_textureFov * _textureAspectRatio) + 0.5f) * screenSize.width();
|
||||||
float y = (sphericalPos.y / _textureFov + 0.5f) * screenSize.height();
|
float y = (sphericalPos.y / _textureFov + 0.5f) * screenSize.height();
|
||||||
|
|
||||||
|
@ -1148,7 +1149,7 @@ glm::vec2 ApplicationOverlay::sphericalToOverlay(glm::vec2 sphericalPos) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 ApplicationOverlay::overlayToSpherical(glm::vec2 overlayPos) const {
|
glm::vec2 ApplicationOverlay::overlayToSpherical(glm::vec2 overlayPos) const {
|
||||||
QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize();
|
QSize screenSize = DependencyManager::get<GLCanvas>()->getDeviceSize();
|
||||||
float yaw = -(overlayPos.x / screenSize.width() - 0.5f) * _textureFov * _textureAspectRatio;
|
float yaw = -(overlayPos.x / screenSize.width() - 0.5f) * _textureFov * _textureAspectRatio;
|
||||||
float pitch = (overlayPos.y / screenSize.height() - 0.5f) * _textureFov;
|
float pitch = (overlayPos.y / screenSize.height() - 0.5f) * _textureFov;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "AttachmentsDialog.h"
|
#include "AttachmentsDialog.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
|
|
||||||
AttachmentsDialog::AttachmentsDialog() :
|
AttachmentsDialog::AttachmentsDialog() :
|
||||||
QDialog(Application::getInstance()->getWindow()) {
|
QDialog(Application::getInstance()->getWindow()) {
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QSizePolicy>
|
#include <QSizePolicy>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include "qtimespan.h"
|
||||||
|
|
||||||
|
|
||||||
#include <AddressManager.h>
|
#include <AddressManager.h>
|
||||||
#include <AccountManager.h>
|
#include <AccountManager.h>
|
||||||
|
@ -24,7 +26,7 @@
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "ChatMessageArea.h"
|
#include "ChatMessageArea.h"
|
||||||
#include "FlowLayout.h"
|
#include "FlowLayout.h"
|
||||||
#include "qtimespan.h"
|
#include "MainWindow.h"
|
||||||
#include "UIUtil.h"
|
#include "UIUtil.h"
|
||||||
#include "XmppClient.h"
|
#include "XmppClient.h"
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include <VoxelConstants.h>
|
#include <VoxelConstants.h>
|
||||||
|
|
||||||
|
#include "MainWindow.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "devices/OculusManager.h"
|
#include "devices/OculusManager.h"
|
||||||
#include "ui/HMDToolsDialog.h"
|
#include "ui/HMDToolsDialog.h"
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
#include "MetavoxelEditor.h"
|
#include "MetavoxelEditor.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -138,7 +139,7 @@ MetavoxelEditor::MetavoxelEditor() :
|
||||||
connect(Application::getInstance()->getMetavoxels(), &MetavoxelSystem::rendering,
|
connect(Application::getInstance()->getMetavoxels(), &MetavoxelSystem::rendering,
|
||||||
this, &MetavoxelEditor::renderPreview);
|
this, &MetavoxelEditor::renderPreview);
|
||||||
|
|
||||||
Application::getInstance()->getGLWidget()->installEventFilter(this);
|
DependencyManager::get<GLCanvas>()->installEventFilter(this);
|
||||||
|
|
||||||
show();
|
show();
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
const int BYTES_PER_KILOBYTE = 1024;
|
const int BYTES_PER_KILOBYTE = 1024;
|
||||||
|
|
||||||
MetavoxelNetworkSimulator::MetavoxelNetworkSimulator() :
|
MetavoxelNetworkSimulator::MetavoxelNetworkSimulator() :
|
||||||
QWidget(Application::getInstance()->getGLWidget(), Qt::Dialog) {
|
QWidget(DependencyManager::get<GLCanvas>().data(), Qt::Dialog) {
|
||||||
|
|
||||||
setWindowTitle("Metavoxel Network Simulator");
|
setWindowTitle("Metavoxel Network Simulator");
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "ModelsBrowser.h"
|
#include "ModelsBrowser.h"
|
||||||
#include "PreferencesDialog.h"
|
#include "PreferencesDialog.h"
|
||||||
|
@ -214,8 +215,8 @@ void PreferencesDialog::savePreferences() {
|
||||||
myAvatar->setClampedTargetScale(ui.avatarScaleSpin->value());
|
myAvatar->setClampedTargetScale(ui.avatarScaleSpin->value());
|
||||||
|
|
||||||
Application::getInstance()->getVoxels()->setMaxVoxels(ui.maxVoxelsSpin->value());
|
Application::getInstance()->getVoxels()->setMaxVoxels(ui.maxVoxelsSpin->value());
|
||||||
Application::getInstance()->resizeGL(Application::getInstance()->getGLWidget()->width(),
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
Application::getInstance()->getGLWidget()->height());
|
Application::getInstance()->resizeGL(glCanvas->width(), glCanvas->height());
|
||||||
|
|
||||||
Menu::getInstance()->setRealWorldFieldOfView(ui.realWorldFieldOfViewSpin->value());
|
Menu::getInstance()->setRealWorldFieldOfView(ui.realWorldFieldOfViewSpin->value());
|
||||||
|
|
||||||
|
@ -247,8 +248,7 @@ void PreferencesDialog::savePreferences() {
|
||||||
Menu::getInstance()->setReceivedAudioStreamSettings(streamSettings);
|
Menu::getInstance()->setReceivedAudioStreamSettings(streamSettings);
|
||||||
Application::getInstance()->getAudio()->setReceivedAudioStreamSettings(streamSettings);
|
Application::getInstance()->getAudio()->setReceivedAudioStreamSettings(streamSettings);
|
||||||
|
|
||||||
Application::getInstance()->resizeGL(Application::getInstance()->getGLWidget()->width(),
|
Application::getInstance()->resizeGL(glCanvas->width(), glCanvas->height());
|
||||||
Application::getInstance()->getGLWidget()->height());
|
|
||||||
|
|
||||||
Application::getInstance()->bumpSettings();
|
Application::getInstance()->bumpSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,9 +83,8 @@ QTemporaryFile* Snapshot::saveTempSnapshot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile* Snapshot::savedFileForSnapshot(bool isTemporary) {
|
QFile* Snapshot::savedFileForSnapshot(bool isTemporary) {
|
||||||
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
QGLWidget* widget = Application::getInstance()->getGLWidget();
|
QImage shot = glCanvas->grabFrameBuffer();
|
||||||
QImage shot = widget->grabFrameBuffer();
|
|
||||||
|
|
||||||
Avatar* avatar = Application::getInstance()->getAvatar();
|
Avatar* avatar = Application::getInstance()->getAvatar();
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,8 @@ Stats::Stats():
|
||||||
_metavoxelReceiveProgress(0),
|
_metavoxelReceiveProgress(0),
|
||||||
_metavoxelReceiveTotal(0)
|
_metavoxelReceiveTotal(0)
|
||||||
{
|
{
|
||||||
GLCanvas* glWidget = Application::getInstance()->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
resetWidth(glWidget->width(), 0);
|
resetWidth(glCanvas->width(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stats::toggleExpanded() {
|
void Stats::toggleExpanded() {
|
||||||
|
@ -67,7 +67,7 @@ void Stats::toggleExpanded() {
|
||||||
// called on mouse click release
|
// called on mouse click release
|
||||||
// check for clicks over stats in order to expand or contract them
|
// check for clicks over stats in order to expand or contract them
|
||||||
void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseDragStartedY, int horizontalOffset) {
|
void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseDragStartedY, int horizontalOffset) {
|
||||||
GLCanvas* glWidget = Application::getInstance()->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
|
|
||||||
if (0 != glm::compMax(glm::abs(glm::ivec2(mouseX - mouseDragStartedX, mouseY - mouseDragStartedY)))) {
|
if (0 != glm::compMax(glm::abs(glm::ivec2(mouseX - mouseDragStartedX, mouseY - mouseDragStartedY)))) {
|
||||||
// not worried about dragging on stats
|
// not worried about dragging on stats
|
||||||
|
@ -114,7 +114,7 @@ void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseD
|
||||||
// top-right stats click
|
// top-right stats click
|
||||||
lines = _expanded ? 11 : 3;
|
lines = _expanded ? 11 : 3;
|
||||||
statsHeight = lines * STATS_PELS_PER_LINE + 10;
|
statsHeight = lines * STATS_PELS_PER_LINE + 10;
|
||||||
statsWidth = glWidget->width() - statsX;
|
statsWidth = glCanvas->width() - statsX;
|
||||||
if (mouseX > statsX && mouseX < statsX + statsWidth && mouseY > statsY && mouseY < statsY + statsHeight) {
|
if (mouseX > statsX && mouseX < statsX + statsWidth && mouseY > statsY && mouseY < statsY + statsHeight) {
|
||||||
toggleExpanded();
|
toggleExpanded();
|
||||||
return;
|
return;
|
||||||
|
@ -122,8 +122,8 @@ void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseD
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stats::resetWidth(int width, int horizontalOffset) {
|
void Stats::resetWidth(int width, int horizontalOffset) {
|
||||||
GLCanvas* glWidget = Application::getInstance()->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
int extraSpace = glWidget->width() - horizontalOffset -2
|
int extraSpace = glCanvas->width() - horizontalOffset -2
|
||||||
- STATS_GENERAL_MIN_WIDTH
|
- STATS_GENERAL_MIN_WIDTH
|
||||||
- (Menu::getInstance()->isOptionChecked(MenuOption::TestPing) ? STATS_PING_MIN_WIDTH -1 : 0)
|
- (Menu::getInstance()->isOptionChecked(MenuOption::TestPing) ? STATS_PING_MIN_WIDTH -1 : 0)
|
||||||
- STATS_GEO_MIN_WIDTH
|
- STATS_GEO_MIN_WIDTH
|
||||||
|
@ -147,7 +147,7 @@ void Stats::resetWidth(int width, int horizontalOffset) {
|
||||||
_pingStatsWidth += (int) extraSpace / panels;
|
_pingStatsWidth += (int) extraSpace / panels;
|
||||||
}
|
}
|
||||||
_geoStatsWidth += (int) extraSpace / panels;
|
_geoStatsWidth += (int) extraSpace / panels;
|
||||||
_voxelStatsWidth += glWidget->width() - (_generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3);
|
_voxelStatsWidth += glCanvas->width() - (_generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ void Stats::display(
|
||||||
int bytesPerSecond,
|
int bytesPerSecond,
|
||||||
int voxelPacketsToProcess)
|
int voxelPacketsToProcess)
|
||||||
{
|
{
|
||||||
GLCanvas* glWidget = Application::getInstance()->getGLWidget();
|
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
|
|
||||||
unsigned int backgroundColor = 0x33333399;
|
unsigned int backgroundColor = 0x33333399;
|
||||||
int verticalOffset = 0, lines = 0;
|
int verticalOffset = 0, lines = 0;
|
||||||
|
@ -210,7 +210,7 @@ void Stats::display(
|
||||||
std::stringstream voxelStats;
|
std::stringstream voxelStats;
|
||||||
|
|
||||||
if (_lastHorizontalOffset != horizontalOffset) {
|
if (_lastHorizontalOffset != horizontalOffset) {
|
||||||
resetWidth(glWidget->width(), horizontalOffset);
|
resetWidth(glCanvas->width(), horizontalOffset);
|
||||||
_lastHorizontalOffset = horizontalOffset;
|
_lastHorizontalOffset = horizontalOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ void Stats::display(
|
||||||
|
|
||||||
lines = _expanded ? 14 : 3;
|
lines = _expanded ? 14 : 3;
|
||||||
|
|
||||||
drawBackground(backgroundColor, horizontalOffset, 0, glWidget->width() - horizontalOffset,
|
drawBackground(backgroundColor, horizontalOffset, 0, glCanvas->width() - horizontalOffset,
|
||||||
lines * STATS_PELS_PER_LINE + 10);
|
lines * STATS_PELS_PER_LINE + 10);
|
||||||
horizontalOffset += 5;
|
horizontalOffset += 5;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
#include "ToolWindow.h"
|
#include "ToolWindow.h"
|
||||||
#include "UIUtil.h"
|
#include "UIUtil.h"
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,9 @@ class Animation;
|
||||||
typedef QSharedPointer<Animation> AnimationPointer;
|
typedef QSharedPointer<Animation> AnimationPointer;
|
||||||
|
|
||||||
/// Scriptable interface for FBX animation loading.
|
/// Scriptable interface for FBX animation loading.
|
||||||
class AnimationCache : public ResourceCache, public DependencyManager::Dependency {
|
class AnimationCache : public ResourceCache {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
SINGLETON_DEPENDENCY(AnimationCache)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE AnimationPointer getAnimation(const QString& url) { return getAnimation(QUrl(url)); }
|
Q_INVOKABLE AnimationPointer getAnimation(const QString& url) { return getAnimation(QUrl(url)); }
|
||||||
|
@ -38,7 +39,6 @@ protected:
|
||||||
private:
|
private:
|
||||||
AnimationCache(QObject* parent = NULL);
|
AnimationCache(QObject* parent = NULL);
|
||||||
virtual ~AnimationCache() { }
|
virtual ~AnimationCache() { }
|
||||||
friend class DependencyManager;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,9 @@ class ProgramObject;
|
||||||
|
|
||||||
/// A screen space ambient occlusion effect. See John Chapman's tutorial at
|
/// A screen space ambient occlusion effect. See John Chapman's tutorial at
|
||||||
/// http://john-chapman-graphics.blogspot.co.uk/2013/01/ssao-tutorial.html for reference.
|
/// http://john-chapman-graphics.blogspot.co.uk/2013/01/ssao-tutorial.html for reference.
|
||||||
class AmbientOcclusionEffect: public DependencyManager::Dependency {
|
class AmbientOcclusionEffect {
|
||||||
|
SINGLETON_DEPENDENCY(AmbientOcclusionEffect)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void init(ViewStateInterface* viewState);
|
void init(ViewStateInterface* viewState);
|
||||||
|
@ -29,7 +31,6 @@ public:
|
||||||
private:
|
private:
|
||||||
AmbientOcclusionEffect() {}
|
AmbientOcclusionEffect() {}
|
||||||
virtual ~AmbientOcclusionEffect() {}
|
virtual ~AmbientOcclusionEffect() {}
|
||||||
friend class DependencyManager;
|
|
||||||
|
|
||||||
ProgramObject* _occlusionProgram;
|
ProgramObject* _occlusionProgram;
|
||||||
int _nearLocation;
|
int _nearLocation;
|
||||||
|
|
|
@ -135,7 +135,7 @@ void DeferredLightingEffect::addSpotLight(const glm::vec3& position, float radiu
|
||||||
|
|
||||||
void DeferredLightingEffect::prepare() {
|
void DeferredLightingEffect::prepare() {
|
||||||
// clear the normal and specular buffers
|
// clear the normal and specular buffers
|
||||||
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
TextureCache::SharedPointer textureCache = DependencyManager::get<TextureCache>();
|
||||||
textureCache->setPrimaryDrawBuffers(false, true, false);
|
textureCache->setPrimaryDrawBuffers(false, true, false);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
textureCache->setPrimaryDrawBuffers(false, false, true);
|
textureCache->setPrimaryDrawBuffers(false, false, true);
|
||||||
|
@ -157,7 +157,7 @@ void DeferredLightingEffect::render() {
|
||||||
glDisable(GL_COLOR_MATERIAL);
|
glDisable(GL_COLOR_MATERIAL);
|
||||||
glDepthMask(false);
|
glDepthMask(false);
|
||||||
|
|
||||||
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
TextureCache::SharedPointer textureCache = DependencyManager::get<TextureCache>();
|
||||||
|
|
||||||
QOpenGLFramebufferObject* primaryFBO = textureCache->getPrimaryFramebufferObject();
|
QOpenGLFramebufferObject* primaryFBO = textureCache->getPrimaryFramebufferObject();
|
||||||
primaryFBO->release();
|
primaryFBO->release();
|
||||||
|
@ -254,7 +254,7 @@ void DeferredLightingEffect::render() {
|
||||||
const glm::vec3& eyePoint = _viewState->getCurrentViewFrustum()->getPosition();
|
const glm::vec3& eyePoint = _viewState->getCurrentViewFrustum()->getPosition();
|
||||||
float nearRadius = glm::distance(eyePoint, _viewState->getCurrentViewFrustum()->getNearTopLeft());
|
float nearRadius = glm::distance(eyePoint, _viewState->getCurrentViewFrustum()->getNearTopLeft());
|
||||||
|
|
||||||
GeometryCache* geometryCache = DependencyManager::get<GeometryCache>();
|
GeometryCache::SharedPointer geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
|
||||||
if (!_pointLights.isEmpty()) {
|
if (!_pointLights.isEmpty()) {
|
||||||
_pointLight.bind();
|
_pointLight.bind();
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
class PostLightingRenderable;
|
class PostLightingRenderable;
|
||||||
|
|
||||||
/// Handles deferred lighting for the bits that require it (voxels, metavoxels...)
|
/// Handles deferred lighting for the bits that require it (voxels, metavoxels...)
|
||||||
class DeferredLightingEffect: public DependencyManager::Dependency {
|
class DeferredLightingEffect {
|
||||||
|
SINGLETON_DEPENDENCY(DeferredLightingEffect)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void init(ViewStateInterface* viewState);
|
void init(ViewStateInterface* viewState);
|
||||||
|
@ -73,7 +75,6 @@ public:
|
||||||
private:
|
private:
|
||||||
DeferredLightingEffect() { }
|
DeferredLightingEffect() { }
|
||||||
virtual ~DeferredLightingEffect() { }
|
virtual ~DeferredLightingEffect() { }
|
||||||
friend class DependencyManager;
|
|
||||||
|
|
||||||
class LightLocations {
|
class LightLocations {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -699,7 +699,7 @@ void NetworkGeometry::clearLoadPriority(const QPointer<QObject>& owner) {
|
||||||
|
|
||||||
void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& url) {
|
void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& url) {
|
||||||
if (_meshes.size() > 0) {
|
if (_meshes.size() > 0) {
|
||||||
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
TextureCache::SharedPointer textureCache = DependencyManager::get<TextureCache>();
|
||||||
for (int i = 0; i < _meshes.size(); i++) {
|
for (int i = 0; i < _meshes.size(); i++) {
|
||||||
NetworkMesh& mesh = _meshes[i];
|
NetworkMesh& mesh = _meshes[i];
|
||||||
for (int j = 0; j < mesh.parts.size(); j++) {
|
for (int j = 0; j < mesh.parts.size(); j++) {
|
||||||
|
@ -914,7 +914,7 @@ void NetworkGeometry::reinsert() {
|
||||||
void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
|
void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
|
||||||
_geometry = geometry;
|
_geometry = geometry;
|
||||||
|
|
||||||
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
TextureCache::SharedPointer textureCache = DependencyManager::get<TextureCache>();
|
||||||
|
|
||||||
foreach (const FBXMesh& mesh, _geometry.meshes) {
|
foreach (const FBXMesh& mesh, _geometry.meshes) {
|
||||||
NetworkMesh networkMesh;
|
NetworkMesh networkMesh;
|
||||||
|
|
|
@ -32,8 +32,9 @@ class NetworkMesh;
|
||||||
class NetworkTexture;
|
class NetworkTexture;
|
||||||
|
|
||||||
/// Stores cached geometry.
|
/// Stores cached geometry.
|
||||||
class GeometryCache : public ResourceCache, public DependencyManager::Dependency {
|
class GeometryCache : public ResourceCache {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
SINGLETON_DEPENDENCY(GeometryCache)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void renderHemisphere(int slices, int stacks);
|
void renderHemisphere(int slices, int stacks);
|
||||||
|
@ -56,7 +57,6 @@ protected:
|
||||||
private:
|
private:
|
||||||
GeometryCache();
|
GeometryCache();
|
||||||
virtual ~GeometryCache();
|
virtual ~GeometryCache();
|
||||||
friend class DependencyManager;
|
|
||||||
|
|
||||||
typedef QPair<int, int> IntPair;
|
typedef QPair<int, int> IntPair;
|
||||||
typedef QPair<GLuint, GLuint> VerticesIndices;
|
typedef QPair<GLuint, GLuint> VerticesIndices;
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
// include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL
|
// include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL
|
||||||
#include <gpu/GPUConfig.h>
|
#include <gpu/GPUConfig.h>
|
||||||
|
|
||||||
#include <QGLWidget>
|
|
||||||
#include <QOpenGLFramebufferObject>
|
#include <QOpenGLFramebufferObject>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
|
|
||||||
|
@ -139,7 +138,7 @@ static void maybeRelease(QOpenGLFramebufferObject* fbo) {
|
||||||
QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
||||||
PerformanceTimer perfTimer("glowEffect");
|
PerformanceTimer perfTimer("glowEffect");
|
||||||
|
|
||||||
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
TextureCache::SharedPointer textureCache = DependencyManager::get<TextureCache>();
|
||||||
QOpenGLFramebufferObject* primaryFBO = textureCache->getPrimaryFramebufferObject();
|
QOpenGLFramebufferObject* primaryFBO = textureCache->getPrimaryFramebufferObject();
|
||||||
primaryFBO->release();
|
primaryFBO->release();
|
||||||
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
|
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
|
||||||
|
|
|
@ -25,8 +25,9 @@ class QOpenGLFramebufferObject;
|
||||||
class ProgramObject;
|
class ProgramObject;
|
||||||
|
|
||||||
/// A generic full screen glow effect.
|
/// A generic full screen glow effect.
|
||||||
class GlowEffect : public QObject, public DependencyManager::Dependency {
|
class GlowEffect : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
SINGLETON_DEPENDENCY(GlowEffect)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -60,7 +61,6 @@ public slots:
|
||||||
private:
|
private:
|
||||||
GlowEffect();
|
GlowEffect();
|
||||||
virtual ~GlowEffect();
|
virtual ~GlowEffect();
|
||||||
friend class DependencyManager;
|
|
||||||
|
|
||||||
int getDeviceWidth() const;
|
int getDeviceWidth() const;
|
||||||
int getDeviceHeight() const;
|
int getDeviceHeight() const;
|
||||||
|
|
|
@ -1161,7 +1161,7 @@ void Blender::run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// post the result to the geometry cache, which will dispatch to the model if still alive
|
// post the result to the geometry cache, which will dispatch to the model if still alive
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<ModelBlender>(), "setBlendedVertices",
|
QMetaObject::invokeMethod(DependencyManager::get<ModelBlender>().data(), "setBlendedVertices",
|
||||||
Q_ARG(const QPointer<Model>&, _model), Q_ARG(int, _blendNumber),
|
Q_ARG(const QPointer<Model>&, _model), Q_ARG(int, _blendNumber),
|
||||||
Q_ARG(const QWeakPointer<NetworkGeometry>&, _geometry), Q_ARG(const QVector<glm::vec3>&, vertices),
|
Q_ARG(const QWeakPointer<NetworkGeometry>&, _geometry), Q_ARG(const QVector<glm::vec3>&, vertices),
|
||||||
Q_ARG(const QVector<glm::vec3>&, normals));
|
Q_ARG(const QVector<glm::vec3>&, normals));
|
||||||
|
@ -2334,8 +2334,8 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
|
||||||
Locations* locations, SkinLocations* skinLocations) {
|
Locations* locations, SkinLocations* skinLocations) {
|
||||||
PROFILE_RANGE(__FUNCTION__);
|
PROFILE_RANGE(__FUNCTION__);
|
||||||
|
|
||||||
TextureCache* textureCache = DependencyManager::get<TextureCache>();
|
TextureCache::SharedPointer textureCache = DependencyManager::get<TextureCache>();
|
||||||
GlowEffect* glowEffect = DependencyManager::get<GlowEffect>();
|
GlowEffect::SharedPointer glowEffect = DependencyManager::get<GlowEffect>();
|
||||||
QString lastMaterialID;
|
QString lastMaterialID;
|
||||||
int meshPartsRendered = 0;
|
int meshPartsRendered = 0;
|
||||||
updateVisibleJointStates();
|
updateVisibleJointStates();
|
||||||
|
|
|
@ -468,8 +468,9 @@ Q_DECLARE_METATYPE(QWeakPointer<NetworkGeometry>)
|
||||||
Q_DECLARE_METATYPE(QVector<glm::vec3>)
|
Q_DECLARE_METATYPE(QVector<glm::vec3>)
|
||||||
|
|
||||||
/// Handle management of pending models that need blending
|
/// Handle management of pending models that need blending
|
||||||
class ModelBlender : public QObject, public DependencyManager::Dependency {
|
class ModelBlender : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
SINGLETON_DEPENDENCY(ModelBlender)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -483,7 +484,6 @@ public slots:
|
||||||
private:
|
private:
|
||||||
ModelBlender();
|
ModelBlender();
|
||||||
virtual ~ModelBlender();
|
virtual ~ModelBlender();
|
||||||
friend class DependencyManager;
|
|
||||||
|
|
||||||
QList<QPointer<Model> > _modelsRequiringBlends;
|
QList<QPointer<Model> > _modelsRequiringBlends;
|
||||||
int _pendingBlenders;
|
int _pendingBlenders;
|
||||||
|
|
|
@ -30,8 +30,9 @@ typedef QSharedPointer<NetworkTexture> NetworkTexturePointer;
|
||||||
enum TextureType { DEFAULT_TEXTURE, NORMAL_TEXTURE, SPECULAR_TEXTURE, EMISSIVE_TEXTURE, SPLAT_TEXTURE };
|
enum TextureType { DEFAULT_TEXTURE, NORMAL_TEXTURE, SPECULAR_TEXTURE, EMISSIVE_TEXTURE, SPLAT_TEXTURE };
|
||||||
|
|
||||||
/// Stores cached textures, including render-to-texture targets.
|
/// Stores cached textures, including render-to-texture targets.
|
||||||
class TextureCache : public ResourceCache, public DependencyManager::Dependency {
|
class TextureCache : public ResourceCache {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
SINGLETON_DEPENDENCY(TextureCache)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -96,7 +97,6 @@ protected:
|
||||||
private:
|
private:
|
||||||
TextureCache();
|
TextureCache();
|
||||||
virtual ~TextureCache();
|
virtual ~TextureCache();
|
||||||
friend class DependencyManager;
|
|
||||||
friend class DilatableNetworkTexture;
|
friend class DilatableNetworkTexture;
|
||||||
|
|
||||||
QOpenGLFramebufferObject* createFramebufferObject();
|
QOpenGLFramebufferObject* createFramebufferObject();
|
||||||
|
|
|
@ -255,7 +255,7 @@ void ScriptEngine::init() {
|
||||||
registerGlobalObject("Quat", &_quatLibrary);
|
registerGlobalObject("Quat", &_quatLibrary);
|
||||||
registerGlobalObject("Vec3", &_vec3Library);
|
registerGlobalObject("Vec3", &_vec3Library);
|
||||||
registerGlobalObject("Uuid", &_uuidLibrary);
|
registerGlobalObject("Uuid", &_uuidLibrary);
|
||||||
registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>());
|
registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
|
||||||
|
|
||||||
registerGlobalObject("Voxels", &_voxelsScriptingInterface);
|
registerGlobalObject("Voxels", &_voxelsScriptingInterface);
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,4 @@ DependencyManager& DependencyManager::getInstance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
DependencyManager::~DependencyManager() {
|
DependencyManager::~DependencyManager() {
|
||||||
foreach (Dependency* instance, _instanceHash) {
|
|
||||||
delete instance;
|
|
||||||
}
|
|
||||||
_instanceHash.clear();
|
|
||||||
}
|
}
|
|
@ -12,55 +12,43 @@
|
||||||
#ifndef hifi_DependencyManager_h
|
#ifndef hifi_DependencyManager_h
|
||||||
#define hifi_DependencyManager_h
|
#define hifi_DependencyManager_h
|
||||||
|
|
||||||
#include <QHash>
|
#include <QSharedPointer>
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <assert.h>
|
|
||||||
|
#define SINGLETON_DEPENDENCY(T)\
|
||||||
|
public:\
|
||||||
|
typedef QSharedPointer<T> SharedPointer;\
|
||||||
|
private:\
|
||||||
|
void customDeleter() {\
|
||||||
|
QObject* thisObject = dynamic_cast<QObject*>(this);\
|
||||||
|
if (thisObject) {\
|
||||||
|
thisObject->deleteLater();\
|
||||||
|
} else {\
|
||||||
|
delete this;\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
friend class DependencyManager;
|
||||||
|
|
||||||
|
class QObject;
|
||||||
|
|
||||||
class DependencyManager {
|
class DependencyManager {
|
||||||
public:
|
public:
|
||||||
// Only accessible method.
|
// Only accessible method.
|
||||||
// usage: T* instance = DependencyManager::get<T>();
|
// usage: T* instance = DependencyManager::get<T>();
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T* get();
|
static QSharedPointer<T> get();
|
||||||
|
|
||||||
// Any class T in the DependencyManager needs to subclass Dependency
|
|
||||||
// They also need to have protected constructor(s) and virtual destructor
|
|
||||||
// As well as declare DependencyManager a friend class
|
|
||||||
class Dependency {
|
|
||||||
protected:
|
|
||||||
Dependency() {}
|
|
||||||
virtual ~Dependency() {} // Ensure the proper destruction of the object
|
|
||||||
friend DependencyManager;
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static DependencyManager& getInstance();
|
static DependencyManager& getInstance();
|
||||||
DependencyManager() {}
|
DependencyManager() {}
|
||||||
~DependencyManager();
|
~DependencyManager();
|
||||||
|
|
||||||
typedef QHash<QString, Dependency*> InstanceHash;
|
|
||||||
static InstanceHash& getInstanceHash() { return getInstance()._instanceHash; }
|
|
||||||
InstanceHash _instanceHash;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T* DependencyManager::get() {
|
QSharedPointer<T> DependencyManager::get() {
|
||||||
const QString& typeId = typeid(T).name();
|
static QSharedPointer<T> sharedPointer = QSharedPointer<T>(new T(), &T::customDeleter);
|
||||||
|
return sharedPointer;
|
||||||
// Search the hash for global instance
|
|
||||||
Dependency* instance = getInstanceHash().value(typeId, NULL);
|
|
||||||
if (instance) {
|
|
||||||
return dynamic_cast<T*>(instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Found no instance in hash so we create one.
|
|
||||||
T* newInstance = new T();
|
|
||||||
instance = dynamic_cast<Dependency*>(newInstance);
|
|
||||||
assert(instance != NULL); // If this triggers, check that T is derived from Dependency
|
|
||||||
getInstanceHash().insert(typeId, instance);
|
|
||||||
return newInstance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // hifi_DependencyManager_h
|
#endif // hifi_DependencyManager_h
|
||||||
|
|
Loading…
Reference in a new issue