mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Make Create not grab tablet if editing an entity with hand
This commit is contained in:
parent
5729d35c48
commit
0eead13fb9
3 changed files with 47 additions and 5 deletions
|
@ -9,7 +9,7 @@
|
|||
/* global Script, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, getControllerJointIndex,
|
||||
enableDispatcherModule, disableDispatcherModule, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION,
|
||||
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");
|
||||
|
@ -172,10 +172,14 @@ Script.include("/~/system/libraries/utils.js");
|
|||
return null;
|
||||
};
|
||||
|
||||
this.isEditing = false;
|
||||
this.setIsEditing = function (editing) {
|
||||
this.isEditing = editing;
|
||||
};
|
||||
|
||||
this.isReady = 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.robbed = false;
|
||||
return makeRunningValues(false, [], []);
|
||||
}
|
||||
|
@ -198,7 +202,8 @@ Script.include("/~/system/libraries/utils.js");
|
|||
};
|
||||
|
||||
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.robbed = false;
|
||||
return makeRunningValues(false, [], []);
|
||||
|
@ -226,6 +231,28 @@ Script.include("/~/system/libraries/utils.js");
|
|||
enableDispatcherModule("LeftNearParentingGrabOverlay", leftNearParentingGrabOverlay);
|
||||
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() {
|
||||
leftNearParentingGrabOverlay.cleanup();
|
||||
rightNearParentingGrabOverlay.cleanup();
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
HAPTIC_PULSE_DURATION:true,
|
||||
DISPATCHER_HOVERING_LIST:true,
|
||||
DISPATCHER_HOVERING_STYLE:true,
|
||||
HIFI_EDIT_MANIPULATION_CHANNEL:true,
|
||||
Entities,
|
||||
makeDispatcherModuleParameters:true,
|
||||
makeRunningValues:true,
|
||||
|
@ -149,6 +150,8 @@ DISPATCHER_PROPERTIES = [
|
|||
"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
|
||||
// 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
|
||||
|
@ -590,6 +593,7 @@ if (typeof module !== 'undefined') {
|
|||
TRIGGER_OFF_VALUE: TRIGGER_OFF_VALUE,
|
||||
TRIGGER_ON_VALUE: TRIGGER_ON_VALUE,
|
||||
DISPATCHER_HOVERING_LIST: DISPATCHER_HOVERING_LIST,
|
||||
HIFI_EDIT_MANIPULATION_CHANNEL: HIFI_EDIT_MANIPULATION_CHANNEL,
|
||||
worldPositionToRegistrationFrameMatrix: worldPositionToRegistrationFrameMatrix
|
||||
};
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
//
|
||||
|
||||
/* 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_WORLD = "world";
|
||||
|
@ -983,6 +983,7 @@ SelectionDisplay = (function() {
|
|||
that.triggerPressMapping = Controller.newMapping(Script.resolvePath('') + '-press');
|
||||
that.triggeredHand = NO_HAND;
|
||||
that.pressedHand = NO_HAND;
|
||||
that.editingHand = NO_HAND;
|
||||
that.triggered = function() {
|
||||
return that.triggeredHand !== NO_HAND;
|
||||
};
|
||||
|
@ -1115,6 +1116,11 @@ SelectionDisplay = (function() {
|
|||
activeTool = hitTool;
|
||||
that.clearDebugPickPlane();
|
||||
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);
|
||||
} else {
|
||||
print("ERROR: entitySelectionTool.mousePressEvent - ActiveTool(" + activeTool.mode + ") missing onBegin");
|
||||
|
@ -1263,6 +1269,11 @@ SelectionDisplay = (function() {
|
|||
if (wantDebug) {
|
||||
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);
|
||||
} else if (wantDebug) {
|
||||
print(" ActiveTool(" + activeTool.mode + ")'s missing onEnd");
|
||||
|
|
Loading…
Reference in a new issue