Showing the changes to interface/src/Application.cpp (1 of 304 files). Show all
Unified · Split
| @@ -5,10 +5,16 @@ · 4 unmodified lines | |||
| 5 | // Created by Andrzej Kapolka on 5/10/13. | 5 | // Created by Andrzej Kapolka on 5/10/13. |
| 6 | // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. | 6 | // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. |
| 7 | 7 | ||
| 8 | #ifdef WIN32 | ||
| 9 | #include <Systime.h> | ||
| 10 | #endif | ||
| 11 | |||
| 8 | #include <sstream> | 12 | #include <sstream> |
| 9 | 13 | ||
| 10 | #include <stdlib.h> | 14 | #include <stdlib.h> |
| 11 | #include <cmath> | 15 | #include <cmath> |
| 16 | #include <math.h> | ||
| 17 | |||
| 12 | 18 | ||
| 13 | #include <glm/gtx/component_wise.hpp> | 19 | #include <glm/gtx/component_wise.hpp> |
| 14 | #include <glm/gtx/quaternion.hpp> | 20 | #include <glm/gtx/quaternion.hpp> |
| @@ -130,7 +136,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 115 unmodified lines | |||
| 130 | _lookingAwayFromOrigin(true), | 136 | _lookingAwayFromOrigin(true), |
| 131 | _lookatTargetAvatar(NULL), | 137 | _lookatTargetAvatar(NULL), |
| 132 | _lookatIndicatorScale(1.0f), | 138 | _lookatIndicatorScale(1.0f), |
| 133 | _perfStatsOn(false), | ||
| 134 | _chatEntryOn(false), | 139 | _chatEntryOn(false), |
| 135 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), | 140 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), |
| 136 | _enableProcessVoxelsThread(true), | 141 | _enableProcessVoxelsThread(true), |
| @@ -168,7 +173,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 31 unmodified lines | |||
| 168 | } | 173 | } |
| 169 | 174 | ||
| 170 | NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort); | 175 | NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort); |
| 171 | 176 | ||
| 172 | // connect our processDatagrams slot to the QUDPSocket readyRead() signal | 177 | // connect our processDatagrams slot to the QUDPSocket readyRead() signal |
| 173 | connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(processDatagrams())); | 178 | connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(processDatagrams())); |
| 174 | 179 | ||
| @@ -179,7 +184,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 4 unmodified lines | |||
| 179 | connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); | 184 | connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); |
| 180 | 185 | ||
| 181 | audioThread->start(); | 186 | audioThread->start(); |
| 182 | 187 | ||
| 183 | connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&))); | 188 | connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&))); |
| 184 | 189 | ||
| 185 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); | 190 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); |
| @@ -216,7 +221,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 30 unmodified lines | |||
| 216 | #endif | 221 | #endif |
| 217 | 222 | ||
| 218 | // tell the NodeList instance who to tell the domain server we care about | 223 | // tell the NodeList instance who to tell the domain server we care about |
| 219 | const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER, | 224 | const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER, |
| 220 | NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER}; | 225 | NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER}; |
| 221 | nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); | 226 | nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); |
| 222 | 227 | ||
| @@ -323,11 +328,21 @@ void Application::initializeGL() { · 100 unmodified lines | |||
| 323 | glutInit(&argc, 0); | 328 | glutInit(&argc, 0); |
| 324 | #endif | 329 | #endif |
| 325 | 330 | ||
| 331 | #ifdef WIN32 | ||
| 332 | GLenum err = glewInit(); | ||
| 333 | if (GLEW_OK != err) { | ||
| 334 | /* Problem: glewInit failed, something is seriously wrong. */ | ||
| 335 | qDebug("Error: %s\n", glewGetErrorString(err)); | ||
| 336 | } | ||
| 337 | qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); | ||
| 338 | #endif | ||
| 339 | |||
| 340 | |||
| 326 | // Before we render anything, let's set up our viewFrustumOffsetCamera with a sufficiently large | 341 | // Before we render anything, let's set up our viewFrustumOffsetCamera with a sufficiently large |
| 327 | // field of view and near and far clip to make it interesting. | 342 | // field of view and near and far clip to make it interesting. |
| 328 | //viewFrustumOffsetCamera.setFieldOfView(90.0); | 343 | //viewFrustumOffsetCamera.setFieldOfView(90.0); |
| 329 | _viewFrustumOffsetCamera.setNearClip(0.1); | 344 | _viewFrustumOffsetCamera.setNearClip(0.1f); |
| 330 | _viewFrustumOffsetCamera.setFarClip(500.0 * TREE_SCALE); | 345 | _viewFrustumOffsetCamera.setFarClip(500.0f * TREE_SCALE); |
| 331 | 346 | ||
| 332 | initDisplay(); | 347 | initDisplay(); |
| 333 | qDebug( "Initialized Display."); | 348 | qDebug( "Initialized Display."); |
| @@ -461,7 +476,7 @@ void Application::paintGL() { · 127 unmodified lines | |||
| 461 | bool eyeRelativeCamera = false; | 476 | bool eyeRelativeCamera = false; |
| 462 | if (_rearMirrorTools->getZoomLevel() == BODY) { | 477 | if (_rearMirrorTools->getZoomLevel() == BODY) { |
| 463 | _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar.getScale()); | 478 | _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar.getScale()); |
| 464 | _mirrorCamera.setTargetPosition(_myAvatar.getChestJointPosition()); | 479 | _mirrorCamera.setTargetPosition(_myAvatar.getChestPosition()); |
| 465 | } else { // HEAD zoom level | 480 | } else { // HEAD zoom level |
| 466 | _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar.getScale()); | 481 | _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar.getScale()); |
| 467 | if (_myAvatar.getSkeletonModel().isActive() && _myAvatar.getHead().getFaceModel().isActive()) { | 482 | if (_myAvatar.getSkeletonModel().isActive() && _myAvatar.getHead().getFaceModel().isActive()) { |
| @@ -1288,38 +1303,6 @@ void Application::sendPingPackets() { · 820 unmodified lines | |||
| 1288 | nodesToPing, sizeof(nodesToPing)); | 1303 | nodesToPing, sizeof(nodesToPing)); |
| 1289 | } | 1304 | } |
| 1290 | 1305 | ||
| 1291 | void Application::sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data) { | ||
| 1292 | unsigned char packet[MAX_PACKET_SIZE]; | ||
| 1293 | unsigned char* packetPosition = packet; | ||
| 1294 | |||
| 1295 | packetPosition += populateTypeAndVersion(packetPosition, PACKET_TYPE_AVATAR_FACE_VIDEO); | ||
| 1296 | |||
| 1297 | QByteArray rfcUUID = NodeList::getInstance()->getOwnerUUID().toRfc4122(); | ||
| 1298 | memcpy(packetPosition, rfcUUID.constData(), rfcUUID.size()); | ||
| 1299 | packetPosition += rfcUUID.size(); | ||
| 1300 | |||
| 1301 | *(uint32_t*)packetPosition = frameCount; | ||
| 1302 | packetPosition += sizeof(uint32_t); | ||
| 1303 | |||
| 1304 | *(uint32_t*)packetPosition = data.size(); | ||
| 1305 | packetPosition += sizeof(uint32_t); | ||
| 1306 | |||
| 1307 | uint32_t* offsetPosition = (uint32_t*)packetPosition; | ||
| 1308 | packetPosition += sizeof(uint32_t); | ||
| 1309 | |||
| 1310 | int headerSize = packetPosition - packet; | ||
| 1311 | |||
| 1312 | // break the data up into submessages of the maximum size (at least one, for zero-length packets) | ||
| 1313 | *offsetPosition = 0; | ||
| 1314 | do { | ||
| 1315 | int payloadSize = min(data.size() - (int)*offsetPosition, MAX_PACKET_SIZE - headerSize); | ||
| 1316 | memcpy(packetPosition, data.constData() + *offsetPosition, payloadSize); | ||
| 1317 | getInstance()->controlledBroadcastToNodes(packet, headerSize + payloadSize, &NODE_TYPE_AVATAR_MIXER, 1); | ||
| 1318 | *offsetPosition += payloadSize; | ||
| 1319 | |||
| 1320 | } while (*offsetPosition < data.size()); | ||
| 1321 | } | ||
| 1322 | |||
| 1323 | // Every second, check the frame rates and other stuff | 1306 | // Every second, check the frame rates and other stuff |
| 1324 | void Application::timer() { | 1307 | void Application::timer() { |
| 1325 | gettimeofday(&_timerEnd, NULL); | 1308 | gettimeofday(&_timerEnd, NULL); |
| @@ -1362,6 +1345,7 @@ static glm::vec3 getFaceVector(BoxFace face) { · 36 unmodified lines | |||
| 1362 | case MIN_Z_FACE: | 1345 | case MIN_Z_FACE: |
| 1363 | return glm::vec3(0, 0, -1); | 1346 | return glm::vec3(0, 0, -1); |
| 1364 | 1347 | ||
| 1348 | default: // quiet windows warnings | ||
| 1365 | case MAX_Z_FACE: | 1349 | case MAX_Z_FACE: |
| 1366 | return glm::vec3(0, 0, 1); | 1350 | return glm::vec3(0, 0, 1); |
| 1367 | } | 1351 | } |
| @@ -1419,13 +1403,15 @@ void Application::terminate() { · 51 unmodified lines | |||
| 1419 | // let the avatar mixer know we're out | 1403 | // let the avatar mixer know we're out |
| 1420 | NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1); | 1404 | NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1); |
| 1421 | 1405 | ||
| 1422 | printf(""); | ||
| 1423 | _voxelProcessor.terminate(); | 1406 | _voxelProcessor.terminate(); |
| 1424 | _voxelHideShowThread.terminate(); | 1407 | _voxelHideShowThread.terminate(); |
| 1425 | _voxelEditSender.terminate(); | 1408 | _voxelEditSender.terminate(); |
| 1426 | _particleEditSender.terminate(); | 1409 | _particleEditSender.terminate(); |
| 1427 | _persistThread->terminate(); | 1410 | if (_persistThread) { |
| 1428 | _persistThread = NULL; | 1411 | _persistThread->terminate(); |
| 1412 | _persistThread->deleteLater(); | ||
| 1413 | _persistThread = NULL; | ||
| 1414 | } | ||
| 1429 | } | 1415 | } |
| 1430 | 1416 | ||
| 1431 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { | 1417 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { |
| @@ -1477,14 +1463,6 @@ void Application::processAvatarURLsMessage(unsigned char* packetData, size_t dat · 45 unmodified lines | |||
| 1477 | avatar->getUUID()); | 1463 | avatar->getUUID()); |
| 1478 | } | 1464 | } |
| 1479 | 1465 | ||
| 1480 | void Application::processAvatarFaceVideoMessage(unsigned char* packetData, size_t dataBytes) { | ||
| 1481 | Avatar* avatar = processAvatarMessageHeader(packetData, dataBytes); | ||
| 1482 | if (!avatar) { | ||
| 1483 | return; | ||
| 1484 | } | ||
| 1485 | avatar->getHead().getVideoFace().processVideoMessage(packetData, dataBytes); | ||
| 1486 | } | ||
| 1487 | |||
| 1488 | void Application::checkBandwidthMeterClick() { | 1466 | void Application::checkBandwidthMeterClick() { |
| 1489 | // ... to be called upon button release | 1467 | // ... to be called upon button release |
| 1490 | 1468 | ||
| @@ -1504,6 +1482,11 @@ void Application::setFullscreen(bool fullscreen) { · 13 unmodified lines | |||
| 1504 | (_window->windowState() & ~Qt::WindowFullScreen)); | 1482 | (_window->windowState() & ~Qt::WindowFullScreen)); |
| 1505 | } | 1483 | } |
| 1506 | 1484 | ||
| 1485 | void Application::setEnable3DTVMode(bool enable3DTVMode) { | ||
| 1486 | resizeGL(_glWidget->width(),_glWidget->height()); | ||
| 1487 | } | ||
| 1488 | |||
| 1489 | |||
| 1507 | void Application::setRenderVoxels(bool voxelRender) { | 1490 | void Application::setRenderVoxels(bool voxelRender) { |
| 1508 | _voxelEditSender.setShouldSend(voxelRender); | 1491 | _voxelEditSender.setShouldSend(voxelRender); |
| 1509 | if (!voxelRender) { | 1492 | if (!voxelRender) { |
| @@ -1953,7 +1936,7 @@ void Application::shrinkMirrorView() { · 443 unmodified lines | |||
| 1953 | 1936 | ||
| 1954 | const float MAX_AVATAR_EDIT_VELOCITY = 1.0f; | 1937 | const float MAX_AVATAR_EDIT_VELOCITY = 1.0f; |
| 1955 | const float MAX_VOXEL_EDIT_DISTANCE = 50.0f; | 1938 | const float MAX_VOXEL_EDIT_DISTANCE = 50.0f; |
| 1956 | const float HEAD_SPHERE_RADIUS = 0.07; | 1939 | const float HEAD_SPHERE_RADIUS = 0.07f; |
| 1957 | 1940 | ||
| 1958 | static QUuid DEFAULT_NODE_ID_REF; | 1941 | static QUuid DEFAULT_NODE_ID_REF; |
| 1959 | 1942 | ||
| @@ -1974,12 +1957,12 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 14 unmodified lines | |||
| 1974 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | 1957 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 1975 | Avatar* avatar = (Avatar*)node->getLinkedData(); | 1958 | Avatar* avatar = (Avatar*)node->getLinkedData(); |
| 1976 | float distance; | 1959 | float distance; |
| 1977 | 1960 | ||
| 1978 | if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) { | 1961 | if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) { |
| 1979 | // rescale to compensate for head embiggening | 1962 | // rescale to compensate for head embiggening |
| 1980 | eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * | 1963 | eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * |
| 1981 | (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); | 1964 | (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); |
| 1982 | 1965 | ||
| 1983 | _lookatIndicatorScale = avatar->getHead().getScale(); | 1966 | _lookatIndicatorScale = avatar->getHead().getScale(); |
| 1984 | _lookatOtherPosition = avatar->getHead().getPosition(); | 1967 | _lookatOtherPosition = avatar->getHead().getPosition(); |
| 1985 | nodeUUID = avatar->getOwningNode()->getUUID(); | 1968 | nodeUUID = avatar->getOwningNode()->getUUID(); |
| @@ -1987,7 +1970,7 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 1 unmodified line | |||
| 1987 | } | 1970 | } |
| 1988 | } | 1971 | } |
| 1989 | } | 1972 | } |
| 1990 | 1973 | ||
| 1991 | return NULL; | 1974 | return NULL; |
| 1992 | } | 1975 | } |
| 1993 | 1976 | ||
| @@ -2029,7 +2012,7 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { · 35 unmodified lines | |||
| 2029 | void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) { | 2012 | void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) { |
| 2030 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2013 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2031 | PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); | 2014 | PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); |
| 2032 | 2015 | ||
| 2033 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { | 2016 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 2034 | QMutexLocker(&node->getMutex()); | 2017 | QMutexLocker(&node->getMutex()); |
| 2035 | if (node->getLinkedData()) { | 2018 | if (node->getLinkedData()) { |
| @@ -2046,11 +2029,11 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 10 unmodified lines | |||
| 2046 | for (vector<Avatar*>::iterator fade = _avatarFades.begin(); fade != _avatarFades.end(); fade++) { | 2029 | for (vector<Avatar*>::iterator fade = _avatarFades.begin(); fade != _avatarFades.end(); fade++) { |
| 2047 | Avatar* avatar = *fade; | 2030 | Avatar* avatar = *fade; |
| 2048 | const float SHRINK_RATE = 0.9f; | 2031 | const float SHRINK_RATE = 0.9f; |
| 2049 | 2032 | ||
| 2050 | avatar->setTargetScale(avatar->getScale() * SHRINK_RATE); | 2033 | avatar->setTargetScale(avatar->getScale() * SHRINK_RATE); |
| 2051 | 2034 | ||
| 2052 | const float MIN_FADE_SCALE = 0.001; | 2035 | const float MIN_FADE_SCALE = 0.001f; |
| 2053 | 2036 | ||
| 2054 | if (avatar->getTargetScale() < MIN_FADE_SCALE) { | 2037 | if (avatar->getTargetScale() < MIN_FADE_SCALE) { |
| 2055 | delete avatar; | 2038 | delete avatar; |
| 2056 | _avatarFades.erase(fade--); | 2039 | _avatarFades.erase(fade--); |
| @@ -2105,17 +2088,23 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 48 unmodified lines | |||
| 2105 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2088 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2106 | PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()"); | 2089 | PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()"); |
| 2107 | 2090 | ||
| 2091 | const float FAR_AWAY_STARE = TREE_SCALE; | ||
| 2108 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | 2092 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 2109 | lookAtSpot = _myCamera.getPosition(); | 2093 | lookAtSpot = _myCamera.getPosition(); |
| 2110 | 2094 | ||
| 2095 | } else if (_mouseHidden) { | ||
| 2096 | // if the mouse cursor is hidden, just look straight ahead | ||
| 2097 | glm::vec3 rayOrigin, rayDirection; | ||
| 2098 | _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection); | ||
| 2099 | lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE; | ||
| 2100 | |||
| 2111 | } else if (!_lookatTargetAvatar) { | 2101 | } else if (!_lookatTargetAvatar) { |
| 2112 | if (_isHoverVoxel) { | 2102 | if (_isHoverVoxel) { |
| 2113 | // Look at the hovered voxel | 2103 | // Look at the hovered voxel |
| 2114 | lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel); | 2104 | lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel); |
| 2115 | 2105 | ||
| 2116 | } else { | 2106 | } else { |
| 2117 | // Just look in direction of the mouse ray | 2107 | // Just look in direction of the mouse ray |
| 2118 | const float FAR_AWAY_STARE = TREE_SCALE; | ||
| 2119 | lookAtSpot = lookAtRayOrigin + lookAtRayDirection * FAR_AWAY_STARE; | 2108 | lookAtSpot = lookAtRayOrigin + lookAtRayDirection * FAR_AWAY_STARE; |
| 2120 | } | 2109 | } |
| 2121 | } | 2110 | } |
| @@ -2268,6 +2257,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 146 unmodified lines | |||
| 2268 | } | 2257 | } |
| 2269 | } | 2258 | } |
| 2270 | 2259 | ||
| 2260 | |||
| 2271 | void Application::updateHandAndTouch(float deltaTime) { | 2261 | void Application::updateHandAndTouch(float deltaTime) { |
| 2272 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2262 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2273 | PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()"); | 2263 | PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()"); |
| @@ -2311,7 +2301,9 @@ void Application::updateThreads(float deltaTime) { · 37 unmodified lines | |||
| 2311 | _voxelHideShowThread.threadRoutine(); | 2301 | _voxelHideShowThread.threadRoutine(); |
| 2312 | _voxelEditSender.threadRoutine(); | 2302 | _voxelEditSender.threadRoutine(); |
| 2313 | _particleEditSender.threadRoutine(); | 2303 | _particleEditSender.threadRoutine(); |
| 2314 | _persistThread->threadRoutine(); | 2304 | if (_persistThread) { |
| 2305 | _persistThread->threadRoutine(); | ||
| 2306 | } | ||
| 2315 | } | 2307 | } |
| 2316 | } | 2308 | } |
| 2317 | 2309 | ||
| @@ -2357,7 +2349,7 @@ void Application::updateTransmitter(float deltaTime) { · 39 unmodified lines | |||
| 2357 | 2349 | ||
| 2358 | // no transmitter drive implies transmitter pick | 2350 | // no transmitter drive implies transmitter pick |
| 2359 | if (!Menu::getInstance()->isOptionChecked(MenuOption::TransmitterDrive) && _myTransmitter.isConnected()) { | 2351 | if (!Menu::getInstance()->isOptionChecked(MenuOption::TransmitterDrive) && _myTransmitter.isConnected()) { |
| 2360 | _transmitterPickStart = _myAvatar.getSkeleton().joint[AVATAR_JOINT_CHEST].position; | 2352 | _transmitterPickStart = _myAvatar.getChestPosition(); |
| 2361 | glm::vec3 direction = _myAvatar.getOrientation() * | 2353 | glm::vec3 direction = _myAvatar.getOrientation() * |
| 2362 | glm::quat(glm::radians(_myTransmitter.getEstimatedRotation())) * IDENTITY_FRONT; | 2354 | glm::quat(glm::radians(_myTransmitter.getEstimatedRotation())) * IDENTITY_FRONT; |
| 2363 | 2355 | ||
| @@ -2406,12 +2398,6 @@ void Application::updateCamera(float deltaTime) { · 42 unmodified lines | |||
| 2406 | glm::vec3 position = _faceshift.getHeadTranslation() * EYE_OFFSET_SCALE; | 2398 | glm::vec3 position = _faceshift.getHeadTranslation() * EYE_OFFSET_SCALE; |
| 2407 | _myCamera.setEyeOffsetPosition(glm::vec3(position.x * xSign, position.y, -position.z)); | 2399 | _myCamera.setEyeOffsetPosition(glm::vec3(position.x * xSign, position.y, -position.z)); |
| 2408 | updateProjectionMatrix(); | 2400 | updateProjectionMatrix(); |
| 2409 | |||
| 2410 | } else if (_webcam.isActive()) { | ||
| 2411 | const float EYE_OFFSET_SCALE = 0.5f; | ||
| 2412 | glm::vec3 position = _webcam.getEstimatedPosition() * EYE_OFFSET_SCALE; | ||
| 2413 | _myCamera.setEyeOffsetPosition(glm::vec3(position.x * xSign, -position.y, position.z)); | ||
| 2414 | updateProjectionMatrix(); | ||
| 2415 | } | 2401 | } |
| 2416 | } | 2402 | } |
| 2417 | } | 2403 | } |
| @@ -2523,8 +2509,8 @@ void Application::updateAvatar(float deltaTime) { · 105 unmodified lines | |||
| 2523 | _myAvatar.getHand().setPitchUpdate(0.f); | 2509 | _myAvatar.getHand().setPitchUpdate(0.f); |
| 2524 | _pitchFromTouch = 0.0f; | 2510 | _pitchFromTouch = 0.0f; |
| 2525 | 2511 | ||
| 2526 | // Update my avatar's state from gyros and/or webcam | 2512 | // Update my avatar's state from gyros |
| 2527 | _myAvatar.updateFromGyrosAndOrWebcam(Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead)); | 2513 | _myAvatar.updateFromGyros(Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead)); |
| 2528 | 2514 | ||
| 2529 | // Update head mouse from faceshift if active | 2515 | // Update head mouse from faceshift if active |
| 2530 | if (_faceshift.isActive()) { | 2516 | if (_faceshift.isActive()) { |
| @@ -2621,32 +2607,32 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 90 unmodified lines | |||
| 2621 | int totalServers = 0; | 2607 | int totalServers = 0; |
| 2622 | int inViewServers = 0; | 2608 | int inViewServers = 0; |
| 2623 | int unknownJurisdictionServers = 0; | 2609 | int unknownJurisdictionServers = 0; |
| 2624 | 2610 | ||
| 2625 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { | 2611 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 2626 | // only send to the NodeTypes that are serverType | 2612 | // only send to the NodeTypes that are serverType |
| 2627 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { | 2613 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { |
| 2628 | totalServers++; | 2614 | totalServers++; |
| 2629 | 2615 | ||
| 2630 | // get the server bounds for this server | 2616 | // get the server bounds for this server |
| 2631 | QUuid nodeUUID = node->getUUID(); | 2617 | QUuid nodeUUID = node->getUUID(); |
| 2632 | 2618 | ||
| 2633 | // if we haven't heard from this voxel server, go ahead and send it a query, so we | 2619 | // if we haven't heard from this voxel server, go ahead and send it a query, so we |
| 2634 | // can get the jurisdiction... | 2620 | // can get the jurisdiction... |
| 2635 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { | 2621 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { |
| 2636 | unknownJurisdictionServers++; | 2622 | unknownJurisdictionServers++; |
| 2637 | } else { | 2623 | } else { |
| 2638 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; | 2624 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; |
| 2639 | 2625 | ||
| 2640 | unsigned char* rootCode = map.getRootOctalCode(); | 2626 | unsigned char* rootCode = map.getRootOctalCode(); |
| 2641 | 2627 | ||
| 2642 | if (rootCode) { | 2628 | if (rootCode) { |
| 2643 | VoxelPositionSize rootDetails; | 2629 | VoxelPositionSize rootDetails; |
| 2644 | voxelDetailsForCode(rootCode, rootDetails); | 2630 | voxelDetailsForCode(rootCode, rootDetails); |
| 2645 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); | 2631 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); |
| 2646 | serverBounds.scale(TREE_SCALE); | 2632 | serverBounds.scale(TREE_SCALE); |
| 2647 | 2633 | ||
| 2648 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); | 2634 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); |
| 2649 | 2635 | ||
| 2650 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { | 2636 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { |
| 2651 | inViewServers++; | 2637 | inViewServers++; |
| 2652 | } | 2638 | } |
| @@ -2679,20 +2665,20 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 26 unmodified lines | |||
| 2679 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { | 2665 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { |
| 2680 | qDebug("perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer); | 2666 | qDebug("perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer); |
| 2681 | } | 2667 | } |
| 2682 | 2668 | ||
| 2683 | NodeList* nodeList = NodeList::getInstance(); | 2669 | NodeList* nodeList = NodeList::getInstance(); |
| 2684 | 2670 | ||
| 2685 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { | 2671 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { |
| 2686 | // only send to the NodeTypes that are serverType | 2672 | // only send to the NodeTypes that are serverType |
| 2687 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { | 2673 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { |
| 2688 | 2674 | ||
| 2689 | 2675 | ||
| 2690 | // get the server bounds for this server | 2676 | // get the server bounds for this server |
| 2691 | QUuid nodeUUID = node->getUUID(); | 2677 | QUuid nodeUUID = node->getUUID(); |
| 2692 | 2678 | ||
| 2693 | bool inView = false; | 2679 | bool inView = false; |
| 2694 | bool unknownView = false; | 2680 | bool unknownView = false; |
| 2695 | 2681 | ||
| 2696 | // if we haven't heard from this voxel server, go ahead and send it a query, so we | 2682 | // if we haven't heard from this voxel server, go ahead and send it a query, so we |
| 2697 | // can get the jurisdiction... | 2683 | // can get the jurisdiction... |
| 2698 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { | 2684 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { |
| @@ -2702,15 +2688,15 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 3 unmodified lines | |||
| 2702 | } | 2688 | } |
| 2703 | } else { | 2689 | } else { |
| 2704 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; | 2690 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; |
| 2705 | 2691 | ||
| 2706 | unsigned char* rootCode = map.getRootOctalCode(); | 2692 | unsigned char* rootCode = map.getRootOctalCode(); |
| 2707 | 2693 | ||
| 2708 | if (rootCode) { | 2694 | if (rootCode) { |
| 2709 | VoxelPositionSize rootDetails; | 2695 | VoxelPositionSize rootDetails; |
| 2710 | voxelDetailsForCode(rootCode, rootDetails); | 2696 | voxelDetailsForCode(rootCode, rootDetails); |
| 2711 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); | 2697 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); |
| 2712 | serverBounds.scale(TREE_SCALE); | 2698 | serverBounds.scale(TREE_SCALE); |
| 2713 | 2699 | ||
| 2714 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); | 2700 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); |
| 2715 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { | 2701 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { |
| 2716 | inView = true; | 2702 | inView = true; |
| @@ -2723,7 +2709,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 6 unmodified lines | |||
| 2723 | } | 2709 | } |
| 2724 | } | 2710 | } |
| 2725 | } | 2711 | } |
| 2726 | 2712 | ||
| 2727 | if (inView) { | 2713 | if (inView) { |
| 2728 | _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS); | 2714 | _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS); |
| 2729 | } else if (unknownView) { | 2715 | } else if (unknownView) { |
| @@ -2731,7 +2717,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 1 unmodified line | |||
| 2731 | qDebug() << "no known jurisdiction for node " << *node << ", give it budget of " | 2717 | qDebug() << "no known jurisdiction for node " << *node << ", give it budget of " |
| 2732 | << perUnknownServer << " to send us jurisdiction."; | 2718 | << perUnknownServer << " to send us jurisdiction."; |
| 2733 | } | 2719 | } |
| 2734 | 2720 | ||
| 2735 | // set the query's position/orientation to be degenerate in a manner that will get the scene quickly | 2721 | // set the query's position/orientation to be degenerate in a manner that will get the scene quickly |
| 2736 | // If there's only one server, then don't do this, and just let the normal voxel query pass through | 2722 | // If there's only one server, then don't do this, and just let the normal voxel query pass through |
| 2737 | // as expected... this way, we will actually get a valid scene if there is one to be seen | 2723 | // as expected... this way, we will actually get a valid scene if there is one to be seen |
| @@ -2739,8 +2725,8 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 1 unmodified line | |||
| 2739 | _voxelQuery.setCameraPosition(glm::vec3(-0.1,-0.1,-0.1)); | 2725 | _voxelQuery.setCameraPosition(glm::vec3(-0.1,-0.1,-0.1)); |
| 2740 | const glm::quat OFF_IN_NEGATIVE_SPACE = glm::quat(-0.5, 0, -0.5, 1.0); | 2726 | const glm::quat OFF_IN_NEGATIVE_SPACE = glm::quat(-0.5, 0, -0.5, 1.0); |
| 2741 | _voxelQuery.setCameraOrientation(OFF_IN_NEGATIVE_SPACE); | 2727 | _voxelQuery.setCameraOrientation(OFF_IN_NEGATIVE_SPACE); |
| 2742 | _voxelQuery.setCameraNearClip(0.1); | 2728 | _voxelQuery.setCameraNearClip(0.1f); |
| 2743 | _voxelQuery.setCameraFarClip(0.1); | 2729 | _voxelQuery.setCameraFarClip(0.1f); |
| 2744 | if (wantExtraDebugging) { | 2730 | if (wantExtraDebugging) { |
| 2745 | qDebug() << "Using 'minimal' camera position for node" << *node; | 2731 | qDebug() << "Using 'minimal' camera position for node" << *node; |
| 2746 | } | 2732 | } |
| @@ -2755,24 +2741,24 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 8 unmodified lines | |||
| 2755 | } | 2741 | } |
| 2756 | // set up the packet for sending... | 2742 | // set up the packet for sending... |
| 2757 | unsigned char* endOfVoxelQueryPacket = voxelQueryPacket; | 2743 | unsigned char* endOfVoxelQueryPacket = voxelQueryPacket; |
| 2758 | 2744 | ||
| 2759 | // insert packet type/version and node UUID | 2745 | // insert packet type/version and node UUID |
| 2760 | endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType); | 2746 | endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType); |
| 2761 | QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); | 2747 | QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); |
| 2762 | memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size()); | 2748 | memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size()); |
| 2763 | endOfVoxelQueryPacket += ownerUUID.size(); | 2749 | endOfVoxelQueryPacket += ownerUUID.size(); |
| 2764 | 2750 | ||
| 2765 | // encode the query data... | 2751 | // encode the query data... |
| 2766 | endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket); | 2752 | endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket); |
| 2767 | 2753 | ||
| 2768 | int packetLength = endOfVoxelQueryPacket - voxelQueryPacket; | 2754 | int packetLength = endOfVoxelQueryPacket - voxelQueryPacket; |
| 2769 | 2755 | ||
| 2770 | // make sure we still have an active socket | 2756 | // make sure we still have an active socket |
| 2771 | if (node->getActiveSocket()) { | 2757 | if (node->getActiveSocket()) { |
| 2772 | nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength, | 2758 | nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength, |
| 2773 | node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort()); | 2759 | node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort()); |
| 2774 | } | 2760 | } |
| 2775 | 2761 | ||
| 2776 | // Feed number of bytes to corresponding channel of the bandwidth meter | 2762 | // Feed number of bytes to corresponding channel of the bandwidth meter |
| 2777 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength); | 2763 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength); |
| 2778 | } | 2764 | } |
| @@ -2898,9 +2884,9 @@ void Application::setupWorldLight() { · 119 unmodified lines | |||
| 2898 | glm::vec3 sunDirection = getSunDirection(); | 2884 | glm::vec3 sunDirection = getSunDirection(); |
| 2899 | GLfloat light_position0[] = { sunDirection.x, sunDirection.y, sunDirection.z, 0.0 }; | 2885 | GLfloat light_position0[] = { sunDirection.x, sunDirection.y, sunDirection.z, 0.0 }; |
| 2900 | glLightfv(GL_LIGHT0, GL_POSITION, light_position0); | 2886 | glLightfv(GL_LIGHT0, GL_POSITION, light_position0); |
| 2901 | GLfloat ambient_color[] = { 0.7, 0.7, 0.8 }; | 2887 | GLfloat ambient_color[] = { 0.7f, 0.7f, 0.8f }; |
| 2902 | glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color); | 2888 | glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color); |
| 2903 | GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 }; | 2889 | GLfloat diffuse_color[] = { 0.8f, 0.7f, 0.7f }; |
| 2904 | glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color); | 2890 | glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color); |
| 2905 | 2891 | ||
| 2906 | glLightfv(GL_LIGHT0, GL_SPECULAR, WHITE_SPECULAR_COLOR); | 2892 | glLightfv(GL_LIGHT0, GL_SPECULAR, WHITE_SPECULAR_COLOR); |
| @@ -2981,7 +2967,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 74 unmodified lines | |||
| 2981 | glEnable(GL_DEPTH_TEST); | 2967 | glEnable(GL_DEPTH_TEST); |
| 2982 | 2968 | ||
| 2983 | // Enable to show line from me to the voxel I am touching | 2969 | // Enable to show line from me to the voxel I am touching |
| 2984 | //renderLineToTouchedVoxel(); | ||
| 2985 | //renderThrustAtVoxel(_voxelThrust); | 2970 | //renderThrustAtVoxel(_voxelThrust); |
| 2986 | 2971 | ||
| 2987 | if (!selfAvatarOnly) { | 2972 | if (!selfAvatarOnly) { |
| @@ -3161,10 +3146,10 @@ void Application::loadTranslatedViewMatrix(const glm::vec3& translation) { · 173 unmodified lines | |||
| 3161 | translation.z + _viewMatrixTranslation.z); | 3146 | translation.z + _viewMatrixTranslation.z); |
| 3162 | } | 3147 | } |
| 3163 | 3148 | ||
| 3164 | void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near, | 3149 | void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal, |
| 3165 | float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const { | 3150 | float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const { |
| 3166 | 3151 | ||
| 3167 | _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, near, far, nearClipPlane, farClipPlane); | 3152 | _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); |
| 3168 | } | 3153 | } |
| 3169 | 3154 | ||
| 3170 | void Application::displayOverlay() { | 3155 | void Application::displayOverlay() { |
| @@ -3252,13 +3237,13 @@ void Application::displayOverlay() { · 81 unmodified lines | |||
| 3252 | char nodes[100]; | 3237 | char nodes[100]; |
| 3253 | 3238 | ||
| 3254 | int totalAvatars = 0, totalServers = 0; | 3239 | int totalAvatars = 0, totalServers = 0; |
| 3255 | 3240 | ||
| 3256 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { | 3241 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 3257 | node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++; | 3242 | node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++; |
| 3258 | } | 3243 | } |
| 3259 | 3244 | ||
| 3260 | sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars); | 3245 | sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars); |
| 3261 | drawtext(_glWidget->width() - 150, 20, 0.10, 0, 1.0, 0, nodes, 1, 0, 0); | 3246 | drawtext(_glWidget->width() - 150, 20, 0.10f, 0, 1.0f, 0, nodes, 1, 0, 0); |
| 3262 | } | 3247 | } |
| 3263 | 3248 | ||
| 3264 | // testing rendering coverage map | 3249 | // testing rendering coverage map |
| @@ -3280,14 +3265,10 @@ void Application::displayOverlay() { · 15 unmodified lines | |||
| 3280 | char frameTimer[10]; | 3265 | char frameTimer[10]; |
| 3281 | uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); | 3266 | uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); |
| 3282 | sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000)); | 3267 | sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000)); |
| 3283 | drawtext(_glWidget->width() - 100, _glWidget->height() - 20, 0.30, 0, 1.0, 0, frameTimer, 0, 0, 0); | 3268 | drawtext(_glWidget->width() - 100, _glWidget->height() - 20, 0.30f, 0, 1.0f, 0, frameTimer, 0, 0, 0); |
| 3284 | drawtext(_glWidget->width() - 102, _glWidget->height() - 22, 0.30, 0, 1.0, 0, frameTimer, 1, 1, 1); | 3269 | drawtext(_glWidget->width() - 102, _glWidget->height() - 22, 0.30f, 0, 1.0f, 0, frameTimer, 1, 1, 1); |
| 3285 | } | 3270 | } |
| 3286 | 3271 | ||
| 3287 | |||
| 3288 | // render the webcam input frame | ||
| 3289 | _webcam.renderPreview(_glWidget->width(), _glWidget->height()); | ||
| 3290 | |||
| 3291 | _palette.render(_glWidget->width(), _glWidget->height()); | 3272 | _palette.render(_glWidget->width(), _glWidget->height()); |
| 3292 | 3273 | ||
| 3293 | QAction* paintColorAction = NULL; | 3274 | QAction* paintColorAction = NULL; |
| @@ -3343,6 +3324,7 @@ void Application::displayOverlay() { · 49 unmodified lines | |||
| 3343 | glPopMatrix(); | 3324 | glPopMatrix(); |
| 3344 | } | 3325 | } |
| 3345 | 3326 | ||
| 3327 | |||
| 3346 | void Application::displayStats() { | 3328 | void Application::displayStats() { |
| 3347 | int statsVerticalOffset = 8; | 3329 | int statsVerticalOffset = 8; |
| 3348 | const int PELS_PER_LINE = 15; | 3330 | const int PELS_PER_LINE = 15; |
| @@ -3366,7 +3348,7 @@ void Application::displayStats() { · 17 unmodified lines | |||
| 3366 | // Now handle voxel servers, since there could be more than one, we average their ping times | 3348 | // Now handle voxel servers, since there could be more than one, we average their ping times |
| 3367 | unsigned long totalPingVoxel = 0; | 3349 | unsigned long totalPingVoxel = 0; |
| 3368 | int voxelServerCount = 0; | 3350 | int voxelServerCount = 0; |
| 3369 | 3351 | ||
| 3370 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { | 3352 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { |
| 3371 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | 3353 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { |
| 3372 | totalPingVoxel += node->getPingMs(); | 3354 | totalPingVoxel += node->getPingMs(); |
| @@ -3376,7 +3358,7 @@ void Application::displayStats() { · 3 unmodified lines | |||
| 3376 | } | 3358 | } |
| 3377 | } | 3359 | } |
| 3378 | } | 3360 | } |
| 3379 | 3361 | ||
| 3380 | if (voxelServerCount) { | 3362 | if (voxelServerCount) { |
| 3381 | pingVoxel = totalPingVoxel/voxelServerCount; | 3363 | pingVoxel = totalPingVoxel/voxelServerCount; |
| 3382 | } | 3364 | } |
| @@ -3524,20 +3506,6 @@ void Application::displayStats() { · 141 unmodified lines | |||
| 3524 | } | 3506 | } |
| 3525 | statsVerticalOffset += PELS_PER_LINE; | 3507 | statsVerticalOffset += PELS_PER_LINE; |
| 3526 | drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str()); | 3508 | drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str()); |
| 3527 | |||
| 3528 | if (_perfStatsOn) { | ||
| 3529 | // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups | ||
| 3530 | char** perfStatLinesArray = new char*[PerfStat::getGroupCount()+1]; | ||
| 3531 | int lines = PerfStat::DumpStats(perfStatLinesArray); | ||
| 3532 | |||
| 3533 | for (int line=0; line < lines; line++) { | ||
| 3534 | statsVerticalOffset += PELS_PER_LINE; | ||
| 3535 | drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, perfStatLinesArray[line]); | ||
| 3536 | delete perfStatLinesArray[line]; // we're responsible for cleanup | ||
| 3537 | perfStatLinesArray[line]=NULL; | ||
| 3538 | } | ||
| 3539 | delete []perfStatLinesArray; // we're responsible for cleanup | ||
| 3540 | } | ||
| 3541 | } | 3509 | } |
| 3542 | 3510 | ||
| 3543 | void Application::renderThrustAtVoxel(const glm::vec3& thrust) { | 3511 | void Application::renderThrustAtVoxel(const glm::vec3& thrust) { |
| @@ -3552,20 +3520,6 @@ void Application::renderThrustAtVoxel(const glm::vec3& thrust) { · 8 unmodified lines | |||
| 3552 | } | 3520 | } |
| 3553 | } | 3521 | } |
| 3554 | 3522 | ||
| 3555 | void Application::renderLineToTouchedVoxel() { | ||
| 3556 | // Draw a teal line to the voxel I am currently dragging on | ||
| 3557 | if (_mousePressed) { | ||
| 3558 | glColor3f(0, 1, 1); | ||
| 3559 | glLineWidth(2.0f); | ||
| 3560 | glBegin(GL_LINES); | ||
| 3561 | glm::vec3 voxelTouched = getMouseVoxelWorldCoordinates(_mouseVoxelDragging); | ||
| 3562 | glVertex3f(voxelTouched.x, voxelTouched.y, voxelTouched.z); | ||
| 3563 | glm::vec3 headPosition = _myAvatar.getHeadJointPosition(); | ||
| 3564 | glVertex3fv(&headPosition.x); | ||
| 3565 | glEnd(); | ||
| 3566 | } | ||
| 3567 | } | ||
| 3568 | |||
| 3569 | 3523 | ||
| 3570 | glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { | 3524 | glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { |
| 3571 | float horizontalScale = _glWidget->width() / 2.0f; | 3525 | float horizontalScale = _glWidget->width() / 2.0f; |
| @@ -3712,10 +3666,10 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 140 unmodified lines | |||
| 3712 | if (!selfAvatarOnly) { | 3666 | if (!selfAvatarOnly) { |
| 3713 | // Render avatars of other nodes | 3667 | // Render avatars of other nodes |
| 3714 | NodeList* nodeList = NodeList::getInstance(); | 3668 | NodeList* nodeList = NodeList::getInstance(); |
| 3715 | 3669 | ||
| 3716 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { | 3670 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { |
| 3717 | QMutexLocker(&node->getMutex()); | 3671 | QMutexLocker(&node->getMutex()); |
| 3718 | 3672 | ||
| 3719 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | 3673 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 3720 | Avatar *avatar = (Avatar *)node->getLinkedData(); | 3674 | Avatar *avatar = (Avatar *)node->getLinkedData(); |
| 3721 | if (!avatar->isInitialized()) { | 3675 | if (!avatar->isInitialized()) { |
| @@ -3972,7 +3926,6 @@ void Application::resetSensors() { · 250 unmodified lines | |||
| 3972 | _headMouseX = _mouseX = _glWidget->width() / 2; | 3926 | _headMouseX = _mouseX = _glWidget->width() / 2; |
| 3973 | _headMouseY = _mouseY = _glWidget->height() / 2; | 3927 | _headMouseY = _mouseY = _glWidget->height() / 2; |
| 3974 | 3928 | ||
| 3975 | _webcam.reset(); | ||
| 3976 | _faceshift.reset(); | 3929 | _faceshift.reset(); |
| 3977 | 3930 | ||
| 3978 | if (OculusManager::isConnected()) { | 3931 | if (OculusManager::isConnected()) { |
| @@ -4063,7 +4016,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 84 unmodified lines | |||
| 4063 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) { | 4016 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) { |
| 4064 | VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE); | 4017 | VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE); |
| 4065 | fade.voxelDetails = rootDetails; | 4018 | fade.voxelDetails = rootDetails; |
| 4066 | const float slightly_smaller = 0.99; | 4019 | const float slightly_smaller = 0.99f; |
| 4067 | fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller; | 4020 | fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller; |
| 4068 | _voxelFades.push_back(fade); | 4021 | _voxelFades.push_back(fade); |
| 4069 | } | 4022 | } |
| @@ -4094,7 +4047,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 24 unmodified lines | |||
| 4094 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) { | 4047 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) { |
| 4095 | VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE); | 4048 | VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE); |
| 4096 | fade.voxelDetails = rootDetails; | 4049 | fade.voxelDetails = rootDetails; |
| 4097 | const float slightly_smaller = 0.99; | 4050 | const float slightly_smaller = 0.99f; |
| 4098 | fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller; | 4051 | fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller; |
| 4099 | _voxelFades.push_back(fade); | 4052 | _voxelFades.push_back(fade); |
| 4100 | } | 4053 | } |
| @@ -4184,7 +4137,7 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 83 unmodified lines | |||
| 4184 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) { | 4137 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) { |
| 4185 | VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE); | 4138 | VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE); |
| 4186 | fade.voxelDetails = rootDetails; | 4139 | fade.voxelDetails = rootDetails; |
| 4187 | const float slightly_smaller = 0.99; | 4140 | const float slightly_smaller = 0.99f; |
| 4188 | fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller; | 4141 | fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller; |
| 4189 | _voxelFades.push_back(fade); | 4142 | _voxelFades.push_back(fade); |
| 4190 | } | 4143 | } |
| @@ -4213,28 +4166,28 @@ void Application::processDatagrams() { · 22 unmodified lines | |||
| 4213 | MAX_PACKET_SIZE, | 4166 | MAX_PACKET_SIZE, |
| 4214 | senderSockAddr.getAddressPointer(), | 4167 | senderSockAddr.getAddressPointer(), |
| 4215 | senderSockAddr.getPortPointer()))) { | 4168 | senderSockAddr.getPortPointer()))) { |
| 4216 | 4169 | ||
| 4217 | _packetCount++; | 4170 | _packetCount++; |
| 4218 | _bytesCount += bytesReceived; | 4171 | _bytesCount += bytesReceived; |
| 4219 | 4172 | ||
| 4220 | if (packetVersionMatch(_incomingPacket)) { | 4173 | if (packetVersionMatch(_incomingPacket)) { |
| 4221 | // only process this packet if we have a match on the packet version | 4174 | // only process this packet if we have a match on the packet version |
| 4222 | switch (_incomingPacket[0]) { | 4175 | switch (_incomingPacket[0]) { |
| 4223 | case PACKET_TYPE_TRANSMITTER_DATA_V2: | 4176 | case PACKET_TYPE_TRANSMITTER_DATA_V2: |
| 4224 | // V2 = IOS transmitter app | 4177 | // V2 = IOS transmitter app |
| 4225 | _myTransmitter.processIncomingData(_incomingPacket, bytesReceived); | 4178 | _myTransmitter.processIncomingData(_incomingPacket, bytesReceived); |
| 4226 | 4179 | ||
| 4227 | break; | 4180 | break; |
| 4228 | case PACKET_TYPE_MIXED_AUDIO: | 4181 | case PACKET_TYPE_MIXED_AUDIO: |
| 4229 | QMetaObject::invokeMethod(&_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection, | 4182 | QMetaObject::invokeMethod(&_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection, |
| 4230 | Q_ARG(QByteArray, QByteArray((char*) _incomingPacket, bytesReceived))); | 4183 | Q_ARG(QByteArray, QByteArray((char*) _incomingPacket, bytesReceived))); |
| 4231 | break; | 4184 | break; |
| 4232 | 4185 | ||
| 4233 | case PACKET_TYPE_PARTICLE_ADD_RESPONSE: | 4186 | case PACKET_TYPE_PARTICLE_ADD_RESPONSE: |
| 4234 | // look up our ParticleEditHanders.... | 4187 | // look up our ParticleEditHanders.... |
| 4235 | ParticleEditHandle::handleAddResponse(_incomingPacket, bytesReceived); | 4188 | ParticleEditHandle::handleAddResponse(_incomingPacket, bytesReceived); |
| 4236 | break; | 4189 | break; |
| 4237 | 4190 | ||
| 4238 | case PACKET_TYPE_PARTICLE_DATA: | 4191 | case PACKET_TYPE_PARTICLE_DATA: |
| 4239 | case PACKET_TYPE_VOXEL_DATA: | 4192 | case PACKET_TYPE_VOXEL_DATA: |
| 4240 | case PACKET_TYPE_VOXEL_ERASE: | 4193 | case PACKET_TYPE_VOXEL_ERASE: |
| @@ -4242,7 +4195,7 @@ void Application::processDatagrams() { · 1 unmodified line | |||
| 4242 | case PACKET_TYPE_ENVIRONMENT_DATA: { | 4195 | case PACKET_TYPE_ENVIRONMENT_DATA: { |
| 4243 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 4196 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 4244 | "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()"); | 4197 | "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()"); |
| 4245 | 4198 | ||
| 4246 | bool wantExtraDebugging = getLogger()->extraDebugging(); | 4199 | bool wantExtraDebugging = getLogger()->extraDebugging(); |
| 4247 | if (wantExtraDebugging && _incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) { | 4200 | if (wantExtraDebugging && _incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) { |
| 4248 | int numBytesPacketHeader = numBytesForPacketHeader(_incomingPacket); | 4201 | int numBytesPacketHeader = numBytesForPacketHeader(_incomingPacket); |
| @@ -4254,10 +4207,10 @@ void Application::processDatagrams() { · 5 unmodified lines | |||
| 4254 | dataAt += sizeof(VOXEL_PACKET_SENT_TIME); | 4207 | dataAt += sizeof(VOXEL_PACKET_SENT_TIME); |
| 4255 | VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); | 4208 | VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); |
| 4256 | int flightTime = arrivedAt - sentAt; | 4209 | int flightTime = arrivedAt - sentAt; |
| 4257 | 4210 | ||
| 4258 | printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime); | 4211 | printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime); |
| 4259 | } | 4212 | } |
| 4260 | 4213 | ||
| 4261 | // add this packet to our list of voxel packets and process them on the voxel processing | 4214 | // add this packet to our list of voxel packets and process them on the voxel processing |
| 4262 | _voxelProcessor.queueReceivedPacket(senderSockAddr, _incomingPacket, bytesReceived); | 4215 | _voxelProcessor.queueReceivedPacket(senderSockAddr, _incomingPacket, bytesReceived); |
| 4263 | break; | 4216 | break; |
| @@ -4275,9 +4228,6 @@ void Application::processDatagrams() { · 11 unmodified lines | |||
| 4275 | case PACKET_TYPE_AVATAR_URLS: | 4228 | case PACKET_TYPE_AVATAR_URLS: |
| 4276 | processAvatarURLsMessage(_incomingPacket, bytesReceived); | 4229 | processAvatarURLsMessage(_incomingPacket, bytesReceived); |
| 4277 | break; | 4230 | break; |
| 4278 | case PACKET_TYPE_AVATAR_FACE_VIDEO: | ||
| 4279 | processAvatarFaceVideoMessage(_incomingPacket, bytesReceived); | ||
| 4280 | break; | ||
| 4281 | case PACKET_TYPE_DATA_SERVER_GET: | 4231 | case PACKET_TYPE_DATA_SERVER_GET: |
| 4282 | case PACKET_TYPE_DATA_SERVER_PUT: | 4232 | case PACKET_TYPE_DATA_SERVER_PUT: |
| 4283 | case PACKET_TYPE_DATA_SERVER_SEND: | 4233 | case PACKET_TYPE_DATA_SERVER_SEND: |
| @@ -4394,15 +4344,19 @@ void Application::updateLocalOctreeCache(bool firstTime) { · 110 unmodified lines | |||
| 4394 | 4344 | ||
| 4395 | if (_persistThread) { | 4345 | if (_persistThread) { |
| 4396 | _persistThread->terminate(); | 4346 | _persistThread->terminate(); |
| 4347 | _persistThread->deleteLater(); | ||
| 4397 | _persistThread = NULL; | 4348 | _persistThread = NULL; |
| 4398 | } | 4349 | } |
| 4399 | 4350 | ||
| 4400 | QString localVoxelCacheFileName = getLocalVoxelCacheFileName(); | 4351 | QString localVoxelCacheFileName = getLocalVoxelCacheFileName(); |
| 4401 | const int LOCAL_CACHE_PERSIST_INTERVAL = 1000 * 10; // every 10 seconds | 4352 | const int LOCAL_CACHE_PERSIST_INTERVAL = 1000 * 10; // every 10 seconds |
| 4402 | _persistThread = new OctreePersistThread(_voxels.getTree(), | ||
| 4403 | localVoxelCacheFileName.toLocal8Bit().constData(),LOCAL_CACHE_PERSIST_INTERVAL); | ||
| 4404 | 4353 | ||
| 4405 | qDebug() << "updateLocalOctreeCache()... localVoxelCacheFileName=" << localVoxelCacheFileName; | 4354 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableLocalVoxelCache)) { |
| 4355 | _persistThread = new OctreePersistThread(_voxels.getTree(), | ||
| 4356 | localVoxelCacheFileName.toLocal8Bit().constData(),LOCAL_CACHE_PERSIST_INTERVAL); | ||
| 4357 | |||
| 4358 | qDebug() << "updateLocalOctreeCache()... localVoxelCacheFileName=" << localVoxelCacheFileName; | ||
| 4359 | } | ||
| 4406 | 4360 | ||
| 4407 | if (_persistThread) { | 4361 | if (_persistThread) { |
| 4408 | _voxels.beginLoadingLocalVoxelCache(); // while local voxels are importing, don't do individual node VBO updates | 4362 | _voxels.beginLoadingLocalVoxelCache(); // while local voxels are importing, don't do individual node VBO updates |