History

Merge branch 'master' of https://github.com/highfidelity/hifi into feat/domain-setup

Liv committed 9 years ago

Commit aea5f172 parents 49eab84 342f8ac179 files · +9927 −1712Browse files

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

Unified · Split

interface/src/Application.cpp+126−50
@@ -193,6 +193,9 @@ · 192 unmodified lines
193#include <src/scripting/LimitlessVoiceRecognitionScriptingInterface.h>193#include <src/scripting/LimitlessVoiceRecognitionScriptingInterface.h>
194#include <EntityScriptClient.h>194#include <EntityScriptClient.h>
195#include <ModelScriptingInterface.h>195#include <ModelScriptingInterface.h>
196#include "commerce/Ledger.h"
197#include "commerce/Wallet.h"
198#include "commerce/QmlCommerce.h"
196 199
197// On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU200// On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
198// FIXME seems to be broken.201// FIXME seems to be broken.
@@ -602,6 +605,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 403 unmodified lines
602 DependencyManager::set<CloseEventSender>();605 DependencyManager::set<CloseEventSender>();
603 DependencyManager::set<ResourceManager>();606 DependencyManager::set<ResourceManager>();
604 DependencyManager::set<ContextOverlayInterface>();607 DependencyManager::set<ContextOverlayInterface>();
608 DependencyManager::set<Ledger>();
609 DependencyManager::set<Wallet>();
605 610
606 return previousSessionCrashed;611 return previousSessionCrashed;
607}612}
@@ -711,7 +716,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 103 unmodified lines
711 qInstallMessageHandler(messageHandler);716 qInstallMessageHandler(messageHandler);
712 717
713 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");718 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
714 _window->setWindowTitle("Interface");719 _window->setWindowTitle("High Fidelity Interface");
715 720
716 Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us721 Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
717 722
@@ -959,6 +964,53 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 241 unmodified lines
959 // Make sure we don't time out during slow operations at startup964 // Make sure we don't time out during slow operations at startup
960 updateHeartbeat();965 updateHeartbeat();
961 966
967 // Now that OpenGL is initialized, we are sure we have a valid context and can create the various pipeline shaders with success.
968 DependencyManager::get<GeometryCache>()->initializeShapePipelines();
969
970 // sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value.
971 // The value will be 0 if the user blew away settings this session, which is both a feature and a bug.
972 static const QString TESTER = "HIFI_TESTER";
973 auto gpuIdent = GPUIdent::getInstance();
974 auto glContextData = getGLContextData();
975 QJsonObject properties = {
976 { "version", applicationVersion() },
977 { "tester", QProcessEnvironment::systemEnvironment().contains(TESTER) },
978 { "previousSessionCrashed", _previousSessionCrashed },
979 { "previousSessionRuntime", sessionRunTime.get() },
980 { "cpu_architecture", QSysInfo::currentCpuArchitecture() },
981 { "kernel_type", QSysInfo::kernelType() },
982 { "kernel_version", QSysInfo::kernelVersion() },
983 { "os_type", QSysInfo::productType() },
984 { "os_version", QSysInfo::productVersion() },
985 { "gpu_name", gpuIdent->getName() },
986 { "gpu_driver", gpuIdent->getDriver() },
987 { "gpu_memory", static_cast<qint64>(gpuIdent->getMemory()) },
988 { "gl_version_int", glVersionToInteger(glContextData.value("version").toString()) },
989 { "gl_version", glContextData["version"] },
990 { "gl_vender", glContextData["vendor"] },
991 { "gl_sl_version", glContextData["sl_version"] },
992 { "gl_renderer", glContextData["renderer"] },
993 { "ideal_thread_count", QThread::idealThreadCount() }
994 };
995 auto macVersion = QSysInfo::macVersion();
996 if (macVersion != QSysInfo::MV_None) {
997 properties["os_osx_version"] = QSysInfo::macVersion();
998 }
999 auto windowsVersion = QSysInfo::windowsVersion();
1000 if (windowsVersion != QSysInfo::WV_None) {
1001 properties["os_win_version"] = QSysInfo::windowsVersion();
1002 }
1003
1004 ProcessorInfo procInfo;
1005 if (getProcessorInfo(procInfo)) {
1006 properties["processor_core_count"] = procInfo.numProcessorCores;
1007 properties["logical_processor_count"] = procInfo.numLogicalProcessors;
1008 properties["processor_l1_cache_count"] = procInfo.numProcessorCachesL1;
1009 properties["processor_l2_cache_count"] = procInfo.numProcessorCachesL2;
1010 properties["processor_l3_cache_count"] = procInfo.numProcessorCachesL3;
1011 }
1012
1013 // add firstRun flag from settings to launch event
962 Setting::Handle<bool> firstRun { Settings::firstRun, true };1014 Setting::Handle<bool> firstRun { Settings::firstRun, true };
963 1015
964 // once the settings have been loaded, check if we need to flip the default for UserActivityLogger1016 // once the settings have been loaded, check if we need to flip the default for UserActivityLogger
@@ -2061,6 +2113,7 @@ void Application::initializeUi() { · 1096 unmodified lines
2061 LoginDialog::registerType();2113 LoginDialog::registerType();
2062 Tooltip::registerType();2114 Tooltip::registerType();
2063 UpdateDialog::registerType();2115 UpdateDialog::registerType();
2116 QmlCommerce::registerType();
2064 qmlRegisterType<ResourceImageItem>("Hifi", 1, 0, "ResourceImageItem");2117 qmlRegisterType<ResourceImageItem>("Hifi", 1, 0, "ResourceImageItem");
2065 qmlRegisterType<Preference>("Hifi", 1, 0, "Preference");2118 qmlRegisterType<Preference>("Hifi", 1, 0, "Preference");
2066 2119
@@ -4419,10 +4472,9 @@ void Application::updateMyAvatarLookAtPosition() { · 2352 unmodified lines
4419 }4472 }
4420 } else {4473 } else {
4421 // I am not looking at anyone else, so just look forward4474 // I am not looking at anyone else, so just look forward
4422 auto headPose = myAvatar->getHeadControllerPoseInSensorFrame();4475 auto headPose = myAvatar->getControllerPoseInWorldFrame(controller::Action::HEAD);
4423 if (headPose.isValid()) {4476 if (headPose.isValid()) {
4424 glm::mat4 worldHeadMat = myAvatar->getSensorToWorldMatrix() * headPose.getMatrix();4477 lookAtSpot = transformPoint(headPose.getMatrix(), glm::vec3(0.0f, 0.0f, TREE_SCALE));
4425 lookAtSpot = transformPoint(worldHeadMat, glm::vec3(0.0f, 0.0f, TREE_SCALE));
4426 } else {4478 } else {
4427 lookAtSpot = myAvatar->getHead()->getEyePosition() +4479 lookAtSpot = myAvatar->getHead()->getEyePosition() +
4428 (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));4480 (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
@@ -4836,52 +4888,76 @@ void Application::update(float deltaTime) { · 407 unmodified lines
4836 myAvatar->setDriveKey(MyAvatar::ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z));4888 myAvatar->setDriveKey(MyAvatar::ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z));
4837 }4889 }
4838 4890
4839 controller::Pose leftHandPose = userInputMapper->getPoseState(controller::Action::LEFT_HAND);4891 static const std::vector<controller::Action> avatarControllerActions = {
4840 controller::Pose rightHandPose = userInputMapper->getPoseState(controller::Action::RIGHT_HAND);4892 controller::Action::LEFT_HAND,
4841 auto myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition());4893 controller::Action::RIGHT_HAND,
4842 auto worldToSensorMatrix = glm::inverse(myAvatar->getSensorToWorldMatrix());4894 controller::Action::LEFT_FOOT,
4843 auto avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix;4895 controller::Action::RIGHT_FOOT,
4844 myAvatar->setHandControllerPosesInSensorFrame(leftHandPose.transform(avatarToSensorMatrix), rightHandPose.transform(avatarToSensorMatrix));4896 controller::Action::HIPS,
4845 4897 controller::Action::SPINE2,
4846 // If have previously done finger poses or there are new valid finger poses, update finger pose values. This so that if4898 controller::Action::HEAD,
4847 // fingers are not being controlled, finger joints are not updated in MySkeletonModel.4899 controller::Action::LEFT_HAND_THUMB1,
4848 // Assumption: Finger poses are either all present and valid or not present at all; thus can test just one joint.4900 controller::Action::LEFT_HAND_THUMB2,
4849 MyAvatar::FingerPosesMap leftHandFingerPoses;4901 controller::Action::LEFT_HAND_THUMB3,
4850 if (myAvatar->getLeftHandFingerControllerPosesInSensorFrame().size() > 04902 controller::Action::LEFT_HAND_THUMB4,
4851 || userInputMapper->getPoseState(controller::Action::LEFT_HAND_THUMB1).isValid()) {4903 controller::Action::LEFT_HAND_INDEX1,
4852 for (int i = (int)controller::Action::LEFT_HAND_THUMB1; i <= (int)controller::Action::LEFT_HAND_PINKY4; i++) {4904 controller::Action::LEFT_HAND_INDEX2,
4853 leftHandFingerPoses[i] = {4905 controller::Action::LEFT_HAND_INDEX3,
4854 userInputMapper->getPoseState((controller::Action)i).transform(avatarToSensorMatrix),4906 controller::Action::LEFT_HAND_INDEX4,
4855 userInputMapper->getActionName((controller::Action)i)4907 controller::Action::LEFT_HAND_MIDDLE1,
4856 };4908 controller::Action::LEFT_HAND_MIDDLE2,
4857 }4909 controller::Action::LEFT_HAND_MIDDLE3,
4858 }4910 controller::Action::LEFT_HAND_MIDDLE4,
4859 MyAvatar::FingerPosesMap rightHandFingerPoses;4911 controller::Action::LEFT_HAND_RING1,
4860 if (myAvatar->getRightHandFingerControllerPosesInSensorFrame().size() > 04912 controller::Action::LEFT_HAND_RING2,
4861 || userInputMapper->getPoseState(controller::Action::RIGHT_HAND_THUMB1).isValid()) {4913 controller::Action::LEFT_HAND_RING3,
4862 for (int i = (int)controller::Action::RIGHT_HAND_THUMB1; i <= (int)controller::Action::RIGHT_HAND_PINKY4; i++) {4914 controller::Action::LEFT_HAND_RING4,
4863 rightHandFingerPoses[i] = {4915 controller::Action::LEFT_HAND_PINKY1,
4864 userInputMapper->getPoseState((controller::Action)i).transform(avatarToSensorMatrix),4916 controller::Action::LEFT_HAND_PINKY2,
4865 userInputMapper->getActionName((controller::Action)i)4917 controller::Action::LEFT_HAND_PINKY3,
4866 };4918 controller::Action::LEFT_HAND_PINKY4,
4867 }4919 controller::Action::RIGHT_HAND_THUMB1,
4868 }4920 controller::Action::RIGHT_HAND_THUMB2,
4869 myAvatar->setFingerControllerPosesInSensorFrame(leftHandFingerPoses, rightHandFingerPoses);4921 controller::Action::RIGHT_HAND_THUMB3,
4870 4922 controller::Action::RIGHT_HAND_THUMB4,
4871 controller::Pose leftFootPose = userInputMapper->getPoseState(controller::Action::LEFT_FOOT);4923 controller::Action::RIGHT_HAND_INDEX1,
4872 controller::Pose rightFootPose = userInputMapper->getPoseState(controller::Action::RIGHT_FOOT);4924 controller::Action::RIGHT_HAND_INDEX2,
4873 myAvatar->setFootControllerPosesInSensorFrame(leftFootPose.transform(avatarToSensorMatrix), rightFootPose.transform(avatarToSensorMatrix));4925 controller::Action::RIGHT_HAND_INDEX3,
4874 4926 controller::Action::RIGHT_HAND_INDEX4,
4875 controller::Pose hipsPose = userInputMapper->getPoseState(controller::Action::HIPS);4927 controller::Action::RIGHT_HAND_MIDDLE1,
4876 controller::Pose spine2Pose = userInputMapper->getPoseState(controller::Action::SPINE2);4928 controller::Action::RIGHT_HAND_MIDDLE2,
4877 myAvatar->setSpineControllerPosesInSensorFrame(hipsPose.transform(avatarToSensorMatrix), spine2Pose.transform(avatarToSensorMatrix));4929 controller::Action::RIGHT_HAND_MIDDLE3,
4878 4930 controller::Action::RIGHT_HAND_MIDDLE4,
4879 controller::Pose headPose = userInputMapper->getPoseState(controller::Action::HEAD);4931 controller::Action::RIGHT_HAND_RING1,
4880 myAvatar->setHeadControllerPoseInSensorFrame(headPose.transform(avatarToSensorMatrix));4932 controller::Action::RIGHT_HAND_RING2,
4881 4933 controller::Action::RIGHT_HAND_RING3,
4882 controller::Pose leftArmPose = userInputMapper->getPoseState(controller::Action::LEFT_ARM);4934 controller::Action::RIGHT_HAND_RING4,
4883 controller::Pose rightArmPose = userInputMapper->getPoseState(controller::Action::RIGHT_ARM);4935 controller::Action::RIGHT_HAND_PINKY1,
4884 myAvatar->setArmControllerPosesInSensorFrame(leftArmPose.transform(avatarToSensorMatrix), rightArmPose.transform(avatarToSensorMatrix));4936 controller::Action::RIGHT_HAND_PINKY2,
4937 controller::Action::RIGHT_HAND_PINKY3,
4938 controller::Action::RIGHT_HAND_PINKY4,
4939 controller::Action::LEFT_ARM,
4940 controller::Action::RIGHT_ARM,
4941 controller::Action::LEFT_SHOULDER,
4942 controller::Action::RIGHT_SHOULDER,
4943 controller::Action::LEFT_FORE_ARM,
4944 controller::Action::RIGHT_FORE_ARM,
4945 controller::Action::LEFT_LEG,
4946 controller::Action::RIGHT_LEG,
4947 controller::Action::LEFT_UP_LEG,
4948 controller::Action::RIGHT_UP_LEG,
4949 controller::Action::LEFT_TOE_BASE,
4950 controller::Action::RIGHT_TOE_BASE
4951 };
4952
4953 // copy controller poses from userInputMapper to myAvatar.
4954 glm::mat4 myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition());
4955 glm::mat4 worldToSensorMatrix = glm::inverse(myAvatar->getSensorToWorldMatrix());
4956 glm::mat4 avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix;
4957 for (auto& action : avatarControllerActions) {
4958 controller::Pose pose = userInputMapper->getPoseState(action);
4959 myAvatar->setControllerPoseInSensorFrame(action, pose.transform(avatarToSensorMatrix));
4960 }
4885 4961
4886 updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process...4962 updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process...
4887 updateDialogs(deltaTime); // update various stats dialogs if present4963 updateDialogs(deltaTime); // update various stats dialogs if present