History

Merge branch 'master' of https://github.com/highfidelity/hifi into commerce_QmlWhitelist

Zach Fox committed 8 years ago

Commit b2bafed2 parents d31578a 4f8a2ea325 files · +8307 −6585Browse files

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

Unified · Split

interface/src/Application.cpp+158−115
@@ -194,8 +194,13 @@ · 193 unmodified lines
194194 #include <EntityScriptClient.h>
195195 #include <ModelScriptingInterface.h>
196196
197+#include <PickManager.h>
198+#include <PointerManager.h>
197199 #include <raypick/RayPickScriptingInterface.h>
198200 #include <raypick/LaserPointerScriptingInterface.h>
201+#include <raypick/PickScriptingInterface.h>
202+#include <raypick/PointerScriptingInterface.h>
203+#include <raypick/MouseRayPick.h>
199204
200205 #include <FadeEffect.h>
201206
@@ -203,6 +208,8 @@ · 1 unmodified line
203208 #include "commerce/Wallet.h"
204209 #include "commerce/QmlCommerce.h"
205210
211+#include "webbrowser/WebBrowserSuggestionsEngine.h"
212+
206213 // On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
207214 // FIXME seems to be broken.
208215 #if defined(Q_OS_WIN)
@@ -618,6 +625,12 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 409 unmodified lines
618625 DependencyManager::registerInheritance<SpatialParentFinder, InterfaceParentFinder>();
619626
620627 // Set dependencies
628+ DependencyManager::set<PickManager>();
629+ DependencyManager::set<PointerManager>();
630+ DependencyManager::set<LaserPointerScriptingInterface>();
631+ DependencyManager::set<RayPickScriptingInterface>();
632+ DependencyManager::set<PointerScriptingInterface>();
633+ DependencyManager::set<PickScriptingInterface>();
621634 DependencyManager::set<Cursor::Manager>();
622635 DependencyManager::set<AccountManager>(std::bind(&Application::getUserAgent, qApp));
623636 DependencyManager::set<StatTracker>();
@@ -698,9 +711,6 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 74 unmodified lines
698711
699712 DependencyManager::set<FadeEffect>();
700713
701− DependencyManager::set<LaserPointerScriptingInterface>();
702− DependencyManager::set<RayPickScriptingInterface>();
703−
704714 return previousSessionCrashed;
705715 }
706716
@@ -893,7 +903,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 186 unmodified lines
893903 connect(audioIO.data(), &AudioClient::muteEnvironmentRequested, [](glm::vec3 position, float radius) {
894904 auto audioClient = DependencyManager::get<AudioClient>();
895905 auto audioScriptingInterface = DependencyManager::get<AudioScriptingInterface>();
896− auto myAvatarPosition = DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition();
906+ auto myAvatarPosition = DependencyManager::get<AvatarManager>()->getMyAvatar()->getWorldPosition();
897907 float distance = glm::distance(myAvatarPosition, position);
898908 bool shouldMute = !audioClient->isMuted() && (distance < radius);
899909
@@ -966,8 +976,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 66 unmodified lines
966976 auto addressManager = DependencyManager::get<AddressManager>();
967977
968978 // use our MyAvatar position and quat for address manager path
969− addressManager->setPositionGetter([this]{ return getMyAvatar()->getPosition(); });
970− addressManager->setOrientationGetter([this]{ return getMyAvatar()->getOrientation(); });
979+ addressManager->setPositionGetter([this]{ return getMyAvatar()->getWorldPosition(); });
980+ addressManager->setOrientationGetter([this]{ return getMyAvatar()->getWorldOrientation(); });
971981
972982 connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);
973983 connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
@@ -1183,6 +1193,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 209 unmodified lines
11831193 _entityEditSender.setServerJurisdictions(&_entityServerJurisdictions);
11841194 _entityEditSender.setMyAvatar(myAvatar.get());
11851195
1196+ // The entity octree will have to know about MyAvatar for the parentJointName import
1197+ getEntities()->getTree()->setMyAvatar(myAvatar);
1198+ _entityClipboard->setMyAvatar(myAvatar);
1199+
11861200 // For now we're going to set the PPS for outbound packets to be super high, this is
11871201 // probably not the right long term solution. But for now, we're going to do this to
11881202 // allow you to move an entity around in your hand
@@ -1464,13 +1478,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 275 unmodified lines
14641478
14651479 // 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
14661480 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
1467− connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity,
1481+ connect(entityScriptingInterface.data(), &EntityScriptingInterface::mousePressOnEntity,
14681482 [this](const EntityItemID& entityItemID, const PointerEvent& event) {
1469− if (getEntities()->wantsKeyboardFocus(entityItemID)) {
1470− setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
1471− setKeyboardFocusEntity(entityItemID);
1472− } else {
1473− setKeyboardFocusEntity(UNKNOWN_ENTITY_ID);
1483+ if (event.shouldFocus()) {
1484+ if (getEntities()->wantsKeyboardFocus(entityItemID)) {
1485+ setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
1486+ setKeyboardFocusEntity(entityItemID);
1487+ } else {
1488+ setKeyboardFocusEntity(UNKNOWN_ENTITY_ID);
1489+ }
14741490 }
14751491 });
14761492
@@ -1501,7 +1517,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 24 unmodified lines
15011517 static const QString FAST_STATS_ARG = "--fast-heartbeat";
15021518 static int SEND_STATS_INTERVAL_MS = arguments().indexOf(FAST_STATS_ARG) != -1 ? 1000 : 10000;
15031519
1504− static glm::vec3 lastAvatarPosition = myAvatar->getPosition();
1520+ static glm::vec3 lastAvatarPosition = myAvatar->getWorldPosition();
15051521 static glm::mat4 lastHMDHeadPose = getHMDSensorPose();
15061522 static controller::Pose lastLeftHandPose = myAvatar->getLeftHandPose();
15071523 static controller::Pose lastRightHandPose = myAvatar->getRightHandPose();
@@ -1629,7 +1645,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 121 unmodified lines
16291645 properties["bytes_downloaded"] = bytesDownloaded;
16301646
16311647 auto myAvatar = getMyAvatar();
1632− glm::vec3 avatarPosition = myAvatar->getPosition();
1648+ glm::vec3 avatarPosition = myAvatar->getWorldPosition();
16331649 properties["avatar_has_moved"] = lastAvatarPosition != avatarPosition;
16341650 lastAvatarPosition = avatarPosition;
16351651
@@ -1709,7 +1725,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 73 unmodified lines
17091725 checkNearbyAvatarsTimer->setInterval(CHECK_NEARBY_AVATARS_INTERVAL_MS); // 10 seconds, Qt::CoarseTimer ok
17101726 connect(checkNearbyAvatarsTimer, &QTimer::timeout, this, [this]() {
17111727 auto avatarManager = DependencyManager::get<AvatarManager>();
1712− int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getPosition(),
1728+ int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getWorldPosition(),
17131729 NEARBY_AVATAR_RADIUS_METERS) - 1;
17141730 if (nearbyAvatars != lastCountOfNearbyAvatars) {
17151731 lastCountOfNearbyAvatars = nearbyAvatars;
@@ -1798,25 +1814,35 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 82 unmodified lines
17981814
17991815 connect(&_myCamera, &Camera::modeUpdated, this, &Application::cameraModeChanged);
18001816
1817+ DependencyManager::get<PickManager>()->setShouldPickHUDOperator([&]() { return DependencyManager::get<HMDScriptingInterface>()->isHMDMode(); });
1818+ DependencyManager::get<PickManager>()->setCalculatePos2DFromHUDOperator([&](const glm::vec3& intersection) {
1819+ const glm::vec2 MARGIN(25.0f);
1820+ glm::vec2 maxPos = _controllerScriptingInterface->getViewportDimensions() - MARGIN;
1821+ glm::vec2 pos2D = DependencyManager::get<HMDScriptingInterface>()->overlayFromWorldPoint(intersection);
1822+ return glm::max(MARGIN, glm::min(pos2D, maxPos));
1823+ });
1824+
18011825 // Setup the mouse ray pick and related operators
1802− DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickID(_rayPickManager.createRayPick(
1803− RayPickFilter(DependencyManager::get<RayPickScriptingInterface>()->PICK_ENTITIES() | DependencyManager::get<RayPickScriptingInterface>()->PICK_INCLUDE_NONCOLLIDABLE()),
1804− 0.0f, true));
1805− DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickResultOperator([&](QUuid rayPickID) {
1826+ DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickID(DependencyManager::get<PickManager>()->addPick(PickQuery::Ray, std::make_shared<MouseRayPick>(
1827+ PickFilter(PickScriptingInterface::PICK_ENTITIES() | PickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()), 0.0f, true)));
1828+ DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickResultOperator([&](unsigned int rayPickID) {
18061829 RayToEntityIntersectionResult entityResult;
1807− RayPickResult result = _rayPickManager.getPrevRayPickResult(rayPickID);
1808− entityResult.intersects = result.type != DependencyManager::get<RayPickScriptingInterface>()->INTERSECTED_NONE();
1809− if (entityResult.intersects) {
1810− entityResult.intersection = result.intersection;
1811− entityResult.distance = result.distance;
1812− entityResult.surfaceNormal = result.surfaceNormal;
1813− entityResult.entityID = result.objectID;
1814− entityResult.entity = DependencyManager::get<EntityTreeRenderer>()->getTree()->findEntityByID(entityResult.entityID);
1830+ entityResult.intersects = false;
1831+ auto pickResult = DependencyManager::get<PickManager>()->getPrevPickResultTyped<RayPickResult>(rayPickID);
1832+ if (pickResult) {
1833+ entityResult.intersects = pickResult->type != IntersectionType::NONE;
1834+ if (entityResult.intersects) {
1835+ entityResult.intersection = pickResult->intersection;
1836+ entityResult.distance = pickResult->distance;
1837+ entityResult.surfaceNormal = pickResult->surfaceNormal;
1838+ entityResult.entityID = pickResult->objectID;
1839+ entityResult.entity = DependencyManager::get<EntityTreeRenderer>()->getTree()->findEntityByID(entityResult.entityID);
1840+ }
18151841 }
18161842 return entityResult;
18171843 });
1818− DependencyManager::get<EntityTreeRenderer>()->setSetPrecisionPickingOperator([&](QUuid rayPickID, bool value) {
1819− _rayPickManager.setPrecisionPicking(rayPickID, value);
1844+ DependencyManager::get<EntityTreeRenderer>()->setSetPrecisionPickingOperator([&](unsigned int rayPickID, bool value) {
1845+ DependencyManager::get<PickManager>()->setPrecisionPicking(rayPickID, value);
18201846 });
18211847
18221848 // Preload Tablet sounds
@@ -2258,6 +2284,7 @@ void Application::initializeUi() { · 435 unmodified lines
22582284 }, callback);
22592285 qmlRegisterType<ResourceImageItem>("Hifi", 1, 0, "ResourceImageItem");
22602286 qmlRegisterType<Preference>("Hifi", 1, 0, "Preference");
2287+ qmlRegisterType<WebBrowserSuggestionsEngine>("HifiWeb", 1, 0, "WebBrowserSuggestionsEngine");
22612288
22622289 {
22632290 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
@@ -2436,7 +2463,7 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 172 unmodified lines
24362463 auto hmdWorldMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
24372464 _myCamera.setOrientation(glm::normalize(glmExtractRotation(hmdWorldMat)));
24382465 _myCamera.setPosition(extractTranslation(hmdWorldMat) +
2439− myAvatar->getOrientation() * boomOffset);
2466+ myAvatar->getWorldOrientation() * boomOffset);
24402467 }
24412468 else {
24422469 _myCamera.setOrientation(myAvatar->getHead()->getOrientation());
@@ -2446,13 +2473,13 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 3 unmodified lines
24462473 }
24472474 else {
24482475 _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2449− + myAvatar->getOrientation() * boomOffset);
2476+ + myAvatar->getWorldOrientation() * boomOffset);
24502477 }
24512478 }
24522479 }
24532480 else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
24542481 if (isHMDMode()) {
2455− auto mirrorBodyOrientation = myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f));
2482+ auto mirrorBodyOrientation = myAvatar->getWorldOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f));
24562483
24572484 glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
24582485 // Mirror HMD yaw and roll
@@ -2475,11 +2502,11 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 16 unmodified lines
24752502 + mirrorBodyOrientation * hmdOffset);
24762503 }
24772504 else {
2478− _myCamera.setOrientation(myAvatar->getOrientation()
2505+ _myCamera.setOrientation(myAvatar->getWorldOrientation()
24792506 * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
24802507 _myCamera.setPosition(myAvatar->getDefaultEyePosition()
24812508 + glm::vec3(0, _raiseMirror * myAvatar->getModelScale(), 0)
2482− + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
2509+ + (myAvatar->getWorldOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
24832510 glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
24842511 }
24852512 renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
@@ -2489,13 +2516,13 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 3 unmodified lines
24892516 if (cameraEntity != nullptr) {
24902517 if (isHMDMode()) {
24912518 glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
2492− _myCamera.setOrientation(cameraEntity->getRotation() * hmdRotation);
2519+ _myCamera.setOrientation(cameraEntity->getWorldOrientation() * hmdRotation);
24932520 glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
2494− _myCamera.setPosition(cameraEntity->getPosition() + (hmdRotation * hmdOffset));
2521+ _myCamera.setPosition(cameraEntity->getWorldPosition() + (hmdRotation * hmdOffset));
24952522 }
24962523 else {
2497− _myCamera.setOrientation(cameraEntity->getRotation());
2498− _myCamera.setPosition(cameraEntity->getPosition());
2524+ _myCamera.setOrientation(cameraEntity->getWorldOrientation());
2525+ _myCamera.setPosition(cameraEntity->getWorldPosition());
24992526 }
25002527 }
25012528 }
@@ -3311,7 +3338,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 809 unmodified lines
33113338
33123339 auto offscreenUi = DependencyManager::get<OffscreenUi>();
33133340 auto eventPosition = compositor.getMouseEventPosition(event);
3314− QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
3341+ QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition);
33153342 auto button = event->button();
33163343 auto buttons = event->buttons();
33173344 // Determine if the ReticleClick Action is 1 and if so, fake include the LeftMouseButton
@@ -3357,7 +3384,7 @@ void Application::mousePressEvent(QMouseEvent* event) { · 39 unmodified lines
33573384 offscreenUi->unfocusWindows();
33583385
33593386 auto eventPosition = getApplicationCompositor().getMouseEventPosition(event);
3360− QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
3387+ QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition);
33613388 QMouseEvent mappedEvent(event->type(),
33623389 transformedPos,
33633390 event->screenPos(), event->button(),
@@ -3387,7 +3414,7 @@ void Application::mousePressEvent(QMouseEvent* event) { · 23 unmodified lines
33873414 void Application::mouseDoublePressEvent(QMouseEvent* event) {
33883415 auto offscreenUi = DependencyManager::get<OffscreenUi>();
33893416 auto eventPosition = getApplicationCompositor().getMouseEventPosition(event);
3390− QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
3417+ QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition);
33913418 QMouseEvent mappedEvent(event->type(),
33923419 transformedPos,
33933420 event->screenPos(), event->button(),
@@ -3413,7 +3440,7 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 19 unmodified lines
34133440
34143441 auto offscreenUi = DependencyManager::get<OffscreenUi>();
34153442 auto eventPosition = getApplicationCompositor().getMouseEventPosition(event);
3416− QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
3443+ QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition);
34173444 QMouseEvent mappedEvent(event->type(),
34183445 transformedPos,
34193446 event->screenPos(), event->button(),
@@ -3906,16 +3933,16 @@ void Application::idle() { · 486 unmodified lines
39063933 if (!_keyboardFocusedEntity.get().isInvalidID()) {
39073934 auto entity = getEntities()->getTree()->findEntityByID(_keyboardFocusedEntity.get());
39083935 if (entity && _keyboardFocusHighlight) {
3909− _keyboardFocusHighlight->setRotation(entity->getRotation());
3910− _keyboardFocusHighlight->setPosition(entity->getPosition());
3936+ _keyboardFocusHighlight->setWorldOrientation(entity->getWorldOrientation());
3937+ _keyboardFocusHighlight->setWorldPosition(entity->getWorldPosition());
39113938 }
39123939 } else {
39133940 // Only Web overlays can have focus.
39143941 auto overlay =
39153942 std::dynamic_pointer_cast<Web3DOverlay>(getOverlays().getOverlay(_keyboardFocusedOverlay.get()));
39163943 if (overlay && _keyboardFocusHighlight) {
3917− _keyboardFocusHighlight->setRotation(overlay->getRotation());
3918− _keyboardFocusHighlight->setPosition(overlay->getPosition());
3944+ _keyboardFocusHighlight->setWorldOrientation(overlay->getWorldOrientation());
3945+ _keyboardFocusHighlight->setWorldPosition(overlay->getWorldPosition());
39193946 }
39203947 }
39213948 }
@@ -4031,6 +4058,7 @@ bool Application::exportEntities(const QString& filename, · 109 unmodified lines
40314058
40324059 auto entityTree = getEntities()->getTree();
40334060 auto exportTree = std::make_shared<EntityTree>();
4061+ exportTree->setMyAvatar(getMyAvatar());
40344062 exportTree->createRootElement();
40354063 glm::vec3 root(TREE_SCALE, TREE_SCALE, TREE_SCALE);
40364064 bool success = true;
@@ -4049,7 +4077,7 @@ bool Application::exportEntities(const QString& filename, · 12 unmodified lines
40494077 !entityIDs.contains(parentID) ||
40504078 !entityTree->findEntityByEntityItemID(parentID))) {
40514079 // If parent wasn't selected, we want absolute position, which isn't in properties.
4052− auto position = entityItem->getPosition();
4080+ auto position = entityItem->getWorldPosition();
40534081 root.x = glm::min(root.x, position.x);
40544082 root.y = glm::min(root.y, position.y);
40554083 root.z = glm::min(root.z, position.z);
@@ -4252,7 +4280,7 @@ void Application::init() { · 196 unmodified lines
42524280 return 0.0f;
42534281 }
42544282
4255− auto distance = glm::distance(getMyAvatar()->getPosition(), item.getPosition());
4283+ auto distance = glm::distance(getMyAvatar()->getWorldPosition(), item.getWorldPosition());
42564284 return atan2(maxSize, distance);
42574285 });
42584286
@@ -4329,7 +4357,7 @@ void Application::updateMyAvatarLookAtPosition() { · 70 unmodified lines
43294357 // TODO -- this code is probably wrong, getHeadPose() returns something in sensor frame, not avatar
43304358 glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose();
43314359 glm::quat hmdRotation = glm::quat_cast(headPose);
4332− lookAtSpot = _myCamera.getPosition() + myAvatar->getOrientation() * (hmdRotation * lookAtPosition);
4360+ lookAtSpot = _myCamera.getPosition() + myAvatar->getWorldOrientation() * (hmdRotation * lookAtPosition);
43334361 } else {
43344362 lookAtSpot = myAvatar->getHead()->getEyePosition()
43354363 + (myAvatar->getHead()->getFinalOrientationInWorldFrame() * lookAtPosition);
@@ -4558,8 +4586,8 @@ void Application::setKeyboardFocusHighlight(const glm::vec3& position, const glm · 222 unmodified lines
45584586 }
45594587
45604588 // Position focus
4561− _keyboardFocusHighlight->setRotation(rotation);
4562− _keyboardFocusHighlight->setPosition(position);
4589+ _keyboardFocusHighlight->setWorldOrientation(rotation);
4590+ _keyboardFocusHighlight->setWorldPosition(position);
45634591 _keyboardFocusHighlight->setDimensions(dimensions);
45644592 _keyboardFocusHighlight->setVisible(true);
45654593 }
@@ -4596,7 +4624,7 @@ void Application::setKeyboardFocusEntity(const EntityItemID& entityItemID) { · 30 unmodified lines
45964624 }
45974625 _lastAcceptedKeyPress = usecTimestampNow();
45984626
4599− setKeyboardFocusHighlight(entity->getPosition(), entity->getRotation(),
4627+ setKeyboardFocusHighlight(entity->getWorldPosition(), entity->getWorldOrientation(),
46004628 entity->getDimensions() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR);
46014629 }
46024630 }
@@ -4633,7 +4661,7 @@ void Application::setKeyboardFocusOverlay(const OverlayID& overlayID) { · 30 unmodified lines
46334661 if (overlay->getProperty("showKeyboardFocusHighlight").toBool()) {
46344662 auto size = overlay->getSize() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR;
46354663 const float OVERLAY_DEPTH = 0.0105f;
4636− setKeyboardFocusHighlight(overlay->getPosition(), overlay->getRotation(), glm::vec3(size.x, size.y, OVERLAY_DEPTH));
4664+ setKeyboardFocusHighlight(overlay->getWorldPosition(), overlay->getWorldOrientation(), glm::vec3(size.x, size.y, OVERLAY_DEPTH));
46374665 } else if (_keyboardFocusHighlight) {
46384666 _keyboardFocusHighlight->setVisible(false);
46394667 }
@@ -4725,7 +4753,7 @@ void Application::update(float deltaTime) { · 85 unmodified lines
47254753
47264754 controller::InputCalibrationData calibrationData = {
47274755 myAvatar->getSensorToWorldMatrix(),
4728− createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition()),
4756+ createMatFromQuatAndPos(myAvatar->getWorldOrientation(), myAvatar->getWorldPosition()),
47294757 myAvatar->getHMDSensorMatrix(),
47304758 myAvatar->getCenterEyeCalibrationMat(),
47314759 myAvatar->getHeadCalibrationMat(),
@@ -4835,7 +4863,7 @@ void Application::update(float deltaTime) { · 103 unmodified lines
48354863 };
48364864
48374865 // copy controller poses from userInputMapper to myAvatar.
4838− glm::mat4 myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition());
4866+ glm::mat4 myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getWorldOrientation(), myAvatar->getWorldPosition());
48394867 glm::mat4 worldToSensorMatrix = glm::inverse(myAvatar->getSensorToWorldMatrix());
48404868 glm::mat4 avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix;
48414869 for (auto& action : avatarControllerActions) {
@@ -4975,13 +5003,13 @@ void Application::update(float deltaTime) { · 133 unmodified lines
49755003
49765004 // TODO: break these out into distinct perfTimers when they prove interesting
49775005 {
4978− PROFILE_RANGE(app, "RayPickManager");
4979− _rayPickManager.update();
5006+ PROFILE_RANGE(app, "PickManager");
5007+ DependencyManager::get<PickManager>()->update();
49805008 }
49815009
49825010 {
4983− PROFILE_RANGE(app, "LaserPointerManager");
4984− _laserPointerManager.update();
5011+ PROFILE_RANGE(app, "PointerManager");
5012+ DependencyManager::get<PointerManager>()->update();
49855013 }
49865014
49875015 {
@@ -5451,7 +5479,7 @@ std::shared_ptr<MyAvatar> Application::getMyAvatar() const { · 463 unmodified lines
54515479 }
54525480
54535481 glm::vec3 Application::getAvatarPosition() const {
5454− return getMyAvatar()->getPosition();
5482+ return getMyAvatar()->getWorldPosition();
54555483 }
54565484
54575485 void Application::copyViewFrustum(ViewFrustum& viewOut) const {
@@ -5535,6 +5563,8 @@ void Application::clearDomainOctreeDetails() { · 77 unmodified lines
55355563 DependencyManager::get<ModelCache>()->clearUnusedResources();
55365564 DependencyManager::get<SoundCache>()->clearUnusedResources();
55375565 DependencyManager::get<TextureCache>()->clearUnusedResources();
5566+
5567+ getMyAvatar()->setAvatarEntityDataChanged(true);
55385568 }
55395569
55405570 void Application::clearDomainAvatars() {
@@ -5664,7 +5694,7 @@ bool Application::nearbyEntitiesAreReadyForPhysics() { · 123 unmodified lines
56645694 // whose bounding boxes cannot be computed (it is too loose for our purposes here). Instead we manufacture
56655695 // custom filters and use the general-purpose EntityTree::findEntities(filter, ...)
56665696 QVector<EntityItemPointer> entities;
5667− AABox avatarBox(getMyAvatar()->getPosition() - glm::vec3(PHYSICS_READY_RANGE), glm::vec3(2 * PHYSICS_READY_RANGE));
5697+ AABox avatarBox(getMyAvatar()->getWorldPosition() - glm::vec3(PHYSICS_READY_RANGE), glm::vec3(2 * PHYSICS_READY_RANGE));
56685698 // create two functions that use avatarBox (entityScan and elementScan), the second calls the first
56695699 std::function<bool (EntityItemPointer&)> entityScan = [=](EntityItemPointer& entity) {
56705700 if (entity->shouldBePhysical()) {
@@ -5866,6 +5896,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 195 unmodified lines
58665896
58675897 scriptEngine->registerGlobalObject("RayPick", DependencyManager::get<RayPickScriptingInterface>().data());
58685898 scriptEngine->registerGlobalObject("LaserPointers", DependencyManager::get<LaserPointerScriptingInterface>().data());
5899+ scriptEngine->registerGlobalObject("Picks", DependencyManager::get<PickScriptingInterface>().data());
5900+ scriptEngine->registerGlobalObject("Pointers", DependencyManager::get<PointerScriptingInterface>().data());
58695901
58705902 // Caches
58715903 scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
@@ -5923,6 +5955,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 51 unmodified lines
59235955
59245956 qScriptRegisterMetaType(scriptEngine.data(), OverlayIDtoScriptValue, OverlayIDfromScriptValue);
59255957
5958+ DependencyManager::get<PickScriptingInterface>()->registerMetaTypes(scriptEngine.data());
5959+
59265960 // connect this script engines printedMessage signal to the global ScriptEngines these various messages
59275961 connect(scriptEngine.data(), &ScriptEngine::printedMessage,
59285962 DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onPrintedMessage);
@@ -6164,46 +6198,60 @@ bool Application::askToReplaceDomainContent(const QString& url) { · 235 unmodified lines
61646198 "and restoring content, visit the documentation page at: ", MAX_CHARACTERS_PER_LINE) +
61656199 "\nhttps://docs.highfidelity.com/create-and-explore/start-working-in-your-sandbox/restoring-sandbox-content";
61666200
6167− bool agreeToReplaceContent = false; // assume false
6168− agreeToReplaceContent = QMessageBox::Yes == OffscreenUi::question("Are you sure you want to replace this domain's content set?",
6169− infoText, QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
6170−
6171− if (agreeToReplaceContent) {
6172− // Given confirmation, send request to domain server to replace content
6173− qCDebug(interfaceapp) << "Attempting to replace domain content: " << url;
6174− QByteArray urlData(url.toUtf8());
6175− auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
6176− limitedNodeList->eachMatchingNode([](const SharedNodePointer& node) {
6177− return node->getType() == NodeType::EntityServer && node->getActiveSocket();
6178− }, [&urlData, limitedNodeList](const SharedNodePointer& octreeNode) {
6179− auto octreeFilePacket = NLPacket::create(PacketType::OctreeFileReplacementFromUrl, urlData.size(), true);
6180− octreeFilePacket->write(urlData);
6181− limitedNodeList->sendPacket(std::move(octreeFilePacket), *octreeNode);
6182− });
6183− auto addressManager = DependencyManager::get<AddressManager>();
6184− addressManager->handleLookupString(DOMAIN_SPAWNING_POINT);
6185− QString newHomeAddress = addressManager->getHost() + DOMAIN_SPAWNING_POINT;
6186− qCDebug(interfaceapp) << "Setting new home bookmark to: " << newHomeAddress;
6187− DependencyManager::get<LocationBookmarks>()->setHomeLocationToAddress(newHomeAddress);
6188− methodDetails = "SuccessfulRequestToReplaceContent";
6189− } else {
6190− methodDetails = "UserDeclinedToReplaceContent";
6191− }
6201+ ModalDialogListener* dig = OffscreenUi::asyncQuestion("Are you sure you want to replace this domain's content set?",
6202+ infoText, QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
6203+
6204+ QObject::connect(dig, &ModalDialogListener::response, this, [=] (QVariant answer) {
6205+ QString details;
6206+ if (static_cast<QMessageBox::StandardButton>(answer.toInt()) == QMessageBox::Yes) {
6207+ // Given confirmation, send request to domain server to replace content
6208+ qCDebug(interfaceapp) << "Attempting to replace domain content: " << url;
6209+ QByteArray urlData(url.toUtf8());
6210+ auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
6211+ limitedNodeList->eachMatchingNode([](const SharedNodePointer& node) {
6212+ return node->getType() == NodeType::EntityServer && node->getActiveSocket();
6213+ }, [&urlData, limitedNodeList](const SharedNodePointer& octreeNode) {
6214+ auto octreeFilePacket = NLPacket::create(PacketType::OctreeFileReplacementFromUrl, urlData.size(), true);
6215+ octreeFilePacket->write(urlData);
6216+ limitedNodeList->sendPacket(std::move(octreeFilePacket), *octreeNode);
6217+ });
6218+ auto addressManager = DependencyManager::get<AddressManager>();
6219+ addressManager->handleLookupString(DOMAIN_SPAWNING_POINT);
6220+ QString newHomeAddress = addressManager->getHost() + DOMAIN_SPAWNING_POINT;
6221+ qCDebug(interfaceapp) << "Setting new home bookmark to: " << newHomeAddress;
6222+ DependencyManager::get<LocationBookmarks>()->setHomeLocationToAddress(newHomeAddress);
6223+ details = "SuccessfulRequestToReplaceContent";
6224+ } else {
6225+ details = "UserDeclinedToReplaceContent";
6226+ }
6227+ QJsonObject messageProperties = {
6228+ { "status", details },
6229+ { "content_set_url", url }
6230+ };
6231+ UserActivityLogger::getInstance().logAction("replace_domain_content", messageProperties);
6232+ QObject::disconnect(dig, &ModalDialogListener::response, this, nullptr);
6233+ });
61926234 } else {
61936235 methodDetails = "ContentSetDidNotOriginateFromMarketplace";
6236+ QJsonObject messageProperties = {
6237+ { "status", methodDetails },
6238+ { "content_set_url", url }
6239+ };
6240+ UserActivityLogger::getInstance().logAction("replace_domain_content", messageProperties);
61946241 }
61956242 } else {
61966243 methodDetails = "UserDoesNotHavePermissionToReplaceContent";
61976244 static const QString warningMessage = simpleWordWrap("The domain owner must enable 'Replace Content' "
61986245 "permissions for you in this domain's server settings before you can continue.", MAX_CHARACTERS_PER_LINE);
6199− OffscreenUi::warning("You do not have permissions to replace domain content", warningMessage,
6246+ OffscreenUi::asyncWarning("You do not have permissions to replace domain content", warningMessage,
62006247 QMessageBox::Ok, QMessageBox::Ok);
6248+
6249+ QJsonObject messageProperties = {
6250+ { "status", methodDetails },
6251+ { "content_set_url", url }
6252+ };
6253+ UserActivityLogger::getInstance().logAction("replace_domain_content", messageProperties);
62016254 }
6202− QJsonObject messageProperties = {
6203− { "status", methodDetails },
6204− { "content_set_url", url }
6205− };
6206− UserActivityLogger::getInstance().logAction("replace_domain_content", messageProperties);
62076255 return true;
62086256 }
62096257
@@ -6363,20 +6411,14 @@ void Application::addAssetToWorldUnzipFailure(QString filePath) { · 153 unmodified lines
63636411 addAssetToWorldError(filename, "Couldn't unzip file " + filename + ".");
63646412 }
63656413
6366−void Application::addAssetToWorld(QString filePath, QString zipFile, bool isZip, bool isBlocks) {
6414+void Application::addAssetToWorld(QString path, QString zipFile, bool isZip, bool isBlocks) {
63676415 // Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget().
63686416 QString mapping;
6369− QString path = filePath;
63706417 QString filename = filenameFromPath(path);
6371− if (isZip) {
6372− QString assetFolder = zipFile.section("/", -1);
6373− assetFolder.remove(".zip");
6374− mapping = "/" + assetFolder + "/" + filename;
6375− } else if (isBlocks) {
6376− qCDebug(interfaceapp) << "Path to asset folder: " << zipFile;
6377− QString assetFolder = zipFile.section('/', -1);
6378− assetFolder.remove(".zip?noDownload=false");
6379− mapping = "/" + assetFolder + "/" + filename;
6418+ if (isZip || isBlocks) {
6419+ QString assetName = zipFile.section("/", -1).remove(QRegExp("[.]zip(.*)$"));
6420+ QString assetFolder = path.section("model_repo/", -1);
6421+ mapping = "/" + assetName + "/" + assetFolder;
63806422 } else {
63816423 mapping = "/" + filename;
63826424 }
@@ -6482,9 +6524,9 @@ void Application::addAssetToWorldAddEntity(QString filePath, QString mapping) { · 99 unmodified lines
64826524 properties.setShapeType(SHAPE_TYPE_SIMPLE_COMPOUND);
64836525 properties.setCollisionless(true); // Temporarily set so that doesn't collide with avatar.
64846526 properties.setVisible(false); // Temporarily set so that don't see at large unresized dimensions.
6485− glm::vec3 positionOffset = getMyAvatar()->getOrientation() * (getMyAvatar()->getSensorToWorldScale() * glm::vec3(0.0f, 0.0f, -2.0f));
6486− properties.setPosition(getMyAvatar()->getPosition() + positionOffset);
6487− properties.setRotation(getMyAvatar()->getOrientation());
6527+ glm::vec3 positionOffset = getMyAvatar()->getWorldOrientation() * (getMyAvatar()->getSensorToWorldScale() * glm::vec3(0.0f, 0.0f, -2.0f));
6528+ properties.setPosition(getMyAvatar()->getWorldPosition() + positionOffset);
6529+ properties.setRotation(getMyAvatar()->getWorldOrientation());
64886530 properties.setGravity(glm::vec3(0.0f, 0.0f, 0.0f));
64896531 auto entityID = DependencyManager::get<EntityScriptingInterface>()->addEntity(properties);
64906532
@@ -6762,8 +6804,10 @@ void Application::handleUnzip(QString zipFile, QStringList unzipFile, bool autoA · 271 unmodified lines
67626804 if (autoAdd) {
67636805 if (!unzipFile.isEmpty()) {
67646806 for (int i = 0; i < unzipFile.length(); i++) {
6765− qCDebug(interfaceapp) << "Preparing file for asset server: " << unzipFile.at(i);
6766− addAssetToWorld(unzipFile.at(i), zipFile, isZip, isBlocks);
6807+ if (QFileInfo(unzipFile.at(i)).isFile()) {
6808+ qCDebug(interfaceapp) << "Preparing file for asset server: " << unzipFile.at(i);
6809+ addAssetToWorld(unzipFile.at(i), zipFile, isZip, isBlocks);
6810+ }
67676811 }
67686812 } else {
67696813 addAssetToWorldUnzipFailure(zipFile);
@@ -7066,11 +7110,11 @@ QRect Application::getRecommendedHUDRect() const { · 296 unmodified lines
70667110 return result;
70677111 }
70687112
7069−QSize Application::getDeviceSize() const {
7113+glm::vec2 Application::getDeviceSize() const {
70707114 static const int MIN_SIZE = 1;
7071− QSize result(MIN_SIZE, MIN_SIZE);
7115+ glm::vec2 result(MIN_SIZE);
70727116 if (_displayPlugin) {
7073− result = fromGlm(getActiveDisplayPlugin()->getRecommendedRenderSize());
7117+ result = getActiveDisplayPlugin()->getRecommendedRenderSize();
70747118 }
70757119 return result;
70767120 }
@@ -7089,10 +7133,6 @@ bool Application::hasFocus() const { · 12 unmodified lines
70897133 return (QApplication::activeWindow() != nullptr);
70907134 }
70917135
7092−glm::vec2 Application::getViewportDimensions() const {
7093− return toGlm(getDeviceSize());
7094−}
7095−
70967136 void Application::setMaxOctreePacketsPerSecond(int maxOctreePPS) {
70977137 if (maxOctreePPS != _maxOctreePPS) {
70987138 _maxOctreePPS = maxOctreePPS;
@@ -7121,6 +7161,7 @@ DisplayPluginPointer Application::getActiveDisplayPlugin() const { · 22 unmodified lines
71217161 return _displayPlugin;
71227162 }
71237163
7164+static const char* EXCLUSION_GROUP_KEY = "exclusionGroup";
71247165
71257166 static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool active = false) {
71267167 auto menu = Menu::getInstance();
@@ -7156,6 +7197,8 @@ static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool acti · 29 unmodified lines
71567197 action->setCheckable(true);
71577198 action->setChecked(active);
71587199 displayPluginGroup->addAction(action);
7200+
7201+ action->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(displayPluginGroup));
71597202 Q_ASSERT(menu->menuItemExists(MenuOption::OutputMenu, name));
71607203 }
71617204