Showing the changes to interface/src/Application.cpp (1 of 110 files). Show all
Unified · Split
| @@ -132,8 +132,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 131 unmodified lines | ||
| 132 | 132 | _lookatIndicatorScale(1.0f), |
| 133 | 133 | _perfStatsOn(false), |
| 134 | 134 | _chatEntryOn(false), |
| 135 | − _oculusProgram(0), | |
| 136 | − _oculusDistortionScale(1.25), | |
| 137 | 135 | #ifndef _WIN32 |
| 138 | 136 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), |
| 139 | 137 | #endif |
| @@ -248,7 +246,6 @@ Application::~Application() { · 108 unmodified lines | ||
| 248 | 246 | VoxelNode::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown |
| 249 | 247 | delete Menu::getInstance(); |
| 250 | 248 | |
| 251 | − delete _oculusProgram; | |
| 252 | 249 | delete _settings; |
| 253 | 250 | delete _followMode; |
| 254 | 251 | delete _glWidget; |
| @@ -425,7 +422,7 @@ void Application::paintGL() { · 170 unmodified lines | ||
| 425 | 422 | } |
| 426 | 423 | |
| 427 | 424 | if (OculusManager::isConnected()) { |
| 428 | − displayOculus(whichCamera); | |
| 425 | + OculusManager::display(whichCamera); | |
| 429 | 426 | |
| 430 | 427 | } else { |
| 431 | 428 | _glowEffect.prepare(); |
| @@ -516,14 +513,11 @@ void Application::paintGL() { · 84 unmodified lines | ||
| 516 | 513 | } |
| 517 | 514 | |
| 518 | 515 | void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) { |
| 519 | − float aspectRatio = ((float)width/(float)height); // based on screen resize | |
| 520 | − | |
| 521 | 516 | if (OculusManager::isConnected()) { |
| 522 | − // more magic numbers; see Oculus SDK docs, p. 32 | |
| 523 | − camera.setAspectRatio(aspectRatio *= 0.5); | |
| 524 | − camera.setFieldOfView(2 * atan((0.0468 * _oculusDistortionScale) / 0.041) * (180 / PIf)); | |
| 517 | + OculusManager::configureCamera(camera, width, height); | |
| 518 | + | |
| 525 | 519 | } else { |
| 526 | − camera.setAspectRatio(aspectRatio); | |
| 520 | + camera.setAspectRatio((float)width / height); | |
| 527 | 521 | camera.setFieldOfView(Menu::getInstance()->getFieldOfView()); |
| 528 | 522 | } |
| 529 | 523 | } |
| @@ -682,9 +676,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 152 unmodified lines | ||
| 682 | 676 | break; |
| 683 | 677 | |
| 684 | 678 | case Qt::Key_C: |
| 685 | − if (isShifted) { | |
| 686 | − Menu::getInstance()->triggerOption(MenuOption::OcclusionCulling); | |
| 687 | − } else if (_nudgeStarted) { | |
| 679 | + if (_nudgeStarted) { | |
| 688 | 680 | _nudgeGuidePosition.y -= _mouseVoxel.s; |
| 689 | 681 | } else { |
| 690 | 682 | _myAvatar.setDriveKeys(DOWN, 1); |
| @@ -1472,7 +1464,6 @@ void Application::checkBandwidthMeterClick() { · 781 unmodified lines | ||
| 1472 | 1464 | void Application::setFullscreen(bool fullscreen) { |
| 1473 | 1465 | _window->setWindowState(fullscreen ? (_window->windowState() | Qt::WindowFullScreen) : |
| 1474 | 1466 | (_window->windowState() & ~Qt::WindowFullScreen)); |
| 1475 | − updateCursor(); | |
| 1476 | 1467 | } |
| 1477 | 1468 | |
| 1478 | 1469 | void Application::setRenderVoxels(bool voxelRender) { |
| @@ -1486,6 +1477,54 @@ void Application::doKillLocalVoxels() { · 7 unmodified lines | ||
| 1486 | 1477 | _wantToKillLocalVoxels = true; |
| 1487 | 1478 | } |
| 1488 | 1479 | |
| 1480 | +void Application::removeVoxel(glm::vec3 position, | |
| 1481 | + float scale) { | |
| 1482 | + VoxelDetail voxel; | |
| 1483 | + voxel.x = position.x / TREE_SCALE; | |
| 1484 | + voxel.y = position.y / TREE_SCALE; | |
| 1485 | + voxel.z = position.z / TREE_SCALE; | |
| 1486 | + voxel.s = scale / TREE_SCALE; | |
| 1487 | + _voxelEditSender.sendVoxelEditMessage(PACKET_TYPE_ERASE_VOXEL, voxel); | |
| 1488 | + | |
| 1489 | + // delete it locally to see the effect immediately (and in case no voxel server is present) | |
| 1490 | + _voxels.deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s); | |
| 1491 | +} | |
| 1492 | + | |
| 1493 | +void Application::makeVoxel(glm::vec3 position, | |
| 1494 | + float scale, | |
| 1495 | + unsigned char red, | |
| 1496 | + unsigned char green, | |
| 1497 | + unsigned char blue, | |
| 1498 | + bool isDestructive) { | |
| 1499 | + VoxelDetail voxel; | |
| 1500 | + voxel.x = position.x / TREE_SCALE; | |
| 1501 | + voxel.y = position.y / TREE_SCALE; | |
| 1502 | + voxel.z = position.z / TREE_SCALE; | |
| 1503 | + voxel.s = scale / TREE_SCALE; | |
| 1504 | + voxel.red = red; | |
| 1505 | + voxel.green = green; | |
| 1506 | + voxel.blue = blue; | |
| 1507 | + PACKET_TYPE message = isDestructive ? PACKET_TYPE_SET_VOXEL_DESTRUCTIVE : PACKET_TYPE_SET_VOXEL; | |
| 1508 | + _voxelEditSender.sendVoxelEditMessage(message, voxel); | |
| 1509 | + | |
| 1510 | + // create the voxel locally so it appears immediately | |
| 1511 | + | |
| 1512 | + _voxels.createVoxel(voxel.x, voxel.y, voxel.z, voxel.s, | |
| 1513 | + voxel.red, voxel.green, voxel.blue, | |
| 1514 | + isDestructive); | |
| 1515 | + | |
| 1516 | + // Implement voxel fade effect | |
| 1517 | + VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f); | |
| 1518 | + const float VOXEL_BOUNDS_ADJUST = 0.01f; | |
| 1519 | + float slightlyBigger = voxel.s * VOXEL_BOUNDS_ADJUST; | |
| 1520 | + fade.voxelDetails.x = voxel.x - slightlyBigger; | |
| 1521 | + fade.voxelDetails.y = voxel.y - slightlyBigger; | |
| 1522 | + fade.voxelDetails.z = voxel.z - slightlyBigger; | |
| 1523 | + fade.voxelDetails.s = voxel.s + slightlyBigger + slightlyBigger; | |
| 1524 | + _voxelFades.push_back(fade); | |
| 1525 | + | |
| 1526 | +} | |
| 1527 | + | |
| 1489 | 1528 | const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) { |
| 1490 | 1529 | return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE, |
| 1491 | 1530 | (_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE, |
| @@ -1523,7 +1562,6 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { · 31 unmodified lines | ||
| 1523 | 1562 | SendVoxelsOperationArgs* args = (SendVoxelsOperationArgs*)extraData; |
| 1524 | 1563 | if (node->isColored()) { |
| 1525 | 1564 | const unsigned char* nodeOctalCode = node->getOctalCode(); |
| 1526 | − | |
| 1527 | 1565 | unsigned char* codeColorBuffer = NULL; |
| 1528 | 1566 | int codeLength = 0; |
| 1529 | 1567 | int bytesInCode = 0; |
| @@ -1544,10 +1582,9 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { · 14 unmodified lines | ||
| 1544 | 1582 | } |
| 1545 | 1583 | |
| 1546 | 1584 | // copy the colors over |
| 1547 | − codeColorBuffer[bytesInCode + RED_INDEX ] = node->getColor()[RED_INDEX ]; | |
| 1585 | + codeColorBuffer[bytesInCode + RED_INDEX] = node->getColor()[RED_INDEX]; | |
| 1548 | 1586 | codeColorBuffer[bytesInCode + GREEN_INDEX] = node->getColor()[GREEN_INDEX]; |
| 1549 | − codeColorBuffer[bytesInCode + BLUE_INDEX ] = node->getColor()[BLUE_INDEX ]; | |
| 1550 | − | |
| 1587 | + codeColorBuffer[bytesInCode + BLUE_INDEX] = node->getColor()[BLUE_INDEX]; | |
| 1551 | 1588 | getInstance()->_voxelEditSender.queueVoxelEditMessage(PACKET_TYPE_SET_VOXEL_DESTRUCTIVE, |
| 1552 | 1589 | codeColorBuffer, codeAndColorLength); |
| 1553 | 1590 | |
| @@ -1611,7 +1648,6 @@ void Application::pasteVoxelsToOctalCode(const unsigned char* octalCodeDestinati · 57 unmodified lines | ||
| 1611 | 1648 | // the server as an set voxel message, this will also rebase the voxels to the new location |
| 1612 | 1649 | SendVoxelsOperationArgs args; |
| 1613 | 1650 | args.newBaseOctCode = octalCodeDestination; |
| 1614 | − | |
| 1615 | 1651 | _sharedVoxelSystem.getTree()->recurseTreeWithOperation(sendVoxelsOperation, &args); |
| 1616 | 1652 | |
| 1617 | 1653 | if (_sharedVoxelSystem.getTree() != &_clipboard) { |
| @@ -1770,7 +1806,7 @@ void Application::init() { · 152 unmodified lines | ||
| 1770 | 1806 | _voxels.setMaxVoxels(Menu::getInstance()->getMaxVoxels()); |
| 1771 | 1807 | _voxels.setUseVoxelShader(Menu::getInstance()->isOptionChecked(MenuOption::UseVoxelShader)); |
| 1772 | 1808 | _voxels.setVoxelsAsPoints(Menu::getInstance()->isOptionChecked(MenuOption::VoxelsAsPoints)); |
| 1773 | − _voxels.setDisableFastVoxelPipeline(Menu::getInstance()->isOptionChecked(MenuOption::DisableFastVoxelPipeline)); | |
| 1809 | + _voxels.setDisableFastVoxelPipeline(false); | |
| 1774 | 1810 | _voxels.init(); |
| 1775 | 1811 | |
| 1776 | 1812 | |
| @@ -2223,11 +2259,11 @@ void Application::updateLeap(float deltaTime) { · 446 unmodified lines | ||
| 2223 | 2259 | LeapManager::nextFrame(); |
| 2224 | 2260 | } |
| 2225 | 2261 | |
| 2226 | −void Application::updateSixense() { | |
| 2262 | +void Application::updateSixense(float deltaTime) { | |
| 2227 | 2263 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2228 | 2264 | PerformanceWarning warn(showWarnings, "Application::updateSixense()"); |
| 2229 | 2265 | |
| 2230 | − _sixenseManager.update(); | |
| 2266 | + _sixenseManager.update(deltaTime); | |
| 2231 | 2267 | } |
| 2232 | 2268 | |
| 2233 | 2269 | void Application::updateSerialDevices(float deltaTime) { |
| @@ -2437,7 +2473,7 @@ void Application::update(float deltaTime) { · 203 unmodified lines | ||
| 2437 | 2473 | updateMouseVoxels(deltaTime, mouseRayOrigin, mouseRayDirection, distance, face); // UI/UX related to voxels |
| 2438 | 2474 | updateHandAndTouch(deltaTime); // Update state for touch sensors |
| 2439 | 2475 | updateLeap(deltaTime); // Leap finger-sensing device |
| 2440 | − updateSixense(); // Razer Hydra controllers | |
| 2476 | + updateSixense(deltaTime); // Razer Hydra controllers | |
| 2441 | 2477 | updateSerialDevices(deltaTime); // Read serial port interface devices |
| 2442 | 2478 | updateAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes |
| 2443 | 2479 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| @@ -2577,10 +2613,11 @@ void Application::queryVoxels() { · 133 unmodified lines | ||
| 2577 | 2613 | bool wantExtraDebugging = Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging); |
| 2578 | 2614 | |
| 2579 | 2615 | // These will be the same for all servers, so we can set them up once and then reuse for each server we send to. |
| 2580 | − _voxelQuery.setWantLowResMoving(Menu::getInstance()->isOptionChecked(MenuOption::LowRes)); | |
| 2581 | − _voxelQuery.setWantColor(Menu::getInstance()->isOptionChecked(MenuOption::SendVoxelColors)); | |
| 2582 | − _voxelQuery.setWantDelta(Menu::getInstance()->isOptionChecked(MenuOption::DeltaSending)); | |
| 2583 | − _voxelQuery.setWantOcclusionCulling(Menu::getInstance()->isOptionChecked(MenuOption::OcclusionCulling)); | |
| 2616 | + _voxelQuery.setWantLowResMoving(!Menu::getInstance()->isOptionChecked(MenuOption::DisableLowRes)); | |
| 2617 | + _voxelQuery.setWantColor(!Menu::getInstance()->isOptionChecked(MenuOption::DisableColorVoxels)); | |
| 2618 | + _voxelQuery.setWantDelta(!Menu::getInstance()->isOptionChecked(MenuOption::DisableDeltaSending)); | |
| 2619 | + _voxelQuery.setWantOcclusionCulling(Menu::getInstance()->isOptionChecked(MenuOption::EnableOcclusionCulling)); | |
| 2620 | + _voxelQuery.setWantCompression(Menu::getInstance()->isOptionChecked(MenuOption::EnableVoxelPacketCompression)); | |
| 2584 | 2621 | |
| 2585 | 2622 | _voxelQuery.setCameraPosition(_viewFrustum.getPosition()); |
| 2586 | 2623 | _voxelQuery.setCameraOrientation(_viewFrustum.getOrientation()); |
| @@ -2642,15 +2679,16 @@ void Application::queryVoxels() { · 55 unmodified lines | ||
| 2642 | 2679 | int perServerPPS = 0; |
| 2643 | 2680 | const int SMALL_BUDGET = 10; |
| 2644 | 2681 | int perUnknownServer = SMALL_BUDGET; |
| 2682 | + int totalPPS = Menu::getInstance()->getMaxVoxelPacketsPerSecond(); | |
| 2645 | 2683 | |
| 2646 | 2684 | // determine PPS based on number of servers |
| 2647 | 2685 | if (inViewServers >= 1) { |
| 2648 | 2686 | // set our preferred PPS to be exactly evenly divided among all of the voxel servers... and allocate 1 PPS |
| 2649 | 2687 | // for each unknown jurisdiction server |
| 2650 | − perServerPPS = (DEFAULT_MAX_VOXEL_PPS / inViewServers) - (unknownJurisdictionServers * perUnknownServer); | |
| 2688 | + perServerPPS = (totalPPS / inViewServers) - (unknownJurisdictionServers * perUnknownServer); | |
| 2651 | 2689 | } else { |
| 2652 | 2690 | if (unknownJurisdictionServers > 0) { |
| 2653 | − perUnknownServer = (DEFAULT_MAX_VOXEL_PPS / unknownJurisdictionServers); | |
| 2691 | + perUnknownServer = (totalPPS / unknownJurisdictionServers); | |
| 2654 | 2692 | } |
| 2655 | 2693 | } |
| 2656 | 2694 | |
| @@ -2857,146 +2895,7 @@ void Application::updateShadowMap() { · 200 unmodified lines | ||
| 2857 | 2895 | |
| 2858 | 2896 | glViewport(0, 0, _glWidget->width(), _glWidget->height()); |
| 2859 | 2897 | } |
| 2860 | − | |
| 2861 | −// this shader is an adaptation (HLSL -> GLSL, removed conditional) of the one in the Oculus sample | |
| 2862 | −// code (Samples/OculusRoomTiny/RenderTiny_D3D1X_Device.cpp), which is under the Apache license | |
| 2863 | −// (http://www.apache.org/licenses/LICENSE-2.0) | |
| 2864 | −static const char* DISTORTION_FRAGMENT_SHADER = | |
| 2865 | − "#version 120\n" | |
| 2866 | − "uniform sampler2D texture;" | |
| 2867 | − "uniform vec2 lensCenter;" | |
| 2868 | − "uniform vec2 screenCenter;" | |
| 2869 | − "uniform vec2 scale;" | |
| 2870 | − "uniform vec2 scaleIn;" | |
| 2871 | − "uniform vec4 hmdWarpParam;" | |
| 2872 | − "vec2 hmdWarp(vec2 in01) {" | |
| 2873 | − " vec2 theta = (in01 - lensCenter) * scaleIn;" | |
| 2874 | − " float rSq = theta.x * theta.x + theta.y * theta.y;" | |
| 2875 | − " vec2 theta1 = theta * (hmdWarpParam.x + hmdWarpParam.y * rSq + " | |
| 2876 | − " hmdWarpParam.z * rSq * rSq + hmdWarpParam.w * rSq * rSq * rSq);" | |
| 2877 | − " return lensCenter + scale * theta1;" | |
| 2878 | − "}" | |
| 2879 | − "void main(void) {" | |
| 2880 | − " vec2 tc = hmdWarp(gl_TexCoord[0].st);" | |
| 2881 | − " vec2 below = step(screenCenter.st + vec2(-0.25, -0.5), tc.st);" | |
| 2882 | − " vec2 above = vec2(1.0, 1.0) - step(screenCenter.st + vec2(0.25, 0.5), tc.st);" | |
| 2883 | − " gl_FragColor = mix(vec4(0.0, 0.0, 0.0, 1.0), texture2D(texture, tc), " | |
| 2884 | − " above.s * above.t * below.s * below.t);" | |
| 2885 | − "}"; | |
| 2886 | − | |
| 2887 | −void Application::displayOculus(Camera& whichCamera) { | |
| 2888 | − _glowEffect.prepare(); | |
| 2889 | − | |
| 2890 | − // magic numbers ahoy! in order to avoid pulling in the Oculus utility library that calculates | |
| 2891 | − // the rendering parameters from the hardware stats, i just folded their calculations into | |
| 2892 | − // constants using the stats for the current-model hardware as contained in the SDK file | |
| 2893 | − // LibOVR/Src/Util/Util_Render_Stereo.cpp | |
| 2894 | − | |
| 2895 | − // eye | |
| 2896 | − | |
| 2897 | − // render the left eye view to the left side of the screen | |
| 2898 | − glMatrixMode(GL_PROJECTION); | |
| 2899 | − glPushMatrix(); | |
| 2900 | − glLoadIdentity(); | |
| 2901 | − glTranslatef(0.151976, 0, 0); // +h, see Oculus SDK docs p. 26 | |
| 2902 | − gluPerspective(whichCamera.getFieldOfView(), whichCamera.getAspectRatio(), | |
| 2903 | − whichCamera.getNearClip(), whichCamera.getFarClip()); | |
| 2904 | − | |
| 2905 | − glViewport(0, 0, _glWidget->width() / 2, _glWidget->height()); | |
| 2906 | − glMatrixMode(GL_MODELVIEW); | |
| 2907 | − glPushMatrix(); | |
| 2908 | − glLoadIdentity(); | |
| 2909 | − glTranslatef(0.032, 0, 0); // dip/2, see p. 27 | |
| 2910 | − | |
| 2911 | − displaySide(whichCamera); | |
| 2912 | − | |
| 2913 | − // and the right eye to the right side | |
| 2914 | − glMatrixMode(GL_PROJECTION); | |
| 2915 | − glLoadIdentity(); | |
| 2916 | − glTranslatef(-0.151976, 0, 0); // -h | |
| 2917 | − gluPerspective(whichCamera.getFieldOfView(), whichCamera.getAspectRatio(), | |
| 2918 | − whichCamera.getNearClip(), whichCamera.getFarClip()); | |
| 2919 | − | |
| 2920 | − glViewport(_glWidget->width() / 2, 0, _glWidget->width() / 2, _glWidget->height()); | |
| 2921 | − glMatrixMode(GL_MODELVIEW); | |
| 2922 | − glLoadIdentity(); | |
| 2923 | − glTranslatef(-0.032, 0, 0); | |
| 2924 | − | |
| 2925 | − displaySide(whichCamera); | |
| 2926 | − | |
| 2927 | − glPopMatrix(); | |
| 2928 | − | |
| 2929 | − // restore our normal viewport | |
| 2930 | − glViewport(0, 0, _glWidget->width(), _glWidget->height()); | |
| 2931 | − | |
| 2932 | − QOpenGLFramebufferObject* fbo = _glowEffect.render(true); | |
| 2933 | − glBindTexture(GL_TEXTURE_2D, fbo->texture()); | |
| 2934 | − | |
| 2935 | − if (_oculusProgram == 0) { | |
| 2936 | − _oculusProgram = new ProgramObject(); | |
| 2937 | − _oculusProgram->addShaderFromSourceCode(QGLShader::Fragment, DISTORTION_FRAGMENT_SHADER); | |
| 2938 | − _oculusProgram->link(); | |
| 2939 | − | |
| 2940 | − _textureLocation = _oculusProgram->uniformLocation("texture"); | |
| 2941 | − _lensCenterLocation = _oculusProgram->uniformLocation("lensCenter"); | |
| 2942 | − _screenCenterLocation = _oculusProgram->uniformLocation("screenCenter"); | |
| 2943 | − _scaleLocation = _oculusProgram->uniformLocation("scale"); | |
| 2944 | − _scaleInLocation = _oculusProgram->uniformLocation("scaleIn"); | |
| 2945 | − _hmdWarpParamLocation = _oculusProgram->uniformLocation("hmdWarpParam"); | |
| 2946 | − } | |
| 2947 | 2898 | |
| 2948 | − glMatrixMode(GL_PROJECTION); | |
| 2949 | − glLoadIdentity(); | |
| 2950 | − gluOrtho2D(0, _glWidget->width(), 0, _glWidget->height()); | |
| 2951 | − glDisable(GL_DEPTH_TEST); | |
| 2952 | − | |
| 2953 | − // for reference on setting these values, see SDK file Samples/OculusRoomTiny/RenderTiny_Device.cpp | |
| 2954 | − | |
| 2955 | − float scaleFactor = 1.0 / _oculusDistortionScale; | |
| 2956 | − float aspectRatio = (_glWidget->width() * 0.5) / _glWidget->height(); | |
| 2957 | − | |
| 2958 | − glDisable(GL_BLEND); | |
| 2959 | − _oculusProgram->bind(); | |
| 2960 | − _oculusProgram->setUniformValue(_textureLocation, 0); | |
| 2961 | − _oculusProgram->setUniformValue(_lensCenterLocation, 0.287994, 0.5); // see SDK docs, p. 29 | |
| 2962 | − _oculusProgram->setUniformValue(_screenCenterLocation, 0.25, 0.5); | |
| 2963 | − _oculusProgram->setUniformValue(_scaleLocation, 0.25 * scaleFactor, 0.5 * scaleFactor * aspectRatio); | |
| 2964 | − _oculusProgram->setUniformValue(_scaleInLocation, 4, 2 / aspectRatio); | |
| 2965 | − _oculusProgram->setUniformValue(_hmdWarpParamLocation, 1.0, 0.22, 0.24, 0); | |
| 2966 | − | |
| 2967 | − glColor3f(1, 0, 1); | |
| 2968 | − glBegin(GL_QUADS); | |
| 2969 | − glTexCoord2f(0, 0); | |
| 2970 | − glVertex2f(0, 0); | |
| 2971 | − glTexCoord2f(0.5, 0); | |
| 2972 | − glVertex2f(_glWidget->width()/2, 0); | |
| 2973 | − glTexCoord2f(0.5, 1); | |
| 2974 | − glVertex2f(_glWidget->width() / 2, _glWidget->height()); | |
| 2975 | − glTexCoord2f(0, 1); | |
| 2976 | − glVertex2f(0, _glWidget->height()); | |
| 2977 | − glEnd(); | |
| 2978 | − | |
| 2979 | − _oculusProgram->setUniformValue(_lensCenterLocation, 0.787994, 0.5); | |
| 2980 | − _oculusProgram->setUniformValue(_screenCenterLocation, 0.75, 0.5); | |
| 2981 | − | |
| 2982 | − glBegin(GL_QUADS); | |
| 2983 | − glTexCoord2f(0.5, 0); | |
| 2984 | − glVertex2f(_glWidget->width() / 2, 0); | |
| 2985 | − glTexCoord2f(1, 0); | |
| 2986 | − glVertex2f(_glWidget->width(), 0); | |
| 2987 | − glTexCoord2f(1, 1); | |
| 2988 | − glVertex2f(_glWidget->width(), _glWidget->height()); | |
| 2989 | − glTexCoord2f(0.5, 1); | |
| 2990 | − glVertex2f(_glWidget->width() / 2, _glWidget->height()); | |
| 2991 | − glEnd(); | |
| 2992 | − | |
| 2993 | − glEnable(GL_BLEND); | |
| 2994 | − glBindTexture(GL_TEXTURE_2D, 0); | |
| 2995 | − _oculusProgram->release(); | |
| 2996 | − | |
| 2997 | − glPopMatrix(); | |
| 2998 | −} | |
| 2999 | − | |
| 3000 | 2899 | const GLfloat WHITE_SPECULAR_COLOR[] = { 1.0f, 1.0f, 1.0f, 1.0f }; |
| 3001 | 2900 | const GLfloat NO_SPECULAR_COLOR[] = { 0.0f, 0.0f, 0.0f, 1.0f }; |
| 3002 | 2901 | |
| @@ -3019,18 +2918,6 @@ void Application::setupWorldLight() { · 16 unmodified lines | ||
| 3019 | 2918 | glMateriali(GL_FRONT, GL_SHININESS, 96); |
| 3020 | 2919 | } |
| 3021 | 2920 | |
| 3022 | −void Application::loadTranslatedViewMatrix(const glm::vec3& translation) { | |
| 3023 | − glLoadMatrixf((const GLfloat*)&_untranslatedViewMatrix); | |
| 3024 | − glTranslatef(translation.x + _viewMatrixTranslation.x, translation.y + _viewMatrixTranslation.y, | |
| 3025 | − translation.z + _viewMatrixTranslation.z); | |
| 3026 | −} | |
| 3027 | − | |
| 3028 | −void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near, | |
| 3029 | − float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const { | |
| 3030 | − | |
| 3031 | − _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, near, far, nearClipPlane, farClipPlane); | |
| 3032 | −} | |
| 3033 | − | |
| 3034 | 2921 | void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { |
| 3035 | 2922 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()"); |
| 3036 | 2923 | // transform by eye offset |
| @@ -3274,6 +3161,18 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 237 unmodified lines | ||
| 3274 | 3161 | } |
| 3275 | 3162 | } |
| 3276 | 3163 | |
| 3164 | +void Application::loadTranslatedViewMatrix(const glm::vec3& translation) { | |
| 3165 | + glLoadMatrixf((const GLfloat*)&_untranslatedViewMatrix); | |
| 3166 | + glTranslatef(translation.x + _viewMatrixTranslation.x, translation.y + _viewMatrixTranslation.y, | |
| 3167 | + translation.z + _viewMatrixTranslation.z); | |
| 3168 | +} | |
| 3169 | + | |
| 3170 | +void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near, | |
| 3171 | + float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const { | |
| 3172 | + | |
| 3173 | + _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, near, far, nearClipPlane, farClipPlane); | |
| 3174 | +} | |
| 3175 | + | |
| 3277 | 3176 | void Application::displayOverlay() { |
| 3278 | 3177 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displayOverlay()"); |
| 3279 | 3178 | |
| @@ -3608,7 +3507,7 @@ void Application::displayStats() { · 328 unmodified lines | ||
| 3608 | 3507 | // Voxel Rendering |
| 3609 | 3508 | voxelStats.str(""); |
| 3610 | 3509 | voxelStats.precision(4); |
| 3611 | − voxelStats << "Voxel Rendering Slots" << | |
| 3510 | + voxelStats << "Voxel Rendering Slots " << | |
| 3612 | 3511 | "Max: " << _voxels.getMaxVoxels() / 1000.f << "K " << |
| 3613 | 3512 | "Drawn: " << _voxels.getVoxelsWritten() / 1000.f << "K " << |
| 3614 | 3513 | "Abandoned: " << _voxels.getAbandonedVoxels() / 1000.f << "K "; |
| @@ -3847,7 +3746,7 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 232 unmodified lines | ||
| 3847 | 3746 | if (!avatar->isInitialized()) { |
| 3848 | 3747 | avatar->init(); |
| 3849 | 3748 | } |
| 3850 | − avatar->render(false, Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls)); | |
| 3749 | + avatar->render(false); | |
| 3851 | 3750 | avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors)); |
| 3852 | 3751 | } |
| 3853 | 3752 | |
| @@ -3857,12 +3756,12 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 3 unmodified lines | ||
| 3857 | 3756 | // render avatar fades |
| 3858 | 3757 | Glower glower; |
| 3859 | 3758 | for (vector<Avatar*>::iterator fade = _avatarFades.begin(); fade != _avatarFades.end(); fade++) { |
| 3860 | − (*fade)->render(false, Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls)); | |
| 3759 | + (*fade)->render(false); | |
| 3861 | 3760 | } |
| 3862 | 3761 | } |
| 3863 | 3762 | |
| 3864 | 3763 | // Render my own Avatar |
| 3865 | − _myAvatar.render(forceRenderHead, Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls)); | |
| 3764 | + _myAvatar.render(forceRenderHead); | |
| 3866 | 3765 | _myAvatar.setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors)); |
| 3867 | 3766 | |
| 3868 | 3767 | if (Menu::getInstance()->isOptionChecked(MenuOption::LookAtIndicator) && _lookatTargetAvatar) { |
| @@ -4129,6 +4028,7 @@ void Application::resetSensors() { · 260 unmodified lines | ||
| 4129 | 4028 | _webcam.reset(); |
| 4130 | 4029 | _faceshift.reset(); |
| 4131 | 4030 | LeapManager::reset(); |
| 4031 | + OculusManager::reset(); | |
| 4132 | 4032 | QCursor::setPos(_headMouseX, _headMouseY); |
| 4133 | 4033 | _myAvatar.reset(); |
| 4134 | 4034 | _myTransmitter.resetLevels(); |
| @@ -4157,11 +4057,6 @@ void Application::setMenuShortcutsEnabled(bool enabled) { · 22 unmodified lines | ||
| 4157 | 4057 | setShortcutsEnabled(_window->menuBar(), enabled); |
| 4158 | 4058 | } |
| 4159 | 4059 | |
| 4160 | −void Application::updateCursor() { | |
| 4161 | − _glWidget->setCursor(OculusManager::isConnected() && _window->windowState().testFlag(Qt::WindowFullScreen) ? | |
| 4162 | − Qt::BlankCursor : Qt::ArrowCursor); | |
| 4163 | −} | |
| 4164 | − | |
| 4165 | 4060 | void Application::attachNewHeadToNode(Node* newNode) { |
| 4166 | 4061 | if (newNode->getLinkedData() == NULL) { |
| 4167 | 4062 | newNode->setLinkedData(new Avatar(newNode)); |
| @@ -4326,13 +4221,26 @@ void* Application::networkReceive(void* args) { · 158 unmodified lines | ||
| 4326 | 4221 | app->_audio.addReceivedAudioToBuffer(app->_incomingPacket, bytesReceived); |
| 4327 | 4222 | break; |
| 4328 | 4223 | case PACKET_TYPE_VOXEL_DATA: |
| 4329 | − case PACKET_TYPE_VOXEL_DATA_MONOCHROME: | |
| 4330 | − case PACKET_TYPE_Z_COMMAND: | |
| 4331 | 4224 | case PACKET_TYPE_ERASE_VOXEL: |
| 4332 | 4225 | case PACKET_TYPE_VOXEL_STATS: |
| 4333 | 4226 | case PACKET_TYPE_ENVIRONMENT_DATA: { |
| 4334 | 4227 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 4335 | 4228 | "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()"); |
| 4229 | + | |
| 4230 | + bool wantExtraDebugging = Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging); | |
| 4231 | + if (wantExtraDebugging && app->_incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) { | |
| 4232 | + int numBytesPacketHeader = numBytesForPacketHeader(app->_incomingPacket); | |
| 4233 | + unsigned char* dataAt = app->_incomingPacket + numBytesPacketHeader; | |
| 4234 | + dataAt += sizeof(VOXEL_PACKET_FLAGS); | |
| 4235 | + VOXEL_PACKET_SEQUENCE sequence = (*(VOXEL_PACKET_SEQUENCE*)dataAt); | |
| 4236 | + dataAt += sizeof(VOXEL_PACKET_SEQUENCE); | |
| 4237 | + VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt); | |
| 4238 | + dataAt += sizeof(VOXEL_PACKET_SENT_TIME); | |
| 4239 | + VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); | |
| 4240 | + int flightTime = arrivedAt - sentAt; | |
| 4241 | + | |
| 4242 | + printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime); | |
| 4243 | + } | |
| 4336 | 4244 | |
| 4337 | 4245 | // add this packet to our list of voxel packets and process them on the voxel processing |
| 4338 | 4246 | app->_voxelProcessor.queueReceivedPacket(senderSockAddr, app->_incomingPacket, bytesReceived); |