Showing the changes to interface/src/Application.cpp (1 of 70 files). Show all
Unified · Split
| @@ -77,8 +77,10 @@ static char STAR_CACHE_FILE[] = "cachedStars.txt"; · 76 unmodified lines | ||
| 77 | 77 | |
| 78 | 78 | static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored |
| 79 | 79 | |
| 80 | −const glm::vec3 START_LOCATION(4.f, 0.f, 5.f); // Where one's own node begins in the world | |
| 81 | − // (will be overwritten if avatar data file is found) | |
| 80 | +// Where one's own Avatar begins in the world (will be overwritten if avatar data file is found) | |
| 81 | +// this is basically in the center of the ground plane. Slightly adjusted. This was asked for by | |
| 82 | +// Grayson as he's building a street around here for demo dinner 2 | |
| 83 | +const glm::vec3 START_LOCATION(0.485f * TREE_SCALE, 0.f, 0.5f * TREE_SCALE); | |
| 82 | 84 | |
| 83 | 85 | const int IDLE_SIMULATE_MSECS = 16; // How often should call simulate and other stuff |
| 84 | 86 | // in the idle loop? (60 FPS is default) |
| @@ -215,6 +217,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 130 unmodified lines | ||
| 215 | 217 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), |
| 216 | 218 | #endif |
| 217 | 219 | _stopNetworkReceiveThread(false), |
| 220 | + _stopProcessVoxelsThread(false), | |
| 218 | 221 | _packetCount(0), |
| 219 | 222 | _packetsPerSecond(0), |
| 220 | 223 | _bytesPerSecond(0), |
| @@ -235,7 +238,12 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 14 unmodified lines | ||
| 235 | 238 | |
| 236 | 239 | NodeList::createInstance(NODE_TYPE_AGENT, listenPort); |
| 237 | 240 | |
| 238 | − _enableNetworkThread = !cmdOptionExists(argc, constArgv, "--nonblocking"); | |
| 241 | + NodeList::getInstance()->addHook(&_voxels); | |
| 242 | + NodeList::getInstance()->addHook(this); | |
| 243 | + | |
| 244 | + | |
| 245 | + // network receive thread and voxel parsing thread are both controlled by the --nonblocking command line | |
| 246 | + _enableProcessVoxelsThread = _enableNetworkThread = !cmdOptionExists(argc, constArgv, "--nonblocking"); | |
| 239 | 247 | if (!_enableNetworkThread) { |
| 240 | 248 | NodeList::getInstance()->getNodeSocket()->setBlocking(false); |
| 241 | 249 | } |
| @@ -318,6 +326,11 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 76 unmodified lines | ||
| 318 | 326 | // initialization continues in initializeGL when OpenGL context is ready |
| 319 | 327 | } |
| 320 | 328 | |
| 329 | +Application::~Application() { | |
| 330 | + NodeList::getInstance()->removeHook(&_voxels); | |
| 331 | + NodeList::getInstance()->removeHook(this); | |
| 332 | +} | |
| 333 | + | |
| 321 | 334 | void Application::initializeGL() { |
| 322 | 335 | qDebug( "Created Display Window.\n" ); |
| 323 | 336 | |
| @@ -354,6 +367,12 @@ void Application::initializeGL() { · 30 unmodified lines | ||
| 354 | 367 | pthread_create(&_networkReceiveThread, NULL, networkReceive, NULL); |
| 355 | 368 | qDebug("Network receive thread created.\n"); |
| 356 | 369 | } |
| 370 | + | |
| 371 | + // create thread for parsing of voxel data independent of the main network and rendering threads | |
| 372 | + if (_enableProcessVoxelsThread) { | |
| 373 | + pthread_create(&_processVoxelsThread, NULL, processVoxels, NULL); | |
| 374 | + qDebug("Voxel parsing thread created.\n"); | |
| 375 | + } | |
| 357 | 376 | |
| 358 | 377 | // call terminate before exiting |
| 359 | 378 | connect(this, SIGNAL(aboutToQuit()), SLOT(terminate())); |
| @@ -429,7 +448,7 @@ void Application::paintGL() { · 69 unmodified lines | ||
| 429 | 448 | // myCamera is. But we also want to do meaningful camera transforms on OpenGL for the offset camera |
| 430 | 449 | Camera whichCamera = _myCamera; |
| 431 | 450 | |
| 432 | − if (_viewFrustumFromOffset->isChecked() && _frustumOn->isChecked()) { | |
| 451 | + if (_frustumOn->isChecked()) { | |
| 433 | 452 | |
| 434 | 453 | // set the camera to third-person view but offset so we can see the frustum |
| 435 | 454 | _viewFrustumOffsetCamera.setTargetPosition(_myCamera.getTargetPosition()); |
| @@ -457,56 +476,49 @@ void Application::paintGL() { · 21 unmodified lines | ||
| 457 | 476 | _frameCount++; |
| 458 | 477 | } |
| 459 | 478 | |
| 460 | −void Application::resizeGL(int width, int height) { | |
| 479 | +void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) { | |
| 461 | 480 | float aspectRatio = ((float)width/(float)height); // based on screen resize |
| 462 | − | |
| 463 | − // reset the camera FOV to our preference... | |
| 464 | − _myCamera.setFieldOfView(_horizontalFieldOfView); | |
| 465 | − | |
| 466 | − // get the lens details from the current camera | |
| 467 | − Camera& camera = _viewFrustumFromOffset->isChecked() ? _viewFrustumOffsetCamera : _myCamera; | |
| 468 | − float nearClip = camera.getNearClip(); | |
| 469 | − float farClip = camera.getFarClip(); | |
| 470 | − float fov; | |
| 471 | − | |
| 481 | + | |
| 472 | 482 | if (OculusManager::isConnected()) { |
| 473 | 483 | // more magic numbers; see Oculus SDK docs, p. 32 |
| 474 | 484 | camera.setAspectRatio(aspectRatio *= 0.5); |
| 475 | − camera.setFieldOfView(fov = 2 * atan((0.0468 * _oculusDistortionScale) / 0.041) * (180 / PIf)); | |
| 476 | − | |
| 477 | − // resize the render texture | |
| 478 | − if (_oculusTextureID != 0) { | |
| 479 | − glBindTexture(GL_TEXTURE_2D, _oculusTextureID); | |
| 480 | − glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); | |
| 481 | − glBindTexture(GL_TEXTURE_2D, 0); | |
| 482 | − } | |
| 485 | + camera.setFieldOfView(2 * atan((0.0468 * _oculusDistortionScale) / 0.041) * (180 / PIf)); | |
| 483 | 486 | } else { |
| 484 | 487 | camera.setAspectRatio(aspectRatio); |
| 485 | − camera.setFieldOfView(fov = _horizontalFieldOfView); | |
| 488 | + camera.setFieldOfView(_fieldOfView); | |
| 486 | 489 | } |
| 490 | +} | |
| 491 | + | |
| 492 | +void Application::resizeGL(int width, int height) { | |
| 493 | + resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height); | |
| 494 | + resetCamerasOnResizeGL(_myCamera, width, height); | |
| 487 | 495 | |
| 488 | − // Tell our viewFrustum about this change | |
| 489 | − _viewFrustum.setAspectRatio(aspectRatio); | |
| 496 | + // resize the render texture | |
| 497 | + if (OculusManager::isConnected() && _oculusTextureID != 0) { | |
| 498 | + glBindTexture(GL_TEXTURE_2D, _oculusTextureID); | |
| 499 | + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); | |
| 500 | + glBindTexture(GL_TEXTURE_2D, 0); | |
| 501 | + } | |
| 502 | + | |
| 503 | + // Tell our viewFrustum about this change, using the application camera | |
| 504 | + loadViewFrustum(_myCamera, _viewFrustum); | |
| 490 | 505 | |
| 491 | 506 | glViewport(0, 0, width, height); // shouldn't this account for the menu??? |
| 492 | 507 | |
| 493 | 508 | glMatrixMode(GL_PROJECTION); |
| 494 | 509 | glLoadIdentity(); |
| 495 | 510 | |
| 496 | − // XXXBHG - If we're in view frustum mode, then we need to do this little bit of hackery so that | |
| 497 | − // OpenGL won't clip our frustum rendering lines. This is a debug hack for sure! Basically, this makes | |
| 498 | − // the near clip a little bit closer (therefor you see more) and the far clip a little bit farther (also, | |
| 499 | − // to see more.) | |
| 500 | − if (_frustumOn->isChecked()) { | |
| 501 | − nearClip -= 0.01f; | |
| 502 | − farClip += 0.01f; | |
| 503 | − } | |
| 504 | − | |
| 505 | 511 | // On window reshape, we need to tell OpenGL about our new setting |
| 506 | 512 | float left, right, bottom, top, nearVal, farVal; |
| 507 | 513 | glm::vec4 nearClipPlane, farClipPlane; |
| 508 | − loadViewFrustum(camera, _viewFrustum); | |
| 509 | 514 | _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); |
| 515 | + | |
| 516 | + // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the | |
| 517 | + // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum | |
| 518 | + if (_frustumOn->isChecked()) { | |
| 519 | + nearVal = _viewFrustumOffsetCamera.getNearClip(); | |
| 520 | + farVal = _viewFrustumOffsetCamera.getFarClip(); | |
| 521 | + } | |
| 510 | 522 | glFrustum(left, right, bottom, top, nearVal, farVal); |
| 511 | 523 | |
| 512 | 524 | glMatrixMode(GL_MODELVIEW); |
| @@ -809,11 +821,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 296 unmodified lines | ||
| 809 | 821 | _colorVoxelMode->trigger(); |
| 810 | 822 | break; |
| 811 | 823 | case Qt::Key_O: |
| 812 | − if (isShifted) { | |
| 813 | − _viewFrustumFromOffset->trigger(); | |
| 814 | − } else { | |
| 815 | − _selectVoxelMode->trigger(); | |
| 816 | − } | |
| 824 | + _selectVoxelMode->trigger(); | |
| 817 | 825 | break; |
| 818 | 826 | case Qt::Key_Slash: |
| 819 | 827 | _renderStatsOn->trigger(); |
| @@ -944,7 +952,7 @@ void Application::mousePressEvent(QMouseEvent* event) { · 124 unmodified lines | ||
| 944 | 952 | |
| 945 | 953 | maybeEditVoxelUnderCursor(); |
| 946 | 954 | |
| 947 | − if (!_palette.isActive()) { | |
| 955 | + if (!_palette.isActive() && (!_isHoverVoxel || _isLookingAtOtherAvatar)) { | |
| 948 | 956 | _pieMenu.mousePressEvent(_mouseX, _mouseY); |
| 949 | 957 | } |
| 950 | 958 | |
| @@ -953,7 +961,16 @@ void Application::mousePressEvent(QMouseEvent* event) { · 2 unmodified lines | ||
| 953 | 961 | _hoverVoxelOriginalColor[1] = _hoverVoxel.green; |
| 954 | 962 | _hoverVoxelOriginalColor[2] = _hoverVoxel.blue; |
| 955 | 963 | _hoverVoxelOriginalColor[3] = 1; |
| 956 | − _audio.startCollisionSound(1.0, HOVER_VOXEL_FREQUENCY * _hoverVoxel.s * TREE_SCALE, 0.0, HOVER_VOXEL_DECAY); | |
| 964 | + const float RED_CLICK_FREQUENCY = 1000.f; | |
| 965 | + const float GREEN_CLICK_FREQUENCY = 1250.f; | |
| 966 | + const float BLUE_CLICK_FREQUENCY = 1330.f; | |
| 967 | + const float MIDDLE_A_FREQUENCY = 440.f; | |
| 968 | + float frequency = MIDDLE_A_FREQUENCY + | |
| 969 | + (_hoverVoxel.red / 255.f * RED_CLICK_FREQUENCY + | |
| 970 | + _hoverVoxel.green / 255.f * GREEN_CLICK_FREQUENCY + | |
| 971 | + _hoverVoxel.blue / 255.f * BLUE_CLICK_FREQUENCY) / 3.f; | |
| 972 | + | |
| 973 | + _audio.startCollisionSound(1.0, frequency, 0.0, HOVER_VOXEL_DECAY); | |
| 957 | 974 | _isHoverVoxelSounding = true; |
| 958 | 975 | } |
| 959 | 976 | |
| @@ -1161,6 +1178,11 @@ void Application::terminate() { · 201 unmodified lines | ||
| 1161 | 1178 | _stopNetworkReceiveThread = true; |
| 1162 | 1179 | pthread_join(_networkReceiveThread, NULL); |
| 1163 | 1180 | } |
| 1181 | + | |
| 1182 | + if (_enableProcessVoxelsThread) { | |
| 1183 | + _stopProcessVoxelsThread = true; | |
| 1184 | + pthread_join(_processVoxelsThread, NULL); | |
| 1185 | + } | |
| 1164 | 1186 | } |
| 1165 | 1187 | |
| 1166 | 1188 | void Application::sendAvatarVoxelURLMessage(const QUrl& url) { |
| @@ -1182,6 +1204,13 @@ void Application::sendAvatarVoxelURLMessage(const QUrl& url) { · 15 unmodified lines | ||
| 1182 | 1204 | } |
| 1183 | 1205 | |
| 1184 | 1206 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { |
| 1207 | + // record the packet for stats-tracking | |
| 1208 | + Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes); | |
| 1209 | + Node* avatarMixerNode = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | |
| 1210 | + if (avatarMixerNode) { | |
| 1211 | + avatarMixerNode->recordBytesReceived(dataBytes); | |
| 1212 | + } | |
| 1213 | + | |
| 1185 | 1214 | // skip the header |
| 1186 | 1215 | int numBytesPacketHeader = numBytesForPacketHeader(packetData); |
| 1187 | 1216 | packetData += numBytesPacketHeader; |
| @@ -1285,15 +1314,15 @@ void Application::editPreferences() { · 97 unmodified lines | ||
| 1285 | 1314 | avatarURL->setMinimumWidth(QLINE_MINIMUM_WIDTH); |
| 1286 | 1315 | form->addRow("Avatar URL:", avatarURL); |
| 1287 | 1316 | |
| 1288 | − QSpinBox* horizontalFieldOfView = new QSpinBox(); | |
| 1289 | − horizontalFieldOfView->setMaximum(180); | |
| 1290 | − horizontalFieldOfView->setMinimum(1); | |
| 1291 | − horizontalFieldOfView->setValue(_horizontalFieldOfView); | |
| 1292 | − form->addRow("Horizontal field of view (degrees):", horizontalFieldOfView); | |
| 1317 | + QSpinBox* fieldOfView = new QSpinBox(); | |
| 1318 | + fieldOfView->setMaximum(180); | |
| 1319 | + fieldOfView->setMinimum(1); | |
| 1320 | + fieldOfView->setValue(_fieldOfView); | |
| 1321 | + form->addRow("Vertical Field of View (Degrees):", fieldOfView); | |
| 1293 | 1322 | |
| 1294 | − QDoubleSpinBox* headCameraPitchYawScale = new QDoubleSpinBox(); | |
| 1295 | − headCameraPitchYawScale->setValue(_headCameraPitchYawScale); | |
| 1296 | − form->addRow("Head Camera Pitch/Yaw Scale:", headCameraPitchYawScale); | |
| 1323 | + QDoubleSpinBox* gyroCameraSensitivity = new QDoubleSpinBox(); | |
| 1324 | + gyroCameraSensitivity->setValue(_gyroCameraSensitivity); | |
| 1325 | + form->addRow("Gyro Camera Sensitivity (0 - 1):", gyroCameraSensitivity); | |
| 1297 | 1326 | |
| 1298 | 1327 | QDoubleSpinBox* leanScale = new QDoubleSpinBox(); |
| 1299 | 1328 | leanScale->setValue(_myAvatar.getLeanScale()); |
| @@ -1343,13 +1372,13 @@ void Application::editPreferences() { · 43 unmodified lines | ||
| 1343 | 1372 | _myAvatar.getVoxels()->setVoxelURL(url); |
| 1344 | 1373 | sendAvatarVoxelURLMessage(url); |
| 1345 | 1374 | |
| 1346 | − _headCameraPitchYawScale = headCameraPitchYawScale->value(); | |
| 1375 | + _gyroCameraSensitivity = gyroCameraSensitivity->value(); | |
| 1347 | 1376 | _myAvatar.setLeanScale(leanScale->value()); |
| 1348 | 1377 | _audioJitterBufferSamples = audioJitterBufferSamples->value(); |
| 1349 | 1378 | if (!shouldDynamicallySetJitterBuffer()) { |
| 1350 | 1379 | _audio.setJitterBufferSamples(_audioJitterBufferSamples); |
| 1351 | 1380 | } |
| 1352 | − _horizontalFieldOfView = horizontalFieldOfView->value(); | |
| 1381 | + _fieldOfView = fieldOfView->value(); | |
| 1353 | 1382 | resizeGL(_glWidget->width(), _glWidget->height()); |
| 1354 | 1383 | |
| 1355 | 1384 | } |
| @@ -1379,6 +1408,8 @@ void Application::setRenderFirstPerson(bool firstPerson) { · 23 unmodified lines | ||
| 1379 | 1408 | if (firstPerson) { |
| 1380 | 1409 | _lookingInMirror->setChecked(false); |
| 1381 | 1410 | _manualThirdPerson->setChecked(false); |
| 1411 | + } else { | |
| 1412 | + _manualThirdPerson->trigger(); | |
| 1382 | 1413 | } |
| 1383 | 1414 | } |
| 1384 | 1415 | |
| @@ -1476,8 +1507,8 @@ void Application::doTreeStats() { · 91 unmodified lines | ||
| 1476 | 1507 | _voxels.collectStatsForTreesAndVBOs(); |
| 1477 | 1508 | } |
| 1478 | 1509 | |
| 1479 | −void Application::setWantsLowResMoving(bool wantsLowResMoving) { | |
| 1480 | − _myAvatar.setWantLowResMoving(wantsLowResMoving); | |
| 1510 | +void Application::disableLowResMoving(bool disableLowResMoving) { | |
| 1511 | + _myAvatar.setWantLowResMoving(!disableLowResMoving); | |
| 1481 | 1512 | } |
| 1482 | 1513 | |
| 1483 | 1514 | void Application::setWantsMonochrome(bool wantsMonochrome) { |
| @@ -1944,8 +1975,11 @@ void Application::initMenu() { · 460 unmodified lines | ||
| 1944 | 1975 | _testPing->setChecked(true); |
| 1945 | 1976 | (_fullScreenMode = optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F))->setCheckable(true); |
| 1946 | 1977 | optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true); |
| 1947 | − optionsMenu->addAction("Toggle Skeleton Tracking", &_webcam, SLOT(setSkeletonTrackingOn(bool)))->setCheckable(true); | |
| 1978 | + optionsMenu->addAction("Skeleton Tracking", &_webcam, SLOT(setSkeletonTrackingOn(bool)))->setCheckable(true); | |
| 1979 | + (_wantCollisionsOn = optionsMenu->addAction("Turn collisions On", this, SLOT(toggleWantCollisionsOn())))->setCheckable(true); | |
| 1980 | + _wantCollisionsOn->setChecked(true); | |
| 1948 | 1981 | optionsMenu->addAction("Cycle Webcam Send Mode", _webcam.getGrabber(), SLOT(cycleVideoSendMode())); |
| 1982 | + optionsMenu->addAction("Webcam Texture", _webcam.getGrabber(), SLOT(setDepthOnly(bool)))->setCheckable(true); | |
| 1949 | 1983 | optionsMenu->addAction("Go Home", this, SLOT(goHome()), Qt::CTRL | Qt::Key_G); |
| 1950 | 1984 | |
| 1951 | 1985 | QMenu* audioMenu = menuBar->addMenu("Audio"); |
| @@ -2045,8 +2079,6 @@ void Application::initMenu() { · 93 unmodified lines | ||
| 2045 | 2079 | QMenu* frustumMenu = debugMenu->addMenu("View Frustum Debugging Tools"); |
| 2046 | 2080 | (_frustumOn = frustumMenu->addAction("Display Frustum"))->setCheckable(true); |
| 2047 | 2081 | _frustumOn->setShortcut(Qt::SHIFT | Qt::Key_F); |
| 2048 | − (_viewFrustumFromOffset = frustumMenu->addAction( | |
| 2049 | − "Use Offset Camera", this, SLOT(setFrustumOffset(bool)), Qt::SHIFT | Qt::Key_O))->setCheckable(true); | |
| 2050 | 2082 | _frustumRenderModeAction = frustumMenu->addAction( |
| 2051 | 2083 | "Render Mode", this, SLOT(cycleFrustumRenderMode()), Qt::SHIFT | Qt::Key_R); |
| 2052 | 2084 | updateFrustumRenderModeAction(); |
| @@ -2055,7 +2087,8 @@ void Application::initMenu() { · 2 unmodified lines | ||
| 2055 | 2087 | debugMenu->addAction("Calculate Tree Stats", this, SLOT(doTreeStats()), Qt::SHIFT | Qt::Key_S); |
| 2056 | 2088 | |
| 2057 | 2089 | QMenu* renderDebugMenu = debugMenu->addMenu("Render Debugging Tools"); |
| 2058 | − renderDebugMenu->addAction("Show Render Pipeline Warnings", this, SLOT(setRenderWarnings(bool)))->setCheckable(true); | |
| 2090 | + (_renderPipelineWarnings = renderDebugMenu->addAction("Show Render Pipeline Warnings", | |
| 2091 | + this, SLOT(setRenderWarnings(bool))))->setCheckable(true); | |
| 2059 | 2092 | renderDebugMenu->addAction("Kill Local Voxels", this, SLOT(doKillLocalVoxels()), Qt::CTRL | Qt::Key_K); |
| 2060 | 2093 | renderDebugMenu->addAction("Randomize Voxel TRUE Colors", this, SLOT(doRandomizeVoxelColors()), Qt::CTRL | Qt::Key_R); |
| 2061 | 2094 | renderDebugMenu->addAction("FALSE Color Voxels Randomly", this, SLOT(doFalseRandomizeVoxelColors())); |
| @@ -2070,7 +2103,7 @@ void Application::initMenu() { · 8 unmodified lines | ||
| 2070 | 2103 | (_shouldLowPassFilter = debugMenu->addAction("Test: LowPass filter"))->setCheckable(true); |
| 2071 | 2104 | |
| 2072 | 2105 | debugMenu->addAction("Wants Monochrome", this, SLOT(setWantsMonochrome(bool)))->setCheckable(true); |
| 2073 | − debugMenu->addAction("Use Lower Resolution While Moving", this, SLOT(setWantsLowResMoving(bool)))->setCheckable(true); | |
| 2106 | + debugMenu->addAction("Disable Lower Resolution While Moving", this, SLOT(disableLowResMoving(bool)))->setCheckable(true); | |
| 2074 | 2107 | debugMenu->addAction("Disable Delta Sending", this, SLOT(disableDeltaSending(bool)))->setCheckable(true); |
| 2075 | 2108 | (_occlusionCulling = debugMenu->addAction("Disable Occlusion Culling", this, SLOT(disableOcclusionCulling(bool)), |
| 2076 | 2109 | Qt::SHIFT | Qt::Key_C))->setCheckable(true); |
| @@ -2138,6 +2171,10 @@ void Application::toggleMixedSong() { · 61 unmodified lines | ||
| 2138 | 2171 | } |
| 2139 | 2172 | } |
| 2140 | 2173 | |
| 2174 | +void Application::toggleWantCollisionsOn() { | |
| 2175 | + _myAvatar.setWantCollisionsOn(_wantCollisionsOn->isChecked()); | |
| 2176 | +} | |
| 2177 | + | |
| 2141 | 2178 | void Application::resetSongMixMenuItem() { |
| 2142 | 2179 | if (_audio.getSongFileBytes() == 0) { |
| 2143 | 2180 | _rawAudioMicrophoneMix->setText("Mix RAW Song"); |
| @@ -2288,6 +2325,56 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& which · 144 unmodified lines | ||
| 2288 | 2325 | renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS); |
| 2289 | 2326 | } |
| 2290 | 2327 | |
| 2328 | +void Application::renderFollowIndicator() { | |
| 2329 | + NodeList* nodeList = NodeList::getInstance(); | |
| 2330 | + | |
| 2331 | + glLineWidth(5); | |
| 2332 | + glBegin(GL_LINES); | |
| 2333 | + for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); ++node) { | |
| 2334 | + if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | |
| 2335 | + Avatar* avatar = (Avatar *) node->getLinkedData(); | |
| 2336 | + Avatar* leader = NULL; | |
| 2337 | + | |
| 2338 | + if (avatar->getLeaderID() != UNKNOWN_NODE_ID) { | |
| 2339 | + if (avatar->getLeaderID() == NodeList::getInstance()->getOwnerID()) { | |
| 2340 | + leader = &_myAvatar; | |
| 2341 | + } else { | |
| 2342 | + for (NodeList::iterator it = nodeList->begin(); it != nodeList->end(); ++it) { | |
| 2343 | + if(it->getNodeID() == avatar->getLeaderID() | |
| 2344 | + && it->getType() == NODE_TYPE_AGENT) { | |
| 2345 | + leader = (Avatar*) it->getLinkedData(); | |
| 2346 | + } | |
| 2347 | + } | |
| 2348 | + } | |
| 2349 | + | |
| 2350 | + if (leader != NULL) { | |
| 2351 | + glColor3f(1.f, 0.f, 0.f); | |
| 2352 | + glVertex3f((avatar->getHead().getPosition().x + avatar->getPosition().x) / 2.f, | |
| 2353 | + (avatar->getHead().getPosition().y + avatar->getPosition().y) / 2.f, | |
| 2354 | + (avatar->getHead().getPosition().z + avatar->getPosition().z) / 2.f); | |
| 2355 | + glColor3f(0.f, 1.f, 0.f); | |
| 2356 | + glVertex3f((leader->getHead().getPosition().x + leader->getPosition().x) / 2.f, | |
| 2357 | + (leader->getHead().getPosition().y + leader->getPosition().y) / 2.f, | |
| 2358 | + (leader->getHead().getPosition().z + leader->getPosition().z) / 2.f); | |
| 2359 | + } | |
| 2360 | + } | |
| 2361 | + } | |
| 2362 | + } | |
| 2363 | + | |
| 2364 | + if (_myAvatar.getLeadingAvatar() != NULL) { | |
| 2365 | + glColor3f(1.f, 0.f, 0.f); | |
| 2366 | + glVertex3f((_myAvatar.getHead().getPosition().x + _myAvatar.getPosition().x) / 2.f, | |
| 2367 | + (_myAvatar.getHead().getPosition().y + _myAvatar.getPosition().y) / 2.f, | |
| 2368 | + (_myAvatar.getHead().getPosition().z + _myAvatar.getPosition().z) / 2.f); | |
| 2369 | + glColor3f(0.f, 1.f, 0.f); | |
| 2370 | + glVertex3f((_myAvatar.getLeadingAvatar()->getHead().getPosition().x + _myAvatar.getLeadingAvatar()->getPosition().x) / 2.f, | |
| 2371 | + (_myAvatar.getLeadingAvatar()->getHead().getPosition().y + _myAvatar.getLeadingAvatar()->getPosition().y) / 2.f, | |
| 2372 | + (_myAvatar.getLeadingAvatar()->getHead().getPosition().z + _myAvatar.getLeadingAvatar()->getPosition().z) / 2.f); | |
| 2373 | + } | |
| 2374 | + | |
| 2375 | + glEnd(); | |
| 2376 | +} | |
| 2377 | + | |
| 2291 | 2378 | void Application::update(float deltaTime) { |
| 2292 | 2379 | |
| 2293 | 2380 | // Use Transmitter Hand to move hand if connected, else use mouse |
| @@ -2473,7 +2560,7 @@ void Application::update(float deltaTime) { · 179 unmodified lines | ||
| 2473 | 2560 | } |
| 2474 | 2561 | |
| 2475 | 2562 | // Leap finger-sensing device |
| 2476 | − LeapManager::enableFakeFingers(_simulateLeapHand->isChecked() || _testRaveGlove->isChecked()); | |
| 2563 | + LeapManager::enableFakeFingers(_simulateLeapHand->isChecked()); | |
| 2477 | 2564 | _myAvatar.getHand().setRaveGloveActive(_testRaveGlove->isChecked()); |
| 2478 | 2565 | LeapManager::nextFrame(_myAvatar); |
| 2479 | 2566 | |
| @@ -2491,6 +2578,11 @@ void Application::update(float deltaTime) { · 11 unmodified lines | ||
| 2491 | 2578 | if (!_enableNetworkThread) { |
| 2492 | 2579 | networkReceive(0); |
| 2493 | 2580 | } |
| 2581 | + | |
| 2582 | + // parse voxel packets | |
| 2583 | + if (!_enableProcessVoxelsThread) { | |
| 2584 | + processVoxels(0); | |
| 2585 | + } | |
| 2494 | 2586 | |
| 2495 | 2587 | //loop through all the other avatars and simulate them... |
| 2496 | 2588 | NodeList* nodeList = NodeList::getInstance(); |
| @@ -2501,7 +2593,7 @@ void Application::update(float deltaTime) { · 4 unmodified lines | ||
| 2501 | 2593 | if (!avatar->isInitialized()) { |
| 2502 | 2594 | avatar->init(); |
| 2503 | 2595 | } |
| 2504 | − avatar->simulate(deltaTime, NULL); | |
| 2596 | + avatar->simulate(deltaTime, NULL, 0.f); | |
| 2505 | 2597 | avatar->setMouseRay(mouseRayOrigin, mouseRayDirection); |
| 2506 | 2598 | } |
| 2507 | 2599 | node->unlock(); |
| @@ -2516,13 +2608,11 @@ void Application::update(float deltaTime) { · 8 unmodified lines | ||
| 2516 | 2608 | } |
| 2517 | 2609 | |
| 2518 | 2610 | if (_transmitterDrives->isChecked() && _myTransmitter.isConnected()) { |
| 2519 | − _myAvatar.simulate(deltaTime, &_myTransmitter); | |
| 2611 | + _myAvatar.simulate(deltaTime, &_myTransmitter, _gyroCameraSensitivity); | |
| 2520 | 2612 | } else { |
| 2521 | − _myAvatar.simulate(deltaTime, NULL); | |
| 2613 | + _myAvatar.simulate(deltaTime, NULL, _gyroCameraSensitivity); | |
| 2522 | 2614 | } |
| 2523 | 2615 | |
| 2524 | − _myAvatar.getHand().simulate(deltaTime, true); | |
| 2525 | − | |
| 2526 | 2616 | if (!OculusManager::isConnected()) { |
| 2527 | 2617 | if (_lookingInMirror->isChecked()) { |
| 2528 | 2618 | if (_myCamera.getMode() != CAMERA_MODE_MIRROR) { |
| @@ -2575,7 +2665,7 @@ void Application::update(float deltaTime) { · 46 unmodified lines | ||
| 2575 | 2665 | |
| 2576 | 2666 | if (_renderParticleSystemOn->isChecked()) { |
| 2577 | 2667 | updateParticleSystem(deltaTime); |
| 2578 | − } | |
| 2668 | + } | |
| 2579 | 2669 | } |
| 2580 | 2670 | |
| 2581 | 2671 | void Application::updateAvatar(float deltaTime) { |
| @@ -2587,10 +2677,6 @@ void Application::updateAvatar(float deltaTime) { · 5 unmodified lines | ||
| 2587 | 2677 | |
| 2588 | 2678 | // Update my avatar's state from gyros and/or webcam |
| 2589 | 2679 | _myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(), |
| 2590 | − glm::vec3(_headCameraPitchYawScale, | |
| 2591 | − _headCameraPitchYawScale, | |
| 2592 | − _headCameraPitchYawScale), | |
| 2593 | − 0.f, | |
| 2594 | 2680 | _pitchFromTouch); |
| 2595 | 2681 | |
| 2596 | 2682 | if (_serialHeadSensor.isActive()) { |
| @@ -2682,7 +2768,7 @@ void Application::updateAvatar(float deltaTime) { · 85 unmodified lines | ||
| 2682 | 2768 | |
| 2683 | 2769 | // If I'm in paint mode, send a voxel out to VOXEL server nodes. |
| 2684 | 2770 | if (_paintOn) { |
| 2685 | − | |
| 2771 | + | |
| 2686 | 2772 | glm::vec3 avatarPos = _myAvatar.getPosition(); |
| 2687 | 2773 | |
| 2688 | 2774 | // For some reason, we don't want to flip X and Z here. |
| @@ -2693,7 +2779,7 @@ void Application::updateAvatar(float deltaTime) { · 4 unmodified lines | ||
| 2693 | 2779 | if (_paintingVoxel.x >= 0.0 && _paintingVoxel.x <= 1.0 && |
| 2694 | 2780 | _paintingVoxel.y >= 0.0 && _paintingVoxel.y <= 1.0 && |
| 2695 | 2781 | _paintingVoxel.z >= 0.0 && _paintingVoxel.z <= 1.0) { |
| 2696 | − | |
| 2782 | + | |
| 2697 | 2783 | PACKET_TYPE message = (_destructiveAddVoxel->isChecked() ? |
| 2698 | 2784 | PACKET_TYPE_SET_VOXEL_DESTRUCTIVE : PACKET_TYPE_SET_VOXEL); |
| 2699 | 2785 | sendVoxelEditMessage(message, _paintingVoxel); |
| @@ -2713,6 +2799,7 @@ void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) { · 13 unmodified lines | ||
| 2713 | 2799 | float fov = camera.getFieldOfView(); |
| 2714 | 2800 | float nearClip = camera.getNearClip(); |
| 2715 | 2801 | float farClip = camera.getFarClip(); |
| 2802 | + float aspectRatio = camera.getAspectRatio(); | |
| 2716 | 2803 | |
| 2717 | 2804 | glm::quat rotation = camera.getRotation(); |
| 2718 | 2805 | |
| @@ -2721,6 +2808,7 @@ void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) { · 2 unmodified lines | ||
| 2721 | 2808 | viewFrustum.setOrientation(rotation); |
| 2722 | 2809 | |
| 2723 | 2810 | // Also make sure it's got the correct lens details from the camera |
| 2811 | + viewFrustum.setAspectRatio(aspectRatio); | |
| 2724 | 2812 | viewFrustum.setFieldOfView(fov); |
| 2725 | 2813 | viewFrustum.setNearClip(nearClip); |
| 2726 | 2814 | viewFrustum.setFarClip(farClip); |
| @@ -2877,6 +2965,29 @@ void Application::displayOculus(Camera& whichCamera) { · 150 unmodified lines | ||
| 2877 | 2965 | glPopMatrix(); |
| 2878 | 2966 | } |
| 2879 | 2967 | |
| 2968 | +const GLfloat WHITE_SPECULAR_COLOR[] = { 1.0f, 1.0f, 1.0f, 1.0f }; | |
| 2969 | +const GLfloat NO_SPECULAR_COLOR[] = { 0.0f, 0.0f, 0.0f, 1.0f }; | |
| 2970 | + | |
| 2971 | +void Application::setupWorldLight(Camera& whichCamera) { | |
| 2972 | + | |
| 2973 | + // Setup 3D lights (after the camera transform, so that they are positioned in world space) | |
| 2974 | + glEnable(GL_COLOR_MATERIAL); | |
| 2975 | + glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); | |
| 2976 | + | |
| 2977 | + glm::vec3 relativeSunLoc = glm::normalize(_environment.getClosestData(whichCamera.getPosition()).getSunLocation() - | |
| 2978 | + whichCamera.getPosition()); | |
| 2979 | + GLfloat light_position0[] = { relativeSunLoc.x, relativeSunLoc.y, relativeSunLoc.z, 0.0 }; | |
| 2980 | + glLightfv(GL_LIGHT0, GL_POSITION, light_position0); | |
| 2981 | + GLfloat ambient_color[] = { 0.7, 0.7, 0.8 }; | |
| 2982 | + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color); | |
| 2983 | + GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 }; | |
| 2984 | + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color); | |
| 2985 | + | |
| 2986 | + glLightfv(GL_LIGHT0, GL_SPECULAR, WHITE_SPECULAR_COLOR); | |
| 2987 | + glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR); | |
| 2988 | + glMateriali(GL_FRONT, GL_SHININESS, 96); | |
| 2989 | +} | |
| 2990 | + | |
| 2880 | 2991 | void Application::displaySide(Camera& whichCamera) { |
| 2881 | 2992 | // transform by eye offset |
| 2882 | 2993 | |
| @@ -2906,22 +3017,7 @@ void Application::displaySide(Camera& whichCamera) { · 23 unmodified lines | ||
| 2906 | 3017 | glTranslatef(-whichCamera.getPosition().x, -whichCamera.getPosition().y, -whichCamera.getPosition().z); |
| 2907 | 3018 | |
| 2908 | 3019 | // Setup 3D lights (after the camera transform, so that they are positioned in world space) |
| 2909 | − glEnable(GL_COLOR_MATERIAL); | |
| 2910 | − glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); | |
| 2911 | − | |
| 2912 | − glm::vec3 relativeSunLoc = glm::normalize(_environment.getClosestData(whichCamera.getPosition()).getSunLocation() - | |
| 2913 | − whichCamera.getPosition()); | |
| 2914 | − GLfloat light_position0[] = { relativeSunLoc.x, relativeSunLoc.y, relativeSunLoc.z, 0.0 }; | |
| 2915 | − glLightfv(GL_LIGHT0, GL_POSITION, light_position0); | |
| 2916 | − GLfloat ambient_color[] = { 0.7, 0.7, 0.8 }; | |
| 2917 | − glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color); | |
| 2918 | − GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 }; | |
| 2919 | − glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color); | |
| 2920 | − GLfloat specular_color[] = { 1.0, 1.0, 1.0, 1.0}; | |
| 2921 | − glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color); | |
| 2922 | − | |
| 2923 | − glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color); | |
| 2924 | − glMateriali(GL_FRONT, GL_SHININESS, 96); | |
| 3020 | + setupWorldLight(whichCamera); | |
| 2925 | 3021 | |
| 2926 | 3022 | if (_renderStarsOn->isChecked()) { |
| 2927 | 3023 | if (!_stars.getFileLoaded()) { |
| @@ -2966,6 +3062,9 @@ void Application::displaySide(Camera& whichCamera) { · 38 unmodified lines | ||
| 2966 | 3062 | glutSolidSphere(sphereRadius, 15, 15); |
| 2967 | 3063 | glPopMatrix(); |
| 2968 | 3064 | |
| 3065 | + // disable specular lighting for ground and voxels | |
| 3066 | + glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR); | |
| 3067 | + | |
| 2969 | 3068 | //draw a grid ground plane.... |
| 2970 | 3069 | if (_renderGroundPlaneOn->isChecked()) { |
| 2971 | 3070 | // draw grass plane with fog |
| @@ -2987,13 +3086,16 @@ void Application::displaySide(Camera& whichCamera) { · 15 unmodified lines | ||
| 2987 | 3086 | glDisable(GL_FOG); |
| 2988 | 3087 | glDisable(GL_NORMALIZE); |
| 2989 | 3088 | |
| 2990 | − renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude()); | |
| 3089 | + //renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude()); | |
| 2991 | 3090 | } |
| 2992 | 3091 | // Draw voxels |
| 2993 | 3092 | if (_renderVoxels->isChecked()) { |
| 2994 | 3093 | _voxels.render(_renderVoxelTextures->isChecked()); |
| 2995 | 3094 | } |
| 2996 | 3095 | |
| 3096 | + // restore default, white specular | |
| 3097 | + glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR); | |
| 3098 | + | |
| 2997 | 3099 | // indicate what we'll be adding/removing in mouse mode, if anything |
| 2998 | 3100 | if (_mouseVoxel.s != 0) { |
| 2999 | 3101 | glDisable(GL_LIGHTING); |
| @@ -3016,6 +3118,8 @@ void Application::displaySide(Camera& whichCamera) { · 16 unmodified lines | ||
| 3016 | 3118 | glEnable(GL_LIGHTING); |
| 3017 | 3119 | } |
| 3018 | 3120 | |
| 3121 | + _myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera); | |
| 3122 | + | |
| 3019 | 3123 | if (_renderAvatarsOn->isChecked()) { |
| 3020 | 3124 | // Render avatars of other nodes |
| 3021 | 3125 | NodeList* nodeList = NodeList::getInstance(); |
| @@ -3041,7 +3145,7 @@ void Application::displaySide(Camera& whichCamera) { · 19 unmodified lines | ||
| 3041 | 3145 | // Render my own Avatar |
| 3042 | 3146 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 3043 | 3147 | _myAvatar.getHead().setLookAtPosition(_myCamera.getPosition()); |
| 3044 | − } | |
| 3148 | + } | |
| 3045 | 3149 | _myAvatar.render(_lookingInMirror->isChecked(), _renderAvatarBalls->isChecked()); |
| 3046 | 3150 | _myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked()); |
| 3047 | 3151 | |
| @@ -3050,6 +3154,8 @@ void Application::displaySide(Camera& whichCamera) { · 2 unmodified lines | ||
| 3050 | 3154 | } |
| 3051 | 3155 | } |
| 3052 | 3156 | |
| 3157 | + _myAvatar.renderScreenTint(SCREEN_TINT_AFTER_AVATARS, whichCamera); | |
| 3158 | + | |
| 3053 | 3159 | if (_renderParticleSystemOn->isChecked()) { |
| 3054 | 3160 | if (_particleSystemInitialized) { |
| 3055 | 3161 | _particleSystem.render(); |
| @@ -3061,6 +3167,20 @@ void Application::displaySide(Camera& whichCamera) { · 5 unmodified lines | ||
| 3061 | 3167 | |
| 3062 | 3168 | // brad's frustum for debugging |
| 3063 | 3169 | if (_frustumOn->isChecked()) renderViewFrustum(_viewFrustum); |
| 3170 | + | |
| 3171 | + // render voxel fades if they exist | |
| 3172 | + if (_voxelFades.size() > 0) { | |
| 3173 | + for(std::vector<VoxelFade>::iterator fade = _voxelFades.begin(); fade != _voxelFades.end();) { | |
| 3174 | + fade->render(); | |
| 3175 | + if(fade->isDone()) { | |
| 3176 | + fade = _voxelFades.erase(fade); | |
| 3177 | + } else { | |
| 3178 | + ++fade; | |
| 3179 | + } | |
| 3180 | + } | |
| 3181 | + } | |
| 3182 | + | |
| 3183 | + renderFollowIndicator(); | |
| 3064 | 3184 | } |
| 3065 | 3185 | |
| 3066 | 3186 | void Application::displayOverlay() { |
| @@ -3220,7 +3340,7 @@ void Application::displayStats() { · 153 unmodified lines | ||
| 3220 | 3340 | int statsVerticalOffset = 8; |
| 3221 | 3341 | |
| 3222 | 3342 | char stats[200]; |
| 3223 | − sprintf(stats, "%3.0f FPS, %d Pkts/sec, %3.2f Mbps", | |
| 3343 | + sprintf(stats, "%3.0f FPS, %d Pkts/sec, %3.2f Mbps ", | |
| 3224 | 3344 | _fps, _packetsPerSecond, (float)_bytesPerSecond * 8.f / 1000000.f); |
| 3225 | 3345 | drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats); |
| 3226 | 3346 | |
| @@ -3251,11 +3371,16 @@ void Application::displayStats() { · 24 unmodified lines | ||
| 3251 | 3371 | pingVoxel = totalPingVoxel/voxelServerCount; |
| 3252 | 3372 | } |
| 3253 | 3373 | |
| 3254 | − | |
| 3255 | 3374 | char pingStats[200]; |
| 3256 | 3375 | sprintf(pingStats, "Ping audio/avatar/voxel: %d / %d / %d avg %d max ", pingAudio, pingAvatar, pingVoxel, pingVoxelMax); |
| 3257 | 3376 | drawtext(10, statsVerticalOffset + 35, 0.10f, 0, 1.0, 0, pingStats); |
| 3258 | 3377 | } |
| 3378 | + | |
| 3379 | + char avatarStats[200]; | |
| 3380 | + glm::vec3 avatarPos = _myAvatar.getPosition(); | |
| 3381 | + sprintf(avatarStats, "Avatar position: %.3f, %.3f, %.3f, yaw = %.2f", avatarPos.x, avatarPos.y, avatarPos.z, _myAvatar.getBodyYaw()); | |
| 3382 | + drawtext(10, statsVerticalOffset + 55, 0.10f, 0, 1.0, 0, avatarStats); | |
| 3383 | + | |
| 3259 | 3384 | |
| 3260 | 3385 | std::stringstream voxelStats; |
| 3261 | 3386 | voxelStats.precision(4); |
| @@ -3276,6 +3401,11 @@ void Application::displayStats() { · 14 unmodified lines | ||
| 3276 | 3401 | voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ENCODE); |
| 3277 | 3402 | voxelStats << "Encode Time on Server: " << voxelDetails; |
| 3278 | 3403 | drawtext(10, statsVerticalOffset + 290, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); |
| 3404 | + | |
| 3405 | + voxelStats.str(""); | |
| 3406 | + voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_MODE); | |
| 3407 | + voxelStats << "Sending Mode: " << voxelDetails; | |
| 3408 | + drawtext(10, statsVerticalOffset + 310, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); | |
| 3279 | 3409 | |
| 3280 | 3410 | Node *avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); |
| 3281 | 3411 | char avatarMixerStats[200]; |
| @@ -3628,6 +3758,62 @@ void Application::shiftPaintingColor() { · 346 unmodified lines | ||
| 3628 | 3758 | } |
| 3629 | 3759 | |
| 3630 | 3760 | |
| 3761 | +void Application::injectVoxelAddedSoundEffect() { | |
| 3762 | + AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(11025); | |
| 3763 | + | |
| 3764 | + if (voxelInjector) { | |
| 3765 | + voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z)); | |
| 3766 | + //voxelInjector->setBearing(-1 * _myAvatar.getAbsoluteHeadYaw()); | |
| 3767 | + voxelInjector->setVolume (16 * pow (_mouseVoxel.s, 2) / .0000001); //255 is max, and also default value | |
| 3768 | + | |
| 3769 | + /* for (int i = 0; i | |
| 3770 | + < 22050; i++) { | |
| 3771 | + if (i % 4 == 0) { | |
| 3772 | + voxelInjector->addSample(4000); | |
| 3773 | + } else if (i % 4 == 1) { | |
| 3774 | + voxelInjector->addSample(0); | |
| 3775 | + } else if (i % 4 == 2) { | |
| 3776 | + voxelInjector->addSample(-4000); | |
| 3777 | + } else { | |
| 3778 | + voxelInjector->addSample(0); | |
| 3779 | + } | |
| 3780 | + */ | |
| 3781 | + | |
| 3782 | + const float BIG_VOXEL_MIN_SIZE = .01f; | |
| 3783 | + | |
| 3784 | + for (int i = 0; i < 11025; i++) { | |
| 3785 | + | |
| 3786 | + /* | |
| 3787 | + A440 square wave | |
| 3788 | + if (sin(i * 2 * PIE / 50)>=0) { | |
| 3789 | + voxelInjector->addSample(4000); | |
| 3790 | + } else { | |
| 3791 | + voxelInjector->addSample(-4000); | |
| 3792 | + } | |
| 3793 | + */ | |
| 3794 | + | |
| 3795 | + if (_mouseVoxel.s > BIG_VOXEL_MIN_SIZE) { | |
| 3796 | + voxelInjector->addSample(20000 * sin((i * 2 * PIE) / (500 * sin((i + 1) / 200)))); | |
| 3797 | + } else { | |
| 3798 | + voxelInjector->addSample(16000 * sin(i / (1.5 * log (_mouseVoxel.s / .0001) * ((i + 11025) / 5512.5)))); //808 | |
| 3799 | + } | |
| 3800 | + } | |
| 3801 | + | |
| 3802 | + //voxelInjector->addSample(32500 * sin(i/(2 * 1 * ((i+5000)/5512.5)))); //80 | |
| 3803 | + //voxelInjector->addSample(20000 * sin(i/(6 * (_mouseVoxel.s/.001) *((i+5512.5)/5512.5)))); //808 | |
| 3804 | + //voxelInjector->addSample(20000 * sin(i/(6 * ((i+5512.5)/5512.5)))); //808 | |
| 3805 | + //voxelInjector->addSample(4000 * sin(i * 2 * PIE /50)); //A440 sine wave | |
| 3806 | + //voxelInjector->addSample(4000 * sin(i * 2 * PIE /50) * sin (i/500)); //A440 sine wave with amplitude modulation | |
| 3807 | + | |
| 3808 | + //FM library | |
| 3809 | + //voxelInjector->addSample(20000 * sin((i * 2 * PIE) /(500*sin((i+1)/200)))); //FM 1 dubstep | |
| 3810 | + //voxelInjector->addSample(20000 * sin((i * 2 * PIE) /(300*sin((i+1)/5.0)))); //FM 2 flange sweep | |
| 3811 | + //voxelInjector->addSample(10000 * sin((i * 2 * PIE) /(500*sin((i+1)/500.0)))); //FM 3 resonant pulse | |
| 3812 | + | |
| 3813 | + AudioInjectionManager::threadInjector(voxelInjector); | |
| 3814 | + } | |
| 3815 | +} | |
| 3816 | + | |
| 3631 | 3817 | bool Application::maybeEditVoxelUnderCursor() { |
| 3632 | 3818 | if (_addVoxelMode->isChecked() || _colorVoxelMode->isChecked()) { |
| 3633 | 3819 | if (_mouseVoxel.s != 0) { |
| @@ -3638,65 +3824,35 @@ bool Application::maybeEditVoxelUnderCursor() { · 4 unmodified lines | ||
| 3638 | 3824 | // create the voxel locally so it appears immediately |
| 3639 | 3825 | _voxels.createVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s, |
| 3640 | 3826 | _mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue, _destructiveAddVoxel->isChecked()); |
| 3827 | + | |
| 3828 | + // Implement voxel fade effect | |
| 3829 | + VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f); | |
| 3830 | + const float VOXEL_BOUNDS_ADJUST = 0.01f; | |
| 3831 | + float slightlyBigger = _mouseVoxel.s * VOXEL_BOUNDS_ADJUST; | |
| 3832 | + fade.voxelDetails.x = _mouseVoxel.x - slightlyBigger; | |
| 3833 | + fade.voxelDetails.y = _mouseVoxel.y - slightlyBigger; | |
| 3834 | + fade.voxelDetails.z = _mouseVoxel.z - slightlyBigger; | |
| 3835 | + fade.voxelDetails.s = _mouseVoxel.s + slightlyBigger + slightlyBigger; | |
| 3836 | + _voxelFades.push_back(fade); | |
| 3837 | + | |
| 3838 | + // inject a sound effect | |
| 3839 | + injectVoxelAddedSoundEffect(); | |
| 3641 | 3840 | |
| 3642 | 3841 | // remember the position for drag detection |
| 3643 | 3842 | _justEditedVoxel = true; |
| 3644 | 3843 | |
| 3645 | − AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(11025); | |
| 3646 | − voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z)); | |
| 3647 | − //_myAvatar.getPosition() | |
| 3648 | −// voxelInjector->setBearing(-1 * _myAvatar.getAbsoluteHeadYaw()); | |
| 3649 | − voxelInjector->setVolume (16 * pow (_mouseVoxel.s, 2) / .0000001); //255 is max, and also default value | |
| 3650 | − | |
| 3651 | − /* for (int i = 0; i | |
| 3652 | − < 22050; i++) { | |
| 3653 | − if (i % 4 == 0) { | |
| 3654 | − voxelInjector->addSample(4000); | |
| 3655 | − } else if (i % 4 == 1) { | |
| 3656 | − voxelInjector->addSample(0); | |
| 3657 | − } else if (i % 4 == 2) { | |
| 3658 | − voxelInjector->addSample(-4000); | |
| 3659 | − } else { | |
| 3660 | − voxelInjector->addSample(0); | |
| 3661 | − } | |
| 3662 | − */ | |
| 3663 | − | |
| 3664 | − | |
| 3665 | − const float BIG_VOXEL_MIN_SIZE = .01f; | |
| 3666 | − | |
| 3667 | − for (int i = 0; i < 11025; i++) { | |
| 3668 | − | |
| 3669 | − /* | |
| 3670 | − A440 square wave | |
| 3671 | − if (sin(i * 2 * PIE / 50)>=0) { | |
| 3672 | − voxelInjector->addSample(4000); | |
| 3673 | − } else { | |
| 3674 | − voxelInjector->addSample(-4000); | |
| 3675 | − } | |
| 3676 | − */ | |
| 3677 | − | |
| 3678 | − if (_mouseVoxel.s > BIG_VOXEL_MIN_SIZE) { | |
| 3679 | − voxelInjector->addSample(20000 * sin((i * 2 * PIE) / (500 * sin((i + 1) / 200)))); | |
| 3680 | − } else { | |
| 3681 | − voxelInjector->addSample(16000 * sin(i / (1.5 * log (_mouseVoxel.s / .0001) * ((i + 11025) / 5512.5)))); //808 | |
| 3682 | − } | |
| 3683 | − } | |
| 3684 | − | |
| 3685 | − //voxelInjector->addSample(32500 * sin(i/(2 * 1 * ((i+5000)/5512.5)))); //80 | |
| 3686 | − //voxelInjector->addSample(20000 * sin(i/(6 * (_mouseVoxel.s/.001) *((i+5512.5)/5512.5)))); //808 | |
| 3687 | − //voxelInjector->addSample(20000 * sin(i/(6 * ((i+5512.5)/5512.5)))); //808 | |
| 3688 | − //voxelInjector->addSample(4000 * sin(i * 2 * PIE /50)); //A440 sine wave | |
| 3689 | − //voxelInjector->addSample(4000 * sin(i * 2 * PIE /50) * sin (i/500)); //A440 sine wave with amplitude modulation | |
| 3690 | − | |
| 3691 | − //FM library | |
| 3692 | − //voxelInjector->addSample(20000 * sin((i * 2 * PIE) /(500*sin((i+1)/200)))); //FM 1 dubstep | |
| 3693 | − //voxelInjector->addSample(20000 * sin((i * 2 * PIE) /(300*sin((i+1)/5.0)))); //FM 2 flange sweep | |
| 3694 | − //voxelInjector->addSample(10000 * sin((i * 2 * PIE) /(500*sin((i+1)/500.0)))); //FM 3 resonant pulse | |
| 3695 | − | |
| 3696 | − AudioInjectionManager::threadInjector(voxelInjector); | |
| 3697 | 3844 | } |
| 3698 | 3845 | } else if (_deleteVoxelMode->isChecked()) { |
| 3699 | 3846 | deleteVoxelUnderCursor(); |
| 3847 | + VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f); | |
| 3848 | + const float VOXEL_BOUNDS_ADJUST = 0.01f; | |
| 3849 | + float slightlyBigger = _mouseVoxel.s * VOXEL_BOUNDS_ADJUST; | |
| 3850 | + fade.voxelDetails.x = _mouseVoxel.x - slightlyBigger; | |
| 3851 | + fade.voxelDetails.y = _mouseVoxel.y - slightlyBigger; | |
| 3852 | + fade.voxelDetails.z = _mouseVoxel.z - slightlyBigger; | |
| 3853 | + fade.voxelDetails.s = _mouseVoxel.s + slightlyBigger + slightlyBigger; | |
| 3854 | + _voxelFades.push_back(fade); | |
| 3855 | + | |
| 3700 | 3856 | } else if (_eyedropperMode->isChecked()) { |
| 3701 | 3857 | eyedropperVoxelUnderCursor(); |
| 3702 | 3858 | } else { |
| @@ -3711,17 +3867,20 @@ void Application::deleteVoxelUnderCursor() { · 8 unmodified lines | ||
| 3711 | 3867 | // sending delete to the server is sufficient, server will send new version so we see updates soon enough |
| 3712 | 3868 | sendVoxelEditMessage(PACKET_TYPE_ERASE_VOXEL, _mouseVoxel); |
| 3713 | 3869 | AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(5000); |
| 3714 | − voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z)); | |
| 3715 | −// voxelInjector->setBearing(0); //straight down the z axis | |
| 3716 | − voxelInjector->setVolume (255); //255 is max, and also default value | |
| 3717 | 3870 | |
| 3718 | − | |
| 3719 | − for (int i = 0; i < 5000; i++) { | |
| 3720 | − voxelInjector->addSample(10000 * sin((i * 2 * PIE) / (500 * sin((i + 1) / 500.0)))); //FM 3 resonant pulse | |
| 3721 | − //voxelInjector->addSample(20000 * sin((i) /((4 / _mouseVoxel.s) * sin((i)/(20 * _mouseVoxel.s / .001))))); //FM 2 comb filter | |
| 3871 | + if (voxelInjector) { | |
| 3872 | + voxelInjector->setPosition(glm::vec3(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z)); | |
| 3873 | + //voxelInjector->setBearing(0); //straight down the z axis | |
| 3874 | + voxelInjector->setVolume (255); //255 is max, and also default value | |
| 3875 | + | |
| 3876 | + | |
| 3877 | + for (int i = 0; i < 5000; i++) { | |
| 3878 | + voxelInjector->addSample(10000 * sin((i * 2 * PIE) / (500 * sin((i + 1) / 500.0)))); //FM 3 resonant pulse | |
| 3879 | + //voxelInjector->addSample(20000 * sin((i) /((4 / _mouseVoxel.s) * sin((i)/(20 * _mouseVoxel.s / .001))))); //FM 2 comb filter | |
| 3880 | + } | |
| 3881 | + | |
| 3882 | + AudioInjectionManager::threadInjector(voxelInjector); | |
| 3722 | 3883 | } |
| 3723 | − | |
| 3724 | − AudioInjectionManager::threadInjector(voxelInjector); | |
| 3725 | 3884 | } |
| 3726 | 3885 | // remember the position for drag detection |
| 3727 | 3886 | _justEditedVoxel = true; |
| @@ -3818,6 +3977,133 @@ void Application::attachNewHeadToNode(Node* newNode) { · 90 unmodified lines | ||
| 3818 | 3977 | } |
| 3819 | 3978 | } |
| 3820 | 3979 | |
| 3980 | +void Application::nodeAdded(Node* node) { | |
| 3981 | +} | |
| 3982 | + | |
| 3983 | +void Application::nodeKilled(Node* node) { | |
| 3984 | + if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | |
| 3985 | + uint16_t nodeID = node->getNodeID(); | |
| 3986 | + // see if this is the first we've heard of this node... | |
| 3987 | + if (_voxelServerJurisdictions.find(nodeID) != _voxelServerJurisdictions.end()) { | |
| 3988 | + VoxelPositionSize jurisditionDetails; | |
| 3989 | + jurisditionDetails = _voxelServerJurisdictions[nodeID]; | |
| 3990 | + | |
| 3991 | + printf("voxel server going away...... v[%f, %f, %f, %f]\n", | |
| 3992 | + jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s); | |
| 3993 | + | |
| 3994 | + // Add the jurisditionDetails object to the list of "fade outs" | |
| 3995 | + VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE); | |
| 3996 | + fade.voxelDetails = jurisditionDetails; | |
| 3997 | + const float slightly_smaller = 0.99; | |
| 3998 | + fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller; | |
| 3999 | + _voxelFades.push_back(fade); | |
| 4000 | + } | |
| 4001 | + } | |
| 4002 | +} | |
| 4003 | + | |
| 4004 | +int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLength, sockaddr senderAddress) { | |
| 4005 | + | |
| 4006 | + // parse the incoming stats data, and stick it into our averaging stats object for now... even though this | |
| 4007 | + // means mixing in stats from potentially multiple servers. | |
| 4008 | + int statsMessageLength = _voxelSceneStats.unpackFromMessage(messageData, messageLength); | |
| 4009 | + | |
| 4010 | + // But, also identify the sender, and keep track of the contained jurisdiction root for this server | |
| 4011 | + Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress); | |
| 4012 | + | |
| 4013 | + // quick fix for crash... why would voxelServer be NULL? | |
| 4014 | + if (voxelServer) { | |
| 4015 | + uint16_t nodeID = voxelServer->getNodeID(); | |
| 4016 | + | |
| 4017 | + VoxelPositionSize jurisditionDetails; | |
| 4018 | + voxelDetailsForCode(_voxelSceneStats.getJurisdictionRoot(), jurisditionDetails); | |
| 4019 | + | |
| 4020 | + // see if this is the first we've heard of this node... | |
| 4021 | + if (_voxelServerJurisdictions.find(nodeID) == _voxelServerJurisdictions.end()) { | |
| 4022 | + printf("stats from new voxel server... v[%f, %f, %f, %f]\n", | |
| 4023 | + jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s); | |
| 4024 | + | |
| 4025 | + // Add the jurisditionDetails object to the list of "fade outs" | |
| 4026 | + VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE); | |
| 4027 | + fade.voxelDetails = jurisditionDetails; | |
| 4028 | + const float slightly_smaller = 0.99; | |
| 4029 | + fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller; | |
| 4030 | + _voxelFades.push_back(fade); | |
| 4031 | + } | |
| 4032 | + // store jurisdiction details for later use | |
| 4033 | + _voxelServerJurisdictions[nodeID] = jurisditionDetails; | |
| 4034 | + } | |
| 4035 | + return statsMessageLength; | |
| 4036 | +} | |
| 4037 | + | |
| 4038 | +// Receive packets from other nodes/servers and decide what to do with them! | |
| 4039 | +void* Application::processVoxels(void* args) { | |
| 4040 | + Application* app = Application::getInstance(); | |
| 4041 | + while (!app->_stopProcessVoxelsThread) { | |
| 4042 | + | |
| 4043 | + // check to see if the UI thread asked us to kill the voxel tree. since we're the only thread allowed to do that | |
| 4044 | + if (app->_wantToKillLocalVoxels) { | |
| 4045 | + app->_voxels.killLocalVoxels(); | |
| 4046 | + app->_wantToKillLocalVoxels = false; | |
| 4047 | + } | |
| 4048 | + | |
| 4049 | + while (app->_voxelPackets.size() > 0) { | |
| 4050 | + NetworkPacket& packet = app->_voxelPackets.front(); | |
| 4051 | + app->processVoxelPacket(packet.getSenderAddress(), packet.getData(), packet.getLength()); | |
| 4052 | + app->_voxelPackets.erase(app->_voxelPackets.begin()); | |
| 4053 | + } | |
| 4054 | + | |
| 4055 | + if (!app->_enableProcessVoxelsThread) { | |
| 4056 | + break; | |
| 4057 | + } | |
| 4058 | + } | |
| 4059 | + | |
| 4060 | + if (app->_enableProcessVoxelsThread) { | |
| 4061 | + pthread_exit(0); | |
| 4062 | + } | |
| 4063 | + return NULL; | |
| 4064 | +} | |
| 4065 | + | |
| 4066 | +void Application::queueVoxelPacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength) { | |
| 4067 | + _voxelPackets.push_back(NetworkPacket(senderAddress, packetData, packetLength)); | |
| 4068 | +} | |
| 4069 | + | |
| 4070 | +void Application::processVoxelPacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength) { | |
| 4071 | + PerformanceWarning warn(_renderPipelineWarnings->isChecked(),"processVoxelPacket()"); | |
| 4072 | + ssize_t messageLength = packetLength; | |
| 4073 | + | |
| 4074 | + // note: PACKET_TYPE_VOXEL_STATS can have PACKET_TYPE_VOXEL_DATA or PACKET_TYPE_VOXEL_DATA_MONOCHROME | |
| 4075 | + // immediately following them inside the same packet. So, we process the PACKET_TYPE_VOXEL_STATS first | |
| 4076 | + // then process any remaining bytes as if it was another packet | |
| 4077 | + if (packetData[0] == PACKET_TYPE_VOXEL_STATS) { | |
| 4078 | + | |
| 4079 | + int statsMessageLength = parseVoxelStats(packetData, messageLength, senderAddress); | |
| 4080 | + if (messageLength > statsMessageLength) { | |
| 4081 | + packetData += statsMessageLength; | |
| 4082 | + messageLength -= statsMessageLength; | |
| 4083 | + if (!packetVersionMatch(packetData)) { | |
| 4084 | + return; // bail since piggyback data doesn't match our versioning | |
| 4085 | + } | |
| 4086 | + } else { | |
| 4087 | + return; // bail since no piggyback data | |
| 4088 | + } | |
| 4089 | + } // fall through to piggyback message | |
| 4090 | + | |
| 4091 | + if (_renderVoxels->isChecked()) { | |
| 4092 | + Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress); | |
| 4093 | + if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) { | |
| 4094 | + voxelServer->lock(); | |
| 4095 | + if (packetData[0] == PACKET_TYPE_ENVIRONMENT_DATA) { | |
| 4096 | + _environment.parseData(&senderAddress, packetData, messageLength); | |
| 4097 | + } else { | |
| 4098 | + _voxels.setDataSourceID(voxelServer->getNodeID()); | |
| 4099 | + _voxels.parseData(packetData, messageLength); | |
| 4100 | + _voxels.setDataSourceID(UNKNOWN_NODE_ID); | |
| 4101 | + } | |
| 4102 | + voxelServer->unlock(); | |
| 4103 | + } | |
| 4104 | + } | |
| 4105 | +} | |
| 4106 | + | |
| 3821 | 4107 | // Receive packets from other nodes/servers and decide what to do with them! |
| 3822 | 4108 | void* Application::networkReceive(void* args) { |
| 3823 | 4109 | sockaddr senderAddress; |
| @@ -3853,40 +4139,8 @@ void* Application::networkReceive(void* args) { · 29 unmodified lines | ||
| 3853 | 4139 | case PACKET_TYPE_ERASE_VOXEL: |
| 3854 | 4140 | case PACKET_TYPE_VOXEL_STATS: |
| 3855 | 4141 | case PACKET_TYPE_ENVIRONMENT_DATA: { |
| 3856 | − | |
| 3857 | − unsigned char* messageData = app->_incomingPacket; | |
| 3858 | − ssize_t messageLength = bytesReceived; | |
| 3859 | − | |
| 3860 | − // note: PACKET_TYPE_VOXEL_STATS can have PACKET_TYPE_VOXEL_DATA or PACKET_TYPE_VOXEL_DATA_MONOCHROME | |
| 3861 | − // immediately following them inside the same packet. So, we process the PACKET_TYPE_VOXEL_STATS first | |
| 3862 | − // then process any remaining bytes as if it was another packet | |
| 3863 | − if (messageData[0] == PACKET_TYPE_VOXEL_STATS) { | |
| 3864 | − int statsMessageLength = app->_voxelSceneStats.unpackFromMessage(messageData, messageLength); | |
| 3865 | − if (messageLength > statsMessageLength) { | |
| 3866 | − messageData += statsMessageLength; | |
| 3867 | − messageLength -= statsMessageLength; | |
| 3868 | − if (!packetVersionMatch(messageData)) { | |
| 3869 | − break; // bail since piggyback data doesn't match our versioning | |
| 3870 | − } | |
| 3871 | − } else { | |
| 3872 | − break; // bail since no piggyback data | |
| 3873 | − } | |
| 3874 | − } // fall through to piggyback message | |
| 3875 | − | |
| 3876 | − if (app->_renderVoxels->isChecked()) { | |
| 3877 | − Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress); | |
| 3878 | − if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) { | |
| 3879 | − voxelServer->lock(); | |
| 3880 | − if (messageData[0] == PACKET_TYPE_ENVIRONMENT_DATA) { | |
| 3881 | − app->_environment.parseData(&senderAddress, messageData, messageLength); | |
| 3882 | − } else { | |
| 3883 | − app->_voxels.setDataSourceID(voxelServer->getNodeID()); | |
| 3884 | − app->_voxels.parseData(messageData, messageLength); | |
| 3885 | − app->_voxels.setDataSourceID(UNKNOWN_NODE_ID); | |
| 3886 | − } | |
| 3887 | − voxelServer->unlock(); | |
| 3888 | − } | |
| 3889 | − } | |
| 4142 | + // add this packet to our list of voxel packets and process them on the voxel processing | |
| 4143 | + app->queueVoxelPacket(senderAddress, app->_incomingPacket, bytesReceived); | |
| 3890 | 4144 | break; |
| 3891 | 4145 | } |
| 3892 | 4146 | case PACKET_TYPE_BULK_AVATAR_DATA: |
| @@ -3955,13 +4209,13 @@ void Application::saveAction(QSettings* set, QAction* action) { · 62 unmodified lines | ||
| 3955 | 4209 | } |
| 3956 | 4210 | |
| 3957 | 4211 | void Application::loadSettings(QSettings* settings) { |
| 3958 | − if (!settings) { | |
| 4212 | + if (!settings) { | |
| 3959 | 4213 | settings = getSettings(); |
| 3960 | 4214 | } |
| 3961 | 4215 | |
| 3962 | − _headCameraPitchYawScale = loadSetting(settings, "headCameraPitchYawScale", 0.0f); | |
| 4216 | + _gyroCameraSensitivity = loadSetting(settings, "gyroCameraSensitivity", 0.5f); | |
| 3963 | 4217 | _audioJitterBufferSamples = loadSetting(settings, "audioJitterBufferSamples", 0); |
| 3964 | − _horizontalFieldOfView = loadSetting(settings, "horizontalFieldOfView", HORIZONTAL_FIELD_OF_VIEW_DEGREES); | |
| 4218 | + _fieldOfView = loadSetting(settings, "fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES); | |
| 3965 | 4219 | |
| 3966 | 4220 | settings->beginGroup("View Frustum Offset Camera"); |
| 3967 | 4221 | // in case settings is corrupt or missing loadSetting() will check for NaN |
| @@ -3983,9 +4237,9 @@ void Application::saveSettings(QSettings* settings) { · 15 unmodified lines | ||
| 3983 | 4237 | settings = getSettings(); |
| 3984 | 4238 | } |
| 3985 | 4239 | |
| 3986 | − settings->setValue("headCameraPitchYawScale", _headCameraPitchYawScale); | |
| 4240 | + settings->setValue("gyroCameraSensitivity", _gyroCameraSensitivity); | |
| 3987 | 4241 | settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples); |
| 3988 | − settings->setValue("horizontalFieldOfView", _horizontalFieldOfView); | |
| 4242 | + settings->setValue("fieldOfView", _fieldOfView); | |
| 3989 | 4243 | settings->beginGroup("View Frustum Offset Camera"); |
| 3990 | 4244 | settings->setValue("viewFrustumOffsetYaw", _viewFrustumOffsetYaw); |
| 3991 | 4245 | settings->setValue("viewFrustumOffsetPitch", _viewFrustumOffsetPitch); |