mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:37:49 +02:00
prevent both hands triggering same time, allow one to trigger after other
This commit is contained in:
parent
dcdf734114
commit
cd842afc1c
2 changed files with 62 additions and 36 deletions
|
@ -74,7 +74,9 @@ Script.include("/~/system/libraries/utils.js");
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
||||||
method: "triggerClicked"
|
method: "triggerClicked",
|
||||||
|
clicked: true,
|
||||||
|
rightHand: this.hand === RIGHT_HAND
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
if (this.selectedTarget.type === Picks.INTERSECTED_ENTITY) {
|
if (this.selectedTarget.type === Picks.INTERSECTED_ENTITY) {
|
||||||
|
@ -95,7 +97,9 @@ Script.include("/~/system/libraries/utils.js");
|
||||||
} else {
|
} else {
|
||||||
if (this.triggerClicked) {
|
if (this.triggerClicked) {
|
||||||
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
||||||
method: "triggerUnClicked"
|
method: "triggerClicked",
|
||||||
|
clicked: false,
|
||||||
|
rightHand: this.hand === RIGHT_HAND
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,9 +68,11 @@ SelectionManager = (function() {
|
||||||
that.pointingAtTabletLeft = messageParsed.tablet;
|
that.pointingAtTabletLeft = messageParsed.tablet;
|
||||||
}
|
}
|
||||||
} else if (messageParsed.method === "triggerClicked") {
|
} else if (messageParsed.method === "triggerClicked") {
|
||||||
that.triggerClicked = true;
|
if (messageParsed.rightHand) {
|
||||||
} else if (messageParsed.method === "triggerUnClicked") {
|
that.triggerClickedRight = messageParsed.clicked;
|
||||||
that.triggerClicked = false;
|
} else {
|
||||||
|
that.triggerClickedLeft = messageParsed.clicked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +116,8 @@ SelectionManager = (function() {
|
||||||
that.pointingAtTabletLeft = false;
|
that.pointingAtTabletLeft = false;
|
||||||
that.pointingAtTabletRight = false;
|
that.pointingAtTabletRight = false;
|
||||||
|
|
||||||
that.triggerClicked = false;
|
that.triggerClickedRight = false;
|
||||||
|
that.triggerClickedLeft = false;
|
||||||
|
|
||||||
that.saveProperties = function() {
|
that.saveProperties = function() {
|
||||||
that.savedProperties = {};
|
that.savedProperties = {};
|
||||||
|
@ -417,6 +420,8 @@ SelectionDisplay = (function() {
|
||||||
ROLL: 2
|
ROLL: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var NO_TRIGGER_HAND = -1;
|
||||||
|
|
||||||
var spaceMode = SPACE_LOCAL;
|
var spaceMode = SPACE_LOCAL;
|
||||||
var overlayNames = [];
|
var overlayNames = [];
|
||||||
var lastControllerPoses = [
|
var lastControllerPoses = [
|
||||||
|
@ -757,17 +762,12 @@ SelectionDisplay = (function() {
|
||||||
// But we dont' get mousePressEvents.
|
// But we dont' get mousePressEvents.
|
||||||
that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click');
|
that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click');
|
||||||
Script.scriptEnding.connect(that.triggerMapping.disable);
|
Script.scriptEnding.connect(that.triggerMapping.disable);
|
||||||
that.triggered = false;
|
that.triggeredHand = NO_TRIGGER_HAND;
|
||||||
var activeHand = Controller.Standard.RightHand;
|
that.triggered = function() {
|
||||||
function makeTriggerHandler(hand) {
|
return that.triggeredHand !== NO_TRIGGER_HAND;
|
||||||
return function () {
|
|
||||||
if (!that.triggered && SelectionManager.triggerClicked) {
|
|
||||||
that.triggered = true;
|
|
||||||
if (activeHand !== hand) {
|
|
||||||
// No switching while the other is already triggered, so no need to release.
|
|
||||||
activeHand = (activeHand === Controller.Standard.RightHand) ?
|
|
||||||
Controller.Standard.LeftHand : Controller.Standard.RightHand;
|
|
||||||
}
|
}
|
||||||
|
function triggerPress(hand) {
|
||||||
|
that.triggeredHand = hand;
|
||||||
var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand &&
|
var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand &&
|
||||||
SelectionManager.pointingAtDesktopWindowRight) ||
|
SelectionManager.pointingAtDesktopWindowRight) ||
|
||||||
(hand === Controller.Standard.LeftHand &&
|
(hand === Controller.Standard.LeftHand &&
|
||||||
|
@ -778,9 +778,31 @@ SelectionDisplay = (function() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
that.mousePressEvent({});
|
that.mousePressEvent({});
|
||||||
} else if (that.triggered && !SelectionManager.triggerClicked) {
|
}
|
||||||
that.triggered = false;
|
function triggerRelease(hand) {
|
||||||
|
that.triggeredHand = NO_TRIGGER_HAND;
|
||||||
that.mouseReleaseEvent({});
|
that.mouseReleaseEvent({});
|
||||||
|
var otherTriggerClicked = hand == Controller.Standard.RightHand ? SelectionManager.triggerClickedLeft :
|
||||||
|
SelectionManager.triggerClickedRight;
|
||||||
|
// When one hand is released check if the other hand is clicked and should then trigger a press
|
||||||
|
if (otherTriggerClicked) {
|
||||||
|
var otherHand = hand == Controller.Standard.RightHand ? Controller.Standard.LeftHand :
|
||||||
|
Controller.Standard.RightHand;
|
||||||
|
triggerPress(otherHand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function makeTriggerHandler(hand) {
|
||||||
|
return function () {
|
||||||
|
// Don't allow both hands to trigger at the same time
|
||||||
|
if (that.triggered() && hand !== that.triggeredHand) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var triggerClicked = hand == Controller.Standard.RightHand ? SelectionManager.triggerClickedRight :
|
||||||
|
SelectionManager.triggerClickedLeft;
|
||||||
|
if (!that.triggered() && triggerClicked) {
|
||||||
|
triggerPress(hand);
|
||||||
|
} else if (that.triggered() && !triggerClicked) {
|
||||||
|
triggerRelease(hand);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -836,7 +858,7 @@ SelectionDisplay = (function() {
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
print("=============== eST::MousePressEvent BEG =======================");
|
print("=============== eST::MousePressEvent BEG =======================");
|
||||||
}
|
}
|
||||||
if (!event.isLeftButton && !that.triggered) {
|
if (!event.isLeftButton && !that.triggered()) {
|
||||||
// EARLY EXIT-(if another mouse button than left is pressed ignore it)
|
// EARLY EXIT-(if another mouse button than left is pressed ignore it)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1082,9 +1104,9 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
that.checkControllerMove = function() {
|
that.checkControllerMove = function() {
|
||||||
if (SelectionManager.hasSelection()) {
|
if (SelectionManager.hasSelection()) {
|
||||||
var controllerPose = getControllerWorldLocation(activeHand, true);
|
var controllerPose = getControllerWorldLocation(that.triggeredHand, true);
|
||||||
var hand = (activeHand === Controller.Standard.LeftHand) ? 0 : 1;
|
var hand = (that.triggeredHand === Controller.Standard.LeftHand) ? 0 : 1;
|
||||||
if (controllerPose.valid && lastControllerPoses[hand].valid && that.triggered) {
|
if (controllerPose.valid && lastControllerPoses[hand].valid && that.triggered()) {
|
||||||
if (!Vec3.equal(controllerPose.position, lastControllerPoses[hand].position) ||
|
if (!Vec3.equal(controllerPose.position, lastControllerPoses[hand].position) ||
|
||||||
!Vec3.equal(controllerPose.rotation, lastControllerPoses[hand].rotation)) {
|
!Vec3.equal(controllerPose.rotation, lastControllerPoses[hand].rotation)) {
|
||||||
that.mouseMoveEvent({});
|
that.mouseMoveEvent({});
|
||||||
|
@ -1095,8 +1117,8 @@ SelectionDisplay = (function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
function controllerComputePickRay() {
|
function controllerComputePickRay() {
|
||||||
var controllerPose = getControllerWorldLocation(activeHand, true);
|
var controllerPose = getControllerWorldLocation(that.triggeredHand, true);
|
||||||
if (controllerPose.valid && that.triggered) {
|
if (controllerPose.valid && that.triggered()) {
|
||||||
var controllerPosition = controllerPose.translation;
|
var controllerPosition = controllerPose.translation;
|
||||||
// This gets point direction right, but if you want general quaternion it would be more complicated:
|
// This gets point direction right, but if you want general quaternion it would be more complicated:
|
||||||
var controllerDirection = Quat.getUp(controllerPose.rotation);
|
var controllerDirection = Quat.getUp(controllerPose.rotation);
|
||||||
|
@ -2246,11 +2268,11 @@ SelectionDisplay = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are we using handControllers or Mouse - only relevant for 3D tools
|
// Are we using handControllers or Mouse - only relevant for 3D tools
|
||||||
var controllerPose = getControllerWorldLocation(activeHand, true);
|
var controllerPose = getControllerWorldLocation(that.triggeredHand, true);
|
||||||
var vector = null;
|
var vector = null;
|
||||||
var newPick = null;
|
var newPick = null;
|
||||||
if (HMD.isHMDAvailable() && HMD.isHandControllerAvailable() &&
|
if (HMD.isHMDAvailable() && HMD.isHandControllerAvailable() &&
|
||||||
controllerPose.valid && that.triggered && directionFor3DStretch) {
|
controllerPose.valid && that.triggered() && directionFor3DStretch) {
|
||||||
localDeltaPivot = deltaPivot3D;
|
localDeltaPivot = deltaPivot3D;
|
||||||
newPick = pickRay.origin;
|
newPick = pickRay.origin;
|
||||||
vector = Vec3.subtract(newPick, lastPick3D);
|
vector = Vec3.subtract(newPick, lastPick3D);
|
||||||
|
|
Loading…
Reference in a new issue