Showing the changes to interface/src/Application_Graphics.cpp (1 of 1 file). Show all
Unified · Split
| @@ -522,45 +522,41 @@ void Application::updateRenderArgs(float deltaTime) { · 521 unmodified lines | ||
| 522 | 522 | appRenderArgs._eyeToWorld = _myCamera.getTransform(); |
| 523 | 523 | appRenderArgs._isStereo = false; |
| 524 | 524 | |
| 525 | − { | |
| 525 | + if (getActiveDisplayPlugin()->isStereo()) { | |
| 526 | 526 | auto hmdInterface = DependencyManager::get<HMDScriptingInterface>(); |
| 527 | − float ipdScale = hmdInterface->getIPDScale(); | |
| 528 | − | |
| 529 | 527 | // scale IPD by sensorToWorldScale, to make the world seem larger or smaller accordingly. |
| 530 | − ipdScale *= sensorToWorldScale; | |
| 528 | + float ipdScale = hmdInterface->getIPDScale() * sensorToWorldScale; | |
| 531 | 529 | |
| 532 | 530 | auto baseProjection = appRenderArgs._renderArgs.getViewFrustum().getProjection(); |
| 533 | 531 | |
| 534 | − if (getActiveDisplayPlugin()->isStereo()) { | |
| 535 | − // Stereo modes will typically have a larger projection matrix overall, | |
| 536 | − // so we ask for the 'mono' projection matrix, which for stereo and HMD | |
| 537 | − // plugins will imply the combined projection for both eyes. | |
| 538 | − // | |
| 539 | − // This is properly implemented for the Oculus plugins, but for OpenVR | |
| 540 | − // and Stereo displays I'm not sure how to get / calculate it, so we're | |
| 541 | − // just relying on the left FOV in each case and hoping that the | |
| 542 | − // overall culling margin of error doesn't cause popping in the | |
| 543 | − // right eye. There are FIXMEs in the relevant plugins | |
| 544 | − _myCamera.setProjection(getActiveDisplayPlugin()->getCullingProjection(baseProjection)); | |
| 545 | − appRenderArgs._isStereo = true; | |
| 546 | − | |
| 547 | − auto& eyeOffsets = appRenderArgs._eyeOffsets; | |
| 548 | − auto& eyeProjections = appRenderArgs._eyeProjections; | |
| 549 | − | |
| 550 | − // FIXME we probably don't need to set the projection matrix every frame, | |
| 551 | − // only when the display plugin changes (or in non-HMD modes when the user | |
| 552 | − // changes the FOV manually, which right now I don't think they can. | |
| 553 | − for_each_eye([&](Eye eye) { | |
| 554 | − // Grab the translation | |
| 555 | − eyeOffsets[eye] = getActiveDisplayPlugin()->getEyeToHeadTransform(eye); | |
| 556 | − // Apply IPD scaling | |
| 557 | − eyeOffsets[eye][3][0] *= ipdScale; | |
| 558 | − eyeProjections[eye] = getActiveDisplayPlugin()->getEyeProjection(eye, baseProjection); | |
| 559 | − }); | |
| 560 | − | |
| 561 | − // Configure the type of display / stereo | |
| 562 | − appRenderArgs._renderArgs._displayMode = (isHMDMode() ? RenderArgs::STEREO_HMD : RenderArgs::STEREO_MONITOR); | |
| 563 | − } | |
| 532 | + // Stereo modes will typically have a larger projection matrix overall, | |
| 533 | + // so we ask for the 'mono' projection matrix, which for stereo and HMD | |
| 534 | + // plugins will imply the combined projection for both eyes. | |
| 535 | + // | |
| 536 | + // This is properly implemented for the Oculus plugins, but for OpenVR | |
| 537 | + // and Stereo displays I'm not sure how to get / calculate it, so we're | |
| 538 | + // just relying on the left FOV in each case and hoping that the | |
| 539 | + // overall culling margin of error doesn't cause popping in the | |
| 540 | + // right eye. There are FIXMEs in the relevant plugins | |
| 541 | + _myCamera.setProjection(getActiveDisplayPlugin()->getCullingProjection(baseProjection)); | |
| 542 | + appRenderArgs._isStereo = true; | |
| 543 | + | |
| 544 | + auto& eyeOffsets = appRenderArgs._eyeOffsets; | |
| 545 | + auto& eyeProjections = appRenderArgs._eyeProjections; | |
| 546 | + | |
| 547 | + // FIXME we probably don't need to set the projection matrix every frame, | |
| 548 | + // only when the display plugin changes (or in non-HMD modes when the user | |
| 549 | + // changes the FOV manually, which right now I don't think they can. | |
| 550 | + for_each_eye([&](Eye eye) { | |
| 551 | + // Grab the translation | |
| 552 | + eyeOffsets[eye] = getActiveDisplayPlugin()->getEyeToHeadTransform(eye); | |
| 553 | + // Apply IPD scaling | |
| 554 | + eyeOffsets[eye][3][0] *= ipdScale; | |
| 555 | + eyeProjections[eye] = getActiveDisplayPlugin()->getEyeProjection(eye, baseProjection); | |
| 556 | + }); | |
| 557 | + | |
| 558 | + // Configure the type of display / stereo | |
| 559 | + appRenderArgs._renderArgs._displayMode = (isHMDMode() ? RenderArgs::STEREO_HMD : RenderArgs::STEREO_MONITOR); | |
| 564 | 560 | } |
| 565 | 561 | |
| 566 | 562 | appRenderArgs._renderArgs._stencilMaskMode = getActiveDisplayPlugin()->getStencilMaskMode(); |