Showing the changes to interface/src/Application.cpp (1 of 74 files). Show all
Unified · Split
| @@ -56,6 +56,8 @@ · 55 unmodified lines | ||
| 56 | 56 | #include <PairingHandler.h> |
| 57 | 57 | #include <PerfStat.h> |
| 58 | 58 | |
| 59 | +#include <VoxelSceneStats.h> | |
| 60 | + | |
| 59 | 61 | #include "Application.h" |
| 60 | 62 | #include "InterfaceConfig.h" |
| 61 | 63 | #include "LogDisplay.h" |
| @@ -73,8 +75,6 @@ using namespace std; · 11 unmodified lines | ||
| 73 | 75 | static char STAR_FILE[] = "http://s3-us-west-1.amazonaws.com/highfidelity/stars.txt"; |
| 74 | 76 | static char STAR_CACHE_FILE[] = "cachedStars.txt"; |
| 75 | 77 | |
| 76 | −static const bool TESTING_PARTICLE_SYSTEM = true; | |
| 77 | − | |
| 78 | 78 | static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored |
| 79 | 79 | |
| 80 | 80 | const glm::vec3 START_LOCATION(4.f, 0.f, 5.f); // Where one's own node begins in the world |
| @@ -174,6 +174,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 93 unmodified lines | ||
| 174 | 174 | _window(new QMainWindow(desktop())), |
| 175 | 175 | _glWidget(new GLCanvas()), |
| 176 | 176 | _bandwidthDialog(NULL), |
| 177 | + _voxelStatsDialog(NULL), | |
| 177 | 178 | _displayLevels(false), |
| 178 | 179 | _frameCount(0), |
| 179 | 180 | _fps(120.0f), |
| @@ -201,6 +202,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 21 unmodified lines | ||
| 201 | 202 | _isHoverVoxelSounding(false), |
| 202 | 203 | _mouseVoxelScale(1.0f / 1024.0f), |
| 203 | 204 | _justEditedVoxel(false), |
| 205 | + _isLookingAtOtherAvatar(false), | |
| 206 | + _lookatIndicatorScale(1.0f), | |
| 204 | 207 | _paintOn(false), |
| 205 | 208 | _dominantColor(0), |
| 206 | 209 | _perfStatsOn(false), |
| @@ -237,6 +240,31 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 30 unmodified lines | ||
| 237 | 240 | NodeList::getInstance()->getNodeSocket()->setBlocking(false); |
| 238 | 241 | } |
| 239 | 242 | |
| 243 | + // setup QSettings | |
| 244 | +#ifdef Q_WS_MAC | |
| 245 | + QString resourcesPath = QCoreApplication::applicationDirPath() + "/../Resources"; | |
| 246 | +#else | |
| 247 | + QString resourcesPath = QCoreApplication::applicationDirPath() + "/resources"; | |
| 248 | +#endif | |
| 249 | + | |
| 250 | + // read the ApplicationInfo.ini file for Name/Version/Domain information | |
| 251 | + QSettings applicationInfo(resourcesPath + "/info/ApplicationInfo.ini", QSettings::IniFormat); | |
| 252 | + | |
| 253 | + // set the associated application properties | |
| 254 | + applicationInfo.beginGroup("INFO"); | |
| 255 | + | |
| 256 | + setApplicationName(applicationInfo.value("name").toString()); | |
| 257 | + setApplicationVersion(applicationInfo.value("version").toString()); | |
| 258 | + setOrganizationName(applicationInfo.value("organizationName").toString()); | |
| 259 | + setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); | |
| 260 | + | |
| 261 | + _settings = new QSettings(this); | |
| 262 | + | |
| 263 | + // check if there is a saved domain server hostname | |
| 264 | + // this must be done now instead of with the other setting checks to allow manual override with | |
| 265 | + // --domain or --local options | |
| 266 | + NodeList::getInstance()->loadData(_settings); | |
| 267 | + | |
| 240 | 268 | const char* domainIP = getCmdOption(argc, constArgv, "--domain"); |
| 241 | 269 | if (domainIP) { |
| 242 | 270 | NodeList::getInstance()->setDomainIP(domainIP); |
| @@ -270,23 +298,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 27 unmodified lines | ||
| 270 | 298 | |
| 271 | 299 | _window->setCentralWidget(_glWidget); |
| 272 | 300 | |
| 273 | −#ifdef Q_WS_MAC | |
| 274 | − QString resourcesPath = QCoreApplication::applicationDirPath() + "/../Resources"; | |
| 275 | −#else | |
| 276 | − QString resourcesPath = QCoreApplication::applicationDirPath() + "/resources"; | |
| 277 | −#endif | |
| 278 | − | |
| 279 | − // read the ApplicationInfo.ini file for Name/Version/Domain information | |
| 280 | − QSettings applicationInfo(resourcesPath + "/info/ApplicationInfo.ini", QSettings::IniFormat); | |
| 281 | − | |
| 282 | − // set the associated application properties | |
| 283 | − applicationInfo.beginGroup("INFO"); | |
| 284 | − | |
| 285 | − setApplicationName(applicationInfo.value("name").toString()); | |
| 286 | − setApplicationVersion(applicationInfo.value("version").toString()); | |
| 287 | − setOrganizationName(applicationInfo.value("organizationName").toString()); | |
| 288 | − setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); | |
| 289 | − | |
| 290 | 301 | #if defined(Q_WS_MAC) && defined(QT_NO_DEBUG) |
| 291 | 302 | // if this is a release OS X build use fervor to check for an update |
| 292 | 303 | FvUpdater::sharedUpdater()->SetFeedURL("https://s3-us-west-1.amazonaws.com/highfidelity/appcast.xml"); |
| @@ -396,7 +407,7 @@ void Application::paintGL() { · 103 unmodified lines | ||
| 396 | 407 | |
| 397 | 408 | } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { |
| 398 | 409 | _myCamera.setTightness(0.0f); // In first person, camera follows head exactly without delay |
| 399 | − _myCamera.setTargetPosition(_myAvatar.getUprightHeadPosition()); | |
| 410 | + _myCamera.setTargetPosition(_myAvatar.getUprightEyeLevelPosition()); | |
| 400 | 411 | _myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation()); |
| 401 | 412 | |
| 402 | 413 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| @@ -939,6 +950,36 @@ void Application::sendPingPackets() { · 536 unmodified lines | ||
| 939 | 950 | nodesToPing, sizeof(nodesToPing)); |
| 940 | 951 | } |
| 941 | 952 | |
| 953 | +void Application::sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data) { | |
| 954 | + unsigned char packet[MAX_PACKET_SIZE]; | |
| 955 | + unsigned char* packetPosition = packet; | |
| 956 | + | |
| 957 | + packetPosition += populateTypeAndVersion(packetPosition, PACKET_TYPE_AVATAR_FACE_VIDEO); | |
| 958 | + | |
| 959 | + *(uint16_t*)packetPosition = NodeList::getInstance()->getOwnerID(); | |
| 960 | + packetPosition += sizeof(uint16_t); | |
| 961 | + | |
| 962 | + *(uint32_t*)packetPosition = frameCount; | |
| 963 | + packetPosition += sizeof(uint32_t); | |
| 964 | + | |
| 965 | + *(uint32_t*)packetPosition = data.size(); | |
| 966 | + packetPosition += sizeof(uint32_t); | |
| 967 | + | |
| 968 | + uint32_t* offsetPosition = (uint32_t*)packetPosition; | |
| 969 | + packetPosition += sizeof(uint32_t); | |
| 970 | + | |
| 971 | + int headerSize = packetPosition - packet; | |
| 972 | + | |
| 973 | + // break the data up into submessages of the maximum size | |
| 974 | + *offsetPosition = 0; | |
| 975 | + while (*offsetPosition < data.size()) { | |
| 976 | + int payloadSize = min(data.size() - (int)*offsetPosition, MAX_PACKET_SIZE - headerSize); | |
| 977 | + memcpy(packetPosition, data.constData() + *offsetPosition, payloadSize); | |
| 978 | + getInstance()->controlledBroadcastToNodes(packet, headerSize + payloadSize, &NODE_TYPE_AVATAR_MIXER, 1); | |
| 979 | + *offsetPosition += payloadSize; | |
| 980 | + } | |
| 981 | +} | |
| 982 | + | |
| 942 | 983 | // Every second, check the frame rates and other stuff |
| 943 | 984 | void Application::timer() { |
| 944 | 985 | gettimeofday(&_timerEnd, NULL); |
| @@ -1048,7 +1089,7 @@ void Application::sendAvatarVoxelURLMessage(const QUrl& url) { · 103 unmodified lines | ||
| 1048 | 1089 | controlledBroadcastToNodes((unsigned char*)message.data(), message.size(), & NODE_TYPE_AVATAR_MIXER, 1); |
| 1049 | 1090 | } |
| 1050 | 1091 | |
| 1051 | −void Application::processAvatarVoxelURLMessage(unsigned char *packetData, size_t dataBytes) { | |
| 1092 | +static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { | |
| 1052 | 1093 | // skip the header |
| 1053 | 1094 | int numBytesPacketHeader = numBytesForPacketHeader(packetData); |
| 1054 | 1095 | packetData += numBytesPacketHeader; |
| @@ -1062,18 +1103,31 @@ void Application::processAvatarVoxelURLMessage(unsigned char *packetData, size_t · 7 unmodified lines | ||
| 1062 | 1103 | // make sure the node exists |
| 1063 | 1104 | Node* node = NodeList::getInstance()->nodeWithID(nodeID); |
| 1064 | 1105 | if (!node || !node->getLinkedData()) { |
| 1065 | − return; | |
| 1106 | + return NULL; | |
| 1066 | 1107 | } |
| 1067 | 1108 | Avatar* avatar = static_cast<Avatar*>(node->getLinkedData()); |
| 1068 | − if (!avatar->isInitialized()) { | |
| 1069 | − return; // wait until initialized | |
| 1070 | − } | |
| 1109 | + return avatar->isInitialized() ? avatar : NULL; | |
| 1110 | +} | |
| 1111 | + | |
| 1112 | +void Application::processAvatarVoxelURLMessage(unsigned char* packetData, size_t dataBytes) { | |
| 1113 | + Avatar* avatar = processAvatarMessageHeader(packetData, dataBytes); | |
| 1114 | + if (!avatar) { | |
| 1115 | + return; | |
| 1116 | + } | |
| 1071 | 1117 | QUrl url = QUrl::fromEncoded(QByteArray((char*)packetData, dataBytes)); |
| 1072 | 1118 | |
| 1073 | 1119 | // invoke the set URL function on the simulate/render thread |
| 1074 | 1120 | QMetaObject::invokeMethod(avatar->getVoxels(), "setVoxelURL", Q_ARG(QUrl, url)); |
| 1075 | 1121 | } |
| 1076 | 1122 | |
| 1123 | +void Application::processAvatarFaceVideoMessage(unsigned char* packetData, size_t dataBytes) { | |
| 1124 | + Avatar* avatar = processAvatarMessageHeader(packetData, dataBytes); | |
| 1125 | + if (!avatar) { | |
| 1126 | + return; | |
| 1127 | + } | |
| 1128 | + avatar->getHead().getFace().processVideoMessage(packetData, dataBytes); | |
| 1129 | +} | |
| 1130 | + | |
| 1077 | 1131 | void Application::checkBandwidthMeterClick() { |
| 1078 | 1132 | // ... to be called upon button release |
| 1079 | 1133 | |
| @@ -1105,6 +1159,21 @@ void Application::bandwidthDetailsClosed() { · 25 unmodified lines | ||
| 1105 | 1159 | delete dlg; |
| 1106 | 1160 | } |
| 1107 | 1161 | |
| 1162 | +void Application::voxelStatsDetails() { | |
| 1163 | + if (!_voxelStatsDialog) { | |
| 1164 | + _voxelStatsDialog = new VoxelStatsDialog(_glWidget, &_voxelSceneStats); | |
| 1165 | + connect(_voxelStatsDialog, SIGNAL(closed()), SLOT(voxelStatsDetailsClosed())); | |
| 1166 | + _voxelStatsDialog->show(); | |
| 1167 | + } | |
| 1168 | + _voxelStatsDialog->raise(); | |
| 1169 | +} | |
| 1170 | + | |
| 1171 | +void Application::voxelStatsDetailsClosed() { | |
| 1172 | + QDialog* dlg = _voxelStatsDialog; | |
| 1173 | + _voxelStatsDialog = NULL; | |
| 1174 | + delete dlg; | |
| 1175 | +} | |
| 1176 | + | |
| 1108 | 1177 | void Application::editPreferences() { |
| 1109 | 1178 | QDialog dialog(_glWidget); |
| 1110 | 1179 | dialog.setWindowTitle("Interface Preferences"); |
| @@ -1153,11 +1222,18 @@ void Application::editPreferences() { · 42 unmodified lines | ||
| 1153 | 1222 | return; |
| 1154 | 1223 | } |
| 1155 | 1224 | |
| 1156 | − char newHostname[MAX_HOSTNAME_BYTES] = {}; | |
| 1157 | − memcpy(newHostname, domainServerHostname->text().toAscii().data(), domainServerHostname->text().size()); | |
| 1225 | + QByteArray newHostname; | |
| 1226 | + | |
| 1227 | + if (domainServerHostname->text().size() > 0) { | |
| 1228 | + // the user input a new hostname, use that | |
| 1229 | + newHostname = domainServerHostname->text().toAscii(); | |
| 1230 | + } else { | |
| 1231 | + // the user left the field blank, use the default hostname | |
| 1232 | + newHostname = QByteArray(DEFAULT_DOMAIN_HOSTNAME); | |
| 1233 | + } | |
| 1158 | 1234 | |
| 1159 | 1235 | // check if the domain server hostname is new |
| 1160 | − if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname, strlen(newHostname)) != 0) { | |
| 1236 | + if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname.constData(), newHostname.size()) != 0) { | |
| 1161 | 1237 | |
| 1162 | 1238 | NodeList::getInstance()->clear(); |
| 1163 | 1239 | |
| @@ -1167,7 +1243,8 @@ void Application::editPreferences() { · 3 unmodified lines | ||
| 1167 | 1243 | // reset the environment to default |
| 1168 | 1244 | _environment.resetToDefault(); |
| 1169 | 1245 | |
| 1170 | − NodeList::getInstance()->setDomainHostname(newHostname); | |
| 1246 | + // set the new hostname | |
| 1247 | + NodeList::getInstance()->setDomainHostname(newHostname.constData()); | |
| 1171 | 1248 | } |
| 1172 | 1249 | |
| 1173 | 1250 | QUrl url(avatarURL->text()); |
| @@ -1428,11 +1505,11 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { · 254 unmodified lines | ||
| 1428 | 1505 | int usecToSleep = CLIENT_TO_SERVER_VOXEL_SEND_INTERVAL_USECS - elapsed; |
| 1429 | 1506 | if (usecToSleep > 0) { |
| 1430 | 1507 | qDebug("sendVoxelsOperation: packet: %d bytes:%lld elapsed %lld usecs, sleeping for %d usecs!\n", |
| 1431 | − args->packetsSent, args->bytesSent, elapsed, usecToSleep); | |
| 1508 | + args->packetsSent, (long long int)args->bytesSent, (long long int)elapsed, usecToSleep); | |
| 1432 | 1509 | usleep(usecToSleep); |
| 1433 | 1510 | } else { |
| 1434 | 1511 | qDebug("sendVoxelsOperation: packet: %d bytes:%lld elapsed %lld usecs, no need to sleep!\n", |
| 1435 | − args->packetsSent, args->bytesSent, elapsed); | |
| 1512 | + args->packetsSent, (long long int)args->bytesSent, (long long int)elapsed); | |
| 1436 | 1513 | } |
| 1437 | 1514 | args->lastSendTime = now; |
| 1438 | 1515 | } |
| @@ -1617,7 +1694,7 @@ void Application::pasteVoxels() { · 178 unmodified lines | ||
| 1617 | 1694 | controlledBroadcastToNodes(args.messageBuffer, args.bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1); |
| 1618 | 1695 | qDebug("sending packet: %d\n", ++args.packetsSent); |
| 1619 | 1696 | args.bytesSent += args.bufferInUse; |
| 1620 | − qDebug("total bytes sent: %lld\n", args.bytesSent); | |
| 1697 | + qDebug("total bytes sent: %lld\n", (long long int)args.bytesSent); | |
| 1621 | 1698 | } |
| 1622 | 1699 | |
| 1623 | 1700 | if (calculatedOctCode) { |
| @@ -1675,10 +1752,15 @@ void Application::initMenu() { · 51 unmodified lines | ||
| 1675 | 1752 | (_renderAvatarBalls = renderMenu->addAction("Avatar as Balls"))->setCheckable(true); |
| 1676 | 1753 | _renderAvatarBalls->setChecked(false); |
| 1677 | 1754 | renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode())); |
| 1755 | + renderMenu->addAction("Cycle Face Mode", &_myAvatar.getHead().getFace(), SLOT(cycleRenderMode())); | |
| 1678 | 1756 | (_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true); |
| 1679 | 1757 | _renderFrameTimerOn->setChecked(false); |
| 1680 | 1758 | (_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true); |
| 1681 | 1759 | _renderLookatOn->setChecked(false); |
| 1760 | + (_renderLookatIndicatorOn = renderMenu->addAction("Lookat Indicator"))->setCheckable(true); | |
| 1761 | + _renderLookatIndicatorOn->setChecked(true); | |
| 1762 | + (_renderParticleSystemOn = renderMenu->addAction("Particle System"))->setCheckable(true); | |
| 1763 | + _renderParticleSystemOn->setChecked(true); | |
| 1682 | 1764 | (_manualFirstPerson = renderMenu->addAction( |
| 1683 | 1765 | "First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true); |
| 1684 | 1766 | (_manualThirdPerson = renderMenu->addAction( |
| @@ -1698,6 +1780,7 @@ void Application::initMenu() { · 13 unmodified lines | ||
| 1698 | 1780 | (_bandwidthDisplayOn = toolsMenu->addAction("Bandwidth Display"))->setCheckable(true); |
| 1699 | 1781 | _bandwidthDisplayOn->setChecked(true); |
| 1700 | 1782 | toolsMenu->addAction("Bandwidth Details", this, SLOT(bandwidthDetails())); |
| 1783 | + toolsMenu->addAction("Voxel Stats Details", this, SLOT(voxelStatsDetails())); | |
| 1701 | 1784 | |
| 1702 | 1785 | |
| 1703 | 1786 | QMenu* voxelMenu = menuBar->addMenu("Voxels"); |
| @@ -1782,6 +1865,11 @@ void Application::initMenu() { · 78 unmodified lines | ||
| 1782 | 1865 | (_simulateLeapHand = debugMenu->addAction("Simulate Leap Hand"))->setCheckable(true); |
| 1783 | 1866 | (_testRaveGlove = debugMenu->addAction("Test RaveGlove"))->setCheckable(true); |
| 1784 | 1867 | |
| 1868 | + QMenu* audioDebugMenu = debugMenu->addMenu("Audio Debugging Tools"); | |
| 1869 | + audioDebugMenu->addAction("Listen Mode Normal", this, SLOT(setListenModeNormal()), Qt::CTRL | Qt::Key_1); | |
| 1870 | + audioDebugMenu->addAction("Listen Mode Point/Radius", this, SLOT(setListenModePoint()), Qt::CTRL | Qt::Key_2); | |
| 1871 | + audioDebugMenu->addAction("Listen Mode Single Source", this, SLOT(setListenModeSingleSource()), Qt::CTRL | Qt::Key_3); | |
| 1872 | + | |
| 1785 | 1873 | QMenu* settingsMenu = menuBar->addMenu("Settings"); |
| 1786 | 1874 | (_settingsAutosave = settingsMenu->addAction("Autosave"))->setCheckable(true); |
| 1787 | 1875 | _settingsAutosave->setChecked(true); |
| @@ -1791,9 +1879,32 @@ void Application::initMenu() { · 3 unmodified lines | ||
| 1791 | 1879 | settingsMenu->addAction("Export settings", this, SLOT(exportSettings())); |
| 1792 | 1880 | |
| 1793 | 1881 | _networkAccessManager = new QNetworkAccessManager(this); |
| 1794 | − _settings = new QSettings(this); | |
| 1795 | 1882 | } |
| 1796 | 1883 | |
| 1884 | +void Application::setListenModeNormal() { | |
| 1885 | + _audio.setListenMode(AudioRingBuffer::NORMAL); | |
| 1886 | +} | |
| 1887 | + | |
| 1888 | +void Application::setListenModePoint() { | |
| 1889 | + _audio.setListenMode(AudioRingBuffer::OMNI_DIRECTIONAL_POINT); | |
| 1890 | + _audio.setListenRadius(1.0); | |
| 1891 | +} | |
| 1892 | + | |
| 1893 | +void Application::setListenModeSingleSource() { | |
| 1894 | + _audio.setListenMode(AudioRingBuffer::SELECTED_SOURCES); | |
| 1895 | + _audio.clearListenSources(); | |
| 1896 | + | |
| 1897 | + glm::vec3 mouseRayOrigin = _myAvatar.getMouseRayOrigin(); | |
| 1898 | + glm::vec3 mouseRayDirection = _myAvatar.getMouseRayDirection(); | |
| 1899 | + glm::vec3 eyePositionIgnored; | |
| 1900 | + uint16_t nodeID; | |
| 1901 | + | |
| 1902 | + if (isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeID)) { | |
| 1903 | + _audio.addListenSource(nodeID); | |
| 1904 | + } | |
| 1905 | +} | |
| 1906 | + | |
| 1907 | + | |
| 1797 | 1908 | void Application::updateFrustumRenderModeAction() { |
| 1798 | 1909 | switch (_frustumDrawingMode) { |
| 1799 | 1910 | default: |
| @@ -1882,7 +1993,10 @@ const float MAX_AVATAR_EDIT_VELOCITY = 1.0f; · 82 unmodified lines | ||
| 1882 | 1993 | const float MAX_VOXEL_EDIT_DISTANCE = 20.0f; |
| 1883 | 1994 | const float HEAD_SPHERE_RADIUS = 0.07; |
| 1884 | 1995 | |
| 1885 | −bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, glm::vec3& eyePosition) { | |
| 1996 | + | |
| 1997 | +bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, | |
| 1998 | + glm::vec3& eyePosition, uint16_t& nodeID) { | |
| 1999 | + | |
| 1886 | 2000 | NodeList* nodeList = NodeList::getInstance(); |
| 1887 | 2001 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { |
| 1888 | 2002 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| @@ -1890,6 +2004,9 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m · 1 unmodified line | ||
| 1890 | 2004 | glm::vec3 headPosition = avatar->getHead().getPosition(); |
| 1891 | 2005 | if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) { |
| 1892 | 2006 | eyePosition = avatar->getHead().getEyeLevelPosition(); |
| 2007 | + _lookatIndicatorScale = avatar->getScale(); | |
| 2008 | + _lookatOtherPosition = headPosition; | |
| 2009 | + nodeID = avatar->getOwningNode()->getNodeID(); | |
| 1893 | 2010 | return true; |
| 1894 | 2011 | } |
| 1895 | 2012 | } |
| @@ -1897,6 +2014,17 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m · 1 unmodified line | ||
| 1897 | 2014 | return false; |
| 1898 | 2015 | } |
| 1899 | 2016 | |
| 2017 | +void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera) { | |
| 2018 | + | |
| 2019 | + const float DISTANCE_FROM_HEAD_SPHERE = 0.1f * _lookatIndicatorScale; | |
| 2020 | + const float INDICATOR_RADIUS = 0.1f * _lookatIndicatorScale; | |
| 2021 | + const float YELLOW[] = { 1.0f, 1.0f, 0.0f }; | |
| 2022 | + const int NUM_SEGMENTS = 30; | |
| 2023 | + glm::vec3 haloOrigin(pointOfInterest.x, pointOfInterest.y + DISTANCE_FROM_HEAD_SPHERE, pointOfInterest.z); | |
| 2024 | + glColor3f(YELLOW[0], YELLOW[1], YELLOW[2]); | |
| 2025 | + renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS); | |
| 2026 | +} | |
| 2027 | + | |
| 1900 | 2028 | void Application::update(float deltaTime) { |
| 1901 | 2029 | // Use Transmitter Hand to move hand if connected, else use mouse |
| 1902 | 2030 | if (_myTransmitter.isConnected()) { |
| @@ -1924,7 +2052,9 @@ void Application::update(float deltaTime) { · 21 unmodified lines | ||
| 1924 | 2052 | |
| 1925 | 2053 | // Set where I am looking based on my mouse ray (so that other people can see) |
| 1926 | 2054 | glm::vec3 eyePosition; |
| 1927 | − if (isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition)) { | |
| 2055 | + uint16_t ignored; | |
| 2056 | + _isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition, ignored); | |
| 2057 | + if (_isLookingAtOtherAvatar) { | |
| 1928 | 2058 | // If the mouse is over another avatar's head... |
| 1929 | 2059 | glm::vec3 myLookAtFromMouse(eyePosition); |
| 1930 | 2060 | _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); |
| @@ -2075,10 +2205,8 @@ void Application::update(float deltaTime) { · 144 unmodified lines | ||
| 2075 | 2205 | |
| 2076 | 2206 | // Leap finger-sensing device |
| 2077 | 2207 | LeapManager::enableFakeFingers(_simulateLeapHand->isChecked() || _testRaveGlove->isChecked()); |
| 2078 | − LeapManager::nextFrame(); | |
| 2079 | 2208 | _myAvatar.getHand().setRaveGloveActive(_testRaveGlove->isChecked()); |
| 2080 | − _myAvatar.getHand().setLeapFingers(LeapManager::getFingerTips(), LeapManager::getFingerRoots()); | |
| 2081 | − _myAvatar.getHand().setLeapHands(LeapManager::getHandPositions(), LeapManager::getHandNormals()); | |
| 2209 | + LeapManager::nextFrame(_myAvatar); | |
| 2082 | 2210 | |
| 2083 | 2211 | // Read serial port interface devices |
| 2084 | 2212 | if (_serialHeadSensor.isActive()) { |
| @@ -2165,6 +2293,9 @@ void Application::update(float deltaTime) { · 80 unmodified lines | ||
| 2165 | 2293 | if (_bandwidthDialog) { |
| 2166 | 2294 | _bandwidthDialog->update(); |
| 2167 | 2295 | } |
| 2296 | + if (_voxelStatsDialog) { | |
| 2297 | + _voxelStatsDialog->update(); | |
| 2298 | + } | |
| 2168 | 2299 | |
| 2169 | 2300 | // Update audio stats for procedural sounds |
| 2170 | 2301 | #ifndef _WIN32 |
| @@ -2173,7 +2304,7 @@ void Application::update(float deltaTime) { · 2 unmodified lines | ||
| 2173 | 2304 | _audio.eventuallyAnalyzePing(); |
| 2174 | 2305 | #endif |
| 2175 | 2306 | |
| 2176 | − if (TESTING_PARTICLE_SYSTEM) { | |
| 2307 | + if (_renderParticleSystemOn->isChecked()) { | |
| 2177 | 2308 | updateParticleSystem(deltaTime); |
| 2178 | 2309 | } |
| 2179 | 2310 | } |
| @@ -2222,7 +2353,9 @@ void Application::updateAvatar(float deltaTime) { · 42 unmodified lines | ||
| 2222 | 2353 | _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); |
| 2223 | 2354 | |
| 2224 | 2355 | glm::vec3 eyePosition; |
| 2225 | − if (isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition)) { | |
| 2356 | + uint16_t ignored; | |
| 2357 | + _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition, ignored); | |
| 2358 | + if (_isLookingAtOtherAvatar) { | |
| 2226 | 2359 | glm::vec3 myLookAtFromMouse(eyePosition); |
| 2227 | 2360 | _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); |
| 2228 | 2361 | } |
| @@ -2620,10 +2753,13 @@ void Application::displaySide(Camera& whichCamera) { · 391 unmodified lines | ||
| 2620 | 2753 | _myAvatar.getHead().setLookAtPosition(_myCamera.getPosition()); |
| 2621 | 2754 | } |
| 2622 | 2755 | _myAvatar.render(_lookingInMirror->isChecked(), _renderAvatarBalls->isChecked()); |
| 2623 | − _myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked()); | |
| 2756 | + | |
| 2757 | + if (_renderLookatIndicatorOn->isChecked() && _isLookingAtOtherAvatar) { | |
| 2758 | + renderLookatIndicator(_lookatOtherPosition, whichCamera); | |
| 2759 | + } | |
| 2624 | 2760 | } |
| 2625 | 2761 | |
| 2626 | − if (TESTING_PARTICLE_SYSTEM) { | |
| 2762 | + if (_renderParticleSystemOn->isChecked()) { | |
| 2627 | 2763 | if (_particleSystemInitialized) { |
| 2628 | 2764 | _particleSystem.render(); |
| 2629 | 2765 | } |
| @@ -2813,27 +2949,19 @@ void Application::displayStats() { · 183 unmodified lines | ||
| 2813 | 2949 | drawtext(10, statsVerticalOffset + 230, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); |
| 2814 | 2950 | |
| 2815 | 2951 | voxelStats.str(""); |
| 2816 | − voxelStats << "Voxels Created: " << _voxels.getVoxelsCreated() / 1000.f << "K (" << _voxels.getVoxelsCreatedPerSecondAverage() / 1000.f | |
| 2817 | − << "Kps) "; | |
| 2952 | + char* voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_VOXELS); | |
| 2953 | + voxelStats << "Voxels Sent from Server: " << voxelDetails; | |
| 2818 | 2954 | drawtext(10, statsVerticalOffset + 250, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); |
| 2819 | − | |
| 2955 | + | |
| 2820 | 2956 | voxelStats.str(""); |
| 2821 | − voxelStats << "Voxels Colored: " << _voxels.getVoxelsColored() / 1000.f << "K (" << _voxels.getVoxelsColoredPerSecondAverage() / 1000.f | |
| 2822 | − << "Kps) "; | |
| 2957 | + voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ELAPSED); | |
| 2958 | + voxelStats << "Scene Send Time from Server: " << voxelDetails; | |
| 2823 | 2959 | drawtext(10, statsVerticalOffset + 270, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); |
| 2824 | − | |
| 2825 | − voxelStats.str(""); | |
| 2826 | − voxelStats << "Voxel Bits Read: " << _voxels.getVoxelsBytesRead() * 8.f / 1000000.f | |
| 2827 | − << "M (" << _voxels.getVoxelsBytesReadPerSecondAverage() * 8.f / 1000000.f << " Mbps)"; | |
| 2828 | − drawtext(10, statsVerticalOffset + 290,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); | |
| 2829 | 2960 | |
| 2830 | 2961 | voxelStats.str(""); |
| 2831 | − float voxelsBytesPerColored = _voxels.getVoxelsColored() | |
| 2832 | − ? ((float) _voxels.getVoxelsBytesRead() / _voxels.getVoxelsColored()) | |
| 2833 | − : 0; | |
| 2834 | − | |
| 2835 | − voxelStats << "Voxels Bits per Colored: " << voxelsBytesPerColored * 8; | |
| 2836 | − drawtext(10, statsVerticalOffset + 310, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); | |
| 2962 | + voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ENCODE); | |
| 2963 | + voxelStats << "Encode Time on Server: " << voxelDetails; | |
| 2964 | + drawtext(10, statsVerticalOffset + 290, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); | |
| 2837 | 2965 | |
| 2838 | 2966 | Node *avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); |
| 2839 | 2967 | char avatarMixerStats[200]; |
| @@ -3388,16 +3516,37 @@ void* Application::networkReceive(void* args) { · 548 unmodified lines | ||
| 3388 | 3516 | case PACKET_TYPE_VOXEL_DATA_MONOCHROME: |
| 3389 | 3517 | case PACKET_TYPE_Z_COMMAND: |
| 3390 | 3518 | case PACKET_TYPE_ERASE_VOXEL: |
| 3519 | + case PACKET_TYPE_VOXEL_STATS: | |
| 3391 | 3520 | case PACKET_TYPE_ENVIRONMENT_DATA: { |
| 3521 | + | |
| 3522 | + unsigned char* messageData = app->_incomingPacket; | |
| 3523 | + ssize_t messageLength = bytesReceived; | |
| 3524 | + | |
| 3525 | + // note: PACKET_TYPE_VOXEL_STATS can have PACKET_TYPE_VOXEL_DATA or PACKET_TYPE_VOXEL_DATA_MONOCHROME | |
| 3526 | + // immediately following them inside the same packet. So, we process the PACKET_TYPE_VOXEL_STATS first | |
| 3527 | + // then process any remaining bytes as if it was another packet | |
| 3528 | + if (messageData[0] == PACKET_TYPE_VOXEL_STATS) { | |
| 3529 | + int statsMessageLength = app->_voxelSceneStats.unpackFromMessage(messageData, messageLength); | |
| 3530 | + if (messageLength > statsMessageLength) { | |
| 3531 | + messageData += statsMessageLength; | |
| 3532 | + messageLength -= statsMessageLength; | |
| 3533 | + if (!packetVersionMatch(messageData)) { | |
| 3534 | + break; // bail since piggyback data doesn't match our versioning | |
| 3535 | + } | |
| 3536 | + } else { | |
| 3537 | + break; // bail since no piggyback data | |
| 3538 | + } | |
| 3539 | + } // fall through to piggyback message | |
| 3540 | + | |
| 3392 | 3541 | if (app->_renderVoxels->isChecked()) { |
| 3393 | 3542 | Node* voxelServer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_VOXEL_SERVER); |
| 3394 | 3543 | if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) { |
| 3395 | 3544 | voxelServer->lock(); |
| 3396 | 3545 | |
| 3397 | − if (app->_incomingPacket[0] == PACKET_TYPE_ENVIRONMENT_DATA) { | |
| 3398 | − app->_environment.parseData(&senderAddress, app->_incomingPacket, bytesReceived); | |
| 3546 | + if (messageData[0] == PACKET_TYPE_ENVIRONMENT_DATA) { | |
| 3547 | + app->_environment.parseData(&senderAddress, messageData, messageLength); | |
| 3399 | 3548 | } else { |
| 3400 | − app->_voxels.parseData(app->_incomingPacket, bytesReceived); | |
| 3549 | + app->_voxels.parseData(messageData, messageLength); | |
| 3401 | 3550 | } |
| 3402 | 3551 | |
| 3403 | 3552 | voxelServer->unlock(); |
| @@ -3414,6 +3563,9 @@ void* Application::networkReceive(void* args) { · 10 unmodified lines | ||
| 3414 | 3563 | case PACKET_TYPE_AVATAR_VOXEL_URL: |
| 3415 | 3564 | processAvatarVoxelURLMessage(app->_incomingPacket, bytesReceived); |
| 3416 | 3565 | break; |
| 3566 | + case PACKET_TYPE_AVATAR_FACE_VIDEO: | |
| 3567 | + processAvatarFaceVideoMessage(app->_incomingPacket, bytesReceived); | |
| 3568 | + break; | |
| 3417 | 3569 | default: |
| 3418 | 3570 | NodeList::getInstance()->processNodeData(&senderAddress, app->_incomingPacket, bytesReceived); |
| 3419 | 3571 | break; |
| @@ -3495,7 +3647,7 @@ void Application::saveSettings(QSettings* settings) { · 75 unmodified lines | ||
| 3495 | 3647 | if (!settings) { |
| 3496 | 3648 | settings = getSettings(); |
| 3497 | 3649 | } |
| 3498 | − | |
| 3650 | + | |
| 3499 | 3651 | settings->setValue("headCameraPitchYawScale", _headCameraPitchYawScale); |
| 3500 | 3652 | settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples); |
| 3501 | 3653 | settings->setValue("horizontalFieldOfView", _horizontalFieldOfView); |
| @@ -3510,6 +3662,9 @@ void Application::saveSettings(QSettings* settings) { · 8 unmodified lines | ||
| 3510 | 3662 | scanMenuBar(&Application::saveAction, settings); |
| 3511 | 3663 | getAvatar()->saveData(settings); |
| 3512 | 3664 | _swatch.saveData(settings); |
| 3665 | + | |
| 3666 | + // ask the NodeList to save its data | |
| 3667 | + NodeList::getInstance()->saveData(settings); | |
| 3513 | 3668 | } |
| 3514 | 3669 | |
| 3515 | 3670 | void Application::importSettings() { |