Showing the changes to interface/src/Application.cpp (1 of 28 files). Show all
Unified · Split
| @@ -8,6 +8,7 @@ · 7 unmodified lines | ||
| 8 | 8 | #include <sstream> |
| 9 | 9 | |
| 10 | 10 | #include <stdlib.h> |
| 11 | +#include <cmath> | |
| 11 | 12 | |
| 12 | 13 | #ifdef _WIN32 |
| 13 | 14 | #include "Syssocket.h" |
| @@ -63,6 +64,7 @@ · 49 unmodified lines | ||
| 63 | 64 | #include "Util.h" |
| 64 | 65 | #include "renderer/ProgramObject.h" |
| 65 | 66 | #include "ui/TextRenderer.h" |
| 67 | +#include "Swatch.h" | |
| 66 | 68 | #include "fvupdater.h" |
| 67 | 69 | |
| 68 | 70 | using namespace std; |
| @@ -198,7 +200,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 129 unmodified lines | ||
| 198 | 200 | _packetCount(0), |
| 199 | 201 | _packetsPerSecond(0), |
| 200 | 202 | _bytesPerSecond(0), |
| 201 | − _bytesCount(0) | |
| 203 | + _bytesCount(0), | |
| 204 | + _swatch(NULL) | |
| 202 | 205 | { |
| 203 | 206 | _applicationStartupTime = startup_time; |
| 204 | 207 | _window->setWindowTitle("Interface"); |
| @@ -274,7 +277,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 69 unmodified lines | ||
| 274 | 277 | FvUpdater::sharedUpdater()->SetFeedURL("https://s3-us-west-1.amazonaws.com/highfidelity/appcast.xml"); |
| 275 | 278 | FvUpdater::sharedUpdater()->CheckForUpdatesSilent(); |
| 276 | 279 | #endif |
| 277 | − | |
| 280 | + | |
| 278 | 281 | initMenu(); |
| 279 | 282 | |
| 280 | 283 | QRect available = desktop()->availableGeometry(); |
| @@ -483,30 +486,41 @@ void Application::resizeGL(int width, int height) { · 202 unmodified lines | ||
| 483 | 486 | glLoadIdentity(); |
| 484 | 487 | } |
| 485 | 488 | |
| 486 | −void Application::broadcastToNodes(unsigned char* data, size_t bytes, const char type) { | |
| 489 | +void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes, | |
| 490 | + const char* nodeTypes, int numNodeTypes) { | |
| 491 | + Application* self = getInstance(); | |
| 492 | + for (int i = 0; i < numNodeTypes; ++i) { | |
| 487 | 493 | |
| 488 | − int n = NodeList::getInstance()->broadcastToNodes(data, bytes, &type, 1); | |
| 494 | + // Intercept data to voxel server when voxels are disabled | |
| 495 | + if (nodeTypes[i] == NODE_TYPE_VOXEL_SERVER && ! self->_renderVoxels->isChecked()) { | |
| 496 | + continue; | |
| 497 | + } | |
| 489 | 498 | |
| 490 | − BandwidthMeter::ChannelIndex channel; | |
| 491 | − switch (type) { | |
| 492 | − case NODE_TYPE_AGENT: | |
| 493 | − case NODE_TYPE_AVATAR_MIXER: | |
| 494 | − channel = BandwidthMeter::AVATARS; | |
| 495 | − break; | |
| 496 | − case NODE_TYPE_VOXEL_SERVER: | |
| 497 | − channel = BandwidthMeter::VOXELS; | |
| 498 | − break; | |
| 499 | − default: | |
| 500 | − return; | |
| 499 | + // Perform the broadcast for one type | |
| 500 | + int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes, & nodeTypes[i], 1); | |
| 501 | + | |
| 502 | + // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise) | |
| 503 | + BandwidthMeter::ChannelIndex channel; | |
| 504 | + switch (nodeTypes[i]) { | |
| 505 | + case NODE_TYPE_AGENT: | |
| 506 | + case NODE_TYPE_AVATAR_MIXER: | |
| 507 | + channel = BandwidthMeter::AVATARS; | |
| 508 | + break; | |
| 509 | + case NODE_TYPE_VOXEL_SERVER: | |
| 510 | + channel = BandwidthMeter::VOXELS; | |
| 511 | + break; | |
| 512 | + default: | |
| 513 | + continue; | |
| 514 | + } | |
| 515 | + self->_bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes); | |
| 501 | 516 | } |
| 502 | − getInstance()->_bandwidthMeter.outputStream(channel).updateValue(n * bytes); | |
| 503 | 517 | } |
| 504 | 518 | |
| 505 | 519 | void Application::sendVoxelServerAddScene() { |
| 506 | 520 | char message[100]; |
| 507 | 521 | sprintf(message,"%c%s",'Z',"add scene"); |
| 508 | 522 | int messageSize = strlen(message) + 1; |
| 509 | − broadcastToNodes((unsigned char*)message, messageSize, NODE_TYPE_VOXEL_SERVER); | |
| 523 | + controlledBroadcastToNodes((unsigned char*)message, messageSize, & NODE_TYPE_VOXEL_SERVER, 1); | |
| 510 | 524 | } |
| 511 | 525 | |
| 512 | 526 | void Application::keyPressEvent(QKeyEvent* event) { |
| @@ -716,7 +730,16 @@ void Application::keyPressEvent(QKeyEvent* event) { · 203 unmodified lines | ||
| 716 | 730 | deleteVoxelUnderCursor(); |
| 717 | 731 | } |
| 718 | 732 | break; |
| 719 | − | |
| 733 | + case Qt::Key_1: | |
| 734 | + case Qt::Key_2: | |
| 735 | + case Qt::Key_3: | |
| 736 | + case Qt::Key_4: | |
| 737 | + case Qt::Key_5: | |
| 738 | + case Qt::Key_6: | |
| 739 | + case Qt::Key_7: | |
| 740 | + case Qt::Key_8: | |
| 741 | + _swatch.handleEvent(event->key(), _eyedropperMode->isChecked()); | |
| 742 | + break; | |
| 720 | 743 | default: |
| 721 | 744 | event->ignore(); |
| 722 | 745 | break; |
| @@ -877,16 +900,16 @@ void Application::wheelEvent(QWheelEvent* event) { · 154 unmodified lines | ||
| 877 | 900 | } |
| 878 | 901 | } |
| 879 | 902 | |
| 880 | −void sendPingPackets() { | |
| 903 | +void Application::sendPingPackets() { | |
| 881 | 904 | |
| 882 | 905 | char nodeTypesOfInterest[] = {NODE_TYPE_VOXEL_SERVER, NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER}; |
| 883 | 906 | long long currentTime = usecTimestampNow(); |
| 884 | − char pingPacket[1 + sizeof(currentTime)]; | |
| 907 | + unsigned char pingPacket[1 + sizeof(currentTime)]; | |
| 885 | 908 | pingPacket[0] = PACKET_HEADER_PING; |
| 886 | 909 | |
| 887 | 910 | memcpy(&pingPacket[1], ¤tTime, sizeof(currentTime)); |
| 888 | − NodeList::getInstance()->broadcastToNodes((unsigned char*)pingPacket, 1 + sizeof(currentTime), nodeTypesOfInterest, 3); | |
| 889 | − | |
| 911 | + getInstance()->controlledBroadcastToNodes(pingPacket, 1 + sizeof(currentTime), | |
| 912 | + nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); | |
| 890 | 913 | } |
| 891 | 914 | |
| 892 | 915 | // Every second, check the frame rates and other stuff |
| @@ -944,14 +967,17 @@ void Application::idle() { · 51 unmodified lines | ||
| 944 | 967 | // Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time we ran |
| 945 | 968 | |
| 946 | 969 | if (diffclock(&_lastTimeIdle, &check) > IDLE_SIMULATE_MSECS) { |
| 947 | − // We call processEvents() here because the idle timer takes priority over | |
| 948 | − // event handling in Qt, so when the framerate gets low events will pile up | |
| 949 | − // unless we handle them here. | |
| 950 | − | |
| 951 | − // NOTE - this is commented out for now - causing event processing issues reported by Philip and Ryan | |
| 952 | − // birarda - July 3rd | |
| 953 | 970 | |
| 954 | − // processEvents(); | |
| 971 | + // If we're using multi-touch look, immediately process any | |
| 972 | + // touch events, and no other events. | |
| 973 | + // This is necessary because id the idle() call takes longer than the | |
| 974 | + // interval between idle() calls, the event loop never gets to run, | |
| 975 | + // and touch events get delayed. | |
| 976 | + if (_touchLook->isChecked()) { | |
| 977 | + sendPostedEvents(NULL, QEvent::TouchBegin); | |
| 978 | + sendPostedEvents(NULL, QEvent::TouchUpdate); | |
| 979 | + sendPostedEvents(NULL, QEvent::TouchEnd); | |
| 980 | + } | |
| 955 | 981 | |
| 956 | 982 | update(1.0f / _fps); |
| 957 | 983 | |
| @@ -987,7 +1013,7 @@ void Application::sendAvatarVoxelURLMessage(const QUrl& url) { · 29 unmodified lines | ||
| 987 | 1013 | message.append((const char*)&ownerID, sizeof(ownerID)); |
| 988 | 1014 | message.append(url.toEncoded()); |
| 989 | 1015 | |
| 990 | − broadcastToNodes((unsigned char*)message.data(), message.size(), NODE_TYPE_AVATAR_MIXER); | |
| 1016 | + controlledBroadcastToNodes((unsigned char*)message.data(), message.size(), & NODE_TYPE_AVATAR_MIXER, 1); | |
| 991 | 1017 | } |
| 992 | 1018 | |
| 993 | 1019 | void Application::processAvatarVoxelURLMessage(unsigned char *packetData, size_t dataBytes) { |
| @@ -1224,7 +1250,7 @@ void Application::sendVoxelEditMessage(PACKET_HEADER header, VoxelDetail& detail · 230 unmodified lines | ||
| 1224 | 1250 | int sizeOut; |
| 1225 | 1251 | |
| 1226 | 1252 | if (createVoxelEditMessage(header, 0, 1, &detail, bufferOut, sizeOut)){ |
| 1227 | − Application::broadcastToNodes(bufferOut, sizeOut, NODE_TYPE_VOXEL_SERVER); | |
| 1253 | + Application::controlledBroadcastToNodes(bufferOut, sizeOut, & NODE_TYPE_VOXEL_SERVER, 1); | |
| 1228 | 1254 | delete[] bufferOut; |
| 1229 | 1255 | } |
| 1230 | 1256 | } |
| @@ -1242,7 +1268,11 @@ void Application::decreaseVoxelSize() { · 11 unmodified lines | ||
| 1242 | 1268 | void Application::increaseVoxelSize() { |
| 1243 | 1269 | _mouseVoxelScale *= 2; |
| 1244 | 1270 | } |
| 1245 | − | |
| 1271 | + | |
| 1272 | +void Application::resetSwatchColors() { | |
| 1273 | + _swatch.reset(); | |
| 1274 | +} | |
| 1275 | + | |
| 1246 | 1276 | static QIcon createSwatchIcon(const QColor& color) { |
| 1247 | 1277 | QPixmap map(16, 16); |
| 1248 | 1278 | map.fill(color); |
| @@ -1305,7 +1335,7 @@ bool Application::sendVoxelsOperation(VoxelNode* node, int level, void* extraDat · 56 unmodified lines | ||
| 1305 | 1335 | |
| 1306 | 1336 | // if we have room don't have room in the buffer, then send the previously generated message first |
| 1307 | 1337 | if (args->bufferInUse + codeAndColorLength > MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE) { |
| 1308 | − broadcastToNodes(args->messageBuffer, args->bufferInUse, NODE_TYPE_VOXEL_SERVER); | |
| 1338 | + controlledBroadcastToNodes(args->messageBuffer, args->bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1); | |
| 1309 | 1339 | args->bufferInUse = sizeof(PACKET_HEADER_SET_VOXEL_DESTRUCTIVE) + sizeof(unsigned short int); // reset |
| 1310 | 1340 | } |
| 1311 | 1341 | |
| @@ -1337,8 +1367,10 @@ void Application::exportVoxels() { · 25 unmodified lines | ||
| 1337 | 1367 | |
| 1338 | 1368 | void Application::importVoxels() { |
| 1339 | 1369 | QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); |
| 1340 | − QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Import Voxels"), desktopLocation, | |
| 1341 | − tr("Sparse Voxel Octree Files, Square PNG (*.svo *.png)")); | |
| 1370 | + QString fileNameString = QFileDialog::getOpenFileName( | |
| 1371 | + _glWidget, tr("Import Voxels"), desktopLocation, | |
| 1372 | + tr("Sparse Voxel Octree Files, Square PNG, Schematic Files (*.svo *.png *.schematic)")); | |
| 1373 | + | |
| 1342 | 1374 | QByteArray fileNameAscii = fileNameString.toAscii(); |
| 1343 | 1375 | const char* fileName = fileNameAscii.data(); |
| 1344 | 1376 | |
| @@ -1359,8 +1391,10 @@ void Application::importVoxels() { · 14 unmodified lines | ||
| 1359 | 1391 | } |
| 1360 | 1392 | |
| 1361 | 1393 | importVoxels.readFromSquareARGB32Pixels(pixels, pngImage.height()); |
| 1362 | − } else { | |
| 1394 | + } else if (fileNameString.endsWith(".svo", Qt::CaseInsensitive)) { | |
| 1363 | 1395 | importVoxels.readFromSVOFile(fileName); |
| 1396 | + } else { | |
| 1397 | + importVoxels.readFromSchematicFile(fileName); | |
| 1364 | 1398 | } |
| 1365 | 1399 | |
| 1366 | 1400 | VoxelNode* selectedNode = _voxels.getVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); |
| @@ -1386,7 +1420,7 @@ void Application::importVoxels() { · 19 unmodified lines | ||
| 1386 | 1420 | |
| 1387 | 1421 | // If we have voxels left in the packet, then send the packet |
| 1388 | 1422 | if (args.bufferInUse > (sizeof(PACKET_HEADER_SET_VOXEL_DESTRUCTIVE) + sizeof(unsigned short int))) { |
| 1389 | − broadcastToNodes(args.messageBuffer, args.bufferInUse, NODE_TYPE_VOXEL_SERVER); | |
| 1423 | + controlledBroadcastToNodes(args.messageBuffer, args.bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1); | |
| 1390 | 1424 | } |
| 1391 | 1425 | |
| 1392 | 1426 | if (calculatedOctCode) { |
| @@ -1438,7 +1472,7 @@ void Application::pasteVoxels() { · 45 unmodified lines | ||
| 1438 | 1472 | |
| 1439 | 1473 | // If we have voxels left in the packet, then send the packet |
| 1440 | 1474 | if (args.bufferInUse > (sizeof(PACKET_HEADER_SET_VOXEL_DESTRUCTIVE) + sizeof(unsigned short int))) { |
| 1441 | − broadcastToNodes(args.messageBuffer, args.bufferInUse, NODE_TYPE_VOXEL_SERVER); | |
| 1475 | + controlledBroadcastToNodes(args.messageBuffer, args.bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1); | |
| 1442 | 1476 | } |
| 1443 | 1477 | |
| 1444 | 1478 | if (calculatedOctCode) { |
| @@ -1480,12 +1514,13 @@ void Application::initMenu() { · 35 unmodified lines | ||
| 1480 | 1514 | (_testPing = optionsMenu->addAction("Test Ping"))->setCheckable(true); |
| 1481 | 1515 | _testPing->setChecked(true); |
| 1482 | 1516 | (_fullScreenMode = optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F))->setCheckable(true); |
| 1483 | − optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true); | |
| 1517 | + optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true); | |
| 1518 | + optionsMenu->addAction("Go Home", this, SLOT(goHome())); | |
| 1484 | 1519 | |
| 1485 | 1520 | QMenu* renderMenu = menuBar->addMenu("Render"); |
| 1486 | 1521 | (_renderVoxels = renderMenu->addAction("Voxels"))->setCheckable(true); |
| 1487 | 1522 | _renderVoxels->setChecked(true); |
| 1488 | − _renderVoxels->setShortcut(Qt::Key_V); | |
| 1523 | + _renderVoxels->setShortcut(Qt::SHIFT | Qt::Key_V); | |
| 1489 | 1524 | (_renderVoxelTextures = renderMenu->addAction("Voxel Textures"))->setCheckable(true); |
| 1490 | 1525 | (_renderStarsOn = renderMenu->addAction("Stars"))->setCheckable(true); |
| 1491 | 1526 | _renderStarsOn->setChecked(true); |
| @@ -1515,6 +1550,8 @@ void Application::initMenu() { · 23 unmodified lines | ||
| 1515 | 1550 | (_logOn = toolsMenu->addAction("Log"))->setCheckable(true); |
| 1516 | 1551 | _logOn->setChecked(false); |
| 1517 | 1552 | _logOn->setShortcut(Qt::CTRL | Qt::Key_L); |
| 1553 | + (_oscilloscopeOn = toolsMenu->addAction("Audio Oscilloscope"))->setCheckable(true); | |
| 1554 | + _oscilloscopeOn->setChecked(true); | |
| 1518 | 1555 | (_bandwidthDisplayOn = toolsMenu->addAction("Bandwidth Display"))->setCheckable(true); |
| 1519 | 1556 | _bandwidthDisplayOn->setChecked(true); |
| 1520 | 1557 | toolsMenu->addAction("Bandwidth Details", this, SLOT(bandwidthDetails())); |
| @@ -1525,36 +1562,39 @@ void Application::initMenu() { · 4 unmodified lines | ||
| 1525 | 1562 | _voxelModeActions->setExclusive(false); // exclusivity implies one is always checked |
| 1526 | 1563 | |
| 1527 | 1564 | (_addVoxelMode = voxelMenu->addAction( |
| 1528 | − "Add Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::CTRL | Qt::Key_A))->setCheckable(true); | |
| 1565 | + "Add Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_V))->setCheckable(true); | |
| 1529 | 1566 | _voxelModeActions->addAction(_addVoxelMode); |
| 1530 | 1567 | (_deleteVoxelMode = voxelMenu->addAction( |
| 1531 | − "Delete Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::CTRL | Qt::Key_D))->setCheckable(true); | |
| 1568 | + "Delete Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_R))->setCheckable(true); | |
| 1532 | 1569 | _voxelModeActions->addAction(_deleteVoxelMode); |
| 1533 | 1570 | (_colorVoxelMode = voxelMenu->addAction( |
| 1534 | − "Color Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::CTRL | Qt::Key_B))->setCheckable(true); | |
| 1571 | + "Color Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_B))->setCheckable(true); | |
| 1535 | 1572 | _voxelModeActions->addAction(_colorVoxelMode); |
| 1536 | 1573 | (_selectVoxelMode = voxelMenu->addAction( |
| 1537 | − "Select Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::CTRL | Qt::Key_S))->setCheckable(true); | |
| 1574 | + "Select Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_O))->setCheckable(true); | |
| 1538 | 1575 | _voxelModeActions->addAction(_selectVoxelMode); |
| 1539 | 1576 | (_eyedropperMode = voxelMenu->addAction( |
| 1540 | − "Get Color Mode", this, SLOT(updateVoxelModeActions()), Qt::CTRL | Qt::Key_G))->setCheckable(true); | |
| 1577 | + "Get Color Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_G))->setCheckable(true); | |
| 1541 | 1578 | _voxelModeActions->addAction(_eyedropperMode); |
| 1542 | − | |
| 1579 | + | |
| 1543 | 1580 | voxelMenu->addAction("Decrease Voxel Size", this, SLOT(decreaseVoxelSize()), QKeySequence::ZoomOut); |
| 1544 | 1581 | voxelMenu->addAction("Increase Voxel Size", this, SLOT(increaseVoxelSize()), QKeySequence::ZoomIn); |
| 1545 | − | |
| 1582 | + voxelMenu->addAction("Reset Swatch Colors", this, SLOT(resetSwatchColors())); | |
| 1583 | + | |
| 1546 | 1584 | _voxelPaintColor = voxelMenu->addAction("Voxel Paint Color", this, |
| 1547 | 1585 | SLOT(chooseVoxelPaintColor()), Qt::META | Qt::Key_C); |
| 1586 | + _swatch.setAction(_voxelPaintColor); | |
| 1587 | + | |
| 1548 | 1588 | QColor paintColor(128, 128, 128); |
| 1549 | 1589 | _voxelPaintColor->setData(paintColor); |
| 1550 | 1590 | _voxelPaintColor->setIcon(createSwatchIcon(paintColor)); |
| 1551 | 1591 | (_destructiveAddVoxel = voxelMenu->addAction("Create Voxel is Destructive"))->setCheckable(true); |
| 1552 | 1592 | |
| 1553 | − voxelMenu->addAction("Export Voxels", this, SLOT(exportVoxels()), Qt::CTRL | Qt::Key_E); | |
| 1554 | − voxelMenu->addAction("Import Voxels", this, SLOT(importVoxels()), Qt::CTRL | Qt::Key_I); | |
| 1555 | − voxelMenu->addAction("Cut Voxels", this, SLOT(cutVoxels()), Qt::CTRL | Qt::Key_X); | |
| 1556 | − voxelMenu->addAction("Copy Voxels", this, SLOT(copyVoxels()), Qt::CTRL | Qt::Key_C); | |
| 1557 | − voxelMenu->addAction("Paste Voxels", this, SLOT(pasteVoxels()), Qt::CTRL | Qt::Key_V); | |
| 1593 | + voxelMenu->addAction("Export Voxels", this, SLOT(exportVoxels()), Qt::CTRL | Qt::Key_E); | |
| 1594 | + voxelMenu->addAction("Import Voxels", this, SLOT(importVoxels()), Qt::CTRL | Qt::Key_I); | |
| 1595 | + voxelMenu->addAction("Cut Voxels", this, SLOT(cutVoxels()), Qt::CTRL | Qt::Key_X); | |
| 1596 | + voxelMenu->addAction("Copy Voxels", this, SLOT(copyVoxels()), Qt::CTRL | Qt::Key_C); | |
| 1597 | + voxelMenu->addAction("Paste Voxels", this, SLOT(pasteVoxels()), Qt::CTRL | Qt::Key_V); | |
| 1558 | 1598 | |
| 1559 | 1599 | QMenu* debugMenu = menuBar->addMenu("Debug"); |
| 1560 | 1600 | |
| @@ -1680,6 +1720,14 @@ void Application::init() { · 119 unmodified lines | ||
| 1680 | 1720 | printLog("Loaded settings.\n"); |
| 1681 | 1721 | |
| 1682 | 1722 | sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); |
| 1723 | + | |
| 1724 | + _palette.init(_glWidget->width(), _glWidget->height()); | |
| 1725 | + _palette.addAction(_addVoxelMode, 0, 0); | |
| 1726 | + _palette.addAction(_deleteVoxelMode, 0, 1); | |
| 1727 | + _palette.addTool(&_swatch); | |
| 1728 | + _palette.addAction(_colorVoxelMode, 0, 2); | |
| 1729 | + _palette.addAction(_eyedropperMode, 0, 3); | |
| 1730 | + _palette.addAction(_selectVoxelMode, 0, 4); | |
| 1683 | 1731 | } |
| 1684 | 1732 | |
| 1685 | 1733 | const float MAX_AVATAR_EDIT_VELOCITY = 1.0f; |
| @@ -1912,7 +1960,7 @@ void Application::update(float deltaTime) { · 226 unmodified lines | ||
| 1912 | 1960 | if (_bandwidthDialog) { |
| 1913 | 1961 | _bandwidthDialog->update(); |
| 1914 | 1962 | } |
| 1915 | − | |
| 1963 | + | |
| 1916 | 1964 | // Update audio stats for procedural sounds |
| 1917 | 1965 | #ifndef _WIN32 |
| 1918 | 1966 | _audio.setLastAcceleration(_myAvatar.getThrust()); |
| @@ -1923,11 +1971,11 @@ void Application::update(float deltaTime) { · 4 unmodified lines | ||
| 1923 | 1971 | |
| 1924 | 1972 | void Application::updateAvatar(float deltaTime) { |
| 1925 | 1973 | |
| 1926 | − // Update my avatar's head position from gyros and/or webcam | |
| 1927 | − _myAvatar.updateHeadFromGyrosAndOrWebcam(_gyroLook->isChecked(), | |
| 1928 | − glm::vec3(_headCameraPitchYawScale, | |
| 1929 | − _headCameraPitchYawScale, | |
| 1930 | − _headCameraPitchYawScale)); | |
| 1974 | + // Update my avatar's state from gyros and/or webcam | |
| 1975 | + _myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(), | |
| 1976 | + glm::vec3(_headCameraPitchYawScale, | |
| 1977 | + _headCameraPitchYawScale, | |
| 1978 | + _headCameraPitchYawScale)); | |
| 1931 | 1979 | |
| 1932 | 1980 | if (_serialHeadSensor.isActive()) { |
| 1933 | 1981 | |
| @@ -1989,9 +2037,10 @@ void Application::updateAvatar(float deltaTime) { · 55 unmodified lines | ||
| 1989 | 2037 | endOfBroadcastStringWrite += packNodeId(endOfBroadcastStringWrite, nodeList->getOwnerID()); |
| 1990 | 2038 | |
| 1991 | 2039 | endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite); |
| 1992 | − | |
| 1993 | − broadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString, NODE_TYPE_VOXEL_SERVER); | |
| 1994 | − broadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString, NODE_TYPE_AVATAR_MIXER); | |
| 2040 | + | |
| 2041 | + const char nodeTypesOfInterest[] = { NODE_TYPE_VOXEL_SERVER, NODE_TYPE_AVATAR_MIXER }; | |
| 2042 | + controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString, | |
| 2043 | + nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); | |
| 1995 | 2044 | |
| 1996 | 2045 | // once in a while, send my voxel url |
| 1997 | 2046 | const float AVATAR_VOXEL_URL_SEND_INTERVAL = 1.0f; // seconds |
| @@ -2350,8 +2399,9 @@ void Application::displayOverlay() { · 352 unmodified lines | ||
| 2350 | 2399 | |
| 2351 | 2400 | #ifndef _WIN32 |
| 2352 | 2401 | _audio.render(_glWidget->width(), _glWidget->height()); |
| 2353 | − _audioScope.render(20, _glWidget->height() - 200); | |
| 2354 | − //_audio.renderEchoCompare(); // PER: Will turn back on to further test echo | |
| 2402 | + if (_oscilloscopeOn->isChecked()) { | |
| 2403 | + _audioScope.render(20, _glWidget->height() - 200); | |
| 2404 | + } | |
| 2355 | 2405 | #endif |
| 2356 | 2406 | |
| 2357 | 2407 | //noiseTest(_glWidget->width(), _glWidget->height()); |
| @@ -2431,7 +2481,52 @@ void Application::displayOverlay() { · 73 unmodified lines | ||
| 2431 | 2481 | |
| 2432 | 2482 | // render the webcam input frame |
| 2433 | 2483 | _webcam.renderPreview(_glWidget->width(), _glWidget->height()); |
| 2434 | − | |
| 2484 | + | |
| 2485 | + _palette.render(_glWidget->width(), _glWidget->height()); | |
| 2486 | + | |
| 2487 | + if (_eyedropperMode->isChecked() && _voxelPaintColor->data().value<QColor>() != _swatch.getColor()) { | |
| 2488 | + QColor color = _voxelPaintColor->data().value<QColor>(); | |
| 2489 | + TextRenderer textRenderer(SANS_FONT_FAMILY, 11, 50); | |
| 2490 | + const char line1[] = "Assign this color to a swatch"; | |
| 2491 | + const char line2[] = "by choosing a key from 1 to 8."; | |
| 2492 | + | |
| 2493 | + int left = (_glWidget->width() - POPUP_WIDTH - 2 * POPUP_MARGIN) / 2; | |
| 2494 | + int top = _glWidget->height() / 40; | |
| 2495 | + | |
| 2496 | + glBegin(GL_POLYGON); | |
| 2497 | + glColor3f(0.0f, 0.0f, 0.0f); | |
| 2498 | + for (double a = M_PI; a < 1.5f * M_PI; a += POPUP_STEP) { | |
| 2499 | + glVertex2f(left + POPUP_MARGIN * cos(a) , top + POPUP_MARGIN * sin(a)); | |
| 2500 | + } | |
| 2501 | + for (double a = 1.5f * M_PI; a < 2.0f * M_PI; a += POPUP_STEP) { | |
| 2502 | + glVertex2f(left + POPUP_WIDTH + POPUP_MARGIN * cos(a), top + POPUP_MARGIN * sin(a)); | |
| 2503 | + } | |
| 2504 | + for (double a = 0.0f; a < 0.5f * M_PI; a += POPUP_STEP) { | |
| 2505 | + glVertex2f(left + POPUP_WIDTH + POPUP_MARGIN * cos(a), top + POPUP_HEIGHT + POPUP_MARGIN * sin(a)); | |
| 2506 | + } | |
| 2507 | + for (double a = 0.5f * M_PI; a < 1.0f * M_PI; a += POPUP_STEP) { | |
| 2508 | + glVertex2f(left + POPUP_MARGIN * cos(a) , top + POPUP_HEIGHT + POPUP_MARGIN * sin(a)); | |
| 2509 | + } | |
| 2510 | + glEnd(); | |
| 2511 | + | |
| 2512 | + glBegin(GL_QUADS); | |
| 2513 | + glColor3f(color.redF(), | |
| 2514 | + color.greenF(), | |
| 2515 | + color.blueF()); | |
| 2516 | + glVertex2f(left , top); | |
| 2517 | + glVertex2f(left + SWATCH_WIDTH, top); | |
| 2518 | + glVertex2f(left + SWATCH_WIDTH, top + SWATCH_HEIGHT); | |
| 2519 | + glVertex2f(left , top + SWATCH_HEIGHT); | |
| 2520 | + glEnd(); | |
| 2521 | + | |
| 2522 | + glColor3f(1.0f, 1.0f, 1.0f); | |
| 2523 | + textRenderer.draw(left + SWATCH_WIDTH + POPUP_MARGIN, top + FIRST_LINE_OFFSET , line1); | |
| 2524 | + textRenderer.draw(left + SWATCH_WIDTH + POPUP_MARGIN, top + SECOND_LINE_OFFSET, line2); | |
| 2525 | + } | |
| 2526 | + else { | |
| 2527 | + _swatch.checkColor(); | |
| 2528 | + } | |
| 2529 | + | |
| 2435 | 2530 | glPopMatrix(); |
| 2436 | 2531 | } |
| 2437 | 2532 | |
| @@ -2953,6 +3048,7 @@ void Application::eyedropperVoxelUnderCursor() { · 515 unmodified lines | ||
| 2953 | 3048 | } |
| 2954 | 3049 | |
| 2955 | 3050 | void Application::goHome() { |
| 3051 | + printLog("Going Home!\n"); | |
| 2956 | 3052 | _myAvatar.setPosition(START_LOCATION); |
| 2957 | 3053 | } |
| 2958 | 3054 | |
| @@ -3127,7 +3223,8 @@ void Application::loadSettings(QSettings* settings) { · 168 unmodified lines | ||
| 3127 | 3223 | settings->endGroup(); |
| 3128 | 3224 | |
| 3129 | 3225 | scanMenuBar(&Application::loadAction, settings); |
| 3130 | − getAvatar()->loadData(settings); | |
| 3226 | + getAvatar()->loadData(settings); | |
| 3227 | + _swatch.loadData(settings); | |
| 3131 | 3228 | } |
| 3132 | 3229 | |
| 3133 | 3230 | |
| @@ -3149,6 +3246,7 @@ void Application::saveSettings(QSettings* settings) { · 15 unmodified lines | ||
| 3149 | 3246 | |
| 3150 | 3247 | scanMenuBar(&Application::saveAction, settings); |
| 3151 | 3248 | getAvatar()->saveData(settings); |
| 3249 | + _swatch.saveData(settings); | |
| 3152 | 3250 | } |
| 3153 | 3251 | |
| 3154 | 3252 | void Application::importSettings() { |