Showing the changes to interface/src/Application.cpp (1 of 21 files). Show all
Unified · Split
| @@ -281,6 +281,7 @@ bool setupEssentials(int& argc, char** argv) { · 280 unmodified lines | ||
| 281 | 281 | Setting::init(); |
| 282 | 282 | |
| 283 | 283 | // Set dependencies |
| 284 | +<<<<<<< HEAD | |
| 284 | 285 | DependencyManager::set<AddressManager>(); |
| 285 | 286 | DependencyManager::set<NodeList>(NodeType::Agent, listenPort); |
| 286 | 287 | DependencyManager::set<GeometryCache>(); |
| @@ -306,6 +307,7 @@ bool setupEssentials(int& argc, char** argv) { · 19 unmodified lines | ||
| 306 | 307 | DependencyManager::set<DesktopScriptingInterface>(); |
| 307 | 308 | DependencyManager::set<EntityScriptingInterface>(); |
| 308 | 309 | DependencyManager::set<WindowScriptingInterface>(); |
| 310 | + DependencyManager::set<HMDScriptingInterface>(); | |
| 309 | 311 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) |
| 310 | 312 | DependencyManager::set<SpeechRecognizer>(); |
| 311 | 313 | #endif |
| @@ -1166,9 +1168,11 @@ void Application::paintGL() { · 854 unmodified lines | ||
| 1166 | 1168 | // right eye. There are FIXMEs in the relevant plugins |
| 1167 | 1169 | _myCamera.setProjection(displayPlugin->getProjection(Mono, _myCamera.getProjection())); |
| 1168 | 1170 | renderArgs._context->enableStereo(true); |
| 1169 | − mat4 eyeViews[2]; | |
| 1171 | + mat4 eyeOffsets[2]; | |
| 1170 | 1172 | mat4 eyeProjections[2]; |
| 1171 | 1173 | auto baseProjection = renderArgs._viewFrustum->getProjection(); |
| 1174 | + auto hmdInterface = DependencyManager::get<HMDScriptingInterface>(); | |
| 1175 | + float IPDScale = hmdInterface->getIPDScale(); | |
| 1172 | 1176 | // FIXME we probably don't need to set the projection matrix every frame, |
| 1173 | 1177 | // only when the display plugin changes (or in non-HMD modes when the user |
| 1174 | 1178 | // changes the FOV manually, which right now I don't think they can. |
| @@ -1177,14 +1181,24 @@ void Application::paintGL() { · 2 unmodified lines | ||
| 1177 | 1181 | // applied to the avatar, so we need to get the difference between the head |
| 1178 | 1182 | // pose applied to the avatar and the per eye pose, and use THAT as |
| 1179 | 1183 | // the per-eye stereo matrix adjustment. |
| 1180 | − mat4 eyePose = displayPlugin->getEyePose(eye); | |
| 1184 | + mat4 eyeToHead = displayPlugin->getEyeToHeadTransform(eye); | |
| 1185 | + // Grab the translation | |
| 1186 | + vec3 eyeOffset = glm::vec3(eyeToHead[3]); | |
| 1187 | + // Apply IPD scaling | |
| 1188 | + mat4 eyeOffsetTransform = glm::translate(mat4(), eyeOffset * -1.0f * IPDScale); | |
| 1189 | + eyeOffsets[eye] = eyeOffsetTransform; | |
| 1190 | + | |
| 1191 | + // Tell the plugin what pose we're using to render. In this case we're just using the | |
| 1192 | + // unmodified head pose because the only plugin that cares (the Oculus plugin) uses it | |
| 1193 | + // for rotational timewarp. If we move to support positonal timewarp, we need to | |
| 1194 | + // ensure this contains the full pose composed with the eye offsets. | |
| 1181 | 1195 | mat4 headPose = displayPlugin->getHeadPose(); |
| 1182 | − mat4 eyeView = glm::inverse(eyePose) * headPose; | |
| 1183 | − eyeViews[eye] = eyeView; | |
| 1196 | + displayPlugin->setEyeRenderPose(eye, headPose); | |
| 1197 | + | |
| 1184 | 1198 | eyeProjections[eye] = displayPlugin->getProjection(eye, baseProjection); |
| 1185 | 1199 | }); |
| 1186 | 1200 | renderArgs._context->setStereoProjections(eyeProjections); |
| 1187 | − renderArgs._context->setStereoViews(eyeViews); | |
| 1201 | + renderArgs._context->setStereoViews(eyeOffsets); | |
| 1188 | 1202 | } |
| 1189 | 1203 | displaySide(&renderArgs, _myCamera); |
| 1190 | 1204 | renderArgs._context->enableStereo(false); |
| @@ -3930,7 +3944,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 2739 unmodified lines | ||
| 3930 | 3944 | |
| 3931 | 3945 | scriptEngine->registerGlobalObject("Paths", DependencyManager::get<PathUtils>().data()); |
| 3932 | 3946 | |
| 3933 | − scriptEngine->registerGlobalObject("HMD", &HMDScriptingInterface::getInstance()); | |
| 3947 | + scriptEngine->registerGlobalObject("HMD", DependencyManager::get<HMDScriptingInterface>().data()); | |
| 3934 | 3948 | scriptEngine->registerFunction("HMD", "getHUDLookAtPosition2D", HMDScriptingInterface::getHUDLookAtPosition2D, 0); |
| 3935 | 3949 | scriptEngine->registerFunction("HMD", "getHUDLookAtPosition3D", HMDScriptingInterface::getHUDLookAtPosition3D, 0); |
| 3936 | 3950 | |
| @@ -4740,19 +4754,25 @@ mat4 Application::getEyeProjection(int eye) const { · 803 unmodified lines | ||
| 4740 | 4754 | |
| 4741 | 4755 | mat4 Application::getEyePose(int eye) const { |
| 4742 | 4756 | if (isHMDMode()) { |
| 4743 | − return getActiveDisplayPlugin()->getEyePose((Eye)eye); | |
| 4757 | + auto hmdInterface = DependencyManager::get<HMDScriptingInterface>(); | |
| 4758 | + float IPDScale = hmdInterface->getIPDScale(); | |
| 4759 | + auto displayPlugin = getActiveDisplayPlugin(); | |
| 4760 | + mat4 headPose = displayPlugin->getHeadPose(); | |
| 4761 | + mat4 eyeToHead = displayPlugin->getEyeToHeadTransform((Eye)eye); | |
| 4762 | + { | |
| 4763 | + vec3 eyeOffset = glm::vec3(eyeToHead[3]); | |
| 4764 | + // Apply IPD scaling | |
| 4765 | + mat4 eyeOffsetTransform = glm::translate(mat4(), eyeOffset * -1.0f * IPDScale); | |
| 4766 | + eyeToHead[3] = vec4(eyeOffset, 1.0); | |
| 4767 | + } | |
| 4768 | + return eyeToHead * headPose; | |
| 4744 | 4769 | } |
| 4745 | − | |
| 4746 | 4770 | return mat4(); |
| 4747 | 4771 | } |
| 4748 | 4772 | |
| 4749 | 4773 | mat4 Application::getEyeOffset(int eye) const { |
| 4750 | − if (isHMDMode()) { | |
| 4751 | − mat4 identity; | |
| 4752 | − return getActiveDisplayPlugin()->getView((Eye)eye, identity); | |
| 4753 | − } | |
| 4754 | − | |
| 4755 | − return mat4(); | |
| 4774 | + // FIXME invert? | |
| 4775 | + return getActiveDisplayPlugin()->getEyeToHeadTransform((Eye)eye); | |
| 4756 | 4776 | } |
| 4757 | 4777 | |
| 4758 | 4778 | mat4 Application::getHMDSensorPose() const { |