mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 05:17:02 +02:00
Make tablet have priority over drawInFront overlays rendered behind it
This commit is contained in:
parent
0e0542ec6e
commit
c41ce5d484
4 changed files with 22 additions and 4 deletions
|
@ -8476,6 +8476,16 @@ QUuid Application::getTabletFrameID() const {
|
||||||
return HMD->getCurrentTabletFrameID();
|
return HMD->getCurrentTabletFrameID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<QUuid> Application::getTabletIDs() const {
|
||||||
|
// Most important overlays first.
|
||||||
|
QVector<QUuid> result;
|
||||||
|
auto HMD = DependencyManager::get<HMDScriptingInterface>();
|
||||||
|
result << HMD->getCurrentTabletScreenID();
|
||||||
|
result << HMD->getCurrentHomeButtonID();
|
||||||
|
result << HMD->getCurrentTabletFrameID();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void Application::setAvatarOverrideUrl(const QUrl& url, bool save) {
|
void Application::setAvatarOverrideUrl(const QUrl& url, bool save) {
|
||||||
_avatarOverrideUrl = url;
|
_avatarOverrideUrl = url;
|
||||||
_saveAvatarOverrideUrl = save;
|
_saveAvatarOverrideUrl = save;
|
||||||
|
|
|
@ -298,6 +298,7 @@ public:
|
||||||
OverlayID getTabletScreenID() const;
|
OverlayID getTabletScreenID() const;
|
||||||
OverlayID getTabletHomeButtonID() const;
|
OverlayID getTabletHomeButtonID() const;
|
||||||
QUuid getTabletFrameID() const; // may be an entity or an overlay
|
QUuid getTabletFrameID() const; // may be an entity or an overlay
|
||||||
|
QVector<QUuid> getTabletIDs() const; // In order of most important IDs first.
|
||||||
|
|
||||||
void setAvatarOverrideUrl(const QUrl& url, bool save);
|
void setAvatarOverrideUrl(const QUrl& url, bool save);
|
||||||
void clearAvatarOverrideUrl() { _avatarOverrideUrl = QUrl(); _saveAvatarOverrideUrl = false; }
|
void clearAvatarOverrideUrl() { _avatarOverrideUrl = QUrl(); _saveAvatarOverrideUrl = false; }
|
||||||
|
|
|
@ -532,6 +532,8 @@ RayToOverlayIntersectionResult Overlays::findRayIntersectionVector(const PickRay
|
||||||
bool visibleOnly, bool collidableOnly) {
|
bool visibleOnly, bool collidableOnly) {
|
||||||
float bestDistance = std::numeric_limits<float>::max();
|
float bestDistance = std::numeric_limits<float>::max();
|
||||||
bool bestIsFront = false;
|
bool bestIsFront = false;
|
||||||
|
bool bestIsTablet = false;
|
||||||
|
auto tabletIDs = qApp->getTabletIDs();
|
||||||
|
|
||||||
QMutexLocker locker(&_mutex);
|
QMutexLocker locker(&_mutex);
|
||||||
RayToOverlayIntersectionResult result;
|
RayToOverlayIntersectionResult result;
|
||||||
|
@ -554,10 +556,11 @@ RayToOverlayIntersectionResult Overlays::findRayIntersectionVector(const PickRay
|
||||||
if (thisOverlay->findRayIntersectionExtraInfo(ray.origin, ray.direction, thisDistance,
|
if (thisOverlay->findRayIntersectionExtraInfo(ray.origin, ray.direction, thisDistance,
|
||||||
thisFace, thisSurfaceNormal, thisExtraInfo, precisionPicking)) {
|
thisFace, thisSurfaceNormal, thisExtraInfo, precisionPicking)) {
|
||||||
bool isDrawInFront = thisOverlay->getDrawInFront();
|
bool isDrawInFront = thisOverlay->getDrawInFront();
|
||||||
if ((bestIsFront && isDrawInFront && thisDistance < bestDistance)
|
bool isTablet = tabletIDs.contains(thisID);
|
||||||
|| (!bestIsFront && (isDrawInFront || thisDistance < bestDistance))) {
|
if (isDrawInFront && !bestIsFront && !bestIsTablet
|
||||||
|
|| (isTablet || isDrawInFront || !bestIsFront) && thisDistance < bestDistance) {
|
||||||
bestIsFront = isDrawInFront;
|
bestIsFront = isDrawInFront;
|
||||||
|
bestIsTablet = isTablet;
|
||||||
bestDistance = thisDistance;
|
bestDistance = thisDistance;
|
||||||
result.intersects = true;
|
result.intersects = true;
|
||||||
result.distance = thisDistance;
|
result.distance = thisDistance;
|
||||||
|
|
|
@ -383,7 +383,11 @@ public slots:
|
||||||
OverlayPropertyResult getOverlaysProperties(const QVariant& overlaysProperties);
|
OverlayPropertyResult getOverlaysProperties(const QVariant& overlaysProperties);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Find the closest 3D overlay intersected by a {@link PickRay}.
|
* Find the closest 3D overlay intersected by a {@link PickRay}. Overlays with their <code>drawInFront</code> property set
|
||||||
|
* to <code>true</code> have priority over overlays that don't, except that tablet overlays have priority over any
|
||||||
|
* <code>drawInFront</code> overlays behind them. I.e., if a <code>drawInFront</code> overlay is behind one that isn't
|
||||||
|
* <code>drawInFront</code>, the <code>drawInFront</code> overlay is returned, but if a tablet overlay is in front of a
|
||||||
|
* <code>drawInFront</code> overlay, the tablet overlay is returned.
|
||||||
* @function Overlays.findRayIntersection
|
* @function Overlays.findRayIntersection
|
||||||
* @param {PickRay} pickRay - The PickRay to use for finding overlays.
|
* @param {PickRay} pickRay - The PickRay to use for finding overlays.
|
||||||
* @param {boolean} [precisionPicking=false] - <em>Unused</em>; exists to match Entity API.
|
* @param {boolean} [precisionPicking=false] - <em>Unused</em>; exists to match Entity API.
|
||||||
|
|
Loading…
Reference in a new issue