Showing the changes to interface/src/Application.cpp (1 of 27 files). Show all
Unified · Split
| @@ -1058,29 +1058,18 @@ void Application::paintGL() { · 1057 unmodified lines | ||
| 1058 | 1058 | // Using the latter will cause the camera to wobble with idle animations, |
| 1059 | 1059 | // or with changes from the face tracker |
| 1060 | 1060 | renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE; |
| 1061 | − | |
| 1062 | − if (!getActiveDisplayPlugin()->isHmd()) { | |
| 1063 | − _myCamera.setPosition(_myAvatar->getDefaultEyePosition()); | |
| 1064 | − _myCamera.setRotation(_myAvatar->getHead()->getCameraOrientation()); | |
| 1065 | − } else { | |
| 1066 | − mat4 camMat = _myAvatar->getSensorToWorldMatrix() * _myAvatar->getHMDSensorMatrix(); | |
| 1067 | − _myCamera.setPosition(extractTranslation(camMat)); | |
| 1068 | − _myCamera.setRotation(glm::quat_cast(camMat)); | |
| 1069 | − } | |
| 1061 | + _myCamera.setPosition(_myAvatar->getDefaultEyePosition()); | |
| 1062 | + _myCamera.setRotation(_myAvatar->getOrientation()); | |
| 1070 | 1063 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| 1071 | − if (isHMDMode()) { | |
| 1072 | − _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()); | |
| 1073 | − } else { | |
| 1074 | − _myCamera.setRotation(_myAvatar->getHead()->getOrientation()); | |
| 1075 | − } | |
| 1076 | − if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { | |
| 1077 | − _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + | |
| 1078 | − _myCamera.getRotation() * glm::vec3(0.0f, 0.0f, 1.0f) * _myAvatar->getBoomLength() * _myAvatar->getScale()); | |
| 1079 | − } else { | |
| 1080 | − _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + | |
| 1081 | − _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * _myAvatar->getBoomLength() * _myAvatar->getScale()); | |
| 1082 | − } | |
| 1083 | − | |
| 1064 | + _myCamera.setRotation(_myAvatar->getOrientation()); | |
| 1065 | + | |
| 1066 | + // https://www.youtube.com/watch?v=pFriRcIwqNU | |
| 1067 | + vec3 boomStick = glm::vec3(0.0f, 0.0f, 1.0f) * _myAvatar->getBoomLength() * _myAvatar->getScale(); | |
| 1068 | + quat boomRotation = _myAvatar->getOrientation(); | |
| 1069 | + if (!isHMDMode() && Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { | |
| 1070 | + boomRotation = _myCamera.getRotation(); | |
| 1071 | + } | |
| 1072 | + _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + boomRotation * boomStick); | |
| 1084 | 1073 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 1085 | 1074 | _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); |
| 1086 | 1075 | _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + |
| @@ -1089,7 +1078,6 @@ void Application::paintGL() { · 2 unmodified lines | ||
| 1089 | 1078 | glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); |
| 1090 | 1079 | renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; |
| 1091 | 1080 | } |
| 1092 | − | |
| 1093 | 1081 | // Update camera position |
| 1094 | 1082 | if (!isHMDMode()) { |
| 1095 | 1083 | _myCamera.update(1.0f / _fps); |
| @@ -1105,57 +1093,37 @@ void Application::paintGL() { · 9 unmodified lines | ||
| 1105 | 1093 | QSize size = DependencyManager::get<FramebufferCache>()->getFrameBufferSize(); |
| 1106 | 1094 | renderArgs._viewport = glm::ivec4(0, 0, size.width(), size.height()); |
| 1107 | 1095 | |
| 1108 | − { | |
| 1109 | − PROFILE_RANGE(__FUNCTION__ "/clear"); | |
| 1110 | − doInBatch(&renderArgs, [&](gpu::Batch& batch) { | |
| 1111 | − auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebuffer(); | |
| 1112 | − batch.setFramebuffer(primaryFbo); | |
| 1113 | − // clear the normal and specular buffers | |
| 1114 | − batch.clearFramebuffer( | |
| 1115 | − gpu::Framebuffer::BUFFER_COLOR0 | | |
| 1116 | − gpu::Framebuffer::BUFFER_COLOR1 | | |
| 1117 | − gpu::Framebuffer::BUFFER_COLOR2 | | |
| 1118 | − gpu::Framebuffer::BUFFER_DEPTH, | |
| 1119 | − vec4(vec3(0), 1), 1.0, 0.0); | |
| 1120 | − }); | |
| 1121 | − } | |
| 1096 | + doInBatch(&renderArgs, [&](gpu::Batch& batch) { | |
| 1097 | + auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebuffer(); | |
| 1098 | + batch.setFramebuffer(primaryFbo); | |
| 1099 | + // clear the normal and specular buffers | |
| 1100 | + batch.clearFramebuffer( | |
| 1101 | + gpu::Framebuffer::BUFFER_COLOR0 | | |
| 1102 | + gpu::Framebuffer::BUFFER_COLOR1 | | |
| 1103 | + gpu::Framebuffer::BUFFER_COLOR2 | | |
| 1104 | + gpu::Framebuffer::BUFFER_DEPTH, | |
| 1105 | + vec4(vec3(0), 1), 1.0, 0.0); | |
| 1106 | + }); | |
| 1122 | 1107 | |
| 1108 | + renderArgs._viewport = gpu::Vec4i(0, 0, size.width(), size.height()); | |
| 1123 | 1109 | if (displayPlugin->isStereo()) { |
| 1124 | − PROFILE_RANGE(__FUNCTION__ "/stereoRender"); | |
| 1125 | − QRect currentViewport(QPoint(0, 0), QSize(size.width() / 2, size.height())); | |
| 1126 | − glEnable(GL_SCISSOR_TEST); | |
| 1127 | − for_each_eye([&](Eye eye){ | |
| 1128 | − // Load the view frustum, used by meshes | |
| 1129 | − Camera eyeCamera; | |
| 1130 | − if (qApp->isHMDMode()) { | |
| 1131 | − // Allow the displayPlugin to compose the final eye transform, based on the most up-to-date head motion. | |
| 1132 | − eyeCamera.setTransform(displayPlugin->getModelview(eye, _myAvatar->getSensorToWorldMatrix())); | |
| 1133 | − } else { | |
| 1134 | − eyeCamera.setTransform(displayPlugin->getModelview(eye, _myCamera.getTransform())); | |
| 1135 | − } | |
| 1136 | − eyeCamera.setProjection(displayPlugin->getProjection(eye, _myCamera.getProjection())); | |
| 1137 | − renderArgs._viewport = toGlm(currentViewport); | |
| 1138 | − doInBatch(&renderArgs, [&](gpu::Batch& batch) { | |
| 1139 | − batch.setViewportTransform(renderArgs._viewport); | |
| 1140 | − batch.setStateScissorRect(renderArgs._viewport); | |
| 1141 | − }); | |
| 1142 | − displaySide(&renderArgs, eyeCamera); | |
| 1143 | − }, [&] { | |
| 1144 | − currentViewport.moveLeft(currentViewport.width()); | |
| 1145 | − }); | |
| 1146 | − glDisable(GL_SCISSOR_TEST); | |
| 1147 | − } else { | |
| 1148 | − PROFILE_RANGE(__FUNCTION__ "/monoRender"); | |
| 1149 | − renderArgs._viewport = gpu::Vec4i(0, 0, size.width(), size.height()); | |
| 1150 | − // Viewport is assigned to the size of the framebuffer | |
| 1151 | − doInBatch(&renderArgs, [&](gpu::Batch& batch) { | |
| 1152 | − batch.setViewportTransform(renderArgs._viewport); | |
| 1153 | − batch.setStateScissorRect(renderArgs._viewport); | |
| 1110 | + //_myCamera.setProjection(displayPlugin->getProjection(Mono, _myCamera.getProjection())); | |
| 1111 | + renderArgs._context->enableStereo(true); | |
| 1112 | + mat4 eyeViews[2]; | |
| 1113 | + mat4 eyeProjections[2]; | |
| 1114 | + auto baseProjection = renderArgs._viewFrustum->getProjection(); | |
| 1115 | + // FIXME we don't need to set these every frame, | |
| 1116 | + // only when the display plugin changes | |
| 1117 | + for_each_eye([&](Eye eye) { | |
| 1118 | + eyeViews[eye] = displayPlugin->getModelview(eye, mat4()); | |
| 1119 | + eyeProjections[eye] = displayPlugin->getProjection(eye, baseProjection); | |
| 1154 | 1120 | }); |
| 1155 | − displaySide(&renderArgs, _myCamera); | |
| 1121 | + renderArgs._context->setStereoProjections(eyeProjections); | |
| 1122 | + renderArgs._context->setStereoViews(eyeViews); | |
| 1156 | 1123 | } |
| 1157 | − | |
| 1158 | − doInBatch(&renderArgs, [](gpu::Batch& batch){ | |
| 1124 | + displaySide(&renderArgs, _myCamera); | |
| 1125 | + renderArgs._context->enableStereo(false); | |
| 1126 | + doInBatch(&renderArgs, [](gpu::Batch& batch) { | |
| 1159 | 1127 | batch.setFramebuffer(nullptr); |
| 1160 | 1128 | }); |
| 1161 | 1129 | } |
| @@ -4997,6 +4965,11 @@ mat4 Application::getHMDSensorPose() const { · 3835 unmodified lines | ||
| 4997 | 4965 | return mat4(); |
| 4998 | 4966 | } |
| 4999 | 4967 | |
| 4968 | +// FIXME there is a bug in the fullscreen setting, where leaving | |
| 4969 | +// fullscreen does not restore the window frame, making it difficult | |
| 4970 | +// or impossible to move or size the window. | |
| 4971 | +// Additionally, setting fullscreen isn't hiding the menu on windows | |
| 4972 | +// make it useless for stereoscopic modes. | |
| 5000 | 4973 | void Application::setFullscreen(const QScreen* target) { |
| 5001 | 4974 | if (!_window->isFullScreen()) { |
| 5002 | 4975 | _savedGeometry = _window->geometry(); |