History

Merge branch 'master' into feature/domain-limited-height

Anthony J. Thibault committed 8 years ago

Commit fbcecbf2 parents d1609fb 4f8a2ea265 files · +6933 −6099Browse files

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

Unified · Split

interface/src/Application.cpp+136−102
@@ -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
@@ -620,6 +625,12 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 418 unmodified lines
620625 DependencyManager::registerInheritance<SpatialParentFinder, InterfaceParentFinder>();
621626
622627 // 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>();
623634 DependencyManager::set<Cursor::Manager>();
624635 DependencyManager::set<AccountManager>(std::bind(&Application::getUserAgent, qApp));
625636 DependencyManager::set<StatTracker>();
@@ -700,9 +711,6 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 74 unmodified lines
700711
701712 DependencyManager::set<FadeEffect>();
702713
703− DependencyManager::set<LaserPointerScriptingInterface>();
704− DependencyManager::set<RayPickScriptingInterface>();
705−
706714 return previousSessionCrashed;
707715 }
708716
@@ -895,7 +903,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 186 unmodified lines
895903 connect(audioIO.data(), &AudioClient::muteEnvironmentRequested, [](glm::vec3 position, float radius) {
896904 auto audioClient = DependencyManager::get<AudioClient>();
897905 auto audioScriptingInterface = DependencyManager::get<AudioScriptingInterface>();
898− auto myAvatarPosition = DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition();
906+ auto myAvatarPosition = DependencyManager::get<AvatarManager>()->getMyAvatar()->getWorldPosition();
899907 float distance = glm::distance(myAvatarPosition, position);
900908 bool shouldMute = !audioClient->isMuted() && (distance < radius);
901909
@@ -968,8 +976,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 66 unmodified lines
968976 auto addressManager = DependencyManager::get<AddressManager>();
969977
970978 // use our MyAvatar position and quat for address manager path
971− addressManager->setPositionGetter([this]{ return getMyAvatar()->getPosition(); });
972− addressManager->setOrientationGetter([this]{ return getMyAvatar()->getOrientation(); });
979+ addressManager->setPositionGetter([this]{ return getMyAvatar()->getWorldPosition(); });
980+ addressManager->setOrientationGetter([this]{ return getMyAvatar()->getWorldOrientation(); });
973981
974982 connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);
975983 connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
@@ -1470,13 +1478,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 494 unmodified lines
14701478
14711479 // 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
14721480 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
1473− connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity,
1481+ connect(entityScriptingInterface.data(), &EntityScriptingInterface::mousePressOnEntity,
14741482 [this](const EntityItemID& entityItemID, const PointerEvent& event) {
1475− if (getEntities()->wantsKeyboardFocus(entityItemID)) {
1476− setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
1477− setKeyboardFocusEntity(entityItemID);
1478− } else {
1479− 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+ }
14801490 }
14811491 });
14821492
@@ -1507,7 +1517,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 24 unmodified lines
15071517 static const QString FAST_STATS_ARG = "--fast-heartbeat";
15081518 static int SEND_STATS_INTERVAL_MS = arguments().indexOf(FAST_STATS_ARG) != -1 ? 1000 : 10000;
15091519
1510− static glm::vec3 lastAvatarPosition = myAvatar->getPosition();
1520+ static glm::vec3 lastAvatarPosition = myAvatar->getWorldPosition();
15111521 static glm::mat4 lastHMDHeadPose = getHMDSensorPose();
15121522 static controller::Pose lastLeftHandPose = myAvatar->getLeftHandPose();
15131523 static controller::Pose lastRightHandPose = myAvatar->getRightHandPose();
@@ -1635,7 +1645,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 121 unmodified lines
16351645 properties["bytes_downloaded"] = bytesDownloaded;
16361646
16371647 auto myAvatar = getMyAvatar();
1638− glm::vec3 avatarPosition = myAvatar->getPosition();
1648+ glm::vec3 avatarPosition = myAvatar->getWorldPosition();
16391649 properties["avatar_has_moved"] = lastAvatarPosition != avatarPosition;
16401650 lastAvatarPosition = avatarPosition;
16411651
@@ -1715,7 +1725,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 73 unmodified lines
17151725 checkNearbyAvatarsTimer->setInterval(CHECK_NEARBY_AVATARS_INTERVAL_MS); // 10 seconds, Qt::CoarseTimer ok
17161726 connect(checkNearbyAvatarsTimer, &QTimer::timeout, this, [this]() {
17171727 auto avatarManager = DependencyManager::get<AvatarManager>();
1718− int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getPosition(),
1728+ int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getWorldPosition(),
17191729 NEARBY_AVATAR_RADIUS_METERS) - 1;
17201730 if (nearbyAvatars != lastCountOfNearbyAvatars) {
17211731 lastCountOfNearbyAvatars = nearbyAvatars;
@@ -1804,25 +1814,35 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 82 unmodified lines
18041814
18051815 connect(&_myCamera, &Camera::modeUpdated, this, &Application::cameraModeChanged);
18061816
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+
18071825 // Setup the mouse ray pick and related operators
1808− DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickID(_rayPickManager.createRayPick(
1809− RayPickFilter(DependencyManager::get<RayPickScriptingInterface>()->PICK_ENTITIES() | DependencyManager::get<RayPickScriptingInterface>()->PICK_INCLUDE_NONCOLLIDABLE()),
1810− 0.0f, true));
1811− 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) {
18121829 RayToEntityIntersectionResult entityResult;
1813− RayPickResult result = _rayPickManager.getPrevRayPickResult(rayPickID);
1814− entityResult.intersects = result.type != DependencyManager::get<RayPickScriptingInterface>()->INTERSECTED_NONE();
1815− if (entityResult.intersects) {
1816− entityResult.intersection = result.intersection;
1817− entityResult.distance = result.distance;
1818− entityResult.surfaceNormal = result.surfaceNormal;
1819− entityResult.entityID = result.objectID;
1820− 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+ }
18211841 }
18221842 return entityResult;
18231843 });
1824− DependencyManager::get<EntityTreeRenderer>()->setSetPrecisionPickingOperator([&](QUuid rayPickID, bool value) {
1825− _rayPickManager.setPrecisionPicking(rayPickID, value);
1844+ DependencyManager::get<EntityTreeRenderer>()->setSetPrecisionPickingOperator([&](unsigned int rayPickID, bool value) {
1845+ DependencyManager::get<PickManager>()->setPrecisionPicking(rayPickID, value);
18261846 });
18271847
18281848 // Preload Tablet sounds
@@ -2408,7 +2428,7 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 579 unmodified lines
24082428 auto hmdWorldMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
24092429 _myCamera.setOrientation(glm::normalize(glmExtractRotation(hmdWorldMat)));
24102430 _myCamera.setPosition(extractTranslation(hmdWorldMat) +
2411− myAvatar->getOrientation() * boomOffset);
2431+ myAvatar->getWorldOrientation() * boomOffset);
24122432 }
24132433 else {
24142434 _myCamera.setOrientation(myAvatar->getHead()->getOrientation());
@@ -2418,13 +2438,13 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 3 unmodified lines
24182438 }
24192439 else {
24202440 _myCamera.setPosition(myAvatar->getDefaultEyePosition()
2421− + myAvatar->getOrientation() * boomOffset);
2441+ + myAvatar->getWorldOrientation() * boomOffset);
24222442 }
24232443 }
24242444 }
24252445 else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
24262446 if (isHMDMode()) {
2427− auto mirrorBodyOrientation = myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f));
2447+ auto mirrorBodyOrientation = myAvatar->getWorldOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f));
24282448
24292449 glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
24302450 // Mirror HMD yaw and roll
@@ -2447,11 +2467,11 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 16 unmodified lines
24472467 + mirrorBodyOrientation * hmdOffset);
24482468 }
24492469 else {
2450− _myCamera.setOrientation(myAvatar->getOrientation()
2470+ _myCamera.setOrientation(myAvatar->getWorldOrientation()
24512471 * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
24522472 _myCamera.setPosition(myAvatar->getDefaultEyePosition()
24532473 + glm::vec3(0, _raiseMirror * myAvatar->getModelScale(), 0)
2454− + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
2474+ + (myAvatar->getWorldOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
24552475 glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
24562476 }
24572477 renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
@@ -2461,13 +2481,13 @@ void Application::updateCamera(RenderArgs& renderArgs) { · 3 unmodified lines
24612481 if (cameraEntity != nullptr) {
24622482 if (isHMDMode()) {
24632483 glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
2464− _myCamera.setOrientation(cameraEntity->getRotation() * hmdRotation);
2484+ _myCamera.setOrientation(cameraEntity->getWorldOrientation() * hmdRotation);
24652485 glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
2466− _myCamera.setPosition(cameraEntity->getPosition() + (hmdRotation * hmdOffset));
2486+ _myCamera.setPosition(cameraEntity->getWorldPosition() + (hmdRotation * hmdOffset));
24672487 }
24682488 else {
2469− _myCamera.setOrientation(cameraEntity->getRotation());
2470− _myCamera.setPosition(cameraEntity->getPosition());
2489+ _myCamera.setOrientation(cameraEntity->getWorldOrientation());
2490+ _myCamera.setPosition(cameraEntity->getWorldPosition());
24712491 }
24722492 }
24732493 }
@@ -3283,7 +3303,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 809 unmodified lines
32833303
32843304 auto offscreenUi = DependencyManager::get<OffscreenUi>();
32853305 auto eventPosition = compositor.getMouseEventPosition(event);
3286− QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
3306+ QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition);
32873307 auto button = event->button();
32883308 auto buttons = event->buttons();
32893309 // Determine if the ReticleClick Action is 1 and if so, fake include the LeftMouseButton
@@ -3329,7 +3349,7 @@ void Application::mousePressEvent(QMouseEvent* event) { · 39 unmodified lines
33293349 offscreenUi->unfocusWindows();
33303350
33313351 auto eventPosition = getApplicationCompositor().getMouseEventPosition(event);
3332− QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
3352+ QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition);
33333353 QMouseEvent mappedEvent(event->type(),
33343354 transformedPos,
33353355 event->screenPos(), event->button(),
@@ -3359,7 +3379,7 @@ void Application::mousePressEvent(QMouseEvent* event) { · 23 unmodified lines
33593379 void Application::mouseDoublePressEvent(QMouseEvent* event) {
33603380 auto offscreenUi = DependencyManager::get<OffscreenUi>();
33613381 auto eventPosition = getApplicationCompositor().getMouseEventPosition(event);
3362− QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
3382+ QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition);
33633383 QMouseEvent mappedEvent(event->type(),
33643384 transformedPos,
33653385 event->screenPos(), event->button(),
@@ -3385,7 +3405,7 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 19 unmodified lines
33853405
33863406 auto offscreenUi = DependencyManager::get<OffscreenUi>();
33873407 auto eventPosition = getApplicationCompositor().getMouseEventPosition(event);
3388− QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
3408+ QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition);
33893409 QMouseEvent mappedEvent(event->type(),
33903410 transformedPos,
33913411 event->screenPos(), event->button(),
@@ -3878,16 +3898,16 @@ void Application::idle() { · 486 unmodified lines
38783898 if (!_keyboardFocusedEntity.get().isInvalidID()) {
38793899 auto entity = getEntities()->getTree()->findEntityByID(_keyboardFocusedEntity.get());
38803900 if (entity && _keyboardFocusHighlight) {
3881− _keyboardFocusHighlight->setRotation(entity->getRotation());
3882− _keyboardFocusHighlight->setPosition(entity->getPosition());
3901+ _keyboardFocusHighlight->setWorldOrientation(entity->getWorldOrientation());
3902+ _keyboardFocusHighlight->setWorldPosition(entity->getWorldPosition());
38833903 }
38843904 } else {
38853905 // Only Web overlays can have focus.
38863906 auto overlay =
38873907 std::dynamic_pointer_cast<Web3DOverlay>(getOverlays().getOverlay(_keyboardFocusedOverlay.get()));
38883908 if (overlay && _keyboardFocusHighlight) {
3889− _keyboardFocusHighlight->setRotation(overlay->getRotation());
3890− _keyboardFocusHighlight->setPosition(overlay->getPosition());
3909+ _keyboardFocusHighlight->setWorldOrientation(overlay->getWorldOrientation());
3910+ _keyboardFocusHighlight->setWorldPosition(overlay->getWorldPosition());
38913911 }
38923912 }
38933913 }
@@ -4022,7 +4042,7 @@ bool Application::exportEntities(const QString& filename, · 128 unmodified lines
40224042 !entityIDs.contains(parentID) ||
40234043 !entityTree->findEntityByEntityItemID(parentID))) {
40244044 // If parent wasn't selected, we want absolute position, which isn't in properties.
4025− auto position = entityItem->getPosition();
4045+ auto position = entityItem->getWorldPosition();
40264046 root.x = glm::min(root.x, position.x);
40274047 root.y = glm::min(root.y, position.y);
40284048 root.z = glm::min(root.z, position.z);
@@ -4225,7 +4245,7 @@ void Application::init() { · 196 unmodified lines
42254245 return 0.0f;
42264246 }
42274247
4228− auto distance = glm::distance(getMyAvatar()->getPosition(), item.getPosition());
4248+ auto distance = glm::distance(getMyAvatar()->getWorldPosition(), item.getWorldPosition());
42294249 return atan2(maxSize, distance);
42304250 });
42314251
@@ -4302,7 +4322,7 @@ void Application::updateMyAvatarLookAtPosition() { · 70 unmodified lines
43024322 // TODO -- this code is probably wrong, getHeadPose() returns something in sensor frame, not avatar
43034323 glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose();
43044324 glm::quat hmdRotation = glm::quat_cast(headPose);
4305− lookAtSpot = _myCamera.getPosition() + myAvatar->getOrientation() * (hmdRotation * lookAtPosition);
4325+ lookAtSpot = _myCamera.getPosition() + myAvatar->getWorldOrientation() * (hmdRotation * lookAtPosition);
43064326 } else {
43074327 lookAtSpot = myAvatar->getHead()->getEyePosition()
43084328 + (myAvatar->getHead()->getFinalOrientationInWorldFrame() * lookAtPosition);
@@ -4531,8 +4551,8 @@ void Application::setKeyboardFocusHighlight(const glm::vec3& position, const glm · 222 unmodified lines
45314551 }
45324552
45334553 // Position focus
4534− _keyboardFocusHighlight->setRotation(rotation);
4535− _keyboardFocusHighlight->setPosition(position);
4554+ _keyboardFocusHighlight->setWorldOrientation(rotation);
4555+ _keyboardFocusHighlight->setWorldPosition(position);
45364556 _keyboardFocusHighlight->setDimensions(dimensions);
45374557 _keyboardFocusHighlight->setVisible(true);
45384558 }
@@ -4569,7 +4589,7 @@ void Application::setKeyboardFocusEntity(const EntityItemID& entityItemID) { · 30 unmodified lines
45694589 }
45704590 _lastAcceptedKeyPress = usecTimestampNow();
45714591
4572− setKeyboardFocusHighlight(entity->getPosition(), entity->getRotation(),
4592+ setKeyboardFocusHighlight(entity->getWorldPosition(), entity->getWorldOrientation(),
45734593 entity->getDimensions() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR);
45744594 }
45754595 }
@@ -4606,7 +4626,7 @@ void Application::setKeyboardFocusOverlay(const OverlayID& overlayID) { · 30 unmodified lines
46064626 if (overlay->getProperty("showKeyboardFocusHighlight").toBool()) {
46074627 auto size = overlay->getSize() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR;
46084628 const float OVERLAY_DEPTH = 0.0105f;
4609− setKeyboardFocusHighlight(overlay->getPosition(), overlay->getRotation(), glm::vec3(size.x, size.y, OVERLAY_DEPTH));
4629+ setKeyboardFocusHighlight(overlay->getWorldPosition(), overlay->getWorldOrientation(), glm::vec3(size.x, size.y, OVERLAY_DEPTH));
46104630 } else if (_keyboardFocusHighlight) {
46114631 _keyboardFocusHighlight->setVisible(false);
46124632 }
@@ -4698,7 +4718,7 @@ void Application::update(float deltaTime) { · 85 unmodified lines
46984718
46994719 controller::InputCalibrationData calibrationData = {
47004720 myAvatar->getSensorToWorldMatrix(),
4701− createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition()),
4721+ createMatFromQuatAndPos(myAvatar->getWorldOrientation(), myAvatar->getWorldPosition()),
47024722 myAvatar->getHMDSensorMatrix(),
47034723 myAvatar->getCenterEyeCalibrationMat(),
47044724 myAvatar->getHeadCalibrationMat(),
@@ -4808,7 +4828,7 @@ void Application::update(float deltaTime) { · 103 unmodified lines
48084828 };
48094829
48104830 // copy controller poses from userInputMapper to myAvatar.
4811− glm::mat4 myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition());
4831+ glm::mat4 myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getWorldOrientation(), myAvatar->getWorldPosition());
48124832 glm::mat4 worldToSensorMatrix = glm::inverse(myAvatar->getSensorToWorldMatrix());
48134833 glm::mat4 avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix;
48144834 for (auto& action : avatarControllerActions) {
@@ -4948,13 +4968,13 @@ void Application::update(float deltaTime) { · 133 unmodified lines
49484968
49494969 // TODO: break these out into distinct perfTimers when they prove interesting
49504970 {
4951− PROFILE_RANGE(app, "RayPickManager");
4952− _rayPickManager.update();
4971+ PROFILE_RANGE(app, "PickManager");
4972+ DependencyManager::get<PickManager>()->update();
49534973 }
49544974
49554975 {
4956− PROFILE_RANGE(app, "LaserPointerManager");
4957− _laserPointerManager.update();
4976+ PROFILE_RANGE(app, "PointerManager");
4977+ DependencyManager::get<PointerManager>()->update();
49584978 }
49594979
49604980 {
@@ -5424,7 +5444,7 @@ std::shared_ptr<MyAvatar> Application::getMyAvatar() const { · 463 unmodified lines
54245444 }
54255445
54265446 glm::vec3 Application::getAvatarPosition() const {
5427− return getMyAvatar()->getPosition();
5447+ return getMyAvatar()->getWorldPosition();
54285448 }
54295449
54305450 void Application::copyViewFrustum(ViewFrustum& viewOut) const {
@@ -5639,7 +5659,7 @@ bool Application::nearbyEntitiesAreReadyForPhysics() { · 208 unmodified lines
56395659 // whose bounding boxes cannot be computed (it is too loose for our purposes here). Instead we manufacture
56405660 // custom filters and use the general-purpose EntityTree::findEntities(filter, ...)
56415661 QVector<EntityItemPointer> entities;
5642− AABox avatarBox(getMyAvatar()->getPosition() - glm::vec3(PHYSICS_READY_RANGE), glm::vec3(2 * PHYSICS_READY_RANGE));
5662+ AABox avatarBox(getMyAvatar()->getWorldPosition() - glm::vec3(PHYSICS_READY_RANGE), glm::vec3(2 * PHYSICS_READY_RANGE));
56435663 // create two functions that use avatarBox (entityScan and elementScan), the second calls the first
56445664 std::function<bool (EntityItemPointer&)> entityScan = [=](EntityItemPointer& entity) {
56455665 if (entity->shouldBePhysical()) {
@@ -5841,6 +5861,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 195 unmodified lines
58415861
58425862 scriptEngine->registerGlobalObject("RayPick", DependencyManager::get<RayPickScriptingInterface>().data());
58435863 scriptEngine->registerGlobalObject("LaserPointers", DependencyManager::get<LaserPointerScriptingInterface>().data());
5864+ scriptEngine->registerGlobalObject("Picks", DependencyManager::get<PickScriptingInterface>().data());
5865+ scriptEngine->registerGlobalObject("Pointers", DependencyManager::get<PointerScriptingInterface>().data());
58445866
58455867 // Caches
58465868 scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
@@ -5898,6 +5920,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 51 unmodified lines
58985920
58995921 qScriptRegisterMetaType(scriptEngine.data(), OverlayIDtoScriptValue, OverlayIDfromScriptValue);
59005922
5923+ DependencyManager::get<PickScriptingInterface>()->registerMetaTypes(scriptEngine.data());
5924+
59015925 // connect this script engines printedMessage signal to the global ScriptEngines these various messages
59025926 connect(scriptEngine.data(), &ScriptEngine::printedMessage,
59035927 DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onPrintedMessage);
@@ -6139,46 +6163,60 @@ bool Application::askToReplaceDomainContent(const QString& url) { · 235 unmodified lines
61396163 "and restoring content, visit the documentation page at: ", MAX_CHARACTERS_PER_LINE) +
61406164 "\nhttps://docs.highfidelity.com/create-and-explore/start-working-in-your-sandbox/restoring-sandbox-content";
61416165
6142− bool agreeToReplaceContent = false; // assume false
6143− agreeToReplaceContent = QMessageBox::Yes == OffscreenUi::question("Are you sure you want to replace this domain's content set?",
6144− infoText, QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
6145−
6146− if (agreeToReplaceContent) {
6147− // Given confirmation, send request to domain server to replace content
6148− qCDebug(interfaceapp) << "Attempting to replace domain content: " << url;
6149− QByteArray urlData(url.toUtf8());
6150− auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
6151− limitedNodeList->eachMatchingNode([](const SharedNodePointer& node) {
6152− return node->getType() == NodeType::EntityServer && node->getActiveSocket();
6153− }, [&urlData, limitedNodeList](const SharedNodePointer& octreeNode) {
6154− auto octreeFilePacket = NLPacket::create(PacketType::OctreeFileReplacementFromUrl, urlData.size(), true);
6155− octreeFilePacket->write(urlData);
6156− limitedNodeList->sendPacket(std::move(octreeFilePacket), *octreeNode);
6157− });
6158− auto addressManager = DependencyManager::get<AddressManager>();
6159− addressManager->handleLookupString(DOMAIN_SPAWNING_POINT);
6160− QString newHomeAddress = addressManager->getHost() + DOMAIN_SPAWNING_POINT;
6161− qCDebug(interfaceapp) << "Setting new home bookmark to: " << newHomeAddress;
6162− DependencyManager::get<LocationBookmarks>()->setHomeLocationToAddress(newHomeAddress);
6163− methodDetails = "SuccessfulRequestToReplaceContent";
6164− } else {
6165− methodDetails = "UserDeclinedToReplaceContent";
6166− }
6166+ ModalDialogListener* dig = OffscreenUi::asyncQuestion("Are you sure you want to replace this domain's content set?",
6167+ infoText, QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
6168+
6169+ QObject::connect(dig, &ModalDialogListener::response, this, [=] (QVariant answer) {
6170+ QString details;
6171+ if (static_cast<QMessageBox::StandardButton>(answer.toInt()) == QMessageBox::Yes) {
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+ details = "SuccessfulRequestToReplaceContent";
6189+ } else {
6190+ details = "UserDeclinedToReplaceContent";
6191+ }
6192+ QJsonObject messageProperties = {
6193+ { "status", details },
6194+ { "content_set_url", url }
6195+ };
6196+ UserActivityLogger::getInstance().logAction("replace_domain_content", messageProperties);
6197+ QObject::disconnect(dig, &ModalDialogListener::response, this, nullptr);
6198+ });
61676199 } else {
61686200 methodDetails = "ContentSetDidNotOriginateFromMarketplace";
6201+ QJsonObject messageProperties = {
6202+ { "status", methodDetails },
6203+ { "content_set_url", url }
6204+ };
6205+ UserActivityLogger::getInstance().logAction("replace_domain_content", messageProperties);
61696206 }
61706207 } else {
61716208 methodDetails = "UserDoesNotHavePermissionToReplaceContent";
61726209 static const QString warningMessage = simpleWordWrap("The domain owner must enable 'Replace Content' "
61736210 "permissions for you in this domain's server settings before you can continue.", MAX_CHARACTERS_PER_LINE);
6174− OffscreenUi::warning("You do not have permissions to replace domain content", warningMessage,
6211+ OffscreenUi::asyncWarning("You do not have permissions to replace domain content", warningMessage,
61756212 QMessageBox::Ok, QMessageBox::Ok);
6213+
6214+ QJsonObject messageProperties = {
6215+ { "status", methodDetails },
6216+ { "content_set_url", url }
6217+ };
6218+ UserActivityLogger::getInstance().logAction("replace_domain_content", messageProperties);
61766219 }
6177− QJsonObject messageProperties = {
6178− { "status", methodDetails },
6179− { "content_set_url", url }
6180− };
6181− UserActivityLogger::getInstance().logAction("replace_domain_content", messageProperties);
61826220 return true;
61836221 }
61846222
@@ -6451,9 +6489,9 @@ void Application::addAssetToWorldAddEntity(QString filePath, QString mapping) { · 266 unmodified lines
64516489 properties.setShapeType(SHAPE_TYPE_SIMPLE_COMPOUND);
64526490 properties.setCollisionless(true); // Temporarily set so that doesn't collide with avatar.
64536491 properties.setVisible(false); // Temporarily set so that don't see at large unresized dimensions.
6454− glm::vec3 positionOffset = getMyAvatar()->getOrientation() * (getMyAvatar()->getSensorToWorldScale() * glm::vec3(0.0f, 0.0f, -2.0f));
6455− properties.setPosition(getMyAvatar()->getPosition() + positionOffset);
6456− properties.setRotation(getMyAvatar()->getOrientation());
6492+ glm::vec3 positionOffset = getMyAvatar()->getWorldOrientation() * (getMyAvatar()->getSensorToWorldScale() * glm::vec3(0.0f, 0.0f, -2.0f));
6493+ properties.setPosition(getMyAvatar()->getWorldPosition() + positionOffset);
6494+ properties.setRotation(getMyAvatar()->getWorldOrientation());
64576495 properties.setGravity(glm::vec3(0.0f, 0.0f, 0.0f));
64586496 auto entityID = DependencyManager::get<EntityScriptingInterface>()->addEntity(properties);
64596497
@@ -7037,11 +7075,11 @@ QRect Application::getRecommendedHUDRect() const { · 577 unmodified lines
70377075 return result;
70387076 }
70397077
7040−QSize Application::getDeviceSize() const {
7078+glm::vec2 Application::getDeviceSize() const {
70417079 static const int MIN_SIZE = 1;
7042− QSize result(MIN_SIZE, MIN_SIZE);
7080+ glm::vec2 result(MIN_SIZE);
70437081 if (_displayPlugin) {
7044− result = fromGlm(getActiveDisplayPlugin()->getRecommendedRenderSize());
7082+ result = getActiveDisplayPlugin()->getRecommendedRenderSize();
70457083 }
70467084 return result;
70477085 }
@@ -7060,10 +7098,6 @@ bool Application::hasFocus() const { · 12 unmodified lines
70607098 return (QApplication::activeWindow() != nullptr);
70617099 }
70627100
7063−glm::vec2 Application::getViewportDimensions() const {
7064− return toGlm(getDeviceSize());
7065−}
7066−
70677101 void Application::setMaxOctreePacketsPerSecond(int maxOctreePPS) {
70687102 if (maxOctreePPS != _maxOctreePPS) {
70697103 _maxOctreePPS = maxOctreePPS;