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 | // Using the latter will cause the camera to wobble with idle animations, | 1058 | // Using the latter will cause the camera to wobble with idle animations, |
| 1059 | // or with changes from the face tracker | 1059 | // or with changes from the face tracker |
| 1060 | renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE; | 1060 | renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE; |
| 1061 | 1061 | _myCamera.setPosition(_myAvatar->getDefaultEyePosition()); | |
| 1062 | if (!getActiveDisplayPlugin()->isHmd()) { | 1062 | _myCamera.setRotation(_myAvatar->getOrientation()); |
| 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 | } | ||
| 1070 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { | 1063 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| 1071 | if (isHMDMode()) { | 1064 | _myCamera.setRotation(_myAvatar->getOrientation()); |
| 1072 | _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()); | 1065 | |
| 1073 | } else { | 1066 | // https://www.youtube.com/watch?v=pFriRcIwqNU |
| 1074 | _myCamera.setRotation(_myAvatar->getHead()->getOrientation()); | 1067 | vec3 boomStick = glm::vec3(0.0f, 0.0f, 1.0f) * _myAvatar->getBoomLength() * _myAvatar->getScale(); |
| 1075 | } | 1068 | quat boomRotation = _myAvatar->getOrientation(); |
| 1076 | if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { | 1069 | if (!isHMDMode() && Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { |
| 1077 | _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + | 1070 | boomRotation = _myCamera.getRotation(); |
| 1078 | _myCamera.getRotation() * glm::vec3(0.0f, 0.0f, 1.0f) * _myAvatar->getBoomLength() * _myAvatar->getScale()); | 1071 | } |
| 1079 | } else { | 1072 | _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + boomRotation * boomStick); |
| 1080 | _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + | ||
| 1081 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * _myAvatar->getBoomLength() * _myAvatar->getScale()); | ||
| 1082 | } | ||
| 1083 | |||
| 1084 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | 1073 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 1085 | _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); | 1074 | _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); |
| 1086 | _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + | 1075 | _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + |
| @@ -1089,7 +1078,6 @@ void Application::paintGL() { · 2 unmodified lines | |||
| 1089 | glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); | 1078 | glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); |
| 1090 | renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; | 1079 | renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; |
| 1091 | } | 1080 | } |
| 1092 | |||
| 1093 | // Update camera position | 1081 | // Update camera position |
| 1094 | if (!isHMDMode()) { | 1082 | if (!isHMDMode()) { |
| 1095 | _myCamera.update(1.0f / _fps); | 1083 | _myCamera.update(1.0f / _fps); |
| @@ -1105,57 +1093,37 @@ void Application::paintGL() { · 9 unmodified lines | |||
| 1105 | QSize size = DependencyManager::get<FramebufferCache>()->getFrameBufferSize(); | 1093 | QSize size = DependencyManager::get<FramebufferCache>()->getFrameBufferSize(); |
| 1106 | renderArgs._viewport = glm::ivec4(0, 0, size.width(), size.height()); | 1094 | renderArgs._viewport = glm::ivec4(0, 0, size.width(), size.height()); |
| 1107 | 1095 | ||
| 1108 | { | 1096 | doInBatch(&renderArgs, [&](gpu::Batch& batch) { |
| 1109 | PROFILE_RANGE(__FUNCTION__ "/clear"); | 1097 | auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebuffer(); |
| 1110 | doInBatch(&renderArgs, [&](gpu::Batch& batch) { | 1098 | batch.setFramebuffer(primaryFbo); |
| 1111 | auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebuffer(); | 1099 | // clear the normal and specular buffers |
| 1112 | batch.setFramebuffer(primaryFbo); | 1100 | batch.clearFramebuffer( |
| 1113 | // clear the normal and specular buffers | 1101 | gpu::Framebuffer::BUFFER_COLOR0 | |
| 1114 | batch.clearFramebuffer( | 1102 | gpu::Framebuffer::BUFFER_COLOR1 | |
| 1115 | gpu::Framebuffer::BUFFER_COLOR0 | | 1103 | gpu::Framebuffer::BUFFER_COLOR2 | |
| 1116 | gpu::Framebuffer::BUFFER_COLOR1 | | 1104 | gpu::Framebuffer::BUFFER_DEPTH, |
| 1117 | gpu::Framebuffer::BUFFER_COLOR2 | | 1105 | vec4(vec3(0), 1), 1.0, 0.0); |
| 1118 | gpu::Framebuffer::BUFFER_DEPTH, | 1106 | }); |
| 1119 | vec4(vec3(0), 1), 1.0, 0.0); | ||
| 1120 | }); | ||
| 1121 | } | ||
| 1122 | 1107 | ||
| 1108 | renderArgs._viewport = gpu::Vec4i(0, 0, size.width(), size.height()); | ||
| 1123 | if (displayPlugin->isStereo()) { | 1109 | if (displayPlugin->isStereo()) { |
| 1124 | PROFILE_RANGE(__FUNCTION__ "/stereoRender"); | 1110 | //_myCamera.setProjection(displayPlugin->getProjection(Mono, _myCamera.getProjection())); |
| 1125 | QRect currentViewport(QPoint(0, 0), QSize(size.width() / 2, size.height())); | 1111 | renderArgs._context->enableStereo(true); |
| 1126 | glEnable(GL_SCISSOR_TEST); | 1112 | mat4 eyeViews[2]; |
| 1127 | for_each_eye([&](Eye eye){ | 1113 | mat4 eyeProjections[2]; |
| 1128 | // Load the view frustum, used by meshes | 1114 | auto baseProjection = renderArgs._viewFrustum->getProjection(); |
| 1129 | Camera eyeCamera; | 1115 | // FIXME we don't need to set these every frame, |
| 1130 | if (qApp->isHMDMode()) { | 1116 | // only when the display plugin changes |
| 1131 | // Allow the displayPlugin to compose the final eye transform, based on the most up-to-date head motion. | 1117 | for_each_eye([&](Eye eye) { |
| 1132 | eyeCamera.setTransform(displayPlugin->getModelview(eye, _myAvatar->getSensorToWorldMatrix())); | 1118 | eyeViews[eye] = displayPlugin->getModelview(eye, mat4()); |
| 1133 | } else { | 1119 | eyeProjections[eye] = displayPlugin->getProjection(eye, baseProjection); |
| 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); | ||
| 1154 | }); | 1120 | }); |
| 1155 | displaySide(&renderArgs, _myCamera); | 1121 | renderArgs._context->setStereoProjections(eyeProjections); |
| 1122 | renderArgs._context->setStereoViews(eyeViews); | ||
| 1156 | } | 1123 | } |
| 1157 | 1124 | displaySide(&renderArgs, _myCamera); | |
| 1158 | doInBatch(&renderArgs, [](gpu::Batch& batch){ | 1125 | renderArgs._context->enableStereo(false); |
| 1126 | doInBatch(&renderArgs, [](gpu::Batch& batch) { | ||
| 1159 | batch.setFramebuffer(nullptr); | 1127 | batch.setFramebuffer(nullptr); |
| 1160 | }); | 1128 | }); |
| 1161 | } | 1129 | } |
| @@ -4997,6 +4965,11 @@ mat4 Application::getHMDSensorPose() const { · 3835 unmodified lines | |||
| 4997 | return mat4(); | 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 | void Application::setFullscreen(const QScreen* target) { | 4973 | void Application::setFullscreen(const QScreen* target) { |
| 5001 | if (!_window->isFullScreen()) { | 4974 | if (!_window->isFullScreen()) { |
| 5002 | _savedGeometry = _window->geometry(); | 4975 | _savedGeometry = _window->geometry(); |