diff --git a/examples/sit.js b/examples/sit.js index 3d41ebf64d..0f4b199855 100644 --- a/examples/sit.js +++ b/examples/sit.js @@ -255,10 +255,21 @@ function update(deltaTime){ } frame++; } + + var locationChanged = false; + if (location.hostname != oldHost) { + print("Changed domain"); + for (model in models) { + removeIndicators(models[model]); + } + oldHost = location.hostname; + locationChanged = true; + } - if (MyAvatar.position.x != avatarOldPosition.x && - MyAvatar.position.y != avatarOldPosition.y && - MyAvatar.position.z != avatarOldPosition.z) { + if (MyAvatar.position.x != avatarOldPosition.x || + MyAvatar.position.y != avatarOldPosition.y || + MyAvatar.position.z != avatarOldPosition.z || + locationChanged) { avatarOldPosition = MyAvatar.position; var SEARCH_RADIUS = 50; @@ -285,14 +296,6 @@ function update(deltaTime){ showIndicators(true); } } - - if (location.hostname != oldHost) { - print("Changed domain"); - for (model in models) { - removeIndicators(models[model]); - } - oldHost = location.hostname; - } } var oldHost = location.hostname; diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index 581947c074..5d16bd78e5 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -227,11 +227,23 @@ unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) { i.previous(); unsigned int thisID = i.key(); Overlay2D* thisOverlay = static_cast(i.value()); - if (thisOverlay->getVisible() && thisOverlay->getBounds().contains(point.x, point.y, false)) { + if (thisOverlay->getVisible() && thisOverlay->isLoaded() && thisOverlay->getBounds().contains(point.x, point.y, false)) { return thisID; } } return 0; // not found } +bool Overlays::isLoaded(unsigned int id) { + QReadLocker lock(&_lock); + Overlay* overlay = _overlays2D.value(id); + if (!overlay) { + _overlays3D.value(id); + } + if (!overlay) { + return false; // not found + } + + return overlay->isLoaded(); +} diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index 2fbdb993f4..8bd8224f82 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -38,6 +38,9 @@ public slots: /// returns the top most overlay at the screen point, or 0 if not overlay at that point unsigned int getOverlayAtPoint(const glm::vec2& point); + + /// returns whether the overlay's assets are loaded or not + bool isLoaded(unsigned int id); private: QMap _overlays2D;