From 692fa52acaa3a8d1debeefa6932bd86907675613 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 18 Feb 2017 15:21:48 +1300 Subject: [PATCH] Disable drawing pointer lasers while painting --- .../controllers/handControllerPointer.js | 23 +++++++++++++++++-- scripts/system/fingerPaint.js | 8 ++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/scripts/system/controllers/handControllerPointer.js b/scripts/system/controllers/handControllerPointer.js index 6bebbf0498..f8a336a017 100644 --- a/scripts/system/controllers/handControllerPointer.js +++ b/scripts/system/controllers/handControllerPointer.js @@ -480,6 +480,10 @@ var LASER_SEARCH_COLOR_XYZW = {x: 10 / 255, y: 10 / 255, z: 255 / 255, w: LASER_ var LASER_TRIGGER_COLOR_XYZW = {x: 250 / 255, y: 10 / 255, z: 10 / 255, w: LASER_ALPHA}; var SYSTEM_LASER_DIRECTION = {x: 0, y: 0, z: -1}; var systemLaserOn = false; + +var HIFI_POINTER_DISABLE_MESSAGE_CHANNEL = "Hifi-Pointer-Disable"; +var isPointerEnabled = true; + function clearSystemLaser() { if (!systemLaserOn) { return; @@ -542,9 +546,8 @@ function update() { return off(); } - // If there's a HUD element at the (newly moved) reticle, just make it visible and bail. - if (isPointingAtOverlay(hudPoint2d)) { + if (isPointingAtOverlay(hudPoint2d) && isPointerEnabled) { if (HMD.active) { Reticle.depth = hudReticleDistance(); @@ -579,9 +582,25 @@ function checkSettings() { } checkSettings(); +// Enable/disable pointer. +function handleMessages(channel, message, sender) { + if (sender === MyAvatar.sessionUUID && channel === HIFI_POINTER_DISABLE_MESSAGE_CHANNEL) { + var data = JSON.parse(message); + if (data.pointerEnabled !== undefined) { + print("pointerEnabled: " + data.pointerEnabled); + isPointerEnabled = data.pointerEnabled; + } + } +} + +Messages.subscribe(HIFI_POINTER_DISABLE_MESSAGE_CHANNEL); +Messages.messageReceived.connect(handleMessages); + var settingsChecker = Script.setInterval(checkSettings, SETTINGS_CHANGE_RECHECK_INTERVAL); Script.update.connect(update); Script.scriptEnding.connect(function () { + Messages.unsubscribe(HIFI_POINTER_DISABLE_MESSAGE_CHANNEL); + Messages.messageReceived.disconnect(handleMessages); Script.clearInterval(settingsChecker); Script.update.disconnect(update); OffscreenFlags.navigationFocusDisabled = false; diff --git a/scripts/system/fingerPaint.js b/scripts/system/fingerPaint.js index 725c04f876..4824f777aa 100644 --- a/scripts/system/fingerPaint.js +++ b/scripts/system/fingerPaint.js @@ -20,7 +20,8 @@ CONTROLLER_MAPPING_NAME = "com.highfidelity.fingerPaint", isTabletDisplayed = false, HIFI_POINT_INDEX_MESSAGE_CHANNEL = "Hifi-Point-Index", - HIFI_GRAB_DISABLE_MESSAGE_CHANNEL = "Hifi-Grab-Disable"; + HIFI_GRAB_DISABLE_MESSAGE_CHANNEL = "Hifi-Grab-Disable", + HIFI_POINTER_DISABLE_MESSAGE_CHANNEL = "Hifi-Pointer-Disable"; function paintBrush(name) { // Paints in 3D. @@ -318,6 +319,9 @@ nearGrabEnabled: enabled, farGrabEnabled: enabled })); + Messages.sendMessage(HIFI_POINTER_DISABLE_MESSAGE_CHANNEL, JSON.stringify({ + pointerEnabled: enabled + })); Messages.sendMessage(HIFI_POINT_INDEX_MESSAGE_CHANNEL, JSON.stringify({ pointIndex: !enabled })); @@ -386,6 +390,7 @@ // Messages channels for enabling/disabling other scripts' functions. Messages.subscribe(HIFI_POINT_INDEX_MESSAGE_CHANNEL); Messages.subscribe(HIFI_GRAB_DISABLE_MESSAGE_CHANNEL); + Messages.subscribe(HIFI_POINTER_DISABLE_MESSAGE_CHANNEL); } function tearDown() { @@ -418,6 +423,7 @@ Messages.unsubscribe(HIFI_POINT_INDEX_MESSAGE_CHANNEL); Messages.unsubscribe(HIFI_GRAB_DISABLE_MESSAGE_CHANNEL); + Messages.unssubscribe(HIFI_POINTER_DISABLE_MESSAGE_CHANNEL); } setUp();