History

Merge branch 'master' of git://github.com/worklist/hifi into 19498

Lucas Crisman committed 12 years ago

Commit 793179d2 parents 76921d9 cc1993629 files · +1408 −619Browse files

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

Unified · Split

interface/src/Application.cpp+165−164
@@ -49,7 +49,7 @@ · 48 unmodified lines
49#include <QXmlStreamReader>49#include <QXmlStreamReader>
50#include <QXmlStreamAttributes>50#include <QXmlStreamAttributes>
51#include <QMediaPlayer>51#include <QMediaPlayer>
52#include <QMimeData> 52#include <QMimeData>
53#include <QMessageBox>53#include <QMessageBox>
54 54
55#include <AccountManager.h>55#include <AccountManager.h>
@@ -111,13 +111,11 @@ const float MIRROR_FIELD_OF_VIEW = 30.0f; · 55 unmodified lines
111const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml";111const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml";
112const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";112const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";
113 113
114const QString CUSTOM_URL_SCHEME = "hifi:";
115
116void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {114void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
117 if (message.size() > 0) {115 if (message.size() > 0) {
118 QString dateString = QDateTime::currentDateTime().toTimeSpec(Qt::LocalTime).toString(Qt::ISODate);116 QString dateString = QDateTime::currentDateTime().toTimeSpec(Qt::LocalTime).toString(Qt::ISODate);
119 QString formattedMessage = QString("[%1] %2\n").arg(dateString).arg(message);117 QString formattedMessage = QString("[%1] %2\n").arg(dateString).arg(message);
120 118
121 fprintf(stdout, "%s", qPrintable(formattedMessage));119 fprintf(stdout, "%s", qPrintable(formattedMessage));
122 Application::getInstance()->getLogger()->addMessage(qPrintable(formattedMessage));120 Application::getInstance()->getLogger()->addMessage(qPrintable(formattedMessage));
123 }121 }
@@ -165,27 +163,28 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 41 unmodified lines
165 _voxelHideShowThread(&_voxels),163 _voxelHideShowThread(&_voxels),
166 _packetsPerSecond(0),164 _packetsPerSecond(0),
167 _bytesPerSecond(0),165 _bytesPerSecond(0),
166 _previousScriptLocation(),
168 _logger(new FileLogger(this))167 _logger(new FileLogger(this))
169{168{
170 // read the ApplicationInfo.ini file for Name/Version/Domain information169 // read the ApplicationInfo.ini file for Name/Version/Domain information
171 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);170 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
172 171
173 // set the associated application properties172 // set the associated application properties
174 applicationInfo.beginGroup("INFO");173 applicationInfo.beginGroup("INFO");
175 174
176 qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion());175 qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion());
177 176
178 setApplicationName(applicationInfo.value("name").toString());177 setApplicationName(applicationInfo.value("name").toString());
179 setApplicationVersion(BUILD_VERSION);178 setApplicationVersion(BUILD_VERSION);
180 setOrganizationName(applicationInfo.value("organizationName").toString());179 setOrganizationName(applicationInfo.value("organizationName").toString());
181 setOrganizationDomain(applicationInfo.value("organizationDomain").toString());180 setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
182 181
183 QSettings::setDefaultFormat(QSettings::IniFormat);182 QSettings::setDefaultFormat(QSettings::IniFormat);
184 183
185 _myAvatar = _avatarManager.getMyAvatar();184 _myAvatar = _avatarManager.getMyAvatar();
186 185
187 _applicationStartupTime = startup_time;186 _applicationStartupTime = startup_time;
188 187
189 QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf");188 QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf");
190 _window->setWindowTitle("Interface");189 _window->setWindowTitle("Interface");
191 190
@@ -200,19 +199,19 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 8 unmodified lines
200 if (portStr) {199 if (portStr) {
201 listenPort = atoi(portStr);200 listenPort = atoi(portStr);
202 }201 }
203 202
204 // start the nodeThread so its event loop is running203 // start the nodeThread so its event loop is running
205 _nodeThread->start();204 _nodeThread->start();
206 205
207 // make sure the node thread is given highest priority206 // make sure the node thread is given highest priority
208 _nodeThread->setPriority(QThread::TimeCriticalPriority);207 _nodeThread->setPriority(QThread::TimeCriticalPriority);
209 208
210 // put the NodeList and datagram processing on the node thread209 // put the NodeList and datagram processing on the node thread
211 NodeList* nodeList = NodeList::createInstance(NodeType::Agent, listenPort);210 NodeList* nodeList = NodeList::createInstance(NodeType::Agent, listenPort);
212 211
213 nodeList->moveToThread(_nodeThread);212 nodeList->moveToThread(_nodeThread);
214 _datagramProcessor.moveToThread(_nodeThread);213 _datagramProcessor.moveToThread(_nodeThread);
215 214
216 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal215 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal
217 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams()));216 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams()));
218 217
@@ -234,20 +233,20 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 15 unmodified lines
234 connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer)));233 connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer)));
235 connect(nodeList, &NodeList::uuidChanged, this, &Application::updateWindowTitle);234 connect(nodeList, &NodeList::uuidChanged, this, &Application::updateWindowTitle);
236 connect(nodeList, &NodeList::limitOfSilentDomainCheckInsReached, nodeList, &NodeList::reset);235 connect(nodeList, &NodeList::limitOfSilentDomainCheckInsReached, nodeList, &NodeList::reset);
237 236
238 // connect to appropriate slots on AccountManager237 // connect to appropriate slots on AccountManager
239 AccountManager& accountManager = AccountManager::getInstance();238 AccountManager& accountManager = AccountManager::getInstance();
240 connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain);239 connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain);
241 connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle);240 connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle);
242 241
243 // set the account manager's root URL and trigger a login request if we don't have the access token242 // set the account manager's root URL and trigger a login request if we don't have the access token
244 accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL);243 accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL);
245 244
246 // once the event loop has started, check and signal for an access token245 // once the event loop has started, check and signal for an access token
247 QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection);246 QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection);
248 247
249 _settings = new QSettings(this);248 _settings = new QSettings(this);
250 249
251 // Check to see if the user passed in a command line option for loading a local250 // Check to see if the user passed in a command line option for loading a local
252 // Voxel File.251 // Voxel File.
253 _voxelsFilename = getCmdOption(argc, constArgv, "-i");252 _voxelsFilename = getCmdOption(argc, constArgv, "-i");
@@ -261,7 +260,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 7 unmodified lines
261 nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer260 nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer
262 << NodeType::VoxelServer << NodeType::ParticleServer261 << NodeType::VoxelServer << NodeType::ParticleServer
263 << NodeType::MetavoxelServer);262 << NodeType::MetavoxelServer);
264 263
265 // connect to the packet sent signal of the _voxelEditSender and the _particleEditSender264 // connect to the packet sent signal of the _voxelEditSender and the _particleEditSender
266 connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent);265 connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent);
267 connect(&_particleEditSender, &ParticleEditPacketSender::packetSent, this, &Application::packetSent);266 connect(&_particleEditSender, &ParticleEditPacketSender::packetSent, this, &Application::packetSent);
@@ -271,7 +270,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 3 unmodified lines
271 connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));270 connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
272 silentNodeTimer->moveToThread(_nodeThread);271 silentNodeTimer->moveToThread(_nodeThread);
273 silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);272 silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);
274 273
275 // send the identity packet for our avatar each second to our avatar mixer274 // send the identity packet for our avatar each second to our avatar mixer
276 QTimer* identityPacketTimer = new QTimer();275 QTimer* identityPacketTimer = new QTimer();
277 connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket);276 connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket);
@@ -319,14 +318,18 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 41 unmodified lines
319 318
320 // Set the sixense filtering319 // Set the sixense filtering
321 _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));320 _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
322 321
323 checkVersion();322 checkVersion();
324 323
325 _overlays.init(_glWidget); // do this before scripts load324 _overlays.init(_glWidget); // do this before scripts load
326 325
327 LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());326 LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());
328 LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);327 LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);
329 328
329 _window->addDockWidget(Qt::NoDockWidgetArea, _runningScriptsWidget = new RunningScriptsWidget());
330 _runningScriptsWidget->setRunningScripts(getRunningScripts());
331 connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript);
332
330 // check first run...333 // check first run...
331 QVariant firstRunValue = _settings->value("firstRun",QVariant(true));334 QVariant firstRunValue = _settings->value("firstRun",QVariant(true));
332 if (firstRunValue.isValid() && firstRunValue.toBool()) {335 if (firstRunValue.isValid() && firstRunValue.toBool()) {
@@ -334,7 +337,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 1 unmodified line
334 // clear the scripts, and set out script to our default scripts337 // clear the scripts, and set out script to our default scripts
335 clearScriptsBeforeRunning();338 clearScriptsBeforeRunning();
336 loadScript("http://public.highfidelity.io/scripts/defaultScripts.js");339 loadScript("http://public.highfidelity.io/scripts/defaultScripts.js");
337 340
338 _settings->setValue("firstRun",QVariant(false));341 _settings->setValue("firstRun",QVariant(false));
339 } else {342 } else {
340 // do this as late as possible so that all required subsystems are inialized343 // do this as late as possible so that all required subsystems are inialized
@@ -345,34 +348,34 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 4 unmodified lines
345Application::~Application() {348Application::~Application() {
346 349
347 qInstallMessageHandler(NULL);350 qInstallMessageHandler(NULL);
348 351
349 // make sure we don't call the idle timer any more352 // make sure we don't call the idle timer any more
350 delete idleTimer;353 delete idleTimer;
351 354
352 Menu::getInstance()->saveSettings();355 Menu::getInstance()->saveSettings();
353 _rearMirrorTools->saveSettings(_settings);356 _rearMirrorTools->saveSettings(_settings);
354 357
355 _sharedVoxelSystem.changeTree(new VoxelTree);358 _sharedVoxelSystem.changeTree(new VoxelTree);
356 if (_voxelImporter) {359 if (_voxelImporter) {
357 _voxelImporter->saveSettings(_settings);360 _voxelImporter->saveSettings(_settings);
358 delete _voxelImporter;361 delete _voxelImporter;
359 }362 }
360 _settings->sync();363 _settings->sync();
361 364
362 // let the avatar mixer know we're out365 // let the avatar mixer know we're out
363 MyAvatar::sendKillAvatar();366 MyAvatar::sendKillAvatar();
364 367
365 // ask the datagram processing thread to quit and wait until it is done368 // ask the datagram processing thread to quit and wait until it is done
366 _nodeThread->quit();369 _nodeThread->quit();
367 _nodeThread->wait();370 _nodeThread->wait();
368 371
369 // stop the audio process372 // stop the audio process
370 QMetaObject::invokeMethod(&_audio, "stop");373 QMetaObject::invokeMethod(&_audio, "stop");
371 374
372 // ask the audio thread to quit and wait until it is done375 // ask the audio thread to quit and wait until it is done
373 _audio.thread()->quit();376 _audio.thread()->quit();
374 _audio.thread()->wait();377 _audio.thread()->wait();
375 378
376 _voxelProcessor.terminate();379 _voxelProcessor.terminate();
377 _voxelHideShowThread.terminate();380 _voxelHideShowThread.terminate();
378 _voxelEditSender.terminate();381 _voxelEditSender.terminate();
@@ -385,9 +388,9 @@ Application::~Application() { · 6 unmodified lines
385 Menu::getInstance()->deleteLater();388 Menu::getInstance()->deleteLater();
386 389
387 _myAvatar = NULL;390 _myAvatar = NULL;
388 391
389 delete _glWidget;392 delete _glWidget;
390 393
391 AccountManager::getInstance().destroy();394 AccountManager::getInstance().destroy();
392}395}
393 396
@@ -579,7 +582,7 @@ void Application::paintGL() { · 185 unmodified lines
579 582
580 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {583 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
581 renderRearViewMirror(_mirrorViewRect);584 renderRearViewMirror(_mirrorViewRect);
582 585
583 } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {586 } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
584 _rearMirrorTools->render(true);587 _rearMirrorTools->render(true);
585 }588 }
@@ -660,10 +663,10 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 74 unmodified lines
660 if (type == NodeType::VoxelServer && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {663 if (type == NodeType::VoxelServer && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
661 continue;664 continue;
662 }665 }
663 666
664 // Perform the broadcast for one type667 // Perform the broadcast for one type
665 int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(packet, NodeSet() << type);668 int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(packet, NodeSet() << type);
666 669
667 // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise)670 // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise)
668 BandwidthMeter::ChannelIndex channel;671 BandwidthMeter::ChannelIndex channel;
669 switch (type) {672 switch (type) {
@@ -682,32 +685,15 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 12 unmodified lines
682}685}
683 686
684bool Application::event(QEvent* event) {687bool Application::event(QEvent* event) {
685 688
686 // handle custom URL689 // handle custom URL
687 if (event->type() == QEvent::FileOpen) {690 if (event->type() == QEvent::FileOpen) {
688 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);691 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
689 if (!fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME)) {692 bool isHifiSchemeURL = !fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME);
690 QString destination = fileEvent->url().toLocalFile().remove(CUSTOM_URL_SCHEME);693 if (isHifiSchemeURL) {
691 QStringList urlParts = destination.split('/', QString::SkipEmptyParts);694 Menu::getInstance()->goTo(fileEvent->url().toString());
692
693 if (urlParts.count() > 1) {
694 // if url has 2 or more parts, the first one is domain name
695 Menu::getInstance()->goToDomain(urlParts[0]);
696
697 // location coordinates
698 Menu::getInstance()->goToDestination(urlParts[1]);
699 if (urlParts.count() > 2) {
700
701 // location orientation
702 Menu::getInstance()->goToOrientation(urlParts[2]);
703 }
704 } else if (urlParts.count() == 1) {
705
706 // location coordinates
707 Menu::getInstance()->goToDestination(urlParts[0]);
708 }
709 }695 }
710 696
711 return false;697 return false;
712 }698 }
713 return QApplication::event(event);699 return QApplication::event(event);
@@ -718,7 +704,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 4 unmodified lines
718 _keysPressed.insert(event->key());704 _keysPressed.insert(event->key());
719 705
720 _controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts706 _controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts
721 707
722 // if one of our scripts have asked to capture this event, then stop processing it708 // if one of our scripts have asked to capture this event, then stop processing it
723 if (_controllerScriptingInterface.isKeyCaptured(event)) {709 if (_controllerScriptingInterface.isKeyCaptured(event)) {
724 return;710 return;
@@ -1130,7 +1116,7 @@ void Application::touchBeginEvent(QTouchEvent* event) { · 405 unmodified lines
1130 if (_controllerScriptingInterface.isTouchCaptured()) {1116 if (_controllerScriptingInterface.isTouchCaptured()) {
1131 return;1117 return;
1132 }1118 }
1133 1119
1134 // put any application specific touch behavior below here..1120 // put any application specific touch behavior below here..
1135 _lastTouchAvgX = _touchAvgX;1121 _lastTouchAvgX = _touchAvgX;
1136 _lastTouchAvgY = _touchAvgY;1122 _lastTouchAvgY = _touchAvgY;
@@ -1173,13 +1159,13 @@ void Application::dropEvent(QDropEvent *event) { · 36 unmodified lines
1173 break;1159 break;
1174 }1160 }
1175 }1161 }
1176 1162
1177 SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath);1163 SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath);
1178 if (snapshotData) {1164 if (snapshotData) {
1179 if (!snapshotData->getDomain().isEmpty()) {1165 if (!snapshotData->getDomain().isEmpty()) {
1180 Menu::getInstance()->goToDomain(snapshotData->getDomain());1166 Menu::getInstance()->goToDomain(snapshotData->getDomain());
1181 }1167 }
1182 1168
1183 _myAvatar->setPosition(snapshotData->getLocation());1169 _myAvatar->setPosition(snapshotData->getLocation());
1184 _myAvatar->setOrientation(snapshotData->getOrientation());1170 _myAvatar->setOrientation(snapshotData->getOrientation());
1185 } else {1171 } else {
@@ -1207,19 +1193,19 @@ void Application::timer() { · 21 unmodified lines
1207 }1193 }
1208 1194
1209 _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);1195 _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1210 1196
1211 _packetsPerSecond = (float) _datagramProcessor.getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);1197 _packetsPerSecond = (float) _datagramProcessor.getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1212 _bytesPerSecond = (float) _datagramProcessor.getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);1198 _bytesPerSecond = (float) _datagramProcessor.getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1213 _frameCount = 0;1199 _frameCount = 0;
1214 1200
1215 _datagramProcessor.resetCounters();1201 _datagramProcessor.resetCounters();
1216 1202
1217 gettimeofday(&_timerStart, NULL);1203 gettimeofday(&_timerStart, NULL);
1218 1204
1219 // ask the node list to check in with the domain server1205 // ask the node list to check in with the domain server
1220 NodeList::getInstance()->sendDomainServerCheckIn();1206 NodeList::getInstance()->sendDomainServerCheckIn();
1221 1207
1222 1208
1223}1209}
1224 1210
1225void Application::idle() {1211void Application::idle() {
@@ -1256,11 +1242,11 @@ void Application::idle() { · 30 unmodified lines
1256 _idleLoopMeasuredJitter = _idleLoopStdev.getStDev();1242 _idleLoopMeasuredJitter = _idleLoopStdev.getStDev();
1257 _idleLoopStdev.reset();1243 _idleLoopStdev.reset();
1258 }1244 }
1259 1245
1260 if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {1246 if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {
1261 _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData());1247 _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData());
1262 }1248 }
1263 1249
1264 // After finishing all of the above work, restart the idle timer, allowing 2ms to process events.1250 // After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
1265 idleTimer->start(2);1251 idleTimer->start(2);
1266 }1252 }
@@ -1392,7 +1378,7 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 125 unmodified lines
1392 tr("Sparse Voxel Octree Files (*.svo)"));1378 tr("Sparse Voxel Octree Files (*.svo)"));
1393 QByteArray fileNameAscii = fileNameString.toLocal8Bit();1379 QByteArray fileNameAscii = fileNameString.toLocal8Bit();
1394 const char* fileName = fileNameAscii.data();1380 const char* fileName = fileNameAscii.data();
1395 1381
1396 VoxelTreeElement* selectedNode = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);1382 VoxelTreeElement* selectedNode = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
1397 if (selectedNode) {1383 if (selectedNode) {
1398 VoxelTree exportTree;1384 VoxelTree exportTree;
@@ -1406,12 +1392,12 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 7 unmodified lines
1406 1392
1407void Application::importVoxels() {1393void Application::importVoxels() {
1408 _importSucceded = false;1394 _importSucceded = false;
1409 1395
1410 if (!_voxelImporter) {1396 if (!_voxelImporter) {
1411 _voxelImporter = new VoxelImporter(_window);1397 _voxelImporter = new VoxelImporter(_window);
1412 _voxelImporter->loadSettings(_settings);1398 _voxelImporter->loadSettings(_settings);
1413 }1399 }
1414 1400
1415 if (!_voxelImporter->exec()) {1401 if (!_voxelImporter->exec()) {
1416 qDebug() << "[DEBUG] Import succeeded." << endl;1402 qDebug() << "[DEBUG] Import succeeded." << endl;
1417 _importSucceded = true;1403 _importSucceded = true;
@@ -1425,7 +1411,7 @@ void Application::importVoxels() { · 7 unmodified lines
1425 1411
1426 // restore the main window's active state1412 // restore the main window's active state
1427 _window->activateWindow();1413 _window->activateWindow();
1428 1414
1429 emit importDone();1415 emit importDone();
1430}1416}
1431 1417
@@ -1481,7 +1467,7 @@ void Application::pasteVoxels(const VoxelDetail& sourceVoxel) { · 49 unmodified lines
1481 }1467 }
1482 1468
1483 pasteVoxelsToOctalCode(octalCodeDestination);1469 pasteVoxelsToOctalCode(octalCodeDestination);
1484 1470
1485 if (calculatedOctCode) {1471 if (calculatedOctCode) {
1486 delete[] calculatedOctCode;1472 delete[] calculatedOctCode;
1487 }1473 }
@@ -1518,9 +1504,9 @@ void Application::init() { · 30 unmodified lines
1518 1504
1519 // Cleanup of the original shared tree1505 // Cleanup of the original shared tree
1520 _sharedVoxelSystem.init();1506 _sharedVoxelSystem.init();
1521 1507
1522 _voxelImporter = new VoxelImporter(_window);1508 _voxelImporter = new VoxelImporter(_window);
1523 1509
1524 _environment.init();1510 _environment.init();
1525 1511
1526 _glowEffect.init();1512 _glowEffect.init();
@@ -1562,11 +1548,11 @@ void Application::init() { · 35 unmodified lines
1562 _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples());1548 _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples());
1563 }1549 }
1564 qDebug("Loaded settings");1550 qDebug("Loaded settings");
1565 1551
1566 // initialize Visage and Faceshift after loading the menu settings1552 // initialize Visage and Faceshift after loading the menu settings
1567 _faceshift.init();1553 _faceshift.init();
1568 _visage.init();1554 _visage.init();
1569 1555
1570 // fire off an immediate domain-server check in now that settings are loaded1556 // fire off an immediate domain-server check in now that settings are loaded
1571 NodeList::getInstance()->sendDomainServerCheckIn();1557 NodeList::getInstance()->sendDomainServerCheckIn();
1572 1558
@@ -1585,20 +1571,20 @@ void Application::init() { · 12 unmodified lines
1585 _particleCollisionSystem.init(&_particleEditSender, _particles.getTree(), _voxels.getTree(), &_audio, &_avatarManager);1571 _particleCollisionSystem.init(&_particleEditSender, _particles.getTree(), _voxels.getTree(), &_audio, &_avatarManager);
1586 1572
1587 // connect the _particleCollisionSystem to our script engine's ParticleScriptingInterface1573 // connect the _particleCollisionSystem to our script engine's ParticleScriptingInterface
1588 connect(&_particleCollisionSystem, 1574 connect(&_particleCollisionSystem,
1589 SIGNAL(particleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&)),1575 SIGNAL(particleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&)),
1590 ScriptEngine::getParticlesScriptingInterface(), 1576 ScriptEngine::getParticlesScriptingInterface(),
1591 SLOT(forwardParticleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&)));1577 SLOT(forwardParticleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&)));
1592 1578
1593 connect(&_particleCollisionSystem, 1579 connect(&_particleCollisionSystem,
1594 SIGNAL(particleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&)),1580 SIGNAL(particleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&)),
1595 ScriptEngine::getParticlesScriptingInterface(), 1581 ScriptEngine::getParticlesScriptingInterface(),
1596 SLOT(forwardParticleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&)));1582 SLOT(forwardParticleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&)));
1597 1583
1598 _audio.init(_glWidget);1584 _audio.init(_glWidget);
1599 1585
1600 _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings);1586 _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings);
1601 1587
1602 connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));1588 connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
1603 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));1589 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
1604 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));1590 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
@@ -1721,7 +1707,7 @@ void Application::updateMyAvatarLookAtPosition() { · 116 unmodified lines
1721 float distance = TREE_SCALE;1707 float distance = TREE_SCALE;
1722 if (_myAvatar->getLookAtTargetAvatar() && _myAvatar != _myAvatar->getLookAtTargetAvatar()) {1708 if (_myAvatar->getLookAtTargetAvatar() && _myAvatar != _myAvatar->getLookAtTargetAvatar()) {
1723 distance = glm::distance(_mouseRayOrigin,1709 distance = glm::distance(_mouseRayOrigin,
1724 static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition()); 1710 static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition());
1725 }1711 }
1726 const float FIXED_MIN_EYE_DISTANCE = 0.3f;1712 const float FIXED_MIN_EYE_DISTANCE = 0.3f;
1727 float minEyeDistance = FIXED_MIN_EYE_DISTANCE + (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON ? 0.0f :1713 float minEyeDistance = FIXED_MIN_EYE_DISTANCE + (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON ? 0.0f :
@@ -1734,7 +1720,7 @@ void Application::updateMyAvatarLookAtPosition() { · 6 unmodified lines
1734 eyePitch = _faceshift.getEstimatedEyePitch();1720 eyePitch = _faceshift.getEstimatedEyePitch();
1735 eyeYaw = _faceshift.getEstimatedEyeYaw();1721 eyeYaw = _faceshift.getEstimatedEyeYaw();
1736 trackerActive = true;1722 trackerActive = true;
1737 1723
1738 } else if (_visage.isActive()) {1724 } else if (_visage.isActive()) {
1739 eyePitch = _visage.getEstimatedEyePitch();1725 eyePitch = _visage.getEstimatedEyePitch();
1740 eyeYaw = _visage.getEstimatedEyeYaw();1726 eyeYaw = _visage.getEstimatedEyeYaw();
@@ -1907,9 +1893,9 @@ void Application::update(float deltaTime) { · 166 unmodified lines
1907 1893
1908 _particles.update(); // update the particles...1894 _particles.update(); // update the particles...
1909 _particleCollisionSystem.update(); // collide the particles...1895 _particleCollisionSystem.update(); // collide the particles...
1910 1896
1911 _overlays.update(deltaTime);1897 _overlays.update(deltaTime);
1912 1898
1913 // let external parties know we're updating1899 // let external parties know we're updating
1914 emit simulating(deltaTime);1900 emit simulating(deltaTime);
1915}1901}
@@ -1933,7 +1919,7 @@ void Application::updateMyAvatar(float deltaTime) { · 17 unmodified lines
1933 // actually need to calculate the view frustum planes to send these details1919 // actually need to calculate the view frustum planes to send these details
1934 // to the server.1920 // to the server.
1935 loadViewFrustum(_myCamera, _viewFrustum);1921 loadViewFrustum(_myCamera, _viewFrustum);
1936 1922
1937 // Update my voxel servers with my current voxel query...1923 // Update my voxel servers with my current voxel query...
1938 quint64 now = usecTimestampNow();1924 quint64 now = usecTimestampNow();
1939 quint64 sinceLastQuery = now - _lastQueriedTime;1925 quint64 sinceLastQuery = now - _lastQueriedTime;
@@ -2209,7 +2195,7 @@ void Application::updateShadowMap() { · 269 unmodified lines
2209 }2195 }
2210 center = inverseRotation * center;2196 center = inverseRotation * center;
2211 glm::vec3 minima(center.x - radius, center.y - radius, center.z - radius);2197 glm::vec3 minima(center.x - radius, center.y - radius, center.z - radius);
2212 glm::vec3 maxima(center.x + radius, center.y + radius, center.z + radius); 2198 glm::vec3 maxima(center.x + radius, center.y + radius, center.z + radius);
2213 2199
2214 // stretch out our extents in z so that we get all of the avatars2200 // stretch out our extents in z so that we get all of the avatars
2215 minima.z -= _viewFrustum.getFarClip() * 0.5f;2201 minima.z -= _viewFrustum.getFarClip() * 0.5f;
@@ -2230,7 +2216,7 @@ void Application::updateShadowMap() { · 14 unmodified lines
2230 _shadowViewFrustum.setEyeOffsetPosition(glm::vec3());2216 _shadowViewFrustum.setEyeOffsetPosition(glm::vec3());
2231 _shadowViewFrustum.setEyeOffsetOrientation(glm::quat());2217 _shadowViewFrustum.setEyeOffsetOrientation(glm::quat());
2232 _shadowViewFrustum.calculate();2218 _shadowViewFrustum.calculate();
2233 2219
2234 glMatrixMode(GL_PROJECTION);2220 glMatrixMode(GL_PROJECTION);
2235 glPushMatrix();2221 glPushMatrix();
2236 glLoadIdentity();2222 glLoadIdentity();
@@ -2285,19 +2271,19 @@ void Application::setupWorldLight() { · 48 unmodified lines
2285 2271
2286QImage Application::renderAvatarBillboard() {2272QImage Application::renderAvatarBillboard() {
2287 _textureCache.getPrimaryFramebufferObject()->bind();2273 _textureCache.getPrimaryFramebufferObject()->bind();
2288 2274
2289 glDisable(GL_BLEND);2275 glDisable(GL_BLEND);
2290 2276
2291 const int BILLBOARD_SIZE = 64;2277 const int BILLBOARD_SIZE = 64;
2292 renderRearViewMirror(QRect(0, _glWidget->height() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true);2278 renderRearViewMirror(QRect(0, _glWidget->height() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true);
2293 2279
2294 QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);2280 QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
2295 glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());2281 glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
2296 2282
2297 glEnable(GL_BLEND);2283 glEnable(GL_BLEND);
2298 2284
2299 _textureCache.getPrimaryFramebufferObject()->release();2285 _textureCache.getPrimaryFramebufferObject()->release();
2300 2286
2301 return image;2287 return image;
2302}2288}
2303 2289
@@ -2398,7 +2384,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 94 unmodified lines
2398 "Application::displaySide() ... metavoxels...");2384 "Application::displaySide() ... metavoxels...");
2399 _metavoxels.render();2385 _metavoxels.render();
2400 }2386 }
2401 2387
2402 if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {2388 if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {
2403 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),2389 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2404 "Application::displaySide() ... bucky balls...");2390 "Application::displaySide() ... bucky balls...");
@@ -2411,7 +2397,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 6 unmodified lines
2411 "Application::displaySide() ... particles...");2397 "Application::displaySide() ... particles...");
2412 _particles.render();2398 _particles.render();
2413 }2399 }
2414 2400
2415 // render the ambient occlusion effect if enabled2401 // render the ambient occlusion effect if enabled
2416 if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {2402 if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
2417 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),2403 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
@@ -2455,7 +2441,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 37 unmodified lines
2455 2441
2456 // give external parties a change to hook in2442 // give external parties a change to hook in
2457 emit renderingInWorldInterface();2443 emit renderingInWorldInterface();
2458 2444
2459 // render JS/scriptable overlays2445 // render JS/scriptable overlays
2460 _overlays.render3D();2446 _overlays.render3D();
2461 }2447 }
@@ -2504,17 +2490,16 @@ void Application::displayOverlay() { · 42 unmodified lines
2504 renderCollisionOverlay(_glWidget->width(), _glWidget->height(), _audio.getCollisionSoundMagnitude());2490 renderCollisionOverlay(_glWidget->width(), _glWidget->height(), _audio.getCollisionSoundMagnitude());
2505 }2491 }
2506 }2492 }
2507 2493
2508 // Audio Scope2494 // Audio Scope
2509 const int AUDIO_SCOPE_Y_OFFSET = 135;2495 const int AUDIO_SCOPE_Y_OFFSET = 135;
2510 if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {2496 if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
2511 _audio.renderMuteIcon(1, _glWidget->height() - 50);
2512 if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) {2497 if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) {
2513 int oscilloscopeTop = _glWidget->height() - AUDIO_SCOPE_Y_OFFSET;2498 int oscilloscopeTop = _glWidget->height() - AUDIO_SCOPE_Y_OFFSET;
2514 _audioScope.render(MIRROR_VIEW_LEFT_PADDING, oscilloscopeTop);2499 _audioScope.render(MIRROR_VIEW_LEFT_PADDING, oscilloscopeTop);
2515 }2500 }
2516 }2501 }
2517 2502
2518 // Audio VU Meter and Mute Icon2503 // Audio VU Meter and Mute Icon
2519 const int MUTE_ICON_SIZE = 24;2504 const int MUTE_ICON_SIZE = 24;
2520 const int AUDIO_METER_INSET = 2;2505 const int AUDIO_METER_INSET = 2;
@@ -2523,7 +2508,7 @@ void Application::displayOverlay() { · 2 unmodified lines
2523 const int AUDIO_METER_HEIGHT = 8;2508 const int AUDIO_METER_HEIGHT = 8;
2524 const int AUDIO_METER_Y_GAP = 8;2509 const int AUDIO_METER_Y_GAP = 8;
2525 const int AUDIO_METER_X = MIRROR_VIEW_LEFT_PADDING + MUTE_ICON_SIZE + AUDIO_METER_INSET;2510 const int AUDIO_METER_X = MIRROR_VIEW_LEFT_PADDING + MUTE_ICON_SIZE + AUDIO_METER_INSET;
2526 2511
2527 int audioMeterY;2512 int audioMeterY;
2528 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {2513 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
2529 audioMeterY = MIRROR_VIEW_HEIGHT + AUDIO_METER_Y_GAP;2514 audioMeterY = MIRROR_VIEW_HEIGHT + AUDIO_METER_Y_GAP;
@@ -2531,8 +2516,8 @@ void Application::displayOverlay() { · 1 unmodified line
2531 audioMeterY = AUDIO_METER_Y_GAP;2516 audioMeterY = AUDIO_METER_Y_GAP;
2532 }2517 }
2533 _audio.renderMuteIcon(MIRROR_VIEW_LEFT_PADDING, audioMeterY);2518 _audio.renderMuteIcon(MIRROR_VIEW_LEFT_PADDING, audioMeterY);
2534 2519
2535 2520
2536 const float AUDIO_METER_BLUE[] = {0.0, 0.0, 1.0};2521 const float AUDIO_METER_BLUE[] = {0.0, 0.0, 1.0};
2537 const float AUDIO_METER_GREEN[] = {0.0, 1.0, 0.0};2522 const float AUDIO_METER_GREEN[] = {0.0, 1.0, 0.0};
2538 const float AUDIO_METER_RED[] = {1.0, 0.0, 0.0};2523 const float AUDIO_METER_RED[] = {1.0, 0.0, 0.0};
@@ -2640,8 +2625,8 @@ void Application::displayOverlay() { · 101 unmodified lines
2640 char frameTimer[10];2625 char frameTimer[10];
2641 quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);2626 quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);
2642 sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000));2627 sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000));
2643 int timerBottom = 2628 int timerBottom =
2644 (Menu::getInstance()->isOptionChecked(MenuOption::Stats) && 2629 (Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
2645 Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth))2630 Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth))
2646 ? 80 : 20;2631 ? 80 : 20;
2647 drawText(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 1.0f, 0.f, frameTimer, WHITE_TEXT);2632 drawText(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 1.0f, 0.f, frameTimer, WHITE_TEXT);
@@ -2684,12 +2669,12 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 36 unmodified lines
2684 _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees2669 _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees
2685 _mirrorCamera.setDistance(BILLBOARD_DISTANCE * _myAvatar->getScale());2670 _mirrorCamera.setDistance(BILLBOARD_DISTANCE * _myAvatar->getScale());
2686 _mirrorCamera.setTargetPosition(_myAvatar->getPosition());2671 _mirrorCamera.setTargetPosition(_myAvatar->getPosition());
2687 2672
2688 } else if (_rearMirrorTools->getZoomLevel() == BODY) {2673 } else if (_rearMirrorTools->getZoomLevel() == BODY) {
2689 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees2674 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
2690 _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());2675 _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
2691 _mirrorCamera.setTargetPosition(_myAvatar->getChestPosition());2676 _mirrorCamera.setTargetPosition(_myAvatar->getChestPosition());
2692 2677
2693 } else { // HEAD zoom level2678 } else { // HEAD zoom level
2694 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees2679 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
2695 _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());2680 _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());
@@ -2704,7 +2689,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 8 unmodified lines
2704 }2689 }
2705 }2690 }
2706 _mirrorCamera.setAspectRatio((float)region.width() / region.height());2691 _mirrorCamera.setAspectRatio((float)region.width() / region.height());
2707 2692
2708 _mirrorCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));2693 _mirrorCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));
2709 _mirrorCamera.update(1.0f/_fps);2694 _mirrorCamera.update(1.0f/_fps);
2710 2695
@@ -2749,7 +2734,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 38 unmodified lines
2749 if (!billboard) {2734 if (!billboard) {
2750 _rearMirrorTools->render(false);2735 _rearMirrorTools->render(false);
2751 }2736 }
2752 2737
2753 // reset Viewport and projection matrix2738 // reset Viewport and projection matrix
2754 glViewport(0, 0, _glWidget->width(), _glWidget->height());2739 glViewport(0, 0, _glWidget->width(), _glWidget->height());
2755 glDisable(GL_SCISSOR_TEST);2740 glDisable(GL_SCISSOR_TEST);
@@ -2969,14 +2954,14 @@ void Application::setMenuShortcutsEnabled(bool enabled) { · 213 unmodified lines
2969}2954}
2970 2955
2971void Application::updateWindowTitle(){2956void Application::updateWindowTitle(){
2972 2957
2973 QString buildVersion = " (build " + applicationVersion() + ")";2958 QString buildVersion = " (build " + applicationVersion() + ")";
2974 NodeList* nodeList = NodeList::getInstance();2959 NodeList* nodeList = NodeList::getInstance();
2975 2960
2976 QString username = AccountManager::getInstance().getUsername();2961 QString username = AccountManager::getInstance().getUsername();
2977 QString title = QString() + (!username.isEmpty() ? username + " " : QString()) + nodeList->getSessionUUID().toString()2962 QString title = QString() + (!username.isEmpty() ? username + " " : QString()) + nodeList->getSessionUUID().toString()
2978 + " @ " + nodeList->getDomainInfo().getHostname() + buildVersion;2963 + " @ " + nodeList->getDomainInfo().getHostname() + buildVersion;
2979 2964
2980 qDebug("Application title set to: %s", title.toStdString().c_str());2965 qDebug("Application title set to: %s", title.toStdString().c_str());
2981 _window->setWindowTitle(title);2966 _window->setWindowTitle(title);
2982}2967}
@@ -2991,7 +2976,7 @@ void Application::domainChanged(const QString& domainHostname) { · 8 unmodified lines
2991 _voxelServerJurisdictions.clear();2976 _voxelServerJurisdictions.clear();
2992 _octreeServerSceneStats.clear();2977 _octreeServerSceneStats.clear();
2993 _particleServerJurisdictions.clear();2978 _particleServerJurisdictions.clear();
2994 2979
2995 // reset the particle renderer2980 // reset the particle renderer
2996 _particles.clear();2981 _particles.clear();
2997 2982
@@ -3001,12 +2986,12 @@ void Application::domainChanged(const QString& domainHostname) { · 3 unmodified lines
3001 2986
3002void Application::connectedToDomain(const QString& hostname) {2987void Application::connectedToDomain(const QString& hostname) {
3003 AccountManager& accountManager = AccountManager::getInstance();2988 AccountManager& accountManager = AccountManager::getInstance();
3004 2989
3005 if (accountManager.isLoggedIn()) {2990 if (accountManager.isLoggedIn()) {
3006 // update our domain-server with the data-server we're logged in with2991 // update our domain-server with the data-server we're logged in with
3007 2992
3008 QString domainPutJsonString = "{\"address\":{\"domain\":\"" + hostname + "\"}}";2993 QString domainPutJsonString = "{\"address\":{\"domain\":\"" + hostname + "\"}}";
3009 2994
3010 accountManager.authenticatedRequest("/api/v1/users/address", QNetworkAccessManager::PutOperation,2995 accountManager.authenticatedRequest("/api/v1/users/address", QNetworkAccessManager::PutOperation,
3011 JSONCallbackParameters(), domainPutJsonString.toUtf8());2996 JSONCallbackParameters(), domainPutJsonString.toUtf8());
3012 }2997 }
@@ -3171,13 +3156,13 @@ void Application::loadScripts() { · 158 unmodified lines
3171 // loads all saved scripts3156 // loads all saved scripts
3172 QSettings* settings = new QSettings(this);3157 QSettings* settings = new QSettings(this);
3173 int size = settings->beginReadArray("Settings");3158 int size = settings->beginReadArray("Settings");
3174 3159
3175 for (int i = 0; i < size; ++i){3160 for (int i = 0; i < size; ++i){
3176 settings->setArrayIndex(i);3161 settings->setArrayIndex(i);
3177 QString string = settings->value("script").toString();3162 QString string = settings->value("script").toString();
3178 loadScript(string);3163 loadScript(string);
3179 }3164 }
3180 3165
3181 settings->endArray();3166 settings->endArray();
3182}3167}
3183 3168
@@ -3192,42 +3177,72 @@ void Application::saveScripts() { · 8 unmodified lines
3192 // saves all current running scripts3177 // saves all current running scripts
3193 QSettings* settings = new QSettings(this);3178 QSettings* settings = new QSettings(this);
3194 settings->beginWriteArray("Settings");3179 settings->beginWriteArray("Settings");
3195 for (int i = 0; i < _activeScripts.size(); ++i){3180 for (int i = 0; i < getRunningScripts().size(); ++i){
3196 settings->setArrayIndex(i);3181 settings->setArrayIndex(i);
3197 settings->setValue("script", _activeScripts.at(i));3182 settings->setValue("script", getRunningScripts().at(i));
3198 }3183 }
3199 3184
3200 settings->endArray();3185 settings->endArray();
3201}3186}
3202 3187
3203void Application::stopAllScripts() {3188void Application::stopAllScripts() {
3204 // stops all current running scripts3189 // stops all current running scripts
3205 QList<QAction*> scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions();3190 for (int i = 0; i < _scriptEnginesHash.size(); ++i) {
3206 foreach (QAction* scriptAction, scriptActions) {3191 _scriptEnginesHash.values().at(i)->stop();
3207 scriptAction->activate(QAction::Trigger);3192 qDebug() << "stopping script..." << getRunningScripts().at(i);
3208 qDebug() << "stopping script..." << scriptAction->text();
3209 }3193 }
3210 _activeScripts.clear();3194 _scriptEnginesHash.clear();
3195 _runningScriptsWidget->setRunningScripts(getRunningScripts());
3196}
3197
3198void Application::stopScript(const QString &scriptName)
3199{
3200 _scriptEnginesHash.value(scriptName)->stop();
3201 qDebug() << "stopping script..." << scriptName;
3202 _scriptEnginesHash.remove(scriptName);
3203 _runningScriptsWidget->setRunningScripts(getRunningScripts());
3211}3204}
3212 3205
3213void Application::reloadAllScripts() {3206void Application::reloadAllScripts() {
3214 // remember all the current scripts so we can reload them3207 // remember all the current scripts so we can reload them
3215 QStringList reloadList = _activeScripts;3208 QStringList reloadList = getRunningScripts();
3216 // reloads all current running scripts3209 // reloads all current running scripts
3217 QList<QAction*> scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions();3210 stopAllScripts();
3218 foreach (QAction* scriptAction, scriptActions) {
3219 scriptAction->activate(QAction::Trigger);
3220 qDebug() << "stopping script..." << scriptAction->text();
3221 }
3222 3211
3223 // NOTE: we don't need to clear the _activeScripts list because that is handled on script shutdown.
3224
3225 foreach (QString scriptName, reloadList){3212 foreach (QString scriptName, reloadList){
3226 qDebug() << "reloading script..." << scriptName;3213 qDebug() << "reloading script..." << scriptName;
3227 loadScript(scriptName);3214 loadScript(scriptName);
3228 }3215 }
3229}3216}
3230 3217
3218void Application::toggleRunningScriptsWidget()
3219{
3220 if (!_runningScriptsWidget->toggleViewAction()->isChecked()) {
3221 _runningScriptsWidget->move(_window->geometry().topLeft().x(), _window->geometry().topLeft().y());
3222 _runningScriptsWidget->resize(0, _window->height());
3223 _runningScriptsWidget->toggleViewAction()->trigger();
3224 _runningScriptsWidget->grabKeyboard();
3225
3226 QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget);
3227 slideAnimation->setStartValue(_runningScriptsWidget->geometry());
3228 slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(),
3229 310, _runningScriptsWidget->height()));
3230 slideAnimation->setDuration(250);
3231 slideAnimation->start(QAbstractAnimation::DeleteWhenStopped);
3232 } else {
3233 _runningScriptsWidget->releaseKeyboard();
3234
3235 QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget);
3236 slideAnimation->setStartValue(_runningScriptsWidget->geometry());
3237 slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(),
3238 0, _runningScriptsWidget->height()));
3239 slideAnimation->setDuration(250);
3240 slideAnimation->start(QAbstractAnimation::DeleteWhenStopped);
3241
3242 QTimer::singleShot(260, _runningScriptsWidget->toggleViewAction(), SLOT(trigger()));
3243 }
3244}
3245
3231void Application::uploadFST(bool isHead) {3246void Application::uploadFST(bool isHead) {
3232 FstReader reader(isHead);3247 FstReader reader(isHead);
3233 if (reader.zip()) {3248 if (reader.zip()) {
@@ -3243,29 +3258,17 @@ void Application::uploadSkeleton() { · 9 unmodified lines
3243 uploadFST(false);3258 uploadFST(false);
3244}3259}
3245 3260
3246void Application::removeScriptName(const QString& fileNameString) {
3247 _activeScripts.removeOne(fileNameString);
3248}
3249
3250void Application::cleanupScriptMenuItem(const QString& scriptMenuName) {
3251 Menu::getInstance()->removeAction(Menu::getInstance()->getActiveScriptsMenu(), scriptMenuName);
3252}
3253
3254void Application::loadScript(const QString& scriptName) {3261void Application::loadScript(const QString& scriptName) {
3255 3262
3256 // start the script on a new thread...3263 // start the script on a new thread...
3257 bool wantMenuItems = true; // tells the ScriptEngine object to add menu items for itself3264 ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), &_controllerScriptingInterface);
3258 ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), wantMenuItems, &_controllerScriptingInterface);3265 _scriptEnginesHash.insert(scriptName, scriptEngine);
3259 3266
3260 if (!scriptEngine->hasScript()) {3267 if (!scriptEngine->hasScript()) {
3261 qDebug() << "Application::loadScript(), script failed to load...";3268 qDebug() << "Application::loadScript(), script failed to load...";
3262 return;3269 return;
3263 }3270 }
3264 _activeScripts.append(scriptName);3271 _runningScriptsWidget->setRunningScripts(getRunningScripts());
3265
3266 // add a stop menu item
3267 Menu::getInstance()->addActionToQMenuAndActionHash(Menu::getInstance()->getActiveScriptsMenu(),
3268 scriptEngine->getScriptMenuName(), 0, scriptEngine, SLOT(stop()));
3269 3272
3270 // setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so3273 // setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so
3271 // we can use the same ones from the application.3274 // we can use the same ones from the application.
@@ -3273,7 +3276,7 @@ void Application::loadScript(const QString& scriptName) { · 1 unmodified line
3273 scriptEngine->getVoxelsScriptingInterface()->setVoxelTree(_voxels.getTree());3276 scriptEngine->getVoxelsScriptingInterface()->setVoxelTree(_voxels.getTree());
3274 scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender);3277 scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender);
3275 scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree());3278 scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree());
3276 3279
3277 // hook our avatar object into this script engine3280 // hook our avatar object into this script engine
3278 scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features3281 scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features
3279 3282
@@ -3298,8 +3301,6 @@ void Application::loadScript(const QString& scriptName) { · 18 unmodified lines
3298 // when the thread is terminated, add both scriptEngine and thread to the deleteLater queue3301 // when the thread is terminated, add both scriptEngine and thread to the deleteLater queue
3299 connect(scriptEngine, SIGNAL(finished(const QString&)), scriptEngine, SLOT(deleteLater()));3302 connect(scriptEngine, SIGNAL(finished(const QString&)), scriptEngine, SLOT(deleteLater()));
3300 connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater()));3303 connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
3301 connect(scriptEngine, SIGNAL(finished(const QString&)), this, SLOT(removeScriptName(const QString&)));
3302 connect(scriptEngine, SIGNAL(cleanupMenuItem(const QString&)), this, SLOT(cleanupScriptMenuItem(const QString&)));
3303 3304
3304 // when the application is about to quit, stop our script engine so it unwinds properly3305 // when the application is about to quit, stop our script engine so it unwinds properly
3305 connect(this, SIGNAL(aboutToQuit()), scriptEngine, SLOT(stop()));3306 connect(this, SIGNAL(aboutToQuit()), scriptEngine, SLOT(stop()));
@@ -3323,12 +3324,12 @@ void Application::loadDialog() { · 17 unmodified lines
3323 suggestedName = _previousScriptLocation;3324 suggestedName = _previousScriptLocation;
3324 }3325 }
3325 3326
3326 QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName, 3327 QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName,
3327 tr("JavaScript Files (*.js)"));3328 tr("JavaScript Files (*.js)"));
3328 if (!fileNameString.isEmpty()) {3329 if (!fileNameString.isEmpty()) {
3329 _previousScriptLocation = fileNameString;3330 _previousScriptLocation = fileNameString;
3330 }3331 }
3331 3332
3332 loadScript(fileNameString);3333 loadScript(fileNameString);
3333}3334}
3334 3335
@@ -3339,7 +3340,7 @@ void Application::loadScriptURLDialog() { · 4 unmodified lines
3339 scriptURLDialog.setLabelText("Script:");3340 scriptURLDialog.setLabelText("Script:");
3340 scriptURLDialog.setWindowFlags(Qt::Sheet);3341 scriptURLDialog.setWindowFlags(Qt::Sheet);
3341 const float DIALOG_RATIO_OF_WINDOW = 0.30f;3342 const float DIALOG_RATIO_OF_WINDOW = 0.30f;
3342 scriptURLDialog.resize(scriptURLDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, 3343 scriptURLDialog.resize(scriptURLDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW,
3343 scriptURLDialog.size().height());3344 scriptURLDialog.size().height());
3344 3345
3345 int dialogReturn = scriptURLDialog.exec();3346 int dialogReturn = scriptURLDialog.exec();
@@ -3377,29 +3378,29 @@ void Application::checkVersion() { · 31 unmodified lines
3377}3378}
3378 3379
3379void Application::parseVersionXml() {3380void Application::parseVersionXml() {
3380 3381
3381 #ifdef Q_OS_WIN323382 #ifdef Q_OS_WIN32
3382 QString operatingSystem("win");3383 QString operatingSystem("win");
3383 #endif3384 #endif
3384 3385
3385 #ifdef Q_OS_MAC3386 #ifdef Q_OS_MAC
3386 QString operatingSystem("mac");3387 QString operatingSystem("mac");
3387 #endif3388 #endif
3388 3389
3389 #ifdef Q_OS_LINUX3390 #ifdef Q_OS_LINUX
3390 QString operatingSystem("ubuntu");3391 QString operatingSystem("ubuntu");
3391 #endif3392 #endif
3392 3393
3393 QString releaseDate;3394 QString releaseDate;
3394 QString releaseNotes;3395 QString releaseNotes;
3395 QString latestVersion;3396 QString latestVersion;
3396 QUrl downloadUrl;3397 QUrl downloadUrl;
3397 QObject* sender = QObject::sender();3398 QObject* sender = QObject::sender();
3398 3399
3399 QXmlStreamReader xml(qobject_cast<QNetworkReply*>(sender));3400 QXmlStreamReader xml(qobject_cast<QNetworkReply*>(sender));
3400 while (!xml.atEnd() && !xml.hasError()) {3401 while (!xml.atEnd() && !xml.hasError()) {
3401 QXmlStreamReader::TokenType token = xml.readNext();3402 QXmlStreamReader::TokenType token = xml.readNext();
3402 3403
3403 if (token == QXmlStreamReader::StartElement) {3404 if (token == QXmlStreamReader::StartElement) {
3404 if (xml.name() == "ReleaseDate") {3405 if (xml.name() == "ReleaseDate") {
3405 xml.readNext();3406 xml.readNext();

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