mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
Use a smaller near grab radius for tablet and mini-tablet
This commit is contained in:
parent
8a8bf6dc04
commit
5e7f68d4b7
2 changed files with 31 additions and 0 deletions
|
@ -25,7 +25,9 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
|
||||
(function() {
|
||||
Script.include("/~/system/libraries/pointersUtils.js");
|
||||
|
||||
var NEAR_MAX_RADIUS = 0.1;
|
||||
var NEAR_TABLET_MAX_RADIUS = 0.05;
|
||||
|
||||
var TARGET_UPDATE_HZ = 60; // 50hz good enough, but we're using update
|
||||
var BASIC_TIMER_INTERVAL_MS = 1000 / TARGET_UPDATE_HZ;
|
||||
|
@ -49,6 +51,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
this.tabletID = null;
|
||||
this.blacklist = [];
|
||||
this.pointerManager = new PointerManager();
|
||||
this.miniTabletID = null;
|
||||
|
||||
// a module can occupy one or more "activity" slots while it's running. If all the required slots for a module are
|
||||
// not set to false (not in use), a module cannot start. When a module is using a slot, that module's name
|
||||
|
@ -211,6 +214,22 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
if (controllerLocations[h].valid) {
|
||||
var nearbyOverlays =
|
||||
Overlays.findOverlays(controllerLocations[h].position, NEAR_MAX_RADIUS * sensorScaleFactor);
|
||||
|
||||
// Tablet and mini-tablet must be within NEAR_TABLET_MAX_RADIUS in order to be grabbed.
|
||||
var tabletIndex = nearbyOverlays.indexOf(HMD.tabletID);
|
||||
var miniTabletIndex = nearbyOverlays.indexOf(_this.miniTabletID);
|
||||
if (tabletIndex !== -1 || miniTabletIndex !== -1) {
|
||||
var closebyOverlays =
|
||||
Overlays.findOverlays(controllerLocations[h].position, NEAR_TABLET_MAX_RADIUS * sensorScaleFactor);
|
||||
// Assumes that the tablet and mini-tablet are not displayed at the same time.
|
||||
if (tabletIndex !== -1 && closebyOverlays.indexOf(HMD.tabletID) === -1) {
|
||||
nearbyOverlays.splice(tabletIndex, 1);
|
||||
}
|
||||
if (miniTabletIndex !== -1 && closebyOverlays.indexOf(_this.miniTabletID) === -1) {
|
||||
nearbyOverlays.splice(miniTabletIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
nearbyOverlays.sort(function (a, b) {
|
||||
var aPosition = Overlays.getProperty(a, "position");
|
||||
var aDistance = Vec3.distance(aPosition, controllerLocations[h].position);
|
||||
|
@ -218,6 +237,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
var bDistance = Vec3.distance(bPosition, controllerLocations[h].position);
|
||||
return aDistance - bDistance;
|
||||
});
|
||||
|
||||
nearbyOverlayIDs.push(nearbyOverlays);
|
||||
} else {
|
||||
nearbyOverlayIDs.push([]);
|
||||
|
@ -470,6 +490,8 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
_this.setBlacklist();
|
||||
}
|
||||
}
|
||||
} else if (channel === 'Hifi-MiniTablet-ID') {
|
||||
_this.miniTabletID = message;
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
|
@ -508,6 +530,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
Entities.mousePressOnEntity.connect(mousePress);
|
||||
var controllerDispatcher = new ControllerDispatcher();
|
||||
Messages.subscribe('Hifi-Hand-RayPick-Blacklist');
|
||||
Messages.subscribe('Hifi-MiniTablet-ID');
|
||||
Messages.messageReceived.connect(controllerDispatcher.handleHandMessage);
|
||||
Script.scriptEnding.connect(controllerDispatcher.cleanup);
|
||||
Script.setTimeout(controllerDispatcher.update, BASIC_TIMER_INTERVAL_MS);
|
||||
|
|
|
@ -169,6 +169,11 @@
|
|||
|
||||
// #region Communications ==================================================================================================
|
||||
|
||||
function updateMiniTabletID() {
|
||||
// Send mini-tablet overlay ID to controllerDispatcher so that it can use a smaller near grab distance.
|
||||
Messages.sendLocalMessage("Hifi-MiniTablet-ID", proxyOverlay);
|
||||
}
|
||||
|
||||
function updateMutedStatus() {
|
||||
var isMuted = Audio.muted;
|
||||
proxyOverlayObject.emitScriptEvent(JSON.stringify({
|
||||
|
@ -257,6 +262,8 @@
|
|||
|
||||
proxyOverlayObject = Overlays.getOverlayObject(proxyUIOverlay);
|
||||
proxyOverlayObject.webEventReceived.connect(onWebEventReceived);
|
||||
|
||||
updateMiniTabletID();
|
||||
}
|
||||
|
||||
function showUI(hand) {
|
||||
|
@ -320,6 +327,7 @@
|
|||
proxyOverlayObject = null;
|
||||
proxyUIOverlay = null;
|
||||
proxyOverlay = null;
|
||||
updateMiniTabletID();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue