History

Merge branch 'master' into tony/remove-joint-states

Anthony J. Thibault committed 10 years ago

Commit f120e102 parents 14189ac b12bc96100 files · +3427 −1962Browse files

Showing the changes to interface/src/Application.cpp (1 of 100 files). Show all

Unified · Split

interface/src/Application.cpp+85−91
@@ -679,7 +679,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 678 unmodified lines
679 }));679 }));
680 680
681 userInputMapper->registerDevice(_applicationStateDevice);681 userInputMapper->registerDevice(_applicationStateDevice);
682 682
683 // Setup the keyboardMouseDevice and the user input mapper with the default bindings683 // Setup the keyboardMouseDevice and the user input mapper with the default bindings
684 userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice());684 userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice());
685 685
@@ -749,7 +749,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 63 unmodified lines
749 _oldHandRightClick[0] = false;749 _oldHandRightClick[0] = false;
750 _oldHandLeftClick[1] = false;750 _oldHandLeftClick[1] = false;
751 _oldHandRightClick[1] = false;751 _oldHandRightClick[1] = false;
752 752
753 auto applicationUpdater = DependencyManager::get<AutoUpdater>();753 auto applicationUpdater = DependencyManager::get<AutoUpdater>();
754 connect(applicationUpdater.data(), &AutoUpdater::newVersionIsAvailable, dialogsManager.data(), &DialogsManager::showUpdateDialog);754 connect(applicationUpdater.data(), &AutoUpdater::newVersionIsAvailable, dialogsManager.data(), &DialogsManager::showUpdateDialog);
755 applicationUpdater->checkForUpdate();755 applicationUpdater->checkForUpdate();
@@ -768,7 +768,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 12 unmodified lines
768 768
769 // If the user clicks an an entity, we will check that it's an unlocked web entity, and if so, set the focus to it769 // If the user clicks an an entity, we will check that it's an unlocked web entity, and if so, set the focus to it
770 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();770 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
771 connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity, 771 connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity,
772 [this, entityScriptingInterface](const EntityItemID& entityItemID, const MouseEvent& event) {772 [this, entityScriptingInterface](const EntityItemID& entityItemID, const MouseEvent& event) {
773 if (_keyboardFocusedItem != entityItemID) {773 if (_keyboardFocusedItem != entityItemID) {
774 _keyboardFocusedItem = UNKNOWN_ENTITY_ID;774 _keyboardFocusedItem = UNKNOWN_ENTITY_ID;
@@ -817,7 +817,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 42 unmodified lines
817 });817 });
818 818
819 // If the user clicks somewhere where there is NO entity at all, we will release focus819 // If the user clicks somewhere where there is NO entity at all, we will release focus
820 connect(getEntities(), &EntityTreeRenderer::mousePressOffEntity, 820 connect(getEntities(), &EntityTreeRenderer::mousePressOffEntity,
821 [=](const RayToEntityIntersectionResult& entityItemID, const QMouseEvent* event, unsigned int deviceId) {821 [=](const RayToEntityIntersectionResult& entityItemID, const QMouseEvent* event, unsigned int deviceId) {
822 _keyboardFocusedItem = UNKNOWN_ENTITY_ID;822 _keyboardFocusedItem = UNKNOWN_ENTITY_ID;
823 if (_keyboardFocusHighlight) {823 if (_keyboardFocusHighlight) {
@@ -826,17 +826,17 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 2 unmodified lines
826 });826 });
827 827
828 connect(this, &Application::applicationStateChanged, this, &Application::activeChanged);828 connect(this, &Application::applicationStateChanged, this, &Application::activeChanged);
829 829
830 qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0);830 qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0);
831}831}
832 832
833void Application::aboutToQuit() {833void Application::aboutToQuit() {
834 emit beforeAboutToQuit();834 emit beforeAboutToQuit();
835 835
836 getActiveDisplayPlugin()->deactivate();836 getActiveDisplayPlugin()->deactivate();
837 837
838 _aboutToQuit = true;838 _aboutToQuit = true;
839 839
840 cleanupBeforeQuit();840 cleanupBeforeQuit();
841}841}
842 842
@@ -860,16 +860,16 @@ void Application::cleanupBeforeQuit() { · 17 unmodified lines
860 _keyboardFocusHighlight = nullptr;860 _keyboardFocusHighlight = nullptr;
861 861
862 _entities.clear(); // this will allow entity scripts to properly shutdown862 _entities.clear(); // this will allow entity scripts to properly shutdown
863 863
864 auto nodeList = DependencyManager::get<NodeList>();864 auto nodeList = DependencyManager::get<NodeList>();
865 865
866 // send the domain a disconnect packet, force stoppage of domain-server check-ins866 // send the domain a disconnect packet, force stoppage of domain-server check-ins
867 nodeList->getDomainHandler().disconnect();867 nodeList->getDomainHandler().disconnect();
868 nodeList->setIsShuttingDown(true);868 nodeList->setIsShuttingDown(true);
869 869
870 // tell the packet receiver we're shutting down, so it can drop packets870 // tell the packet receiver we're shutting down, so it can drop packets
871 nodeList->getPacketReceiver().setShouldDropPackets(true);871 nodeList->getPacketReceiver().setShouldDropPackets(true);
872 872
873 _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts873 _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts
874 ScriptEngine::stopAllScripts(this); // stop all currently running global scripts874 ScriptEngine::stopAllScripts(this); // stop all currently running global scripts
875 875
@@ -947,7 +947,7 @@ Application::~Application() { · 71 unmodified lines
947 DependencyManager::destroy<GeometryCache>();947 DependencyManager::destroy<GeometryCache>();
948 DependencyManager::destroy<ScriptCache>();948 DependencyManager::destroy<ScriptCache>();
949 DependencyManager::destroy<SoundCache>();949 DependencyManager::destroy<SoundCache>();
950 950
951 // cleanup the AssetClient thread951 // cleanup the AssetClient thread
952 QThread* assetThread = DependencyManager::get<AssetClient>()->thread();952 QThread* assetThread = DependencyManager::get<AssetClient>()->thread();
953 DependencyManager::destroy<AssetClient>();953 DependencyManager::destroy<AssetClient>();
@@ -955,14 +955,14 @@ Application::~Application() { · 1 unmodified line
955 assetThread->wait();955 assetThread->wait();
956 956
957 QThread* nodeThread = DependencyManager::get<NodeList>()->thread();957 QThread* nodeThread = DependencyManager::get<NodeList>()->thread();
958 958
959 // remove the NodeList from the DependencyManager959 // remove the NodeList from the DependencyManager
960 DependencyManager::destroy<NodeList>();960 DependencyManager::destroy<NodeList>();
961 961
962 // ask the node thread to quit and wait until it is done962 // ask the node thread to quit and wait until it is done
963 nodeThread->quit();963 nodeThread->quit();
964 nodeThread->wait();964 nodeThread->wait();
965 965
966 Leapmotion::destroy();966 Leapmotion::destroy();
967 RealSense::destroy();967 RealSense::destroy();
968 968
@@ -1058,7 +1058,7 @@ void Application::initializeUi() { · 89 unmodified lines
1058 resizeGL();1058 resizeGL();
1059 }1059 }
1060 });1060 });
1061 1061
1062 // This will set up the input plugins UI1062 // This will set up the input plugins UI
1063 _activeInputPlugins.clear();1063 _activeInputPlugins.clear();
1064 foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) {1064 foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) {
@@ -1100,8 +1100,8 @@ void Application::paintGL() { · 35 unmodified lines
1100 return;1100 return;
1101 }1101 }
1102 1102
1103 // Some plugins process message events, potentially leading to 1103 // Some plugins process message events, potentially leading to
1104 // re-entering a paint event. don't allow further processing if this 1104 // re-entering a paint event. don't allow further processing if this
1105 // happens1105 // happens
1106 if (_inPaint) {1106 if (_inPaint) {
1107 return;1107 return;
@@ -1137,17 +1137,17 @@ void Application::paintGL() { · 29 unmodified lines
1137 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {1137 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
1138 PerformanceTimer perfTimer("Mirror");1138 PerformanceTimer perfTimer("Mirror");
1139 auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor();1139 auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor();
1140 1140
1141 renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;1141 renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
1142 renderRearViewMirror(&renderArgs, _mirrorViewRect);1142 renderRearViewMirror(&renderArgs, _mirrorViewRect);
1143 renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;1143 renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
1144 1144
1145 {1145 {
1146 float ratio = ((float)QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale());1146 float ratio = ((float)QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale());
1147 // Flip the src and destination rect horizontally to do the mirror1147 // Flip the src and destination rect horizontally to do the mirror
1148 auto mirrorRect = glm::ivec4(0, 0, _mirrorViewRect.width() * ratio, _mirrorViewRect.height() * ratio);1148 auto mirrorRect = glm::ivec4(0, 0, _mirrorViewRect.width() * ratio, _mirrorViewRect.height() * ratio);
1149 auto mirrorRectDest = glm::ivec4(mirrorRect.z, mirrorRect.y, mirrorRect.x, mirrorRect.w);1149 auto mirrorRectDest = glm::ivec4(mirrorRect.z, mirrorRect.y, mirrorRect.x, mirrorRect.w);
1150 1150
1151 auto selfieFbo = DependencyManager::get<FramebufferCache>()->getSelfieFramebuffer();1151 auto selfieFbo = DependencyManager::get<FramebufferCache>()->getSelfieFramebuffer();
1152 gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {1152 gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
1153 batch.setFramebuffer(selfieFbo);1153 batch.setFramebuffer(selfieFbo);
@@ -1169,9 +1169,9 @@ void Application::paintGL() { · 15 unmodified lines
1169 1169
1170 {1170 {
1171 PerformanceTimer perfTimer("CameraUpdates");1171 PerformanceTimer perfTimer("CameraUpdates");
1172 1172
1173 auto myAvatar = getMyAvatar();1173 auto myAvatar = getMyAvatar();
1174 1174
1175 myAvatar->startCapture();1175 myAvatar->startCapture();
1176 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {1176 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
1177 Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);1177 Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
@@ -1208,26 +1208,26 @@ void Application::paintGL() { · 30 unmodified lines
1208 * (myAvatar->getScale() * myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f)));1208 * (myAvatar->getScale() * myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f)));
1209 } else {1209 } else {
1210 _myCamera.setPosition(myAvatar->getDefaultEyePosition()1210 _myCamera.setPosition(myAvatar->getDefaultEyePosition()
1211 + myAvatar->getOrientation() 1211 + myAvatar->getOrientation()
1212 * (myAvatar->getScale() * myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f)));1212 * (myAvatar->getScale() * myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f)));
1213 }1213 }
1214 }1214 }
1215 } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {1215 } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
1216 if (isHMDMode()) {1216 if (isHMDMode()) {
1217 glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());1217 glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
1218 _myCamera.setRotation(myAvatar->getWorldAlignedOrientation() 1218 _myCamera.setRotation(myAvatar->getWorldAlignedOrientation()
1219 * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation);1219 * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation);
1220 glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());1220 glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
1221 _myCamera.setPosition(myAvatar->getDefaultEyePosition() 1221 _myCamera.setPosition(myAvatar->getDefaultEyePosition()
1222 + glm::vec3(0, _raiseMirror * myAvatar->getScale(), 0) 1222 + glm::vec3(0, _raiseMirror * myAvatar->getScale(), 0)
1223 + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *1223 + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
1224 glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror 1224 glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror
1225 + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset);1225 + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset);
1226 } else {1226 } else {
1227 _myCamera.setRotation(myAvatar->getWorldAlignedOrientation() 1227 _myCamera.setRotation(myAvatar->getWorldAlignedOrientation()
1228 * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));1228 * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
1229 _myCamera.setPosition(myAvatar->getDefaultEyePosition() 1229 _myCamera.setPosition(myAvatar->getDefaultEyePosition()
1230 + glm::vec3(0, _raiseMirror * myAvatar->getScale(), 0) 1230 + glm::vec3(0, _raiseMirror * myAvatar->getScale(), 0)
1231 + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *1231 + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
1232 glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);1232 glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
1233 }1233 }
@@ -1246,7 +1246,7 @@ void Application::paintGL() { · 12 unmodified lines
1246 }1246 }
1247 }1247 }
1248 }1248 }
1249 // Update camera position 1249 // Update camera position
1250 if (!isHMDMode()) {1250 if (!isHMDMode()) {
1251 _myCamera.update(1.0f / _fps);1251 _myCamera.update(1.0f / _fps);
1252 }1252 }
@@ -1264,12 +1264,12 @@ void Application::paintGL() { · 11 unmodified lines
1264 if (displayPlugin->isStereo()) {1264 if (displayPlugin->isStereo()) {
1265 // Stereo modes will typically have a larger projection matrix overall,1265 // Stereo modes will typically have a larger projection matrix overall,
1266 // so we ask for the 'mono' projection matrix, which for stereo and HMD1266 // so we ask for the 'mono' projection matrix, which for stereo and HMD
1267 // plugins will imply the combined projection for both eyes. 1267 // plugins will imply the combined projection for both eyes.
1268 //1268 //
1269 // This is properly implemented for the Oculus plugins, but for OpenVR1269 // This is properly implemented for the Oculus plugins, but for OpenVR
1270 // and Stereo displays I'm not sure how to get / calculate it, so we're 1270 // and Stereo displays I'm not sure how to get / calculate it, so we're
1271 // just relying on the left FOV in each case and hoping that the 1271 // just relying on the left FOV in each case and hoping that the
1272 // overall culling margin of error doesn't cause popping in the 1272 // overall culling margin of error doesn't cause popping in the
1273 // right eye. There are FIXMEs in the relevant plugins1273 // right eye. There are FIXMEs in the relevant plugins
1274 _myCamera.setProjection(displayPlugin->getProjection(Mono, _myCamera.getProjection()));1274 _myCamera.setProjection(displayPlugin->getProjection(Mono, _myCamera.getProjection()));
1275 renderArgs._context->enableStereo(true);1275 renderArgs._context->enableStereo(true);
@@ -1279,11 +1279,11 @@ void Application::paintGL() { · 3 unmodified lines
1279 auto hmdInterface = DependencyManager::get<HMDScriptingInterface>();1279 auto hmdInterface = DependencyManager::get<HMDScriptingInterface>();
1280 float IPDScale = hmdInterface->getIPDScale();1280 float IPDScale = hmdInterface->getIPDScale();
1281 // FIXME we probably don't need to set the projection matrix every frame,1281 // FIXME we probably don't need to set the projection matrix every frame,
1282 // only when the display plugin changes (or in non-HMD modes when the user 1282 // only when the display plugin changes (or in non-HMD modes when the user
1283 // changes the FOV manually, which right now I don't think they can.1283 // changes the FOV manually, which right now I don't think they can.
1284 for_each_eye([&](Eye eye) {1284 for_each_eye([&](Eye eye) {
1285 // For providing the stereo eye views, the HMD head pose has already been 1285 // For providing the stereo eye views, the HMD head pose has already been
1286 // applied to the avatar, so we need to get the difference between the head 1286 // applied to the avatar, so we need to get the difference between the head
1287 // pose applied to the avatar and the per eye pose, and use THAT as1287 // pose applied to the avatar and the per eye pose, and use THAT as
1288 // the per-eye stereo matrix adjustment.1288 // the per-eye stereo matrix adjustment.
1289 mat4 eyeToHead = displayPlugin->getEyeToHeadTransform(eye);1289 mat4 eyeToHead = displayPlugin->getEyeToHeadTransform(eye);
@@ -1293,10 +1293,10 @@ void Application::paintGL() { · 3 unmodified lines
1293 mat4 eyeOffsetTransform = glm::translate(mat4(), eyeOffset * -1.0f * IPDScale);1293 mat4 eyeOffsetTransform = glm::translate(mat4(), eyeOffset * -1.0f * IPDScale);
1294 eyeOffsets[eye] = eyeOffsetTransform;1294 eyeOffsets[eye] = eyeOffsetTransform;
1295 1295
1296 // Tell the plugin what pose we're using to render. In this case we're just using the 1296 // Tell the plugin what pose we're using to render. In this case we're just using the
1297 // unmodified head pose because the only plugin that cares (the Oculus plugin) uses it 1297 // unmodified head pose because the only plugin that cares (the Oculus plugin) uses it
1298 // for rotational timewarp. If we move to support positonal timewarp, we need to 1298 // for rotational timewarp. If we move to support positonal timewarp, we need to
1299 // ensure this contains the full pose composed with the eye offsets. 1299 // ensure this contains the full pose composed with the eye offsets.
1300 mat4 headPose = displayPlugin->getHeadPose();1300 mat4 headPose = displayPlugin->getHeadPose();
1301 displayPlugin->setEyeRenderPose(eye, headPose);1301 displayPlugin->setEyeRenderPose(eye, headPose);
1302 1302
@@ -1343,7 +1343,7 @@ void Application::paintGL() { · 40 unmodified lines
1343 PerformanceTimer perfTimer("pluginOutput");1343 PerformanceTimer perfTimer("pluginOutput");
1344 auto primaryFbo = framebufferCache->getPrimaryFramebuffer();1344 auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
1345 GLuint finalTexture = gpu::GLBackend::getTextureID(primaryFbo->getRenderBuffer(0));1345 GLuint finalTexture = gpu::GLBackend::getTextureID(primaryFbo->getRenderBuffer(0));
1346 // Ensure the rendering context commands are completed when rendering 1346 // Ensure the rendering context commands are completed when rendering
1347 GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);1347 GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1348 // Ensure the sync object is flushed to the driver thread before releasing the context1348 // Ensure the sync object is flushed to the driver thread before releasing the context
1349 // CRITICAL for the mac driver apparently.1349 // CRITICAL for the mac driver apparently.
@@ -1394,7 +1394,7 @@ void Application::audioMuteToggled() { · 44 unmodified lines
1394}1394}
1395 1395
1396void Application::faceTrackerMuteToggled() {1396void Application::faceTrackerMuteToggled() {
1397 1397
1398 QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteFaceTracking);1398 QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteFaceTracking);
1399 Q_CHECK_PTR(muteAction);1399 Q_CHECK_PTR(muteAction);
1400 bool isMuted = getSelectedFaceTracker()->isMuted();1400 bool isMuted = getSelectedFaceTracker()->isMuted();
@@ -1427,7 +1427,7 @@ void Application::resizeGL() { · 26 unmodified lines
1427 if (nullptr == _displayPlugin) {1427 if (nullptr == _displayPlugin) {
1428 return;1428 return;
1429 }1429 }
1430 1430
1431 auto displayPlugin = getActiveDisplayPlugin();1431 auto displayPlugin = getActiveDisplayPlugin();
1432 // Set the desired FBO texture size. If it hasn't changed, this does nothing.1432 // Set the desired FBO texture size. If it hasn't changed, this does nothing.
1433 // Otherwise, it must rebuild the FBOs1433 // Otherwise, it must rebuild the FBOs
@@ -1437,14 +1437,14 @@ void Application::resizeGL() { · 3 unmodified lines
1437 _renderResolution = renderSize;1437 _renderResolution = renderSize;
1438 DependencyManager::get<FramebufferCache>()->setFrameBufferSize(fromGlm(renderSize));1438 DependencyManager::get<FramebufferCache>()->setFrameBufferSize(fromGlm(renderSize));
1439 }1439 }
1440 1440
1441 // FIXME the aspect ratio for stereo displays is incorrect based on this.1441 // FIXME the aspect ratio for stereo displays is incorrect based on this.
1442 float aspectRatio = displayPlugin->getRecommendedAspectRatio();1442 float aspectRatio = displayPlugin->getRecommendedAspectRatio();
1443 _myCamera.setProjection(glm::perspective(glm::radians(_fieldOfView.get()), aspectRatio,1443 _myCamera.setProjection(glm::perspective(glm::radians(_fieldOfView.get()), aspectRatio,
1444 DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP));1444 DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP));
1445 // Possible change in aspect ratio1445 // Possible change in aspect ratio
1446 loadViewFrustum(_myCamera, _viewFrustum);1446 loadViewFrustum(_myCamera, _viewFrustum);
1447 1447
1448 auto offscreenUi = DependencyManager::get<OffscreenUi>();1448 auto offscreenUi = DependencyManager::get<OffscreenUi>();
1449 auto uiSize = displayPlugin->getRecommendedUiSize();1449 auto uiSize = displayPlugin->getRecommendedUiSize();
1450 // Bit of a hack since there's no device pixel ratio change event I can find.1450 // Bit of a hack since there's no device pixel ratio change event I can find.
@@ -1613,7 +1613,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 162 unmodified lines
1613 if (isMeta) {1613 if (isMeta) {
1614 auto offscreenUi = DependencyManager::get<OffscreenUi>();1614 auto offscreenUi = DependencyManager::get<OffscreenUi>();
1615 offscreenUi->load("Browser.qml");1615 offscreenUi->load("Browser.qml");
1616 } 1616 }
1617 break;1617 break;
1618 1618
1619 case Qt::Key_X:1619 case Qt::Key_X:
@@ -2109,7 +2109,7 @@ void Application::wheelEvent(QWheelEvent* event) { · 489 unmodified lines
2109 if (_controllerScriptingInterface->isWheelCaptured()) {2109 if (_controllerScriptingInterface->isWheelCaptured()) {
2110 return;2110 return;
2111 }2111 }
2112 2112
2113 if (Menu::getInstance()->isOptionChecked(KeyboardMouseDevice::NAME)) {2113 if (Menu::getInstance()->isOptionChecked(KeyboardMouseDevice::NAME)) {
2114 _keyboardMouseDevice->wheelEvent(event);2114 _keyboardMouseDevice->wheelEvent(event);
2115 }2115 }
@@ -2227,7 +2227,7 @@ void Application::idle(uint64_t now) { · 111 unmodified lines
2227 _idleLoopStdev.reset();2227 _idleLoopStdev.reset();
2228 }2228 }
2229 }2229 }
2230 2230
2231 _overlayConductor.update(secondsSinceLastUpdate);2231 _overlayConductor.update(secondsSinceLastUpdate);
2232 2232
2233 // check for any requested background downloads.2233 // check for any requested background downloads.
@@ -2481,7 +2481,7 @@ void Application::init() { · 247 unmodified lines
2481 DependencyManager::get<AddressManager>()->loadSettings(addressLookupString);2481 DependencyManager::get<AddressManager>()->loadSettings(addressLookupString);
2482 2482
2483 qCDebug(interfaceapp) << "Loaded settings";2483 qCDebug(interfaceapp) << "Loaded settings";
2484 2484
2485 Leapmotion::init();2485 Leapmotion::init();
2486 RealSense::init();2486 RealSense::init();
2487 2487
@@ -2539,7 +2539,7 @@ void Application::setAvatarUpdateThreading(bool isThreaded) { · 51 unmodified lines
2539 if (_avatarUpdate && (_avatarUpdate->isThreaded() == isThreaded)) {2539 if (_avatarUpdate && (_avatarUpdate->isThreaded() == isThreaded)) {
2540 return;2540 return;
2541 }2541 }
2542 2542
2543 auto myAvatar = getMyAvatar();2543 auto myAvatar = getMyAvatar();
2544 if (_avatarUpdate) {2544 if (_avatarUpdate) {
2545 _avatarUpdate->terminate(); // Must be before we shutdown anim graph.2545 _avatarUpdate->terminate(); // Must be before we shutdown anim graph.
@@ -2750,7 +2750,7 @@ void Application::updateDialogs(float deltaTime) { · 204 unmodified lines
2750 if(audioStatsDialog) {2750 if(audioStatsDialog) {
2751 audioStatsDialog->update();2751 audioStatsDialog->update();
2752 }2752 }
2753 2753
2754 // Update bandwidth dialog, if any2754 // Update bandwidth dialog, if any
2755 BandwidthDialog* bandwidthDialog = dialogsManager->getBandwidthDialog();2755 BandwidthDialog* bandwidthDialog = dialogsManager->getBandwidthDialog();
2756 if (bandwidthDialog) {2756 if (bandwidthDialog) {
@@ -2828,14 +2828,8 @@ void Application::update(float deltaTime) { · 71 unmodified lines
2828 myAvatar->setDriveKeys(TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y));2828 myAvatar->setDriveKeys(TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y));
2829 myAvatar->setDriveKeys(TRANSLATE_X, userInputMapper->getActionState(controller::Action::TRANSLATE_X));2829 myAvatar->setDriveKeys(TRANSLATE_X, userInputMapper->getActionState(controller::Action::TRANSLATE_X));
2830 if (deltaTime > FLT_EPSILON) {2830 if (deltaTime > FLT_EPSILON) {
2831 // For rotations what we really want are meausures of "angles per second" (in order to prevent 2831 myAvatar->setDriveKeys(PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH));
2832 // fps-dependent spin rates) so we need to scale the units of the controller contribution.2832 myAvatar->setDriveKeys(YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW));
2833 // (TODO?: maybe we should similarly scale ALL action state info, or change the expected behavior
2834 // controllers to provide a delta_per_second value rather than a raw delta.)
2835 const float EXPECTED_FRAME_RATE = 60.0f;
2836 float timeFactor = EXPECTED_FRAME_RATE * deltaTime;
2837 myAvatar->setDriveKeys(PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH) / timeFactor);
2838 myAvatar->setDriveKeys(YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW) / timeFactor);
2839 myAvatar->setDriveKeys(STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW));2833 myAvatar->setDriveKeys(STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW));
2840 }2834 }
2841 }2835 }
@@ -2892,7 +2886,7 @@ void Application::update(float deltaTime) { · 50 unmodified lines
2892 _entities.getTree()->withWriteLock([&] {2886 _entities.getTree()->withWriteLock([&] {
2893 _physicsEngine->stepSimulation();2887 _physicsEngine->stepSimulation();
2894 });2888 });
2895 2889
2896 if (_physicsEngine->hasOutgoingChanges()) {2890 if (_physicsEngine->hasOutgoingChanges()) {
2897 _entities.getTree()->withWriteLock([&] {2891 _entities.getTree()->withWriteLock([&] {
2898 _entitySimulation.handleOutgoingChanges(_physicsEngine->getOutgoingChanges(), _physicsEngine->getSessionID());2892 _entitySimulation.handleOutgoingChanges(_physicsEngine->getOutgoingChanges(), _physicsEngine->getSessionID());
@@ -3021,10 +3015,10 @@ int Application::sendNackPackets() { · 122 unmodified lines
3021 foreach(const OCTREE_PACKET_SEQUENCE& missingNumber, missingSequenceNumbers) {3015 foreach(const OCTREE_PACKET_SEQUENCE& missingNumber, missingSequenceNumbers) {
3022 nackPacketList->writePrimitive(missingNumber);3016 nackPacketList->writePrimitive(missingNumber);
3023 }3017 }
3024 3018
3025 if (nackPacketList->getNumPackets()) {3019 if (nackPacketList->getNumPackets()) {
3026 packetsSent += nackPacketList->getNumPackets();3020 packetsSent += nackPacketList->getNumPackets();
3027 3021
3028 // send the packet list3022 // send the packet list
3029 nodeList->sendPacketList(std::move(nackPacketList), *node);3023 nodeList->sendPacketList(std::move(nackPacketList), *node);
3030 }3024 }
@@ -3632,7 +3626,7 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi · 601 unmodified lines
3632 float fov = MIRROR_FIELD_OF_VIEW;3626 float fov = MIRROR_FIELD_OF_VIEW;
3633 3627
3634 auto myAvatar = getMyAvatar();3628 auto myAvatar = getMyAvatar();
3635 3629
3636 // bool eyeRelativeCamera = false;3630 // bool eyeRelativeCamera = false;
3637 if (billboard) {3631 if (billboard) {
3638 fov = BILLBOARD_FIELD_OF_VIEW; // degees3632 fov = BILLBOARD_FIELD_OF_VIEW; // degees
@@ -3840,7 +3834,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 201 unmodified lines
3840 Menu::getInstance()->getActionForOption(MenuOption::UploadAsset)->setEnabled(false);3834 Menu::getInstance()->getActionForOption(MenuOption::UploadAsset)->setEnabled(false);
3841 }3835 }
3842}3836}
3843 3837
3844void Application::trackIncomingOctreePacket(NLPacket& packet, SharedNodePointer sendingNode, bool wasStatsPacket) {3838void Application::trackIncomingOctreePacket(NLPacket& packet, SharedNodePointer sendingNode, bool wasStatsPacket) {
3845 3839
3846 // Attempt to identify the sender from its address.3840 // Attempt to identify the sender from its address.
@@ -3865,7 +3859,7 @@ int Application::processOctreeStats(NLPacket& packet, SharedNodePointer sendingN · 18 unmodified lines
3865 int statsMessageLength = 0;3859 int statsMessageLength = 0;
3866 3860
3867 const QUuid& nodeUUID = sendingNode->getUUID();3861 const QUuid& nodeUUID = sendingNode->getUUID();
3868 3862
3869 // now that we know the node ID, let's add these stats to the stats for that node...3863 // now that we know the node ID, let's add these stats to the stats for that node...
3870 _octreeServerSceneStats.withWriteLock([&] {3864 _octreeServerSceneStats.withWriteLock([&] {
3871 OctreeSceneStats& octreeStats = _octreeServerSceneStats[nodeUUID];3865 OctreeSceneStats& octreeStats = _octreeServerSceneStats[nodeUUID];
@@ -4066,7 +4060,7 @@ bool Application::acceptURL(const QString& urlString, bool defaultUpload) { · 194 unmodified lines
4066 Qt::AutoConnection, Q_ARG(const QString&, urlString));4060 Qt::AutoConnection, Q_ARG(const QString&, urlString));
4067 return true;4061 return true;
4068 }4062 }
4069 4063
4070 QUrl url(urlString);4064 QUrl url(urlString);
4071 QHashIterator<QString, AcceptURLMethod> i(_acceptedExtensions);4065 QHashIterator<QString, AcceptURLMethod> i(_acceptedExtensions);
4072 QString lowerPath = url.path().toLower();4066 QString lowerPath = url.path().toLower();
@@ -4077,7 +4071,7 @@ bool Application::acceptURL(const QString& urlString, bool defaultUpload) { · 4 unmodified lines
4077 return (this->*method)(urlString);4071 return (this->*method)(urlString);
4078 }4072 }
4079 }4073 }
4080 4074
4081 return defaultUpload && askToUploadAsset(urlString);4075 return defaultUpload && askToUploadAsset(urlString);
4082}4076}
4083 4077
@@ -4159,10 +4153,10 @@ bool Application::askToUploadAsset(const QString& filename) { · 75 unmodified lines
4159 QString("You don't have upload rights on that domain.\n\n"));4153 QString("You don't have upload rights on that domain.\n\n"));
4160 return false;4154 return false;
4161 }4155 }
4162 4156
4163 QUrl url { filename };4157 QUrl url { filename };
4164 if (auto upload = DependencyManager::get<AssetClient>()->createUpload(url.toLocalFile())) {4158 if (auto upload = DependencyManager::get<AssetClient>()->createUpload(url.toLocalFile())) {
4165 4159
4166 QMessageBox messageBox;4160 QMessageBox messageBox;
4167 messageBox.setWindowTitle("Asset upload");4161 messageBox.setWindowTitle("Asset upload");
4168 messageBox.setText("You are about to upload the following file to the asset server:\n" +4162 messageBox.setText("You are about to upload the following file to the asset server:\n" +
@@ -4170,19 +4164,19 @@ bool Application::askToUploadAsset(const QString& filename) { · 1 unmodified line
4170 messageBox.setInformativeText("Do you want to continue?");4164 messageBox.setInformativeText("Do you want to continue?");
4171 messageBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);4165 messageBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
4172 messageBox.setDefaultButton(QMessageBox::Ok);4166 messageBox.setDefaultButton(QMessageBox::Ok);
4173 4167
4174 // Option to drop model in world for models4168 // Option to drop model in world for models
4175 if (filename.endsWith(FBX_EXTENSION) || filename.endsWith(OBJ_EXTENSION)) {4169 if (filename.endsWith(FBX_EXTENSION) || filename.endsWith(OBJ_EXTENSION)) {
4176 auto checkBox = new QCheckBox(&messageBox);4170 auto checkBox = new QCheckBox(&messageBox);
4177 checkBox->setText("Add to scene");4171 checkBox->setText("Add to scene");
4178 messageBox.setCheckBox(checkBox);4172 messageBox.setCheckBox(checkBox);
4179 }4173 }
4180 4174
4181 if (messageBox.exec() != QMessageBox::Ok) {4175 if (messageBox.exec() != QMessageBox::Ok) {
4182 upload->deleteLater();4176 upload->deleteLater();
4183 return false;4177 return false;
4184 }4178 }
4185 4179
4186 // connect to the finished signal so we know when the AssetUpload is done4180 // connect to the finished signal so we know when the AssetUpload is done
4187 if (messageBox.checkBox() && (messageBox.checkBox()->checkState() == Qt::Checked)) {4181 if (messageBox.checkBox() && (messageBox.checkBox()->checkState() == Qt::Checked)) {
4188 // Custom behavior for models4182 // Custom behavior for models
@@ -4192,12 +4186,12 @@ bool Application::askToUploadAsset(const QString& filename) { · 3 unmodified lines
4192 &AssetUploadDialogFactory::getInstance(),4186 &AssetUploadDialogFactory::getInstance(),
4193 &AssetUploadDialogFactory::handleUploadFinished);4187 &AssetUploadDialogFactory::handleUploadFinished);
4194 }4188 }
4195 4189
4196 // start the upload now4190 // start the upload now
4197 upload->start();4191 upload->start();
4198 return true;4192 return true;
4199 }4193 }
4200 4194
4201 // display a message box with the error4195 // display a message box with the error
4202 QMessageBox::warning(_window, "Failed Upload", QString("Failed to upload %1.\n\n").arg(filename));4196 QMessageBox::warning(_window, "Failed Upload", QString("Failed to upload %1.\n\n").arg(filename));
4203 return false;4197 return false;
@@ -4205,20 +4199,20 @@ bool Application::askToUploadAsset(const QString& filename) { · 1 unmodified line
4205 4199
4206void Application::modelUploadFinished(AssetUpload* upload, const QString& hash) {4200void Application::modelUploadFinished(AssetUpload* upload, const QString& hash) {
4207 auto filename = QFileInfo(upload->getFilename()).fileName();4201 auto filename = QFileInfo(upload->getFilename()).fileName();
4208 4202
4209 if ((upload->getError() == AssetUpload::NoError) &&4203 if ((upload->getError() == AssetUpload::NoError) &&
4210 (filename.endsWith(FBX_EXTENSION) || filename.endsWith(OBJ_EXTENSION))) {4204 (filename.endsWith(FBX_EXTENSION) || filename.endsWith(OBJ_EXTENSION))) {
4211 4205
4212 auto entities = DependencyManager::get<EntityScriptingInterface>();4206 auto entities = DependencyManager::get<EntityScriptingInterface>();
4213 4207
4214 EntityItemProperties properties;4208 EntityItemProperties properties;
4215 properties.setType(EntityTypes::Model);4209 properties.setType(EntityTypes::Model);
4216 properties.setModelURL(QString("%1:%2.%3").arg(URL_SCHEME_ATP).arg(hash).arg(upload->getExtension()));4210 properties.setModelURL(QString("%1:%2.%3").arg(URL_SCHEME_ATP).arg(hash).arg(upload->getExtension()));
4217 properties.setPosition(_myCamera.getPosition() + _myCamera.getOrientation() * Vectors::FRONT * 2.0f);4211 properties.setPosition(_myCamera.getPosition() + _myCamera.getOrientation() * Vectors::FRONT * 2.0f);
4218 properties.setName(QUrl(upload->getFilename()).fileName());4212 properties.setName(QUrl(upload->getFilename()).fileName());
4219 4213
4220 entities->addEntity(properties);4214 entities->addEntity(properties);
4221 4215
4222 upload->deleteLater();4216 upload->deleteLater();
4223 } else {4217 } else {
4224 AssetUploadDialogFactory::getInstance().handleUploadFinished(upload, hash);4218 AssetUploadDialogFactory::getInstance().handleUploadFinished(upload, hash);
@@ -4499,7 +4493,7 @@ void Application::takeSnapshot() { · 274 unmodified lines
4499 _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget);4493 _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget);
4500 }4494 }
4501 _snapshotShareDialog->show();4495 _snapshotShareDialog->show();
4502 4496
4503}4497}
4504 4498
4505float Application::getRenderResolutionScale() const {4499float Application::getRenderResolutionScale() const {
@@ -4744,8 +4738,8 @@ void Application::updateDisplayMode() { · 238 unmodified lines
4744 return;4738 return;
4745 }4739 }
4746 4740
4747 // Some plugins *cough* Oculus *cough* process message events from inside their 4741 // Some plugins *cough* Oculus *cough* process message events from inside their
4748 // display function, and we don't want to change the display plugin underneath 4742 // display function, and we don't want to change the display plugin underneath
4749 // the paintGL call, so we need to guard against that4743 // the paintGL call, so we need to guard against that
4750 if (_inPaint) {4744 if (_inPaint) {
4751 qDebug() << "Deferring plugin switch until out of painting";4745 qDebug() << "Deferring plugin switch until out of painting";
@@ -4779,14 +4773,14 @@ void Application::updateDisplayMode() { · 27 unmodified lines
4779 4773
4780 oldDisplayPlugin = _displayPlugin;4774 oldDisplayPlugin = _displayPlugin;
4781 _displayPlugin = newDisplayPlugin;4775 _displayPlugin = newDisplayPlugin;
4782 4776
4783 // If the displayPlugin is a screen based HMD, then it will want the HMDTools displayed4777 // If the displayPlugin is a screen based HMD, then it will want the HMDTools displayed
4784 // Direct Mode HMDs (like windows Oculus) will be isHmd() but will have a screen of -14778 // Direct Mode HMDs (like windows Oculus) will be isHmd() but will have a screen of -1
4785 bool newPluginWantsHMDTools = newDisplayPlugin ?4779 bool newPluginWantsHMDTools = newDisplayPlugin ?
4786 (newDisplayPlugin->isHmd() && (newDisplayPlugin->getHmdScreen() >= 0)) : false;4780 (newDisplayPlugin->isHmd() && (newDisplayPlugin->getHmdScreen() >= 0)) : false;
4787 bool oldPluginWantedHMDTools = oldDisplayPlugin ? 4781 bool oldPluginWantedHMDTools = oldDisplayPlugin ?
4788 (oldDisplayPlugin->isHmd() && (oldDisplayPlugin->getHmdScreen() >= 0)) : false;4782 (oldDisplayPlugin->isHmd() && (oldDisplayPlugin->getHmdScreen() >= 0)) : false;
4789 4783
4790 // Only show the hmd tools after the correct plugin has4784 // Only show the hmd tools after the correct plugin has
4791 // been activated so that it's UI is setup correctly4785 // been activated so that it's UI is setup correctly
4792 if (newPluginWantsHMDTools) {4786 if (newPluginWantsHMDTools) {
@@ -4796,7 +4790,7 @@ void Application::updateDisplayMode() { · 3 unmodified lines
4796 if (oldDisplayPlugin) {4790 if (oldDisplayPlugin) {
4797 oldDisplayPlugin->deactivate();4791 oldDisplayPlugin->deactivate();
4798 _offscreenContext->makeCurrent();4792 _offscreenContext->makeCurrent();
4799 4793
4800 // if the old plugin was HMD and the new plugin is not HMD, then hide our hmdtools4794 // if the old plugin was HMD and the new plugin is not HMD, then hide our hmdtools
4801 if (oldPluginWantedHMDTools && !newPluginWantsHMDTools) {4795 if (oldPluginWantedHMDTools && !newPluginWantsHMDTools) {
4802 DependencyManager::get<DialogsManager>()->hmdTools(false);4796 DependencyManager::get<DialogsManager>()->hmdTools(false);
@@ -4929,7 +4923,7 @@ void Application::setPalmData(Hand* hand, const controller::Pose& pose, float de · 126 unmodified lines
4929 rawVelocity = glm::vec3(0.0f);4923 rawVelocity = glm::vec3(0.0f);
4930 }4924 }
4931 palm.setRawVelocity(rawVelocity); // meters/sec4925 palm.setRawVelocity(rawVelocity); // meters/sec
4932 4926
4933 // Angular Velocity of Palm4927 // Angular Velocity of Palm
4934 glm::quat deltaRotation = rotation * glm::inverse(palm.getRawRotation());4928 glm::quat deltaRotation = rotation * glm::inverse(palm.getRawRotation());
4935 glm::vec3 angularVelocity(0.0f);4929 glm::vec3 angularVelocity(0.0f);
@@ -5009,7 +5003,7 @@ void Application::emulateMouse(Hand* hand, float click, float shift, HandData::H · 73 unmodified lines
5009 pos.setY(canvasSize.y / 2.0f + cursorRange * yAngle);5003 pos.setY(canvasSize.y / 2.0f + cursorRange * yAngle);
5010 5004
5011 }5005 }
5012 5006
5013 //If we are off screen then we should stop processing, and if a trigger or bumper is pressed,5007 //If we are off screen then we should stop processing, and if a trigger or bumper is pressed,
5014 //we should unpress them.5008 //we should unpress them.
5015 if (pos.x() == INT_MAX) {5009 if (pos.x() == INT_MAX) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t