Make Create not grab tablet if editing an entity with hand

This commit is contained in:
David Rowe 2018-10-25 15:03:47 +13:00
parent 5729d35c48
commit 0eead13fb9
3 changed files with 47 additions and 5 deletions

View file

@ -9,7 +9,7 @@
/* global Script, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, getControllerJointIndex, /* global Script, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, getControllerJointIndex,
enableDispatcherModule, disableDispatcherModule, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, enableDispatcherModule, disableDispatcherModule, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION,
makeDispatcherModuleParameters, Overlays, makeRunningValues, Vec3, resizeTablet, getTabletWidthFromSettings, makeDispatcherModuleParameters, Overlays, makeRunningValues, Vec3, resizeTablet, getTabletWidthFromSettings,
NEAR_GRAB_RADIUS, HMD, Uuid NEAR_GRAB_RADIUS, HMD, Uuid, HIFI_EDIT_MANIPULATION_CHANNEL
*/ */
Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@ -172,10 +172,14 @@ Script.include("/~/system/libraries/utils.js");
return null; return null;
}; };
this.isEditing = false;
this.setIsEditing = function (editing) {
this.isEditing = editing;
};
this.isReady = function (controllerData) { this.isReady = function (controllerData) {
if ((controllerData.triggerClicks[this.hand] === 0 && if ((controllerData.triggerClicks[this.hand] === 0 && controllerData.secondaryValues[this.hand] === 0)
controllerData.secondaryValues[this.hand] === 0)) { || this.isEditing) {
this.robbed = false; this.robbed = false;
return makeRunningValues(false, [], []); return makeRunningValues(false, [], []);
} }
@ -198,7 +202,8 @@ Script.include("/~/system/libraries/utils.js");
}; };
this.run = function (controllerData) { this.run = function (controllerData) {
if (controllerData.triggerClicks[this.hand] === 0 && controllerData.secondaryValues[this.hand] === 0) { if ((controllerData.triggerClicks[this.hand] === 0 && controllerData.secondaryValues[this.hand] === 0)
|| this.isEditing) {
this.endNearParentingGrabOverlay(); this.endNearParentingGrabOverlay();
this.robbed = false; this.robbed = false;
return makeRunningValues(false, [], []); return makeRunningValues(false, [], []);
@ -226,6 +231,28 @@ Script.include("/~/system/libraries/utils.js");
enableDispatcherModule("LeftNearParentingGrabOverlay", leftNearParentingGrabOverlay); enableDispatcherModule("LeftNearParentingGrabOverlay", leftNearParentingGrabOverlay);
enableDispatcherModule("RightNearParentingGrabOverlay", rightNearParentingGrabOverlay); enableDispatcherModule("RightNearParentingGrabOverlay", rightNearParentingGrabOverlay);
function onMessageReceived(channel, data, senderID) {
var message;
if (channel !== HIFI_EDIT_MANIPULATION_CHANNEL || senderID !== MyAvatar.sessionUUID) {
return;
}
try {
message = JSON.parse(data);
} catch (e) {
return;
}
if (message.hand === Controller.Standard.LeftHand) {
leftNearParentingGrabOverlay.setIsEditing(message.action === "startEdit");
} else if (message.hand === Controller.Standard.RightHand) {
rightNearParentingGrabOverlay.setIsEditing(message.action === "startEdit");
}
}
Messages.subscribe(HIFI_EDIT_MANIPULATION_CHANNEL);
Messages.messageReceived.connect(onMessageReceived);
function cleanup() { function cleanup() {
leftNearParentingGrabOverlay.cleanup(); leftNearParentingGrabOverlay.cleanup();
rightNearParentingGrabOverlay.cleanup(); rightNearParentingGrabOverlay.cleanup();

View file

@ -24,6 +24,7 @@
HAPTIC_PULSE_DURATION:true, HAPTIC_PULSE_DURATION:true,
DISPATCHER_HOVERING_LIST:true, DISPATCHER_HOVERING_LIST:true,
DISPATCHER_HOVERING_STYLE:true, DISPATCHER_HOVERING_STYLE:true,
HIFI_EDIT_MANIPULATION_CHANNEL:true,
Entities, Entities,
makeDispatcherModuleParameters:true, makeDispatcherModuleParameters:true,
makeRunningValues:true, makeRunningValues:true,
@ -149,6 +150,8 @@ DISPATCHER_PROPERTIES = [
"userData" "userData"
]; ];
HIFI_EDIT_MANIPULATION_CHANNEL = "HiFi-Edit-Manipulation";
// priority -- a lower priority means the module will be asked sooner than one with a higher priority in a given update step // priority -- a lower priority means the module will be asked sooner than one with a higher priority in a given update step
// activitySlots -- indicates which "slots" must not yet be in use for this module to start // activitySlots -- indicates which "slots" must not yet be in use for this module to start
// requiredDataForReady -- which "situation" parts this module looks at to decide if it will start // requiredDataForReady -- which "situation" parts this module looks at to decide if it will start
@ -590,6 +593,7 @@ if (typeof module !== 'undefined') {
TRIGGER_OFF_VALUE: TRIGGER_OFF_VALUE, TRIGGER_OFF_VALUE: TRIGGER_OFF_VALUE,
TRIGGER_ON_VALUE: TRIGGER_ON_VALUE, TRIGGER_ON_VALUE: TRIGGER_ON_VALUE,
DISPATCHER_HOVERING_LIST: DISPATCHER_HOVERING_LIST, DISPATCHER_HOVERING_LIST: DISPATCHER_HOVERING_LIST,
HIFI_EDIT_MANIPULATION_CHANNEL: HIFI_EDIT_MANIPULATION_CHANNEL,
worldPositionToRegistrationFrameMatrix: worldPositionToRegistrationFrameMatrix worldPositionToRegistrationFrameMatrix: worldPositionToRegistrationFrameMatrix
}; };
} }

View file

@ -14,7 +14,7 @@
// //
/* global SelectionManager, SelectionDisplay, grid, rayPlaneIntersection, rayPlaneIntersection2, pushCommandForSelections, /* global SelectionManager, SelectionDisplay, grid, rayPlaneIntersection, rayPlaneIntersection2, pushCommandForSelections,
getMainTabletIDs, getControllerWorldLocation, TRIGGER_ON_VALUE */ getMainTabletIDs, getControllerWorldLocation, TRIGGER_ON_VALUE, HIFI_EDIT_MANIPULATION_CHANNEL */
const SPACE_LOCAL = "local"; const SPACE_LOCAL = "local";
const SPACE_WORLD = "world"; const SPACE_WORLD = "world";
@ -983,6 +983,7 @@ SelectionDisplay = (function() {
that.triggerPressMapping = Controller.newMapping(Script.resolvePath('') + '-press'); that.triggerPressMapping = Controller.newMapping(Script.resolvePath('') + '-press');
that.triggeredHand = NO_HAND; that.triggeredHand = NO_HAND;
that.pressedHand = NO_HAND; that.pressedHand = NO_HAND;
that.editingHand = NO_HAND;
that.triggered = function() { that.triggered = function() {
return that.triggeredHand !== NO_HAND; return that.triggeredHand !== NO_HAND;
}; };
@ -1115,6 +1116,11 @@ SelectionDisplay = (function() {
activeTool = hitTool; activeTool = hitTool;
that.clearDebugPickPlane(); that.clearDebugPickPlane();
if (activeTool.onBegin) { if (activeTool.onBegin) {
Messages.sendLocalMessage(HIFI_EDIT_MANIPULATION_CHANNEL, JSON.stringify({
action: "startEdit",
hand: that.triggeredHand
}));
that.editingHand = that.triggeredHand;
activeTool.onBegin(event, pickRay, results); activeTool.onBegin(event, pickRay, results);
} else { } else {
print("ERROR: entitySelectionTool.mousePressEvent - ActiveTool(" + activeTool.mode + ") missing onBegin"); print("ERROR: entitySelectionTool.mousePressEvent - ActiveTool(" + activeTool.mode + ") missing onBegin");
@ -1263,6 +1269,11 @@ SelectionDisplay = (function() {
if (wantDebug) { if (wantDebug) {
print(" Triggering ActiveTool(" + activeTool.mode + ")'s onEnd"); print(" Triggering ActiveTool(" + activeTool.mode + ")'s onEnd");
} }
Messages.sendLocalMessage(HIFI_EDIT_MANIPULATION_CHANNEL, JSON.stringify({
action: "finishEdit",
hand: that.editingHand
}));
that.editingHand = NO_HAND;
activeTool.onEnd(event); activeTool.onEnd(event);
} else if (wantDebug) { } else if (wantDebug) {
print(" ActiveTool(" + activeTool.mode + ")'s missing onEnd"); print(" ActiveTool(" + activeTool.mode + ")'s missing onEnd");