History

Merge branch 'master' of https://github.com/highfidelity/hifi into temp1

Sam Gateau committed 11 years ago

Commit ace6dc42 parents 48fca4c 6378009134 files · +4645 −95061Browse files

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

Unified · Split

interface/src/Application.cpp+69−51
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 // include this before QGLWidget, which includes an earlier version of OpenGL
2424 #include "InterfaceConfig.h"
2525
26+#include <QAbstractNativeEventFilter>
2627 #include <QActionGroup>
2728 #include <QColorDialog>
2829 #include <QDesktopWidget>
@@ -81,13 +82,15 @@ · 52 unmodified lines
8182 #include <UUID.h>
8283
8384 #include "Application.h"
84−#include "Audio.h"
85+#include "AudioClient.h"
8586 #include "InterfaceVersion.h"
8687 #include "LODManager.h"
8788 #include "Menu.h"
8889 #include "ModelUploader.h"
8990 #include "Util.h"
9091
92+#include "avatar/AvatarManager.h"
93+
9194 #include "audio/AudioToolBox.h"
9295 #include "audio/AudioIOStatsRenderer.h"
9396 #include "audio/AudioScope.h"
@@ -127,8 +130,6 @@ · 33 unmodified lines
127130 #include "ui/StandAloneJSConsole.h"
128131 #include "ui/Stats.h"
129132
130−
131−
132133 using namespace std;
133134
134135 // Starfield information
@@ -144,6 +145,37 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 9 unmodified lines
144145
145146 const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
146147
148+#ifdef Q_OS_WIN
149+class MyNativeEventFilter : public QAbstractNativeEventFilter {
150+public:
151+ static MyNativeEventFilter& getInstance() {
152+ static MyNativeEventFilter staticInstance;
153+ return staticInstance;
154+ }
155+
156+ bool nativeEventFilter(const QByteArray &eventType, void* msg, long* result) Q_DECL_OVERRIDE {
157+ if (eventType == "windows_generic_MSG") {
158+ MSG* message = (MSG*)msg;
159+ if (message->message == UWM_IDENTIFY_INSTANCES) {
160+ *result = UWM_IDENTIFY_INSTANCES;
161+ return true;
162+ }
163+ if (message->message == WM_SHOWWINDOW) {
164+ Application::getInstance()->getWindow()->showNormal();
165+ }
166+ if (message->message == WM_COPYDATA) {
167+ COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam);
168+ QUrl url = QUrl((const char*)(pcds->lpData));
169+ if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) {
170+ DependencyManager::get<AddressManager>()->handleLookupString(url.toString());
171+ }
172+ }
173+ }
174+ return false;
175+ }
176+};
177+#endif
178+
147179 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
148180 QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);
149181
@@ -163,6 +195,7 @@ bool setupEssentials(int& argc, char** argv) { · 13 unmodified lines
163195 QCoreApplication::setApplicationVersion(BUILD_VERSION);
164196
165197 DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
198+ DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>();
166199
167200 // Set dependencies
168201 auto glCanvas = DependencyManager::set<GLCanvas>();
@@ -171,7 +204,7 @@ bool setupEssentials(int& argc, char** argv) { · 2 unmodified lines
171204 auto geometryCache = DependencyManager::set<GeometryCache>();
172205 auto glowEffect = DependencyManager::set<GlowEffect>();
173206 auto faceshift = DependencyManager::set<Faceshift>();
174− auto audio = DependencyManager::set<Audio>();
207+ auto audio = DependencyManager::set<AudioClient>();
175208 auto audioScope = DependencyManager::set<AudioScope>();
176209 auto audioIOStatsRenderer = DependencyManager::set<AudioIOStatsRenderer>();
177210 auto deferredLightingEffect = DependencyManager::set<DeferredLightingEffect>();
@@ -182,6 +215,7 @@ bool setupEssentials(int& argc, char** argv) { · 4 unmodified lines
182215 auto ddeFaceTracker = DependencyManager::set<DdeFaceTracker>();
183216 auto modelBlender = DependencyManager::set<ModelBlender>();
184217 auto audioToolBox = DependencyManager::set<AudioToolBox>();
218+ auto avatarManager = DependencyManager::set<AvatarManager>();
185219 auto lodManager = DependencyManager::set<LODManager>();
186220 auto jsConsole = DependencyManager::set<StandAloneJSConsole>();
187221 auto dialogsManager = DependencyManager::set<DialogsManager>();
@@ -242,9 +276,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 54 unmodified lines
242276 _aboutToQuit(false),
243277 _notifiedPacketVersionMismatchThisDomain(false)
244278 {
279+#ifdef Q_OS_WIN
280+ installNativeEventFilter(&MyNativeEventFilter::getInstance());
281+#endif
282+
245283 _logger = new FileLogger(this); // After setting organization name in order to get correct directory
246284 qInstallMessageHandler(messageHandler);
247−
285+
248286 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
249287 _window->setWindowTitle("Interface");
250288
@@ -253,7 +291,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 2 unmodified lines
253291 auto glCanvas = DependencyManager::get<GLCanvas>();
254292 auto nodeList = DependencyManager::get<NodeList>();
255293
256− _myAvatar = _avatarManager.getMyAvatar();
294+ _myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
257295
258296 _applicationStartupTime = startup_time;
259297
@@ -284,9 +322,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 24 unmodified lines
284322 QThread* audioThread = new QThread(this);
285323 audioThread->setObjectName("Audio Thread");
286324
287− auto audioIO = DependencyManager::get<Audio>();
325+ auto audioIO = DependencyManager::get<AudioClient>();
326+
327+ audioIO->setPositionGetter(getPositionForAudio);
328+ audioIO->setOrientationGetter(getOrientationForAudio);
329+
288330 audioIO->moveToThread(audioThread);
289− connect(audioThread, &QThread::started, audioIO.data(), &Audio::start);
331+ connect(audioThread, &QThread::started, audioIO.data(), &AudioClient::start);
290332 connect(audioIO.data(), SIGNAL(muteToggled()), this, SLOT(audioMuteToggled()));
291333
292334 audioThread->start();
@@ -330,9 +372,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 37 unmodified lines
330372 auto dialogsManager = DependencyManager::get<DialogsManager>();
331373 connect(&accountManager, &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog);
332374 connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle);
333−
334− // once we have a profile in account manager make sure we generate a new keypair
335− connect(&accountManager, &AccountManager::profileChanged, &accountManager, &AccountManager::generateNewKeypair);
336375
337376 // set the account manager's root URL and trigger a login request if we don't have the access token
338377 accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL);
@@ -497,7 +536,7 @@ Application::~Application() { · 158 unmodified lines
497536 // kill any audio injectors that are still around
498537 AudioScriptingInterface::getInstance().stopAllInjectors();
499538
500− auto audioIO = DependencyManager::get<Audio>();
539+ auto audioIO = DependencyManager::get<AudioClient>();
501540
502541 // stop the audio process
503542 QMetaObject::invokeMethod(audioIO.data(), "stop", Qt::BlockingQueuedConnection);
@@ -706,7 +745,7 @@ void Application::runTests() { · 202 unmodified lines
706745 void Application::audioMuteToggled() {
707746 QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteAudio);
708747 Q_CHECK_PTR(muteAction);
709− muteAction->setChecked(DependencyManager::get<Audio>()->isMuted());
748+ muteAction->setChecked(DependencyManager::get<AudioClient>()->isMuted());
710749 }
711750
712751 void Application::aboutApp() {
@@ -1566,13 +1605,16 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa · 853 unmodified lines
15661605 }
15671606
15681607 void Application::loadSettings() {
1569− DependencyManager::get<Audio>()->loadSettings();
1608+
1609+ DependencyManager::get<AudioClient>()->loadSettings();
1610+
15701611 Menu::getInstance()->loadSettings();
15711612 _myAvatar->loadData();
15721613 }
15731614
15741615 void Application::saveSettings() {
1575− DependencyManager::get<Audio>()->saveSettings();
1616+ DependencyManager::get<AudioClient>()->saveSettings();
1617+
15761618 Menu::getInstance()->saveSettings();
15771619 _myAvatar->saveData();
15781620 }
@@ -1606,7 +1648,7 @@ void Application::init() { · 27 unmodified lines
16061648 DependencyManager::get<AmbientOcclusionEffect>()->init(this);
16071649
16081650 // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager
1609− _avatarManager.init();
1651+ DependencyManager::get<AvatarManager>()->init();
16101652 _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
16111653
16121654 _mirrorCamera.setMode(CAMERA_MODE_MIRROR);
@@ -1985,7 +2027,7 @@ void Application::update(float deltaTime) { · 372 unmodified lines
19852027
19862028 updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process...
19872029
1988− _avatarManager.updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them...
2030+ DependencyManager::get<AvatarManager>()->updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them...
19892031
19902032 updateMetavoxels(deltaTime); // update metavoxels
19912033 updateCamera(deltaTime); // handle various camera tweaks like off axis projection
@@ -2012,7 +2054,7 @@ void Application::update(float deltaTime) { · 20 unmodified lines
20122054 {
20132055 PerformanceTimer perfTimer("myAvatar");
20142056 updateMyAvatarLookAtPosition();
2015− updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
2057+ DependencyManager::get<AvatarManager>()->updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
20162058 }
20172059
20182060 {
@@ -2069,31 +2111,11 @@ void Application::update(float deltaTime) { · 50 unmodified lines
20692111 if (sinceLastNack > TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS) {
20702112 _lastSendDownstreamAudioStats = now;
20712113
2072− QMetaObject::invokeMethod(DependencyManager::get<Audio>().data(), "sendDownstreamAudioStatsPacket", Qt::QueuedConnection);
2114+ QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "sendDownstreamAudioStatsPacket", Qt::QueuedConnection);
20732115 }
20742116 }
20752117 }
20762118
2077−void Application::updateMyAvatar(float deltaTime) {
2078− bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2079− PerformanceWarning warn(showWarnings, "Application::updateMyAvatar()");
2080−
2081− _myAvatar->update(deltaTime);
2082−
2083− quint64 now = usecTimestampNow();
2084− quint64 dt = now - _lastSendAvatarDataTime;
2085−
2086− if (dt > MIN_TIME_BETWEEN_MY_AVATAR_DATA_SENDS) {
2087− // send head/hand data to the avatar mixer and voxel server
2088− PerformanceTimer perfTimer("send");
2089− QByteArray packet = byteArrayWithPopulatedHeader(PacketTypeAvatarData);
2090− packet.append(_myAvatar->toByteArray());
2091− controlledBroadcastToNodes(packet, NodeSet() << NodeType::AvatarMixer);
2092−
2093− _lastSendAvatarDataTime = now;
2094− }
2095−}
2096−
20972119 int Application::sendNackPackets() {
20982120
20992121 if (Menu::getInstance()->isOptionChecked(MenuOption::DisableNackPackets)) {
@@ -2533,7 +2555,7 @@ void Application::updateShadowMap() { · 433 unmodified lines
25332555
25342556 {
25352557 PerformanceTimer perfTimer("avatarManager");
2536− _avatarManager.renderAvatars(Avatar::SHADOW_RENDER_MODE);
2558+ DependencyManager::get<AvatarManager>()->renderAvatars(Avatar::SHADOW_RENDER_MODE);
25372559 }
25382560
25392561 {
@@ -2789,7 +2811,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 249 unmodified lines
27892811 bool mirrorMode = (theCamera.getMode() == CAMERA_MODE_MIRROR);
27902812 {
27912813 PerformanceTimer perfTimer("avatars");
2792− _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE,
2814+ DependencyManager::get<AvatarManager>()->renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE,
27932815 false, selfAvatarOnly);
27942816 }
27952817
@@ -2804,7 +2826,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 8 unmodified lines
28042826
28052827 {
28062828 PerformanceTimer perfTimer("avatarsPostLighting");
2807− _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE,
2829+ DependencyManager::get<AvatarManager>()->renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE,
28082830 true, selfAvatarOnly);
28092831 }
28102832
@@ -3068,7 +3090,7 @@ void Application::resetSensors() { · 257 unmodified lines
30683090
30693091 _myAvatar->reset();
30703092
3071− QMetaObject::invokeMethod(DependencyManager::get<Audio>().data(), "reset", Qt::QueuedConnection);
3093+ QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "reset", Qt::QueuedConnection);
30723094 }
30733095
30743096 static void setShortcutsEnabled(QWidget* widget, bool enabled) {
@@ -3208,7 +3230,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 133 unmodified lines
32083230 _entityEditSender.nodeKilled(node);
32093231
32103232 if (node->getType() == NodeType::AudioMixer) {
3211− QMetaObject::invokeMethod(DependencyManager::get<Audio>().data(), "audioMixerKilled");
3233+ QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "audioMixerKilled");
32123234 }
32133235
32143236 if (node->getType() == NodeType::EntityServer) {
@@ -3251,7 +3273,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 36 unmodified lines
32513273
32523274 } else if (node->getType() == NodeType::AvatarMixer) {
32533275 // our avatar mixer has gone away - clear the hash of avatars
3254− _avatarManager.clearOtherAvatars();
3276+ DependencyManager::get<AvatarManager>()->clearOtherAvatars();
32553277 }
32563278 }
32573279
@@ -3400,7 +3422,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 142 unmodified lines
34003422
34013423 // hook our avatar and avatar hash map object into this script engine
34023424 scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features
3403− scriptEngine->setAvatarHashMap(&_avatarManager, "AvatarList");
3425+ scriptEngine->setAvatarHashMap(DependencyManager::get<AvatarManager>().data(), "AvatarList");
34043426
34053427 scriptEngine->registerGlobalObject("Camera", &_myCamera);
34063428
@@ -3441,7 +3463,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 34 unmodified lines
34413463 scriptEngine->registerGlobalObject("GlobalServices", GlobalServicesScriptingInterface::getInstance());
34423464 qScriptRegisterMetaType(scriptEngine, DownloadInfoResultToScriptValue, DownloadInfoResultFromScriptValue);
34433465
3444− scriptEngine->registerGlobalObject("AvatarManager", &_avatarManager);
3466+ scriptEngine->registerGlobalObject("AvatarManager", DependencyManager::get<AvatarManager>().data());
34453467
34463468 scriptEngine->registerGlobalObject("Joysticks", &JoystickScriptingInterface::getInstance());
34473469 qScriptRegisterMetaType(scriptEngine, joystickToScriptValue, joystickFromScriptValue);
@@ -3741,10 +3763,6 @@ void Application::toggleLogDialog() { · 293 unmodified lines
37413763 }
37423764 }
37433765
3744−void Application::initAvatarAndViewFrustum() {
3745− updateMyAvatar(0.0f);
3746−}
3747−
37483766 void Application::checkVersion() {
37493767 QNetworkRequest latestVersionRequest((QUrl(CHECK_VERSION_URL)));
37503768 latestVersionRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t