Showing the changes to interface/src/Application.cpp (1 of 64 files). Show all
Unified · Split
| @@ -231,6 +231,7 @@ static const QString FBX_EXTENSION = ".fbx"; · 230 unmodified lines | ||
| 231 | 231 | static const QString OBJ_EXTENSION = ".obj"; |
| 232 | 232 | static const QString AVA_JSON_EXTENSION = ".ava.json"; |
| 233 | 233 | static const QString WEB_VIEW_TAG = "noDownload=true"; |
| 234 | +static const QString ZIP_EXTENSION = ".zip"; | |
| 234 | 235 | |
| 235 | 236 | static const float MIRROR_FULLSCREEN_DISTANCE = 0.389f; |
| 236 | 237 | |
| @@ -262,7 +263,8 @@ const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensi · 25 unmodified lines | ||
| 262 | 263 | { AVA_JSON_EXTENSION, &Application::askToWearAvatarAttachmentUrl }, |
| 263 | 264 | { JSON_EXTENSION, &Application::importJSONFromURL }, |
| 264 | 265 | { JS_EXTENSION, &Application::askToLoadScript }, |
| 265 | − { FST_EXTENSION, &Application::askToSetAvatarUrl } | |
| 266 | + { FST_EXTENSION, &Application::askToSetAvatarUrl }, | |
| 267 | + { ZIP_EXTENSION, &Application::importFromZIP } | |
| 266 | 268 | }; |
| 267 | 269 | |
| 268 | 270 | class DeadlockWatchdogThread : public QThread { |
| @@ -2262,7 +2264,7 @@ void Application::paintGL() { · 1993 unmodified lines | ||
| 2262 | 2264 | QMutexLocker viewLocker(&_viewMutex); |
| 2263 | 2265 | _viewFrustum.calculate(); |
| 2264 | 2266 | } |
| 2265 | − renderArgs = RenderArgs(_gpuContext, getEntities(), lodManager->getOctreeSizeScale(), | |
| 2267 | + renderArgs = RenderArgs(_gpuContext, lodManager->getOctreeSizeScale(), | |
| 2266 | 2268 | lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE, |
| 2267 | 2269 | RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE); |
| 2268 | 2270 | { |
| @@ -2792,6 +2794,20 @@ bool Application::importSVOFromURL(const QString& urlString) { · 523 unmodified lines | ||
| 2792 | 2794 | return true; |
| 2793 | 2795 | } |
| 2794 | 2796 | |
| 2797 | +void Application::onPresent(quint32 frameCount) { | |
| 2798 | + if (shouldPaint()) { | |
| 2799 | + postEvent(this, new QEvent(static_cast<QEvent::Type>(Idle)), Qt::HighEventPriority); | |
| 2800 | + postEvent(this, new QEvent(static_cast<QEvent::Type>(Paint)), Qt::HighEventPriority); | |
| 2801 | + } | |
| 2802 | +} | |
| 2803 | + | |
| 2804 | +bool Application::importFromZIP(const QString& filePath) { | |
| 2805 | + qDebug() << "A zip file has been dropped in: " << filePath; | |
| 2806 | + QUrl empty; | |
| 2807 | + qApp->getFileDownloadInterface()->runUnzip(filePath, empty, true, true); | |
| 2808 | + return true; | |
| 2809 | +} | |
| 2810 | + | |
| 2795 | 2811 | bool _renderRequested { false }; |
| 2796 | 2812 | |
| 2797 | 2813 | bool Application::event(QEvent* event) { |
| @@ -2808,23 +2824,9 @@ bool Application::event(QEvent* event) { · 10 unmodified lines | ||
| 2808 | 2824 | // Explicit idle keeps the idle running at a lower interval, but without any rendering |
| 2809 | 2825 | // see (windowMinimizedChanged) |
| 2810 | 2826 | case Event::Idle: |
| 2811 | − { | |
| 2812 | − float nsecsElapsed = (float)_lastTimeUpdated.nsecsElapsed(); | |
| 2813 | − _lastTimeUpdated.start(); | |
| 2814 | − idle(nsecsElapsed); | |
| 2815 | − } | |
| 2816 | − return true; | |
| 2817 | − | |
| 2818 | − case Event::Present: | |
| 2819 | − if (!_renderRequested) { | |
| 2820 | − float nsecsElapsed = (float)_lastTimeUpdated.nsecsElapsed(); | |
| 2821 | − if (shouldPaint(nsecsElapsed)) { | |
| 2822 | − _renderRequested = true; | |
| 2823 | − _lastTimeUpdated.start(); | |
| 2824 | − idle(nsecsElapsed); | |
| 2825 | − postEvent(this, new QEvent(static_cast<QEvent::Type>(Paint)), Qt::HighEventPriority); | |
| 2826 | − } | |
| 2827 | − } | |
| 2827 | + idle(); | |
| 2828 | + // Clear the event queue of pending idle calls | |
| 2829 | + removePostedEvents(this, Idle); | |
| 2828 | 2830 | return true; |
| 2829 | 2831 | |
| 2830 | 2832 | case Event::Paint: |
| @@ -2832,9 +2834,8 @@ bool Application::event(QEvent* event) { · 1 unmodified line | ||
| 2832 | 2834 | // or AvatarInputs will mysteriously move to the bottom-right |
| 2833 | 2835 | AvatarInputs::getInstance()->update(); |
| 2834 | 2836 | paintGL(); |
| 2835 | − // wait for the next present event before starting idle / paint again | |
| 2836 | − removePostedEvents(this, Present); | |
| 2837 | − _renderRequested = false; | |
| 2837 | + // Clear the event queue of pending paint calls | |
| 2838 | + removePostedEvents(this, Paint); | |
| 2838 | 2839 | return true; |
| 2839 | 2840 | |
| 2840 | 2841 | default: |
| @@ -3653,7 +3654,7 @@ bool Application::acceptSnapshot(const QString& urlString) { · 812 unmodified lines | ||
| 3653 | 3654 | |
| 3654 | 3655 | static uint32_t _renderedFrameIndex { INVALID_FRAME }; |
| 3655 | 3656 | |
| 3656 | −bool Application::shouldPaint(float nsecsElapsed) { | |
| 3657 | +bool Application::shouldPaint() { | |
| 3657 | 3658 | if (_aboutToQuit) { |
| 3658 | 3659 | return false; |
| 3659 | 3660 | } |
| @@ -3673,11 +3674,9 @@ bool Application::shouldPaint(float nsecsElapsed) { · 13 unmodified lines | ||
| 3673 | 3674 | (float)paintDelaySamples / paintDelayUsecs << "us"; |
| 3674 | 3675 | } |
| 3675 | 3676 | #endif |
| 3676 | − | |
| 3677 | − float msecondsSinceLastUpdate = nsecsElapsed / NSECS_PER_USEC / USECS_PER_MSEC; | |
| 3678 | − | |
| 3677 | + | |
| 3679 | 3678 | // Throttle if requested |
| 3680 | − if (displayPlugin->isThrottled() && (msecondsSinceLastUpdate < THROTTLED_SIM_FRAME_PERIOD_MS)) { | |
| 3679 | + if (displayPlugin->isThrottled() && (_lastTimeUpdated.elapsed() < THROTTLED_SIM_FRAME_PERIOD_MS)) { | |
| 3681 | 3680 | return false; |
| 3682 | 3681 | } |
| 3683 | 3682 | |
| @@ -3894,7 +3893,7 @@ void setupCpuMonitorThread() { · 210 unmodified lines | ||
| 3894 | 3893 | #endif |
| 3895 | 3894 | |
| 3896 | 3895 | |
| 3897 | −void Application::idle(float nsecsElapsed) { | |
| 3896 | +void Application::idle() { | |
| 3898 | 3897 | PerformanceTimer perfTimer("idle"); |
| 3899 | 3898 | |
| 3900 | 3899 | // Update the deadlock watchdog |
| @@ -3951,7 +3950,8 @@ void Application::idle(float nsecsElapsed) { · 50 unmodified lines | ||
| 3951 | 3950 | steamClient->runCallbacks(); |
| 3952 | 3951 | } |
| 3953 | 3952 | |
| 3954 | − float secondsSinceLastUpdate = nsecsElapsed / NSECS_PER_MSEC / MSECS_PER_SECOND; | |
| 3953 | + float secondsSinceLastUpdate = (float)_lastTimeUpdated.nsecsElapsed() / NSECS_PER_MSEC / MSECS_PER_SECOND; | |
| 3954 | + _lastTimeUpdated.start(); | |
| 3955 | 3955 | |
| 3956 | 3956 | // If the offscreen Ui has something active that is NOT the root, then assume it has keyboard focus. |
| 3957 | 3957 | if (_keyboardDeviceHasFocus && offscreenUi && offscreenUi->getWindow()->activeFocusItem() != offscreenUi->getRootItem()) { |
| @@ -4185,6 +4185,7 @@ void Application::loadSettings() { · 227 unmodified lines | ||
| 4185 | 4185 | //DependencyManager::get<LODManager>()->setAutomaticLODAdjust(false); |
| 4186 | 4186 | |
| 4187 | 4187 | Menu::getInstance()->loadSettings(); |
| 4188 | + | |
| 4188 | 4189 | // If there is a preferred plugin, we probably messed it up with the menu settings, so fix it. |
| 4189 | 4190 | auto pluginManager = PluginManager::getInstance(); |
| 4190 | 4191 | auto plugins = pluginManager->getPreferredDisplayPlugins(); |
| @@ -4198,24 +4199,44 @@ void Application::loadSettings() { · 7 unmodified lines | ||
| 4198 | 4199 | break; |
| 4199 | 4200 | } |
| 4200 | 4201 | } |
| 4201 | − } else { | |
| 4202 | + } | |
| 4203 | + | |
| 4204 | + Setting::Handle<bool> firstRun { Settings::firstRun, true }; | |
| 4205 | + bool isFirstPerson = false; | |
| 4206 | + if (firstRun.get()) { | |
| 4202 | 4207 | // If this is our first run, and no preferred devices were set, default to |
| 4203 | 4208 | // an HMD device if available. |
| 4204 | − Setting::Handle<bool> firstRun { Settings::firstRun, true }; | |
| 4205 | − if (firstRun.get()) { | |
| 4206 | − auto displayPlugins = pluginManager->getDisplayPlugins(); | |
| 4207 | − for (auto& plugin : displayPlugins) { | |
| 4208 | − if (plugin->isHmd()) { | |
| 4209 | − if (auto action = menu->getActionForOption(plugin->getName())) { | |
| 4210 | − action->setChecked(true); | |
| 4211 | − action->trigger(); | |
| 4212 | − break; | |
| 4213 | − } | |
| 4209 | + auto displayPlugins = pluginManager->getDisplayPlugins(); | |
| 4210 | + for (auto& plugin : displayPlugins) { | |
| 4211 | + if (plugin->isHmd()) { | |
| 4212 | + if (auto action = menu->getActionForOption(plugin->getName())) { | |
| 4213 | + action->setChecked(true); | |
| 4214 | + action->trigger(); | |
| 4215 | + break; | |
| 4214 | 4216 | } |
| 4215 | 4217 | } |
| 4216 | 4218 | } |
| 4219 | + | |
| 4220 | + isFirstPerson = (qApp->isHMDMode()); | |
| 4221 | + } else { | |
| 4222 | + // if this is not the first run, the camera will be initialized differently depending on user settings | |
| 4223 | + | |
| 4224 | + if (qApp->isHMDMode()) { | |
| 4225 | + // if the HMD is active, use first-person camera, unless the appropriate setting is checked | |
| 4226 | + isFirstPerson = menu->isOptionChecked(MenuOption::FirstPersonHMD); | |
| 4227 | + } else { | |
| 4228 | + // if HMD is not active, only use first person if the menu option is checked | |
| 4229 | + isFirstPerson = menu->isOptionChecked(MenuOption::FirstPerson); | |
| 4230 | + } | |
| 4217 | 4231 | } |
| 4218 | 4232 | |
| 4233 | + // finish initializing the camera, based on everything we checked above. Third person camera will be used if no settings | |
| 4234 | + // dictated that we should be in first person | |
| 4235 | + Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, isFirstPerson); | |
| 4236 | + Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !isFirstPerson); | |
| 4237 | + _myCamera.setMode((isFirstPerson) ? CAMERA_MODE_FIRST_PERSON : CAMERA_MODE_THIRD_PERSON); | |
| 4238 | + cameraMenuChanged(); | |
| 4239 | + | |
| 4219 | 4240 | auto inputs = pluginManager->getInputPlugins(); |
| 4220 | 4241 | for (auto plugin : inputs) { |
| 4221 | 4242 | if (!plugin->isActive()) { |
| @@ -4264,7 +4285,6 @@ void Application::init() { · 42 unmodified lines | ||
| 4264 | 4285 | DependencyManager::get<DeferredLightingEffect>()->init(); |
| 4265 | 4286 | |
| 4266 | 4287 | DependencyManager::get<AvatarManager>()->init(); |
| 4267 | − _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); | |
| 4268 | 4288 | |
| 4269 | 4289 | _timerStart.start(); |
| 4270 | 4290 | _lastTimeUpdated.start(); |
| @@ -4416,10 +4436,9 @@ void Application::updateMyAvatarLookAtPosition() { · 145 unmodified lines | ||
| 4416 | 4436 | } |
| 4417 | 4437 | } else { |
| 4418 | 4438 | // I am not looking at anyone else, so just look forward |
| 4419 | − auto headPose = myAvatar->getHeadControllerPoseInSensorFrame(); | |
| 4439 | + auto headPose = myAvatar->getControllerPoseInWorldFrame(controller::Action::HEAD); | |
| 4420 | 4440 | if (headPose.isValid()) { |
| 4421 | − glm::mat4 worldHeadMat = myAvatar->getSensorToWorldMatrix() * headPose.getMatrix(); | |
| 4422 | − lookAtSpot = transformPoint(worldHeadMat, glm::vec3(0.0f, 0.0f, TREE_SCALE)); | |
| 4441 | + lookAtSpot = transformPoint(headPose.getMatrix(), glm::vec3(0.0f, 0.0f, TREE_SCALE)); | |
| 4423 | 4442 | } else { |
| 4424 | 4443 | lookAtSpot = myAvatar->getHead()->getEyePosition() + |
| 4425 | 4444 | (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE)); |
| @@ -4833,52 +4852,76 @@ void Application::update(float deltaTime) { · 407 unmodified lines | ||
| 4833 | 4852 | myAvatar->setDriveKey(MyAvatar::ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z)); |
| 4834 | 4853 | } |
| 4835 | 4854 | |
| 4836 | − controller::Pose leftHandPose = userInputMapper->getPoseState(controller::Action::LEFT_HAND); | |
| 4837 | − controller::Pose rightHandPose = userInputMapper->getPoseState(controller::Action::RIGHT_HAND); | |
| 4838 | − auto myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition()); | |
| 4839 | − auto worldToSensorMatrix = glm::inverse(myAvatar->getSensorToWorldMatrix()); | |
| 4840 | − auto avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix; | |
| 4841 | − myAvatar->setHandControllerPosesInSensorFrame(leftHandPose.transform(avatarToSensorMatrix), rightHandPose.transform(avatarToSensorMatrix)); | |
| 4855 | + static const std::vector<controller::Action> avatarControllerActions = { | |
| 4856 | + controller::Action::LEFT_HAND, | |
| 4857 | + controller::Action::RIGHT_HAND, | |
| 4858 | + controller::Action::LEFT_FOOT, | |
| 4859 | + controller::Action::RIGHT_FOOT, | |
| 4860 | + controller::Action::HIPS, | |
| 4861 | + controller::Action::SPINE2, | |
| 4862 | + controller::Action::HEAD, | |
| 4863 | + controller::Action::LEFT_HAND_THUMB1, | |
| 4864 | + controller::Action::LEFT_HAND_THUMB2, | |
| 4865 | + controller::Action::LEFT_HAND_THUMB3, | |
| 4866 | + controller::Action::LEFT_HAND_THUMB4, | |
| 4867 | + controller::Action::LEFT_HAND_INDEX1, | |
| 4868 | + controller::Action::LEFT_HAND_INDEX2, | |
| 4869 | + controller::Action::LEFT_HAND_INDEX3, | |
| 4870 | + controller::Action::LEFT_HAND_INDEX4, | |
| 4871 | + controller::Action::LEFT_HAND_MIDDLE1, | |
| 4872 | + controller::Action::LEFT_HAND_MIDDLE2, | |
| 4873 | + controller::Action::LEFT_HAND_MIDDLE3, | |
| 4874 | + controller::Action::LEFT_HAND_MIDDLE4, | |
| 4875 | + controller::Action::LEFT_HAND_RING1, | |
| 4876 | + controller::Action::LEFT_HAND_RING2, | |
| 4877 | + controller::Action::LEFT_HAND_RING3, | |
| 4878 | + controller::Action::LEFT_HAND_RING4, | |
| 4879 | + controller::Action::LEFT_HAND_PINKY1, | |
| 4880 | + controller::Action::LEFT_HAND_PINKY2, | |
| 4881 | + controller::Action::LEFT_HAND_PINKY3, | |
| 4882 | + controller::Action::LEFT_HAND_PINKY4, | |
| 4883 | + controller::Action::RIGHT_HAND_THUMB1, | |
| 4884 | + controller::Action::RIGHT_HAND_THUMB2, | |
| 4885 | + controller::Action::RIGHT_HAND_THUMB3, | |
| 4886 | + controller::Action::RIGHT_HAND_THUMB4, | |
| 4887 | + controller::Action::RIGHT_HAND_INDEX1, | |
| 4888 | + controller::Action::RIGHT_HAND_INDEX2, | |
| 4889 | + controller::Action::RIGHT_HAND_INDEX3, | |
| 4890 | + controller::Action::RIGHT_HAND_INDEX4, | |
| 4891 | + controller::Action::RIGHT_HAND_MIDDLE1, | |
| 4892 | + controller::Action::RIGHT_HAND_MIDDLE2, | |
| 4893 | + controller::Action::RIGHT_HAND_MIDDLE3, | |
| 4894 | + controller::Action::RIGHT_HAND_MIDDLE4, | |
| 4895 | + controller::Action::RIGHT_HAND_RING1, | |
| 4896 | + controller::Action::RIGHT_HAND_RING2, | |
| 4897 | + controller::Action::RIGHT_HAND_RING3, | |
| 4898 | + controller::Action::RIGHT_HAND_RING4, | |
| 4899 | + controller::Action::RIGHT_HAND_PINKY1, | |
| 4900 | + controller::Action::RIGHT_HAND_PINKY2, | |
| 4901 | + controller::Action::RIGHT_HAND_PINKY3, | |
| 4902 | + controller::Action::RIGHT_HAND_PINKY4, | |
| 4903 | + controller::Action::LEFT_ARM, | |
| 4904 | + controller::Action::RIGHT_ARM, | |
| 4905 | + controller::Action::LEFT_SHOULDER, | |
| 4906 | + controller::Action::RIGHT_SHOULDER, | |
| 4907 | + controller::Action::LEFT_FORE_ARM, | |
| 4908 | + controller::Action::RIGHT_FORE_ARM, | |
| 4909 | + controller::Action::LEFT_LEG, | |
| 4910 | + controller::Action::RIGHT_LEG, | |
| 4911 | + controller::Action::LEFT_UP_LEG, | |
| 4912 | + controller::Action::RIGHT_UP_LEG, | |
| 4913 | + controller::Action::LEFT_TOE_BASE, | |
| 4914 | + controller::Action::RIGHT_TOE_BASE | |
| 4915 | + }; | |
| 4842 | 4916 | |
| 4843 | − // If have previously done finger poses or there are new valid finger poses, update finger pose values. This so that if | |
| 4844 | − // fingers are not being controlled, finger joints are not updated in MySkeletonModel. | |
| 4845 | − // Assumption: Finger poses are either all present and valid or not present at all; thus can test just one joint. | |
| 4846 | − MyAvatar::FingerPosesMap leftHandFingerPoses; | |
| 4847 | − if (myAvatar->getLeftHandFingerControllerPosesInSensorFrame().size() > 0 | |
| 4848 | − || userInputMapper->getPoseState(controller::Action::LEFT_HAND_THUMB1).isValid()) { | |
| 4849 | − for (int i = (int)controller::Action::LEFT_HAND_THUMB1; i <= (int)controller::Action::LEFT_HAND_PINKY4; i++) { | |
| 4850 | − leftHandFingerPoses[i] = { | |
| 4851 | − userInputMapper->getPoseState((controller::Action)i).transform(avatarToSensorMatrix), | |
| 4852 | − userInputMapper->getActionName((controller::Action)i) | |
| 4853 | − }; | |
| 4854 | − } | |
| 4855 | − } | |
| 4856 | − MyAvatar::FingerPosesMap rightHandFingerPoses; | |
| 4857 | − if (myAvatar->getRightHandFingerControllerPosesInSensorFrame().size() > 0 | |
| 4858 | − || userInputMapper->getPoseState(controller::Action::RIGHT_HAND_THUMB1).isValid()) { | |
| 4859 | − for (int i = (int)controller::Action::RIGHT_HAND_THUMB1; i <= (int)controller::Action::RIGHT_HAND_PINKY4; i++) { | |
| 4860 | − rightHandFingerPoses[i] = { | |
| 4861 | − userInputMapper->getPoseState((controller::Action)i).transform(avatarToSensorMatrix), | |
| 4862 | − userInputMapper->getActionName((controller::Action)i) | |
| 4863 | − }; | |
| 4864 | − } | |
| 4917 | + // copy controller poses from userInputMapper to myAvatar. | |
| 4918 | + glm::mat4 myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition()); | |
| 4919 | + glm::mat4 worldToSensorMatrix = glm::inverse(myAvatar->getSensorToWorldMatrix()); | |
| 4920 | + glm::mat4 avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix; | |
| 4921 | + for (auto& action : avatarControllerActions) { | |
| 4922 | + controller::Pose pose = userInputMapper->getPoseState(action); | |
| 4923 | + myAvatar->setControllerPoseInSensorFrame(action, pose.transform(avatarToSensorMatrix)); | |
| 4865 | 4924 | } |
| 4866 | − myAvatar->setFingerControllerPosesInSensorFrame(leftHandFingerPoses, rightHandFingerPoses); | |
| 4867 | − | |
| 4868 | − controller::Pose leftFootPose = userInputMapper->getPoseState(controller::Action::LEFT_FOOT); | |
| 4869 | − controller::Pose rightFootPose = userInputMapper->getPoseState(controller::Action::RIGHT_FOOT); | |
| 4870 | − myAvatar->setFootControllerPosesInSensorFrame(leftFootPose.transform(avatarToSensorMatrix), rightFootPose.transform(avatarToSensorMatrix)); | |
| 4871 | − | |
| 4872 | − controller::Pose hipsPose = userInputMapper->getPoseState(controller::Action::HIPS); | |
| 4873 | − controller::Pose spine2Pose = userInputMapper->getPoseState(controller::Action::SPINE2); | |
| 4874 | − myAvatar->setSpineControllerPosesInSensorFrame(hipsPose.transform(avatarToSensorMatrix), spine2Pose.transform(avatarToSensorMatrix)); | |
| 4875 | − | |
| 4876 | − controller::Pose headPose = userInputMapper->getPoseState(controller::Action::HEAD); | |
| 4877 | − myAvatar->setHeadControllerPoseInSensorFrame(headPose.transform(avatarToSensorMatrix)); | |
| 4878 | − | |
| 4879 | − controller::Pose leftArmPose = userInputMapper->getPoseState(controller::Action::LEFT_ARM); | |
| 4880 | − controller::Pose rightArmPose = userInputMapper->getPoseState(controller::Action::RIGHT_ARM); | |
| 4881 | − myAvatar->setArmControllerPosesInSensorFrame(leftArmPose.transform(avatarToSensorMatrix), rightArmPose.transform(avatarToSensorMatrix)); | |
| 4882 | 4925 | |
| 4883 | 4926 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| 4884 | 4927 | updateDialogs(deltaTime); // update various stats dialogs if present |
| @@ -6242,7 +6285,7 @@ void Application::addAssetToWorldFromURLRequestFinished() { · 1357 unmodified lines | ||
| 6242 | 6285 | if (tempFile.open(QIODevice::WriteOnly)) { |
| 6243 | 6286 | tempFile.write(request->getData()); |
| 6244 | 6287 | addAssetToWorldInfoClear(filename); // Remove message from list; next one added will have a different key. |
| 6245 | − qApp->getFileDownloadInterface()->runUnzip(downloadPath, url, true); | |
| 6288 | + qApp->getFileDownloadInterface()->runUnzip(downloadPath, url, true, false); | |
| 6246 | 6289 | } else { |
| 6247 | 6290 | QString errorInfo = "Couldn't open temporary file for download"; |
| 6248 | 6291 | qWarning(interfaceapp) << errorInfo; |
| @@ -6272,12 +6315,18 @@ void Application::addAssetToWorldUnzipFailure(QString filePath) { · 23 unmodified lines | ||
| 6272 | 6315 | addAssetToWorldError(filename, "Couldn't unzip file " + filename + "."); |
| 6273 | 6316 | } |
| 6274 | 6317 | |
| 6275 | −void Application::addAssetToWorld(QString filePath) { | |
| 6318 | +void Application::addAssetToWorld(QString filePath, QString zipFile, bool isZip) { | |
| 6276 | 6319 | // Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget(). |
| 6277 | − | |
| 6278 | − QString path = QUrl(filePath).toLocalFile(); | |
| 6320 | + QString mapping; | |
| 6321 | + QString path = filePath; | |
| 6279 | 6322 | QString filename = filenameFromPath(path); |
| 6280 | − QString mapping = "/" + filename; | |
| 6323 | + if (isZip) { | |
| 6324 | + QString assetFolder = zipFile.section("/", -1); | |
| 6325 | + assetFolder.remove(".zip"); | |
| 6326 | + mapping = "/" + assetFolder + "/" + filename; | |
| 6327 | + } else { | |
| 6328 | + mapping = "/" + filename; | |
| 6329 | + } | |
| 6281 | 6330 | |
| 6282 | 6331 | // Test repeated because possibly different code paths. |
| 6283 | 6332 | if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) { |
| @@ -6358,7 +6407,13 @@ void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, Q · 74 unmodified lines | ||
| 6358 | 6407 | qWarning(interfaceapp) << "Error downloading model: " + errorInfo; |
| 6359 | 6408 | addAssetToWorldError(filenameFromPath(filePath), errorInfo); |
| 6360 | 6409 | } else { |
| 6361 | − addAssetToWorldAddEntity(filePath, mapping); | |
| 6410 | + // to prevent files that aren't models from being loaded into world automatically | |
| 6411 | + if (filePath.endsWith(".obj") || filePath.endsWith(".fbx")) { | |
| 6412 | + addAssetToWorldAddEntity(filePath, mapping); | |
| 6413 | + } else { | |
| 6414 | + qCDebug(interfaceapp) << "Zipped contents are not supported entity files"; | |
| 6415 | + addAssetToWorldInfoDone(filenameFromPath(filePath)); | |
| 6416 | + } | |
| 6362 | 6417 | } |
| 6363 | 6418 | request->deleteLater(); |
| 6364 | 6419 | }); |
| @@ -6648,15 +6703,18 @@ void Application::onAssetToWorldMessageBoxClosed() { · 283 unmodified lines | ||
| 6648 | 6703 | } |
| 6649 | 6704 | |
| 6650 | 6705 | |
| 6651 | −void Application::handleUnzip(QString zipFile, QString unzipFile, bool autoAdd) { | |
| 6706 | +void Application::handleUnzip(QString zipFile, QStringList unzipFile, bool autoAdd, bool isZip) { | |
| 6652 | 6707 | if (autoAdd) { |
| 6653 | 6708 | if (!unzipFile.isEmpty()) { |
| 6654 | − addAssetToWorld(unzipFile); | |
| 6709 | + for (int i = 0; i < unzipFile.length(); i++) { | |
| 6710 | + qCDebug(interfaceapp) << "Preparing file for asset server: " << unzipFile.at(i); | |
| 6711 | + addAssetToWorld(unzipFile.at(i), zipFile, isZip); | |
| 6712 | + } | |
| 6655 | 6713 | } else { |
| 6656 | 6714 | addAssetToWorldUnzipFailure(zipFile); |
| 6657 | 6715 | } |
| 6658 | 6716 | } else { |
| 6659 | − showAssetServerWidget(unzipFile); | |
| 6717 | + showAssetServerWidget(unzipFile.first()); | |
| 6660 | 6718 | } |
| 6661 | 6719 | } |
| 6662 | 6720 | |
| @@ -7119,6 +7177,7 @@ void Application::updateDisplayMode() { · 456 unmodified lines | ||
| 7119 | 7177 | |
| 7120 | 7178 | auto oldDisplayPlugin = _displayPlugin; |
| 7121 | 7179 | if (_displayPlugin) { |
| 7180 | + disconnect(_displayPluginPresentConnection); | |
| 7122 | 7181 | _displayPlugin->deactivate(); |
| 7123 | 7182 | } |
| 7124 | 7183 | |
| @@ -7159,6 +7218,7 @@ void Application::updateDisplayMode() { · 34 unmodified lines | ||
| 7159 | 7218 | _offscreenContext->makeCurrent(); |
| 7160 | 7219 | getApplicationCompositor().setDisplayPlugin(newDisplayPlugin); |
| 7161 | 7220 | _displayPlugin = newDisplayPlugin; |
| 7221 | + _displayPluginPresentConnection = connect(_displayPlugin.get(), &DisplayPlugin::presented, this, &Application::onPresent); | |
| 7162 | 7222 | offscreenUi->getDesktop()->setProperty("repositionLocked", wasRepositionLocked); |
| 7163 | 7223 | } |
| 7164 | 7224 | |