History

Merge branch 'master' of https://github.com/highfidelity/hifi into proto-received-message

Ryan Huffman committed 10 years ago

Commit 89c412c2 parents ce882a9 d076294320 files · +41473 −8534Browse files

Showing the changes to interface/src/Application.cpp (1 of 320 files). Show all

Unified · Split

interface/src/Application.cpp+22−43
@@ -50,6 +50,7 @@ · 49 unmodified lines
50#include <AssetClient.h>50#include <AssetClient.h>
51#include <AssetUpload.h>51#include <AssetUpload.h>
52#include <AutoUpdater.h>52#include <AutoUpdater.h>
53#include <AudioInjectorManager.h>
53#include <CursorManager.h>54#include <CursorManager.h>
54#include <DeferredLightingEffect.h>55#include <DeferredLightingEffect.h>
55#include <display-plugins/DisplayPlugin.h>56#include <display-plugins/DisplayPlugin.h>
@@ -77,7 +78,7 @@ · 21 unmodified lines
77#include <ObjectMotionState.h>78#include <ObjectMotionState.h>
78#include <OctalCode.h>79#include <OctalCode.h>
79#include <OctreeSceneStats.h>80#include <OctreeSceneStats.h>
80#include <gl/OffscreenGlCanvas.h>81#include <gl/OffscreenGLCanvas.h>
81#include <PathUtils.h>82#include <PathUtils.h>
82#include <PerfStat.h>83#include <PerfStat.h>
83#include <PhysicsEngine.h>84#include <PhysicsEngine.h>
@@ -109,8 +110,6 @@ · 25 unmodified lines
109#include "devices/EyeTracker.h"110#include "devices/EyeTracker.h"
110#include "devices/Faceshift.h"111#include "devices/Faceshift.h"
111#include "devices/Leapmotion.h"112#include "devices/Leapmotion.h"
112#include "devices/MIDIManager.h"
113#include "devices/RealSense.h"
114#include "DiscoverabilityManager.h"113#include "DiscoverabilityManager.h"
115#include "GLCanvas.h"114#include "GLCanvas.h"
116#include "InterfaceActionFactory.h"115#include "InterfaceActionFactory.h"
@@ -148,6 +147,8 @@ · 31 unmodified lines
148#include "ui/Stats.h"147#include "ui/Stats.h"
149#include "ui/UpdateDialog.h"148#include "ui/UpdateDialog.h"
150#include "Util.h"149#include "Util.h"
150#include "InterfaceParentFinder.h"
151
151 152
152 153
153// ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU154// ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
@@ -296,6 +297,7 @@ bool setupEssentials(int& argc, char** argv) { · 142 unmodified lines
296 DependencyManager::registerInheritance<LimitedNodeList, NodeList>();297 DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
297 DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>();298 DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>();
298 DependencyManager::registerInheritance<EntityActionFactoryInterface, InterfaceActionFactory>();299 DependencyManager::registerInheritance<EntityActionFactoryInterface, InterfaceActionFactory>();
300 DependencyManager::registerInheritance<SpatialParentFinder, InterfaceParentFinder>();
299 301
300 Setting::init();302 Setting::init();
301 303
@@ -340,9 +342,11 @@ bool setupEssentials(int& argc, char** argv) { · 38 unmodified lines
340 DependencyManager::set<PathUtils>();342 DependencyManager::set<PathUtils>();
341 DependencyManager::set<InterfaceActionFactory>();343 DependencyManager::set<InterfaceActionFactory>();
342 DependencyManager::set<AssetClient>();344 DependencyManager::set<AssetClient>();
345 DependencyManager::set<AudioInjectorManager>();
343 DependencyManager::set<MessagesClient>();346 DependencyManager::set<MessagesClient>();
344 DependencyManager::set<UserInputMapper>();347 DependencyManager::set<UserInputMapper>();
345 DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>();348 DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>();
349 DependencyManager::set<InterfaceParentFinder>();
346 return true;350 return true;
347}351}
348 352
@@ -614,7 +618,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 265 unmodified lines
614 // enable mouse tracking; otherwise, we only get drag events618 // enable mouse tracking; otherwise, we only get drag events
615 _glWidget->setMouseTracking(true);619 _glWidget->setMouseTracking(true);
616 620
617 _offscreenContext = new OffscreenGlCanvas();621 _offscreenContext = new OffscreenGLCanvas();
618 _offscreenContext->create(_glWidget->context()->contextHandle());622 _offscreenContext->create(_glWidget->context()->contextHandle());
619 _offscreenContext->makeCurrent();623 _offscreenContext->makeCurrent();
620 initializeGL();624 initializeGL();
@@ -717,12 +721,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 96 unmodified lines
717 // set the local loopback interface for local sounds from audio scripts721 // set the local loopback interface for local sounds from audio scripts
718 AudioScriptingInterface::getInstance().setLocalAudioInterface(audioIO.data());722 AudioScriptingInterface::getInstance().setLocalAudioInterface(audioIO.data());
719 723
720#ifdef HAVE_RTMIDI
721 // setup the MIDIManager
722 MIDIManager& midiManagerInstance = MIDIManager::getInstance();
723 midiManagerInstance.openDefaultPort();
724#endif
725
726 this->installEventFilter(this);724 this->installEventFilter(this);
727 725
728 // initialize our face trackers after loading the menu settings726 // initialize our face trackers after loading the menu settings
@@ -894,6 +892,10 @@ void Application::cleanupBeforeQuit() { · 165 unmodified lines
894 892
895 // destroy the AudioClient so it and its thread have a chance to go down safely893 // destroy the AudioClient so it and its thread have a chance to go down safely
896 DependencyManager::destroy<AudioClient>();894 DependencyManager::destroy<AudioClient>();
895
896 // destroy the AudioInjectorManager so it and its thread have a chance to go down safely
897 // this will also stop any ongoing network injectors
898 DependencyManager::destroy<AudioInjectorManager>();
897 899
898 // Destroy third party processes after scripts have finished using them.900 // Destroy third party processes after scripts have finished using them.
899#ifdef HAVE_DDE901#ifdef HAVE_DDE
@@ -964,7 +966,6 @@ Application::~Application() { · 64 unmodified lines
964 nodeThread->wait();966 nodeThread->wait();
965 967
966 Leapmotion::destroy();968 Leapmotion::destroy();
967 RealSense::destroy();
968 969
969#if 0970#if 0
970 ConnexionClient::getInstance().destroy();971 ConnexionClient::getInstance().destroy();
@@ -1244,7 +1245,7 @@ void Application::paintGL() { · 273 unmodified lines
1244 * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation);1245 * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation);
1245 glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());1246 glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
1246 _myCamera.setPosition(myAvatar->getDefaultEyePosition()1247 _myCamera.setPosition(myAvatar->getDefaultEyePosition()
1247 + glm::vec3(0, _raiseMirror * myAvatar->getScale(), 0)1248 + glm::vec3(0, _raiseMirror * myAvatar->getAvatarScale(), 0)
1248 + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *1249 + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
1249 glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror1250 glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror
1250 + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset);1251 + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset);
@@ -1252,7 +1253,7 @@ void Application::paintGL() { · 1 unmodified line
1252 _myCamera.setRotation(myAvatar->getWorldAlignedOrientation()1253 _myCamera.setRotation(myAvatar->getWorldAlignedOrientation()
1253 * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));1254 * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
1254 _myCamera.setPosition(myAvatar->getDefaultEyePosition()1255 _myCamera.setPosition(myAvatar->getDefaultEyePosition()
1255 + glm::vec3(0, _raiseMirror * myAvatar->getScale(), 0)1256 + glm::vec3(0, _raiseMirror * myAvatar->getAvatarScale(), 0)
1256 + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *1257 + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
1257 glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);1258 glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
1258 }1259 }
@@ -2513,7 +2514,6 @@ void Application::init() { · 1254 unmodified lines
2513 qCDebug(interfaceapp) << "Loaded settings";2514 qCDebug(interfaceapp) << "Loaded settings";
2514 2515
2515 Leapmotion::init();2516 Leapmotion::init();
2516 RealSense::init();
2517 2517
2518 // fire off an immediate domain-server check in now that settings are loaded2518 // fire off an immediate domain-server check in now that settings are loaded
2519 DependencyManager::get<NodeList>()->sendDomainServerCheckIn();2519 DependencyManager::get<NodeList>()->sendDomainServerCheckIn();
@@ -2549,11 +2549,12 @@ void Application::init() { · 29 unmodified lines
2549 setAvatarUpdateThreading();2549 setAvatarUpdateThreading();
2550}2550}
2551 2551
2552const bool ENABLE_AVATAR_UPDATE_THREADING = false;
2552void Application::setAvatarUpdateThreading() {2553void Application::setAvatarUpdateThreading() {
2553 setAvatarUpdateThreading(Menu::getInstance()->isOptionChecked(MenuOption::EnableAvatarUpdateThreading));2554 setAvatarUpdateThreading(ENABLE_AVATAR_UPDATE_THREADING);
2554}2555}
2555void Application::setRawAvatarUpdateThreading() {2556void Application::setRawAvatarUpdateThreading() {
2556 setRawAvatarUpdateThreading(Menu::getInstance()->isOptionChecked(MenuOption::EnableAvatarUpdateThreading));2557 setRawAvatarUpdateThreading(ENABLE_AVATAR_UPDATE_THREADING);
2557}2558}
2558void Application::setRawAvatarUpdateThreading(bool isThreaded) {2559void Application::setRawAvatarUpdateThreading(bool isThreaded) {
2559 if (_avatarUpdate) {2560 if (_avatarUpdate) {
@@ -2570,18 +2571,11 @@ void Application::setAvatarUpdateThreading(bool isThreaded) { · 10 unmodified lines
2570 return;2571 return;
2571 }2572 }
2572 2573
2573 auto myAvatar = getMyAvatar();
2574 bool isRigEnabled = myAvatar->getEnableRigAnimations();
2575 bool isGraphEnabled = myAvatar->getEnableAnimGraph();
2576 if (_avatarUpdate) {2574 if (_avatarUpdate) {
2577 _avatarUpdate->terminate(); // Must be before we shutdown anim graph.2575 _avatarUpdate->terminate(); // Must be before we shutdown anim graph.
2578 }2576 }
2579 myAvatar->setEnableRigAnimations(false);
2580 myAvatar->setEnableAnimGraph(false);
2581 _avatarUpdate = new AvatarUpdate();2577 _avatarUpdate = new AvatarUpdate();
2582 _avatarUpdate->initialize(isThreaded);2578 _avatarUpdate->initialize(isThreaded);
2583 myAvatar->setEnableRigAnimations(isRigEnabled);
2584 myAvatar->setEnableAnimGraph(isGraphEnabled);
2585}2579}
2586 2580
2587void Application::updateLOD() {2581void Application::updateLOD() {
@@ -2855,6 +2849,8 @@ void Application::update(float deltaTime) { · 267 unmodified lines
2855 }2849 }
2856 }2850 }
2857 2851
2852 _controllerScriptingInterface->updateInputControllers();
2853
2858 // Transfer the user inputs to the driveKeys2854 // Transfer the user inputs to the driveKeys
2859 // FIXME can we drop drive keys and just have the avatar read the action states directly?2855 // FIXME can we drop drive keys and just have the avatar read the action states directly?
2860 myAvatar->clearDriveKeys();2856 myAvatar->clearDriveKeys();
@@ -2964,11 +2960,6 @@ void Application::update(float deltaTime) { · 103 unmodified lines
2964 loadViewFrustum(_myCamera, _viewFrustum);2960 loadViewFrustum(_myCamera, _viewFrustum);
2965 }2961 }
2966 2962
2967 // Update animation debug draw renderer
2968 {
2969 AnimDebugDraw::getInstance().update();
2970 }
2971
2972 quint64 now = usecTimestampNow();2963 quint64 now = usecTimestampNow();
2973 2964
2974 // Update my voxel servers with my current voxel query...2965 // Update my voxel servers with my current voxel query...
@@ -3077,9 +3068,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 102 unmodified lines
3077 3068
3078 // These will be the same for all servers, so we can set them up once and then reuse for each server we send to.3069 // These will be the same for all servers, so we can set them up once and then reuse for each server we send to.
3079 _octreeQuery.setWantLowResMoving(true);3070 _octreeQuery.setWantLowResMoving(true);
3080 _octreeQuery.setWantColor(true);
3081 _octreeQuery.setWantDelta(true);3071 _octreeQuery.setWantDelta(true);
3082 _octreeQuery.setWantOcclusionCulling(false);
3083 _octreeQuery.setWantCompression(true);3072 _octreeQuery.setWantCompression(true);
3084 3073
3085 _octreeQuery.setCameraPosition(_viewFrustum.getPosition());3074 _octreeQuery.setCameraPosition(_viewFrustum.getPosition());
@@ -3325,7 +3314,7 @@ MyAvatar* Application::getMyAvatar() const { · 239 unmodified lines
3325 return DependencyManager::get<AvatarManager>()->getMyAvatar();3314 return DependencyManager::get<AvatarManager>()->getMyAvatar();
3326}3315}
3327 3316
3328const glm::vec3& Application::getAvatarPosition() const {3317glm::vec3 Application::getAvatarPosition() const {
3329 return getMyAvatar()->getPosition();3318 return getMyAvatar()->getPosition();
3330}3319}
3331 3320
@@ -3528,6 +3517,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 196 unmodified lines
3528 myAvatar->preRender(renderArgs);3517 myAvatar->preRender(renderArgs);
3529 myAvatar->endRender();3518 myAvatar->endRender();
3530 3519
3520 // Update animation debug draw renderer
3521 AnimDebugDraw::getInstance().update();
3531 3522
3532 activeRenderingThread = QThread::currentThread();3523 activeRenderingThread = QThread::currentThread();
3533 PROFILE_RANGE(__FUNCTION__);3524 PROFILE_RANGE(__FUNCTION__);
@@ -4067,10 +4058,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 533 unmodified lines
4067 scriptEngine->registerGlobalObject("Scene", DependencyManager::get<SceneScriptingInterface>().data());4058 scriptEngine->registerGlobalObject("Scene", DependencyManager::get<SceneScriptingInterface>().data());
4068 4059
4069 scriptEngine->registerGlobalObject("ScriptDiscoveryService", this->getRunningScriptsWidget());4060 scriptEngine->registerGlobalObject("ScriptDiscoveryService", this->getRunningScriptsWidget());
4070
4071#ifdef HAVE_RTMIDI
4072 scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
4073#endif
4074}4061}
4075 4062
4076bool Application::canAcceptURL(const QString& urlString) {4063bool Application::canAcceptURL(const QString& urlString) {
@@ -4356,10 +4343,6 @@ void Application::stopAllScripts(bool restart) { · 279 unmodified lines
4356 it.value()->stop();4343 it.value()->stop();
4357 qCDebug(interfaceapp) << "stopping script..." << it.key();4344 qCDebug(interfaceapp) << "stopping script..." << it.key();
4358 }4345 }
4359 // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities
4360 // whenever a script stops in case it happened to have been setting joint rotations.
4361 // TODO: expose animation priorities and provide a layered animation control system.
4362 getMyAvatar()->clearJointAnimationPriorities();
4363 getMyAvatar()->clearScriptableSettings();4346 getMyAvatar()->clearScriptableSettings();
4364}4347}
4365 4348
@@ -4375,10 +4358,6 @@ bool Application::stopScript(const QString& scriptHash, bool restart) { · 9 unmodified lines
4375 scriptEngine->stop();4358 scriptEngine->stop();
4376 stoppedScript = true;4359 stoppedScript = true;
4377 qCDebug(interfaceapp) << "stopping script..." << scriptHash;4360 qCDebug(interfaceapp) << "stopping script..." << scriptHash;
4378 // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities
4379 // whenever a script stops in case it happened to have been setting joint rotations.
4380 // TODO: expose animation priorities and provide a layered animation control system.
4381 getMyAvatar()->clearJointAnimationPriorities();
4382 }4361 }
4383 if (_scriptEnginesHash.empty()) {4362 if (_scriptEnginesHash.empty()) {
4384 getMyAvatar()->clearScriptableSettings();4363 getMyAvatar()->clearScriptableSettings();