mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 15:53:35 +02:00
Only first laser highlights
This commit is contained in:
parent
5878e36ea8
commit
403dd3d7d0
2 changed files with 107 additions and 2 deletions
scripts/system/controllers
|
@ -44,7 +44,12 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
this.highVarianceCount = 0;
|
||||
this.veryhighVarianceCount = 0;
|
||||
this.tabletID = null;
|
||||
this.TABLET_UI_UUIDS = [];
|
||||
this.blacklist = [];
|
||||
this.leftPointerNonHoverItem = null;
|
||||
this.leftPointerNonHoverItemChanged = false;
|
||||
this.rightPointerNonHoverItem = null;
|
||||
this.rightPointerNonHoverItemChanged = false;
|
||||
this.pointerManager = new PointerManager();
|
||||
|
||||
// a module can occupy one or more "activity" slots while it's running. If all the required slots for a module are
|
||||
|
@ -122,6 +127,10 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
return getControllerWorldLocation(Controller.Standard.RightHand, true);
|
||||
};
|
||||
|
||||
this.isTabletID = function (uuid) {
|
||||
return _this.TABLET_UI_UUIDS.indexOf(uuid) !== -1;
|
||||
};
|
||||
|
||||
this.updateTimings = function () {
|
||||
_this.intervalCount++;
|
||||
var thisInterval = Date.now();
|
||||
|
@ -148,11 +157,35 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
this.setIgnorePointerItems = function() {
|
||||
if (HMD.tabletID !== this.tabletID) {
|
||||
this.tabletID = HMD.tabletID;
|
||||
this.TABLET_UI_UUIDS = [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID, HMD.homeButtonHighlightID];
|
||||
Pointers.setIgnoreItems(_this.leftPointer, _this.blacklist);
|
||||
Pointers.setIgnoreItems(_this.rightPointer, _this.blacklist);
|
||||
}
|
||||
};
|
||||
|
||||
this.setNonHoverItems = function () {
|
||||
if (_this.leftPointerNonHoverItemChanged) {
|
||||
if (_this.leftPointerNonHoverItem === null) {
|
||||
Pointers.setNonHoverItems(_this.leftPointer, []);
|
||||
} else if (_this.isTabletID(_this.leftPointerNonHoverItem)) {
|
||||
Pointers.setNonHoverItems(_this.leftPointer, _this.TABLET_UI_UUIDS);
|
||||
} else {
|
||||
Pointers.setNonHoverItems(_this.leftPointer, [_this.leftPointerNonHoverItem]);
|
||||
}
|
||||
_this.leftPointerNonHoverItemChanged = false;
|
||||
}
|
||||
if (_this.rightPointerNonHoverItemChanged) {
|
||||
if (_this.rightPointerNonHoverItem === null) {
|
||||
Pointers.setNonHoverItems(_this.rightPointer, []);
|
||||
} else if (_this.isTabletID(_this.rightPointerNonHoverItem)) {
|
||||
Pointers.setNonHoverItems(_this.rightPointer, _this.TABLET_UI_UUIDS);
|
||||
} else {
|
||||
Pointers.setNonHoverItems(_this.rightPointer, [_this.rightPointerNonHoverItem]);
|
||||
}
|
||||
_this.rightPointerNonHoverItemChanged = false;
|
||||
}
|
||||
};
|
||||
|
||||
this.update = function () {
|
||||
try {
|
||||
_this.updateInternal();
|
||||
|
@ -324,6 +357,19 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
_this.runningPluginNames[orderedPluginName] = true;
|
||||
_this.markSlots(candidatePlugin, orderedPluginName);
|
||||
_this.pointerManager.makePointerVisible(candidatePlugin.parameters.handLaser);
|
||||
|
||||
if (candidatePlugin.parameters.handLaser.nonHoverItem !== undefined) {
|
||||
if (candidatePlugin.parameters.handLaser.hand === LEFT_HAND
|
||||
&& _this.leftPointerNonHoverItem !== candidatePlugin.parameters.handLaser.nonHoverItem) {
|
||||
_this.leftPointerNonHoverItem = candidatePlugin.parameters.handLaser.nonHoverItem;
|
||||
_this.leftPointerNonHoverItemChanged = true;
|
||||
} else if (candidatePlugin.parameters.handLaser.hand === RIGHT_HAND
|
||||
&& _this.rightPointerNonHoverItem !== candidatePlugin.parameters.handLaser.nonHoverItem) {
|
||||
_this.rightPointerNonHoverItem = candidatePlugin.parameters.handLaser.nonHoverItem;
|
||||
_this.rightPointerNonHoverItemChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
print("controllerDispatcher running " + orderedPluginName);
|
||||
}
|
||||
|
@ -354,6 +400,21 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
Script.beginProfileRange("dispatch.run." + runningPluginName);
|
||||
}
|
||||
var runningness = plugin.run(controllerData, deltaTime);
|
||||
|
||||
if (runningness.active) {
|
||||
if (plugin.parameters.handLaser.nonHoverItem !== undefined) {
|
||||
if (plugin.parameters.handLaser.hand === LEFT_HAND
|
||||
&& _this.leftPointerNonHoverItem !== plugin.parameters.handLaser.nonHoverItem) {
|
||||
_this.leftPointerNonHoverItem = plugin.parameters.handLaser.nonHoverItem;
|
||||
_this.leftPointerNonHoverItemChanged = true;
|
||||
} else if (plugin.parameters.handLaser.hand === RIGHT_HAND
|
||||
&& _this.rightPointerNonHoverItem !== plugin.parameters.handLaser.nonHoverItem) {
|
||||
_this.rightPointerNonHoverItem = plugin.parameters.handLaser.nonHoverItem;
|
||||
_this.rightPointerNonHoverItemChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!runningness.active) {
|
||||
// plugin is finished running, for now. remove it from the list
|
||||
// of running plugins and mark its activity-slots as "not in use"
|
||||
|
@ -372,6 +433,9 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
}
|
||||
}
|
||||
_this.pointerManager.updatePointersRenderState(controllerData.triggerClicks, controllerData.triggerValues);
|
||||
|
||||
_this.setNonHoverItems();
|
||||
|
||||
if (PROFILE) {
|
||||
Script.endProfileRange("dispatch.run");
|
||||
}
|
||||
|
|
|
@ -87,28 +87,69 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
return MyAvatar.getDominantHand() === "right" ? 1 : 0;
|
||||
};
|
||||
|
||||
this.hoverItem = null;
|
||||
|
||||
this.isTabletID = function (uuid) {
|
||||
return [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID, HMD.homeButtonHightlightID].indexOf(uuid) !== -1;
|
||||
};
|
||||
|
||||
this.isReady = function(controllerData) {
|
||||
var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE
|
||||
&& controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE;
|
||||
if (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)) {
|
||||
this.updateAllwaysOn();
|
||||
if (this.parameters.handLaser.allwaysOn || isTriggerPressed) {
|
||||
var pointingAt = controllerData.rayPicks[this.hand].objectID;
|
||||
if (this.isTabletID(pointingAt)) {
|
||||
pointingAt = HMD.tabletID;
|
||||
}
|
||||
|
||||
if (pointingAt !== this.getOtherModule().hoverItem) {
|
||||
this.hoverItem = pointingAt;
|
||||
this.getOtherModule().parameters.handLaser.nonHoverItem = pointingAt;
|
||||
} else {
|
||||
this.hoverItem = null;
|
||||
this.getOtherModule().parameters.handLaser.nonHoverItem = null;
|
||||
}
|
||||
|
||||
return makeRunningValues(true, [], []);
|
||||
}
|
||||
}
|
||||
|
||||
this.hoverItem = null;
|
||||
this.getOtherModule().parameters.handLaser.nonHoverItem = null;
|
||||
|
||||
return makeRunningValues(false, [], []);
|
||||
};
|
||||
|
||||
this.run = function(controllerData, deltaTime) {
|
||||
var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData);
|
||||
if (!grabModuleNeedsToRun && (controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE
|
||||
|| this.parameters.handLaser.allwaysOn
|
||||
var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE;
|
||||
if (!grabModuleNeedsToRun && (isTriggerPressed || this.parameters.handLaser.allwaysOn
|
||||
&& (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)))) {
|
||||
this.running = true;
|
||||
|
||||
var pointingAt = controllerData.rayPicks[this.hand].objectID;
|
||||
if (this.isTabletID(pointingAt)) {
|
||||
pointingAt = HMD.tabletID;
|
||||
}
|
||||
|
||||
if (pointingAt !== this.getOtherModule().hoverItem || isTriggerPressed) {
|
||||
this.hoverItem = pointingAt;
|
||||
this.getOtherModule().parameters.handLaser.nonHoverItem = pointingAt;
|
||||
} else {
|
||||
this.hoverItem = null;
|
||||
this.getOtherModule().parameters.handLaser.nonHoverItem = null;
|
||||
}
|
||||
|
||||
return makeRunningValues(true, [], []);
|
||||
}
|
||||
this.deleteContextOverlay();
|
||||
this.running = false;
|
||||
|
||||
this.hoverItem = null;
|
||||
this.getOtherModule().parameters.handLaser.nonHoverItem = null;
|
||||
|
||||
return makeRunningValues(false, [], []);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue