Showing the changes to interface/src/Application.cpp (1 of 123 files). Show all
Unified · Split
| @@ -177,6 +177,8 @@ · 176 unmodified lines | ||
| 177 | 177 | #include "FrameTimingsScriptingInterface.h" |
| 178 | 178 | #include <GPUIdent.h> |
| 179 | 179 | #include <gl/GLHelpers.h> |
| 180 | +#include <EntityScriptClient.h> | |
| 181 | +#include <ModelScriptingInterface.h> | |
| 180 | 182 | |
| 181 | 183 | // On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU |
| 182 | 184 | // FIXME seems to be broken. |
| @@ -213,18 +215,10 @@ static const QString FBX_EXTENSION = ".fbx"; · 30 unmodified lines | ||
| 213 | 215 | static const QString OBJ_EXTENSION = ".obj"; |
| 214 | 216 | static const QString AVA_JSON_EXTENSION = ".ava.json"; |
| 215 | 217 | |
| 216 | −static const int MIRROR_VIEW_TOP_PADDING = 5; | |
| 217 | −static const int MIRROR_VIEW_LEFT_PADDING = 10; | |
| 218 | −static const int MIRROR_VIEW_WIDTH = 265; | |
| 219 | −static const int MIRROR_VIEW_HEIGHT = 215; | |
| 220 | 218 | static const float MIRROR_FULLSCREEN_DISTANCE = 0.389f; |
| 221 | −static const float MIRROR_REARVIEW_DISTANCE = 0.722f; | |
| 222 | −static const float MIRROR_REARVIEW_BODY_DISTANCE = 2.56f; | |
| 223 | −static const float MIRROR_FIELD_OF_VIEW = 30.0f; | |
| 224 | 219 | |
| 225 | 220 | static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS_PER_SECOND; |
| 226 | 221 | |
| 227 | −static const QString INFO_WELCOME_PATH = "html/interface-welcome.html"; | |
| 228 | 222 | static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-commands.html"; |
| 229 | 223 | static const QString INFO_HELP_PATH = "html/help.html"; |
| 230 | 224 | |
| @@ -423,6 +417,7 @@ static const QString STATE_CAMERA_THIRD_PERSON = "CameraThirdPerson"; · 192 unmodified lines | ||
| 423 | 417 | static const QString STATE_CAMERA_ENTITY = "CameraEntity"; |
| 424 | 418 | static const QString STATE_CAMERA_INDEPENDENT = "CameraIndependent"; |
| 425 | 419 | static const QString STATE_SNAP_TURN = "SnapTurn"; |
| 420 | +static const QString STATE_ADVANCED_MOVEMENT_CONTROLS = "AdvancedMovement"; | |
| 426 | 421 | static const QString STATE_GROUNDED = "Grounded"; |
| 427 | 422 | static const QString STATE_NAV_FOCUSED = "NavigationFocused"; |
| 428 | 423 | |
| @@ -513,7 +508,7 @@ bool setupEssentials(int& argc, char** argv) { · 84 unmodified lines | ||
| 513 | 508 | DependencyManager::set<MessagesClient>(); |
| 514 | 509 | controller::StateController::setStateVariables({ { STATE_IN_HMD, STATE_CAMERA_FULL_SCREEN_MIRROR, |
| 515 | 510 | STATE_CAMERA_FIRST_PERSON, STATE_CAMERA_THIRD_PERSON, STATE_CAMERA_ENTITY, STATE_CAMERA_INDEPENDENT, |
| 516 | − STATE_SNAP_TURN, STATE_GROUNDED, STATE_NAV_FOCUSED } }); | |
| 511 | + STATE_SNAP_TURN, STATE_ADVANCED_MOVEMENT_CONTROLS, STATE_GROUNDED, STATE_NAV_FOCUSED } }); | |
| 517 | 512 | DependencyManager::set<UserInputMapper>(); |
| 518 | 513 | DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>(); |
| 519 | 514 | DependencyManager::set<InterfaceParentFinder>(); |
| @@ -565,7 +560,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 45 unmodified lines | ||
| 565 | 560 | _entityClipboardRenderer(false, this, this), |
| 566 | 561 | _entityClipboard(new EntityTree()), |
| 567 | 562 | _lastQueriedTime(usecTimestampNow()), |
| 568 | − _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), | |
| 569 | 563 | _previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION), |
| 570 | 564 | _fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES), |
| 571 | 565 | _hmdTabletScale("hmdTabletScale", DEFAULT_HMD_TABLET_SCALE_PERCENT), |
| @@ -1129,6 +1123,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 557 unmodified lines | ||
| 1129 | 1123 | _applicationStateDevice->setInputVariant(STATE_SNAP_TURN, []() -> float { |
| 1130 | 1124 | return qApp->getMyAvatar()->getSnapTurn() ? 1 : 0; |
| 1131 | 1125 | }); |
| 1126 | + _applicationStateDevice->setInputVariant(STATE_ADVANCED_MOVEMENT_CONTROLS, []() -> float { | |
| 1127 | + return qApp->getMyAvatar()->useAdvancedMovementControls() ? 1 : 0; | |
| 1128 | + }); | |
| 1129 | + | |
| 1132 | 1130 | _applicationStateDevice->setInputVariant(STATE_GROUNDED, []() -> float { |
| 1133 | 1131 | return qApp->getMyAvatar()->getCharacterController()->onGround() ? 1 : 0; |
| 1134 | 1132 | }); |
| @@ -2119,21 +2117,6 @@ void Application::paintGL() { · 984 unmodified lines | ||
| 2119 | 2117 | batch.resetStages(); |
| 2120 | 2118 | }); |
| 2121 | 2119 | |
| 2122 | − auto inputs = AvatarInputs::getInstance(); | |
| 2123 | − if (inputs->mirrorVisible()) { | |
| 2124 | − PerformanceTimer perfTimer("Mirror"); | |
| 2125 | − | |
| 2126 | − renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; | |
| 2127 | − renderArgs._blitFramebuffer = DependencyManager::get<FramebufferCache>()->getSelfieFramebuffer(); | |
| 2128 | − | |
| 2129 | − _mirrorViewRect.moveTo(inputs->x(), inputs->y()); | |
| 2130 | − | |
| 2131 | − renderRearViewMirror(&renderArgs, _mirrorViewRect, inputs->mirrorZoomed()); | |
| 2132 | − | |
| 2133 | − renderArgs._blitFramebuffer.reset(); | |
| 2134 | − renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE; | |
| 2135 | − } | |
| 2136 | − | |
| 2137 | 2120 | { |
| 2138 | 2121 | PerformanceTimer perfTimer("renderOverlay"); |
| 2139 | 2122 | // NOTE: There is no batch associated with this renderArgs |
| @@ -2381,10 +2364,6 @@ void Application::setSettingConstrainToolbarPosition(bool setting) { · 241 unmodified lines | ||
| 2381 | 2364 | DependencyManager::get<OffscreenUi>()->setConstrainToolbarToCenterX(setting); |
| 2382 | 2365 | } |
| 2383 | 2366 | |
| 2384 | −void Application::aboutApp() { | |
| 2385 | − InfoView::show(INFO_WELCOME_PATH); | |
| 2386 | −} | |
| 2387 | − | |
| 2388 | 2367 | void Application::showHelp() { |
| 2389 | 2368 | static const QString HAND_CONTROLLER_NAME_VIVE = "vive"; |
| 2390 | 2369 | static const QString HAND_CONTROLLER_NAME_OCULUS_TOUCH = "oculus"; |
| @@ -2886,51 +2865,49 @@ void Application::keyPressEvent(QKeyEvent* event) { · 495 unmodified lines | ||
| 2886 | 2865 | break; |
| 2887 | 2866 | #endif |
| 2888 | 2867 | |
| 2889 | − case Qt::Key_H: | |
| 2890 | − if (isShifted) { | |
| 2891 | − Menu::getInstance()->triggerOption(MenuOption::MiniMirror); | |
| 2892 | − } else { | |
| 2893 | − // whenever switching to/from full screen mirror from the keyboard, remember | |
| 2894 | − // the state you were in before full screen mirror, and return to that. | |
| 2895 | − auto previousMode = _myCamera.getMode(); | |
| 2896 | − if (previousMode != CAMERA_MODE_MIRROR) { | |
| 2897 | − switch (previousMode) { | |
| 2898 | − case CAMERA_MODE_FIRST_PERSON: | |
| 2899 | − _returnFromFullScreenMirrorTo = MenuOption::FirstPerson; | |
| 2900 | − break; | |
| 2901 | − case CAMERA_MODE_THIRD_PERSON: | |
| 2902 | − _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson; | |
| 2903 | − break; | |
| 2904 | − | |
| 2905 | − // FIXME - it's not clear that these modes make sense to return to... | |
| 2906 | − case CAMERA_MODE_INDEPENDENT: | |
| 2907 | − _returnFromFullScreenMirrorTo = MenuOption::IndependentMode; | |
| 2908 | − break; | |
| 2909 | − case CAMERA_MODE_ENTITY: | |
| 2910 | − _returnFromFullScreenMirrorTo = MenuOption::CameraEntityMode; | |
| 2911 | − break; | |
| 2912 | − | |
| 2913 | − default: | |
| 2914 | − _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson; | |
| 2915 | − break; | |
| 2916 | − } | |
| 2868 | + case Qt::Key_H: { | |
| 2869 | + // whenever switching to/from full screen mirror from the keyboard, remember | |
| 2870 | + // the state you were in before full screen mirror, and return to that. | |
| 2871 | + auto previousMode = _myCamera.getMode(); | |
| 2872 | + if (previousMode != CAMERA_MODE_MIRROR) { | |
| 2873 | + switch (previousMode) { | |
| 2874 | + case CAMERA_MODE_FIRST_PERSON: | |
| 2875 | + _returnFromFullScreenMirrorTo = MenuOption::FirstPerson; | |
| 2876 | + break; | |
| 2877 | + case CAMERA_MODE_THIRD_PERSON: | |
| 2878 | + _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson; | |
| 2879 | + break; | |
| 2880 | + | |
| 2881 | + // FIXME - it's not clear that these modes make sense to return to... | |
| 2882 | + case CAMERA_MODE_INDEPENDENT: | |
| 2883 | + _returnFromFullScreenMirrorTo = MenuOption::IndependentMode; | |
| 2884 | + break; | |
| 2885 | + case CAMERA_MODE_ENTITY: | |
| 2886 | + _returnFromFullScreenMirrorTo = MenuOption::CameraEntityMode; | |
| 2887 | + break; | |
| 2888 | + | |
| 2889 | + default: | |
| 2890 | + _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson; | |
| 2891 | + break; | |
| 2917 | 2892 | } |
| 2893 | + } | |
| 2918 | 2894 | |
| 2919 | − bool isMirrorChecked = Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror); | |
| 2920 | − Menu::getInstance()->setIsOptionChecked(MenuOption::FullscreenMirror, !isMirrorChecked); | |
| 2921 | − if (isMirrorChecked) { | |
| 2895 | + bool isMirrorChecked = Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror); | |
| 2896 | + Menu::getInstance()->setIsOptionChecked(MenuOption::FullscreenMirror, !isMirrorChecked); | |
| 2897 | + if (isMirrorChecked) { | |
| 2922 | 2898 | |
| 2923 | − // if we got here without coming in from a non-Full Screen mirror case, then our | |
| 2924 | − // _returnFromFullScreenMirrorTo is unknown. In that case we'll go to the old | |
| 2925 | − // behavior of returning to ThirdPerson | |
| 2926 | − if (_returnFromFullScreenMirrorTo.isEmpty()) { | |
| 2927 | − _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson; | |
| 2928 | − } | |
| 2929 | − Menu::getInstance()->setIsOptionChecked(_returnFromFullScreenMirrorTo, true); | |
| 2899 | + // if we got here without coming in from a non-Full Screen mirror case, then our | |
| 2900 | + // _returnFromFullScreenMirrorTo is unknown. In that case we'll go to the old | |
| 2901 | + // behavior of returning to ThirdPerson | |
| 2902 | + if (_returnFromFullScreenMirrorTo.isEmpty()) { | |
| 2903 | + _returnFromFullScreenMirrorTo = MenuOption::ThirdPerson; | |
| 2930 | 2904 | } |
| 2931 | − cameraMenuChanged(); | |
| 2905 | + Menu::getInstance()->setIsOptionChecked(_returnFromFullScreenMirrorTo, true); | |
| 2932 | 2906 | } |
| 2907 | + cameraMenuChanged(); | |
| 2933 | 2908 | break; |
| 2909 | + } | |
| 2910 | + | |
| 2934 | 2911 | case Qt::Key_P: { |
| 2935 | 2912 | if (!(isShifted || isMeta || isOption)) { |
| 2936 | 2913 | bool isFirstPersonChecked = Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson); |
| @@ -3845,8 +3822,6 @@ void Application::init() { · 908 unmodified lines | ||
| 3845 | 3822 | DependencyManager::get<AvatarManager>()->init(); |
| 3846 | 3823 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 3847 | 3824 | |
| 3848 | − _mirrorCamera.setMode(CAMERA_MODE_MIRROR); | |
| 3849 | − | |
| 3850 | 3825 | _timerStart.start(); |
| 3851 | 3826 | _lastTimeUpdated.start(); |
| 3852 | 3827 | |
| @@ -4383,16 +4358,16 @@ void Application::update(float deltaTime) { · 530 unmodified lines | ||
| 4383 | 4358 | myAvatar->clearDriveKeys(); |
| 4384 | 4359 | if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) { |
| 4385 | 4360 | if (!_controllerScriptingInterface->areActionsCaptured()) { |
| 4386 | − myAvatar->setDriveKeys(TRANSLATE_Z, -1.0f * userInputMapper->getActionState(controller::Action::TRANSLATE_Z)); | |
| 4387 | − myAvatar->setDriveKeys(TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y)); | |
| 4388 | − myAvatar->setDriveKeys(TRANSLATE_X, userInputMapper->getActionState(controller::Action::TRANSLATE_X)); | |
| 4361 | + myAvatar->setDriveKey(MyAvatar::TRANSLATE_Z, -1.0f * userInputMapper->getActionState(controller::Action::TRANSLATE_Z)); | |
| 4362 | + myAvatar->setDriveKey(MyAvatar::TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y)); | |
| 4363 | + myAvatar->setDriveKey(MyAvatar::TRANSLATE_X, userInputMapper->getActionState(controller::Action::TRANSLATE_X)); | |
| 4389 | 4364 | if (deltaTime > FLT_EPSILON) { |
| 4390 | − myAvatar->setDriveKeys(PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH)); | |
| 4391 | − myAvatar->setDriveKeys(YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW)); | |
| 4392 | − myAvatar->setDriveKeys(STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW)); | |
| 4365 | + myAvatar->setDriveKey(MyAvatar::PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH)); | |
| 4366 | + myAvatar->setDriveKey(MyAvatar::YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW)); | |
| 4367 | + myAvatar->setDriveKey(MyAvatar::STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW)); | |
| 4393 | 4368 | } |
| 4394 | 4369 | } |
| 4395 | − myAvatar->setDriveKeys(ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z)); | |
| 4370 | + myAvatar->setDriveKey(MyAvatar::ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z)); | |
| 4396 | 4371 | } |
| 4397 | 4372 | |
| 4398 | 4373 | controller::Pose leftHandPose = userInputMapper->getPoseState(controller::Action::LEFT_HAND); |
| @@ -4463,9 +4438,12 @@ void Application::update(float deltaTime) { · 64 unmodified lines | ||
| 4463 | 4438 | |
| 4464 | 4439 | getEntities()->getTree()->withWriteLock([&] { |
| 4465 | 4440 | PerformanceTimer perfTimer("handleOutgoingChanges"); |
| 4466 | − const VectorOfMotionStates& outgoingChanges = _physicsEngine->getOutgoingChanges(); | |
| 4467 | − _entitySimulation->handleOutgoingChanges(outgoingChanges); | |
| 4468 | − avatarManager->handleOutgoingChanges(outgoingChanges); | |
| 4441 | + const VectorOfMotionStates& deactivations = _physicsEngine->getDeactivatedMotionStates(); | |
| 4442 | + _entitySimulation->handleDeactivatedMotionStates(deactivations); | |
| 4443 | + | |
| 4444 | + const VectorOfMotionStates& outgoingChanges = _physicsEngine->getChangedMotionStates(); | |
| 4445 | + _entitySimulation->handleChangedMotionStates(outgoingChanges); | |
| 4446 | + avatarManager->handleChangedMotionStates(outgoingChanges); | |
| 4469 | 4447 | }); |
| 4470 | 4448 | |
| 4471 | 4449 | if (!_aboutToQuit) { |
| @@ -5122,58 +5100,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 650 unmodified lines | ||
| 5122 | 5100 | activeRenderingThread = nullptr; |
| 5123 | 5101 | } |
| 5124 | 5102 | |
| 5125 | −void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& region, bool isZoomed) { | |
| 5126 | − auto originalViewport = renderArgs->_viewport; | |
| 5127 | − // Grab current viewport to reset it at the end | |
| 5128 | − | |
| 5129 | − float aspect = (float)region.width() / region.height(); | |
| 5130 | − float fov = MIRROR_FIELD_OF_VIEW; | |
| 5131 | − | |
| 5132 | − auto myAvatar = getMyAvatar(); | |
| 5133 | − | |
| 5134 | − // bool eyeRelativeCamera = false; | |
| 5135 | − if (!isZoomed) { | |
| 5136 | − _mirrorCamera.setPosition(myAvatar->getChestPosition() + | |
| 5137 | − myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * myAvatar->getScale()); | |
| 5138 | − | |
| 5139 | − } else { // HEAD zoom level | |
| 5140 | − // FIXME note that the positioning of the camera relative to the avatar can suffer limited | |
| 5141 | − // precision as the user's position moves further away from the origin. Thus at | |
| 5142 | − // /1e7,1e7,1e7 (well outside the buildable volume) the mirror camera veers and sways | |
| 5143 | − // wildly as you rotate your avatar because the floating point values are becoming | |
| 5144 | − // larger, squeezing out the available digits of precision you have available at the | |
| 5145 | − // human scale for camera positioning. | |
| 5146 | − | |
| 5147 | − // Previously there was a hack to correct this using the mechanism of repositioning | |
| 5148 | − // the avatar at the origin of the world for the purposes of rendering the mirror, | |
| 5149 | − // but it resulted in failing to render the avatar's head model in the mirror view | |
| 5150 | − // when in first person mode. Presumably this was because of some missed culling logic | |
| 5151 | − // that was not accounted for in the hack. | |
| 5152 | − | |
| 5153 | − // This was removed in commit 71e59cfa88c6563749594e25494102fe01db38e9 but could be further | |
| 5154 | − // investigated in order to adapt the technique while fixing the head rendering issue, | |
| 5155 | − // but the complexity of the hack suggests that a better approach | |
| 5156 | − _mirrorCamera.setPosition(myAvatar->getDefaultEyePosition() + | |
| 5157 | − myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_DISTANCE * myAvatar->getScale()); | |
| 5158 | − } | |
| 5159 | − _mirrorCamera.setProjection(glm::perspective(glm::radians(fov), aspect, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP)); | |
| 5160 | − _mirrorCamera.setOrientation(myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); | |
| 5161 | − | |
| 5162 | − | |
| 5163 | − // set the bounds of rear mirror view | |
| 5164 | − // the region is in device independent coordinates; must convert to device | |
| 5165 | − float ratio = (float)QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale(); | |
| 5166 | − int width = region.width() * ratio; | |
| 5167 | − int height = region.height() * ratio; | |
| 5168 | − gpu::Vec4i viewport = gpu::Vec4i(0, 0, width, height); | |
| 5169 | − renderArgs->_viewport = viewport; | |
| 5170 | − | |
| 5171 | − // render rear mirror view | |
| 5172 | − displaySide(renderArgs, _mirrorCamera, true); | |
| 5173 | − | |
| 5174 | − renderArgs->_viewport = originalViewport; | |
| 5175 | −} | |
| 5176 | − | |
| 5177 | 5103 | void Application::resetSensors(bool andReload) { |
| 5178 | 5104 | DependencyManager::get<Faceshift>()->reset(); |
| 5179 | 5105 | DependencyManager::get<DdeFaceTracker>()->reset(); |
| @@ -5503,8 +5429,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 323 unmodified lines | ||
| 5503 | 5429 | scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this)); |
| 5504 | 5430 | |
| 5505 | 5431 | // hook our avatar and avatar hash map object into this script engine |
| 5506 | − scriptEngine->registerGlobalObject("MyAvatar", getMyAvatar().get()); | |
| 5507 | − qScriptRegisterMetaType(scriptEngine, audioListenModeToScriptValue, audioListenModeFromScriptValue); | |
| 5432 | + getMyAvatar()->registerMetaTypes(scriptEngine); | |
| 5508 | 5433 | |
| 5509 | 5434 | scriptEngine->registerGlobalObject("AvatarList", DependencyManager::get<AvatarManager>().data()); |
| 5510 | 5435 | |