mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 04:44:32 +02:00
Merge pull request #13703 from dback2/editHandleTriggerValues
Edit handles trigger fixes
This commit is contained in:
commit
1b031ff065
3 changed files with 50 additions and 40 deletions
|
@ -66,11 +66,13 @@ Script.include("/~/system/libraries/utils.js");
|
||||||
|
|
||||||
this.sendPickData = function(controllerData) {
|
this.sendPickData = function(controllerData) {
|
||||||
if (controllerData.triggerClicks[this.hand]) {
|
if (controllerData.triggerClicks[this.hand]) {
|
||||||
|
var hand = this.hand === RIGHT_HAND ? Controller.Standard.RightHand : Controller.Standard.LeftHand;
|
||||||
if (!this.triggerClicked) {
|
if (!this.triggerClicked) {
|
||||||
this.selectedTarget = controllerData.rayPicks[this.hand];
|
this.selectedTarget = controllerData.rayPicks[this.hand];
|
||||||
if (!this.selectedTarget.intersects) {
|
if (!this.selectedTarget.intersects) {
|
||||||
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
||||||
method: "clearSelection"
|
method: "clearSelection",
|
||||||
|
hand: hand
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,13 +80,15 @@ Script.include("/~/system/libraries/utils.js");
|
||||||
if (!this.isTabletMaterialEntity(this.selectedTarget.objectID)) {
|
if (!this.isTabletMaterialEntity(this.selectedTarget.objectID)) {
|
||||||
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
||||||
method: "selectEntity",
|
method: "selectEntity",
|
||||||
entityID: this.selectedTarget.objectID
|
entityID: this.selectedTarget.objectID,
|
||||||
|
hand: hand
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
} else if (this.selectedTarget.type === Picks.INTERSECTED_OVERLAY) {
|
} else if (this.selectedTarget.type === Picks.INTERSECTED_OVERLAY) {
|
||||||
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
||||||
method: "selectOverlay",
|
method: "selectOverlay",
|
||||||
overlayID: this.selectedTarget.objectID
|
overlayID: this.selectedTarget.objectID,
|
||||||
|
hand: hand
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -963,6 +963,7 @@ function handleOverlaySelectionToolUpdates(channel, message, sender) {
|
||||||
var data = JSON.parse(message);
|
var data = JSON.parse(message);
|
||||||
|
|
||||||
if (data.method === "selectOverlay") {
|
if (data.method === "selectOverlay") {
|
||||||
|
if (!selectionDisplay.triggered() || selectionDisplay.triggeredHand === data.hand) {
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
print("setting selection to overlay " + data.overlayID);
|
print("setting selection to overlay " + data.overlayID);
|
||||||
}
|
}
|
||||||
|
@ -972,6 +973,7 @@ function handleOverlaySelectionToolUpdates(channel, message, sender) {
|
||||||
selectionManager.setSelections([entity]);
|
selectionManager.setSelections([entity]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMessagesReceived(channel, message, sender) {
|
function handleMessagesReceived(channel, message, sender) {
|
||||||
|
|
|
@ -53,14 +53,18 @@ SelectionManager = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messageParsed.method === "selectEntity") {
|
if (messageParsed.method === "selectEntity") {
|
||||||
|
if (!SelectionDisplay.triggered() || SelectionDisplay.triggeredHand === messageParsed.hand) {
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
print("setting selection to " + messageParsed.entityID);
|
print("setting selection to " + messageParsed.entityID);
|
||||||
}
|
}
|
||||||
that.setSelections([messageParsed.entityID]);
|
that.setSelections([messageParsed.entityID]);
|
||||||
|
}
|
||||||
} else if (messageParsed.method === "clearSelection") {
|
} else if (messageParsed.method === "clearSelection") {
|
||||||
|
if (!SelectionDisplay.triggered() || SelectionDisplay.triggeredHand === messageParsed.hand) {
|
||||||
that.clearSelections();
|
that.clearSelections();
|
||||||
|
}
|
||||||
} else if (messageParsed.method === "pointingAt") {
|
} else if (messageParsed.method === "pointingAt") {
|
||||||
if (messageParsed.rightHand) {
|
if (messageParsed.hand === Controller.Standard.RightHand) {
|
||||||
that.pointingAtDesktopWindowRight = messageParsed.desktopWindow;
|
that.pointingAtDesktopWindowRight = messageParsed.desktopWindow;
|
||||||
that.pointingAtTabletRight = messageParsed.tablet;
|
that.pointingAtTabletRight = messageParsed.tablet;
|
||||||
} else {
|
} else {
|
||||||
|
@ -411,6 +415,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 = [
|
||||||
|
@ -751,20 +757,17 @@ 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.TRIGGER_GRAB_VALUE = 0.85; // From handControllerGrab/Pointer.js. Should refactor.
|
that.triggeredHand = NO_TRIGGER_HAND;
|
||||||
that.TRIGGER_ON_VALUE = 0.4;
|
that.triggered = function() {
|
||||||
that.TRIGGER_OFF_VALUE = 0.15;
|
return that.triggeredHand !== NO_TRIGGER_HAND;
|
||||||
that.triggered = false;
|
|
||||||
var activeHand = Controller.Standard.RightHand;
|
|
||||||
function makeTriggerHandler(hand) {
|
|
||||||
return function (value) {
|
|
||||||
if (!that.triggered && (value > that.TRIGGER_GRAB_VALUE)) { // should we smooth?
|
|
||||||
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 makeClickHandler(hand) {
|
||||||
|
return function (clicked) {
|
||||||
|
// Don't allow both hands to trigger at the same time
|
||||||
|
if (that.triggered() && hand !== that.triggeredHand) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!that.triggered() && clicked) {
|
||||||
var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand &&
|
var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand &&
|
||||||
SelectionManager.pointingAtDesktopWindowRight) ||
|
SelectionManager.pointingAtDesktopWindowRight) ||
|
||||||
(hand === Controller.Standard.LeftHand &&
|
(hand === Controller.Standard.LeftHand &&
|
||||||
|
@ -774,15 +777,16 @@ SelectionDisplay = (function() {
|
||||||
if (pointingAtDesktopWindow || pointingAtTablet) {
|
if (pointingAtDesktopWindow || pointingAtTablet) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
that.triggeredHand = hand;
|
||||||
that.mousePressEvent({});
|
that.mousePressEvent({});
|
||||||
} else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) {
|
} else if (that.triggered() && !clicked) {
|
||||||
that.triggered = false;
|
that.triggeredHand = NO_TRIGGER_HAND;
|
||||||
that.mouseReleaseEvent({});
|
that.mouseReleaseEvent({});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
that.triggerMapping.from(Controller.Standard.RT).peek().to(makeTriggerHandler(Controller.Standard.RightHand));
|
that.triggerMapping.from(Controller.Standard.RTClick).peek().to(makeClickHandler(Controller.Standard.RightHand));
|
||||||
that.triggerMapping.from(Controller.Standard.LT).peek().to(makeTriggerHandler(Controller.Standard.LeftHand));
|
that.triggerMapping.from(Controller.Standard.LTClick).peek().to(makeClickHandler(Controller.Standard.LeftHand));
|
||||||
|
|
||||||
// FUNCTION DEF(s): Intersection Check Helpers
|
// FUNCTION DEF(s): Intersection Check Helpers
|
||||||
function testRayIntersect(queryRay, overlayIncludes, overlayExcludes) {
|
function testRayIntersect(queryRay, overlayIncludes, overlayExcludes) {
|
||||||
|
@ -833,7 +837,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;
|
||||||
}
|
}
|
||||||
|
@ -1079,9 +1083,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({});
|
||||||
|
@ -1092,8 +1096,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);
|
||||||
|
@ -2243,11 +2247,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