From 9240672c9d80ca4d636bd93733fcde49912f0422 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 25 Jul 2016 13:06:09 -0700 Subject: [PATCH 01/27] change distance hold origin --- scripts/system/controllers/handControllerGrab.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index bfdb26a2bb..5079c093df 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -61,9 +61,9 @@ var DISTANCE_HOLDING_UNITY_DISTANCE = 6; // The distance at which the distance var MOVE_WITH_HEAD = true; // experimental head-control of distantly held objects var COLORS_GRAB_SEARCHING_HALF_SQUEEZE = { - red: 255, - green: 97, - blue: 129 + red: 161, + green: 108, + blue: 238 }; var COLORS_GRAB_SEARCHING_FULL_SQUEEZE = { @@ -1518,7 +1518,10 @@ function MyController(hand) { // visualizations - this.overlayLineOn(handPosition, grabbedProperties.position, COLORS_GRAB_DISTANCE_HOLD); + var rayPickInfo = this.calcRayPickInfo(this.hand); + // this.searchIndicatorOn(rayPickInfo.searchRay); + + this.overlayLineOn(rayPickInfo.searchRay.origin, grabbedProperties.position, COLORS_GRAB_DISTANCE_HOLD); var distanceToObject = Vec3.length(Vec3.subtract(MyAvatar.position, this.currentObjectPosition)); var success = Entities.updateAction(this.grabbedEntity, this.actionID, { From 05e3a8613ad5f86034f0a6ac8559633b394767bb Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 25 Jul 2016 16:28:47 -0700 Subject: [PATCH 02/27] colors back to blue and red --- scripts/system/controllers/handControllerGrab.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 5079c093df..95cc7be405 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -61,15 +61,15 @@ var DISTANCE_HOLDING_UNITY_DISTANCE = 6; // The distance at which the distance var MOVE_WITH_HEAD = true; // experimental head-control of distantly held objects var COLORS_GRAB_SEARCHING_HALF_SQUEEZE = { - red: 161, - green: 108, - blue: 238 + red: 10, + green: 10, + blue: 255 }; var COLORS_GRAB_SEARCHING_FULL_SQUEEZE = { - red: 255, - green: 97, - blue: 129 + red: 250, + green: 10, + blue: 10 }; var COLORS_GRAB_DISTANCE_HOLD = { From 6a72fe7df4c75dd41fd510c8277ee6a63c47e901 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 25 Jul 2016 16:58:59 -0700 Subject: [PATCH 03/27] cleanup --- scripts/system/controllers/handControllerGrab.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 95cc7be405..00c37bd074 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1519,7 +1519,6 @@ function MyController(hand) { // visualizations var rayPickInfo = this.calcRayPickInfo(this.hand); - // this.searchIndicatorOn(rayPickInfo.searchRay); this.overlayLineOn(rayPickInfo.searchRay.origin, grabbedProperties.position, COLORS_GRAB_DISTANCE_HOLD); From a7b8f2c9df45ed22a10198e9886f3834938d42b1 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 2 Aug 2016 12:25:24 -0700 Subject: [PATCH 04/27] updates --- interface/resources/controllers/hydra.json | 3 +- .../resources/controllers/oculus_touch.json | 4 +- .../system/controllers/handControllerGrab.js | 4 +- scripts/system/controllers/teleport.js | 103 ++++++++++++++---- 4 files changed, 90 insertions(+), 24 deletions(-) diff --git a/interface/resources/controllers/hydra.json b/interface/resources/controllers/hydra.json index 716d283a86..8fffe3a922 100644 --- a/interface/resources/controllers/hydra.json +++ b/interface/resources/controllers/hydra.json @@ -26,8 +26,7 @@ { "from": [ "Hydra.L1", "Hydra.L3" ], "to": "Standard.LeftPrimaryThumb" }, { "from": [ "Hydra.R1", "Hydra.R3" ], "to": "Standard.RightPrimaryThumb" }, - { "from": [ "Hydra.R2", "Hydra.R4" ], "to": "Standard.RightSecondaryThumb" }, - { "from": [ "Hydra.L2", "Hydra.L4" ], "to": "Standard.LeftSecondaryThumb" }, + { "from": "Hydra.LeftHand", "to": "Standard.LeftHand" }, { "from": "Hydra.RightHand", "to": "Standard.RightHand" } diff --git a/interface/resources/controllers/oculus_touch.json b/interface/resources/controllers/oculus_touch.json index 001d5b8716..6fc7daf1f8 100644 --- a/interface/resources/controllers/oculus_touch.json +++ b/interface/resources/controllers/oculus_touch.json @@ -3,8 +3,8 @@ "channels": [ { "from": "OculusTouch.A", "to": "Standard.RightPrimaryThumb" }, { "from": "OculusTouch.B", "to": "Standard.RightSecondaryThumb" }, - { "from": "OculusTouch.X", "to": "Standard.LeftPrimaryThumb" }, - { "from": "OculusTouch.Y", "to": "Standard.LeftSecondaryThumb" }, + // { "from": "OculusTouch.X", "to": "Standard.LeftPrimaryThumb" }, + // { "from": "OculusTouch.Y", "to": "Standard.LeftSecondaryThumb" }, { "from": "OculusTouch.LY", "filters": "invert", "to": "Standard.LY" }, { "from": "OculusTouch.LX", "to": "Standard.LX" }, diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 00c37bd074..53ed7e91c9 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1365,7 +1365,7 @@ function MyController(hand) { }; this.distanceHoldingEnter = function() { - + Messages.sendLocalMessage('Hifi-Teleport-Disabler','disable'); this.clearEquipHaptics(); // controller pose is in avatar frame @@ -1620,6 +1620,7 @@ function MyController(hand) { }; this.nearGrabbingEnter = function() { + Messages.sendLocalMessage('Hifi-Teleport-Disabler','disable'); this.lineOff(); this.overlayLineOff(); @@ -1947,6 +1948,7 @@ function MyController(hand) { }; this.release = function() { + Messages.sendLocalMessage('Hifi-Teleport-Disabler','enable'); this.turnOffVisualizations(); var noVelocity = false; diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index ca8891f6ab..33ec226c94 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -239,19 +239,22 @@ function Teleporter() { this.update = function() { + if (isDisabled) { + return; + } if (teleporter.teleportHand === 'left') { teleporter.leftRay(); - - if ((leftPad.buttonValue === 0 || leftTrigger.buttonValue === 0) && inTeleportMode === true) { + //|| leftTrigger.buttonValue === 0 + if ((leftPad.buttonValue === 0 ) && inTeleportMode === true) { _this.teleport(); return; } } else { teleporter.rightRay(); - - if ((rightPad.buttonValue === 0 || rightTrigger.buttonValue === 0) && inTeleportMode === true) { + //|| rightTrigger.buttonValue === 0 + if ((rightPad.buttonValue === 0 ) && inTeleportMode === true) { _this.teleport(); return; } @@ -570,8 +573,8 @@ var rightTrigger = new Trigger('right'); var mappingName, teleportMapping; -var TELEPORT_DELAY = 100; - +var activationTimeout = null; +var TELEPORT_DELAY = 800; function registerMappings() { mappingName = 'Hifi-Teleporter-Dev-' + Math.random(); @@ -582,22 +585,63 @@ function registerMappings() { teleportMapping.from(Controller.Standard.RightPrimaryThumb).peek().to(rightPad.buttonPress); teleportMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(leftPad.buttonPress); - teleportMapping.from(Controller.Standard.LeftPrimaryThumb).when(leftTrigger.down).to(function(value) { - teleporter.enterTeleportMode('left') + teleportMapping.from(Controller.Standard.LeftPrimaryThumb) + // .when(leftTrigger.down) + .to(function(value) { + if (isDisabled === true) { + return; + } + if (activationTimeout !== null) { + return + } + activationTimeout = Script.setTimeout(function() { + teleporter.enterTeleportMode('left') + Script.clearTimeout(activationTimeout); + activationTimeout = null; + }, TELEPORT_DELAY) return; }); - teleportMapping.from(Controller.Standard.RightPrimaryThumb).when(rightTrigger.down).to(function(value) { - teleporter.enterTeleportMode('right') - return; - }); - teleportMapping.from(Controller.Standard.RT).when(Controller.Standard.RightPrimaryThumb).to(function(value) { - teleporter.enterTeleportMode('right') - return; - }); - teleportMapping.from(Controller.Standard.LT).when(Controller.Standard.LeftPrimaryThumb).to(function(value) { - teleporter.enterTeleportMode('left') + teleportMapping.from(Controller.Standard.RightPrimaryThumb) + // .when(rightTrigger.down) + .to(function(value) { + if (isDisabled === true) { + return; + } + if (activationTimeout !== null) { + return + } + activationTimeout = Script.setTimeout(function() { + teleporter.enterTeleportMode('right') + Script.clearTimeout(activationTimeout); + activationTimeout = null; + }, TELEPORT_DELAY) return; }); + // teleportMapping.from(Controller.Standard.RT).when(Controller.Standard.RightPrimaryThumb).to(function(value) { + // if (isDisabled === true) { + // return; + // } + // if (activationTimeout !== null) { + // return + // } + // activationTimeout = Script.setTimeout(function() { + // teleporter.enterTeleportMode('right') + // Script.clearTimeout(activationTimeout); + // activationTimeout = null; + // }, TELEPORT_DELAY) + // return; + // }); + // teleportMapping.from(Controller.Standard.LT).when(Controller.Standard.LeftPrimaryThumb).to(function(value) { + // if (isDisabled === true) { + // return; + // } + // activationTimeout = Script.setTimeout(function() { + // teleporter.enterTeleportMode('left') + // Script.clearTimeout(activationTimeout); + // activationTimeout = null; + // }, TELEPORT_DELAY) + // return; + // }); } @@ -618,4 +662,25 @@ function cleanup() { if (teleporter.updateConnected !== null) { Script.update.disconnect(teleporter.update); } -} \ No newline at end of file +} + +var isDisabled = false; +var handleHandMessages = function(channel, message, sender) { + var data; + print('its a message') + if (sender === MyAvatar.sessionUUID) { + if (channel === 'Hifi-Teleport-Disabler') { + print('got teleport disabler message' + message) + if (message === 'disable') { + isDisabled = true; + } + if (message === 'enable') { + isDisabled = false; + } + + } + } +} + +Messages.subscribe('Hifi-Teleport-Disabler'); +Messages.messageReceived.connect(handleHandMessages); \ No newline at end of file From 7fae7e9c77e0a39f41bec7ad05d9e33b7f9283c7 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 2 Aug 2016 12:26:37 -0700 Subject: [PATCH 05/27] cleanup --- interface/resources/controllers/hydra.json | 4 +- scripts/system/controllers/teleport.js | 62 +++++++++++----------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/interface/resources/controllers/hydra.json b/interface/resources/controllers/hydra.json index 8fffe3a922..8eb33fef3b 100644 --- a/interface/resources/controllers/hydra.json +++ b/interface/resources/controllers/hydra.json @@ -26,8 +26,8 @@ { "from": [ "Hydra.L1", "Hydra.L3" ], "to": "Standard.LeftPrimaryThumb" }, { "from": [ "Hydra.R1", "Hydra.R3" ], "to": "Standard.RightPrimaryThumb" }, - - + { "from": [ "Hydra.R2", "Hydra.R4" ], "to": "Standard.RightSecondaryThumb" }, + { "from": [ "Hydra.L2", "Hydra.L4" ], "to": "Standard.LeftSecondaryThumb" }, { "from": "Hydra.LeftHand", "to": "Standard.LeftHand" }, { "from": "Hydra.RightHand", "to": "Standard.RightHand" } ] diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index 33ec226c94..433bca9379 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -246,7 +246,7 @@ function Teleporter() { if (teleporter.teleportHand === 'left') { teleporter.leftRay(); //|| leftTrigger.buttonValue === 0 - if ((leftPad.buttonValue === 0 ) && inTeleportMode === true) { + if ((leftPad.buttonValue === 0) && inTeleportMode === true) { _this.teleport(); return; } @@ -254,7 +254,7 @@ function Teleporter() { } else { teleporter.rightRay(); //|| rightTrigger.buttonValue === 0 - if ((rightPad.buttonValue === 0 ) && inTeleportMode === true) { + if ((rightPad.buttonValue === 0) && inTeleportMode === true) { _this.teleport(); return; } @@ -586,37 +586,37 @@ function registerMappings() { teleportMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(leftPad.buttonPress); teleportMapping.from(Controller.Standard.LeftPrimaryThumb) - // .when(leftTrigger.down) - .to(function(value) { - if (isDisabled === true) { + // .when(leftTrigger.down) + .to(function(value) { + if (isDisabled === true) { + return; + } + if (activationTimeout !== null) { + return + } + activationTimeout = Script.setTimeout(function() { + teleporter.enterTeleportMode('left') + Script.clearTimeout(activationTimeout); + activationTimeout = null; + }, TELEPORT_DELAY) return; - } - if (activationTimeout !== null) { - return - } - activationTimeout = Script.setTimeout(function() { - teleporter.enterTeleportMode('left') - Script.clearTimeout(activationTimeout); - activationTimeout = null; - }, TELEPORT_DELAY) - return; - }); + }); teleportMapping.from(Controller.Standard.RightPrimaryThumb) - // .when(rightTrigger.down) - .to(function(value) { - if (isDisabled === true) { + // .when(rightTrigger.down) + .to(function(value) { + if (isDisabled === true) { + return; + } + if (activationTimeout !== null) { + return + } + activationTimeout = Script.setTimeout(function() { + teleporter.enterTeleportMode('right') + Script.clearTimeout(activationTimeout); + activationTimeout = null; + }, TELEPORT_DELAY) return; - } - if (activationTimeout !== null) { - return - } - activationTimeout = Script.setTimeout(function() { - teleporter.enterTeleportMode('right') - Script.clearTimeout(activationTimeout); - activationTimeout = null; - }, TELEPORT_DELAY) - return; - }); + }); // teleportMapping.from(Controller.Standard.RT).when(Controller.Standard.RightPrimaryThumb).to(function(value) { // if (isDisabled === true) { // return; @@ -667,10 +667,8 @@ function cleanup() { var isDisabled = false; var handleHandMessages = function(channel, message, sender) { var data; - print('its a message') if (sender === MyAvatar.sessionUUID) { if (channel === 'Hifi-Teleport-Disabler') { - print('got teleport disabler message' + message) if (message === 'disable') { isDisabled = true; } From 41aa485f11f3511a7fc25398996ed53cf9703ce3 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 2 Aug 2016 12:52:35 -0700 Subject: [PATCH 06/27] one hand teleprt --- .../system/controllers/handControllerGrab.js | 12 +++++++--- scripts/system/controllers/teleport.js | 24 ++++++++++++++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index ab386aa735..4458679742 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1378,7 +1378,7 @@ function MyController(hand) { }; this.distanceHoldingEnter = function() { - Messages.sendLocalMessage('Hifi-Teleport-Disabler','disable'); + Messages.sendLocalMessage('Hifi-Teleport-Disabler','both'); this.clearEquipHaptics(); // controller pose is in avatar frame @@ -1636,8 +1636,14 @@ function MyController(hand) { }; this.nearGrabbingEnter = function() { - Messages.sendLocalMessage('Hifi-Teleport-Disabler','disable'); + if (this.hand === 0) { + Messages.sendLocalMessage('Hifi-Teleport-Disabler', 'left'); + } + if (this.hand === 1) { + Messages.sendLocalMessage('Hifi-Teleport-Disabler', 'right'); + + } this.lineOff(); this.overlayLineOff(); @@ -1964,7 +1970,7 @@ function MyController(hand) { }; this.release = function() { - Messages.sendLocalMessage('Hifi-Teleport-Disabler','enable'); + Messages.sendLocalMessage('Hifi-Teleport-Disabler','none'); this.turnOffVisualizations(); var noVelocity = false; diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index 433bca9379..d32eb77d34 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -239,11 +239,14 @@ function Teleporter() { this.update = function() { - if (isDisabled) { + if (isDisabled === 'both') { return; } if (teleporter.teleportHand === 'left') { + if (isDisabled === 'left') { + return; + } teleporter.leftRay(); //|| leftTrigger.buttonValue === 0 if ((leftPad.buttonValue === 0) && inTeleportMode === true) { @@ -252,6 +255,9 @@ function Teleporter() { } } else { + if (isDisabled === 'right') { + return; + } teleporter.rightRay(); //|| rightTrigger.buttonValue === 0 if ((rightPad.buttonValue === 0) && inTeleportMode === true) { @@ -588,7 +594,7 @@ function registerMappings() { teleportMapping.from(Controller.Standard.LeftPrimaryThumb) // .when(leftTrigger.down) .to(function(value) { - if (isDisabled === true) { + if (isDisabled === 'left' || isDisabled === 'both') { return; } if (activationTimeout !== null) { @@ -604,7 +610,7 @@ function registerMappings() { teleportMapping.from(Controller.Standard.RightPrimaryThumb) // .when(rightTrigger.down) .to(function(value) { - if (isDisabled === true) { + if (isDisabled === 'right' || isDisabled === 'both') { return; } if (activationTimeout !== null) { @@ -669,10 +675,16 @@ var handleHandMessages = function(channel, message, sender) { var data; if (sender === MyAvatar.sessionUUID) { if (channel === 'Hifi-Teleport-Disabler') { - if (message === 'disable') { - isDisabled = true; + if (message === 'both') { + isDisabled = 'both'; } - if (message === 'enable') { + if (message === 'left') { + isDisabled = 'left'; + } + if (message === 'right') { + isDisabled = 'right' + } + if (message === 'none') { isDisabled = false; } From f6984aaff80f81bd469661bdcd3b7162fe8605d6 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 2 Aug 2016 14:42:21 -0700 Subject: [PATCH 07/27] clear timeout one more place --- .../controllers/handControllerPointer.js | 24 +++++++++++++++++++ scripts/system/controllers/teleport.js | 4 +++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/handControllerPointer.js b/scripts/system/controllers/handControllerPointer.js index dab6438efa..3f1fbb27de 100644 --- a/scripts/system/controllers/handControllerPointer.js +++ b/scripts/system/controllers/handControllerPointer.js @@ -509,3 +509,27 @@ Script.scriptEnding.connect(function () { OffscreenFlags.navigationFocusDisabled = false; }); +var isDisabled = false; +var handleHandMessages = function(channel, message, sender) { + var data; + if (sender === MyAvatar.sessionUUID) { + if (channel === 'Hifi-Hand-Pointer-Disabler') { + if (message === 'both') { + isDisabled = 'both'; + } + if (message === 'left') { + isDisabled = 'left'; + } + if (message === 'right') { + isDisabled = 'right' + } + if (message === 'none') { + isDisabled = false; + } + + } + } +} + +Messages.subscribe('Hifi-Hand-Pointer-Disabler'); +Messages.messageReceived.connect(handleHandMessages); \ No newline at end of file diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index d32eb77d34..d8c56b36ca 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -221,13 +221,15 @@ function Teleporter() { } this.exitTeleportMode = function(value) { + if(activationTimeout!==null){ + Script.clearTimeout(activationTimeout); + } if (this.updateConnected === true) { Script.update.disconnect(this.update); } this.disableMappings(); this.turnOffOverlayBeams(); - this.updateConnected = null; Script.setTimeout(function() { From ca3a194454fae57465d280034ff7b13e92833f78 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Tue, 2 Aug 2016 11:39:22 -0700 Subject: [PATCH 08/27] implment coded renegotiation in client if for some reason unexpected audio codecs come in to inbound stream --- .../src/audio/AudioMixerClientData.cpp | 7 ++++++- .../src/audio/AudioMixerClientData.h | 1 + libraries/audio-client/src/AudioClient.cpp | 17 ++++++++++++++++- libraries/audio-client/src/AudioClient.h | 2 ++ libraries/audio/src/InboundAudioStream.cpp | 2 +- libraries/audio/src/InboundAudioStream.h | 2 +- 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/assignment-client/src/audio/AudioMixerClientData.cpp b/assignment-client/src/audio/AudioMixerClientData.cpp index 85491537a2..0a45137da6 100644 --- a/assignment-client/src/audio/AudioMixerClientData.cpp +++ b/assignment-client/src/audio/AudioMixerClientData.cpp @@ -113,7 +113,7 @@ int AudioMixerClientData::parseData(ReceivedMessage& message) { avatarAudioStream->setupCodec(_codec, _selectedCodecName, AudioConstants::MONO); qDebug() << "creating new AvatarAudioStream... codec:" << _selectedCodecName; - connect(avatarAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioMixerClientData::sendSelectAudioFormat); + connect(avatarAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioMixerClientData::handleMismatchAudioFormat); auto emplaced = _audioStreams.emplace( QUuid(), @@ -345,6 +345,11 @@ QJsonObject AudioMixerClientData::getAudioStreamStats() { return result; } +void AudioMixerClientData::handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec) { + qDebug() << __FUNCTION__ << "sendingNode:" << *node << "currentCodec:" << currentCodec << "recievedCodec:" << recievedCodec; + sendSelectAudioFormat(node, currentCodec); +} + void AudioMixerClientData::sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName) { auto replyPacket = NLPacket::create(PacketType::SelectedAudioFormat); replyPacket->writeString(selectedCodecName); diff --git a/assignment-client/src/audio/AudioMixerClientData.h b/assignment-client/src/audio/AudioMixerClientData.h index babfae3539..106841ee03 100644 --- a/assignment-client/src/audio/AudioMixerClientData.h +++ b/assignment-client/src/audio/AudioMixerClientData.h @@ -84,6 +84,7 @@ signals: void injectorStreamFinished(const QUuid& streamIdentifier); public slots: + void handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec); void sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName); private: diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index ac42de903d..398f4bb27c 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -119,6 +119,9 @@ AudioClient::AudioClient() : this, &AudioClient::processReceivedSamples, Qt::DirectConnection); connect(this, &AudioClient::changeDevice, this, [=](const QAudioDeviceInfo& outputDeviceInfo) { switchOutputToAudioDevice(outputDeviceInfo); }); + connect(&_receivedAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioClient::handleMismatchAudioFormat); + + _inputDevices = getDeviceNames(QAudio::AudioInput); _outputDevices = getDeviceNames(QAudio::AudioOutput); @@ -147,6 +150,12 @@ AudioClient::~AudioClient() { } } +void AudioClient::handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec) { + qDebug() << __FUNCTION__ << "sendingNode:" << *node << "currentCodec:" << currentCodec << "recievedCodec:" << recievedCodec; + selectAudioFormat(recievedCodec); +} + + void AudioClient::reset() { _receivedAudioStream.reset(); _stats.reset(); @@ -532,7 +541,13 @@ void AudioClient::negotiateAudioFormat() { } void AudioClient::handleSelectedAudioFormat(QSharedPointer message) { - _selectedCodecName = message->readString(); + QString selectedCodecName = message->readString(); + selectAudioFormat(selectedCodecName); +} + +void AudioClient::selectAudioFormat(const QString& selectedCodecName) { + + _selectedCodecName = selectedCodecName; qDebug() << "Selected Codec:" << _selectedCodecName; diff --git a/libraries/audio-client/src/AudioClient.h b/libraries/audio-client/src/AudioClient.h index 472092163b..171014edda 100644 --- a/libraries/audio-client/src/AudioClient.h +++ b/libraries/audio-client/src/AudioClient.h @@ -104,6 +104,7 @@ public: }; void negotiateAudioFormat(); + void selectAudioFormat(const QString& selectedCodecName); const MixedProcessedAudioStream& getReceivedAudioStream() const { return _receivedAudioStream; } MixedProcessedAudioStream& getReceivedAudioStream() { return _receivedAudioStream; } @@ -153,6 +154,7 @@ public slots: void handleNoisyMutePacket(QSharedPointer message); void handleMuteEnvironmentPacket(QSharedPointer message); void handleSelectedAudioFormat(QSharedPointer message); + void handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec); void sendDownstreamAudioStatsPacket() { _stats.sendDownstreamAudioStatsPacket(); } void handleAudioInput(); diff --git a/libraries/audio/src/InboundAudioStream.cpp b/libraries/audio/src/InboundAudioStream.cpp index de05abaa88..b908f57439 100644 --- a/libraries/audio/src/InboundAudioStream.cpp +++ b/libraries/audio/src/InboundAudioStream.cpp @@ -147,7 +147,7 @@ int InboundAudioStream::parseData(ReceivedMessage& message) { writeDroppableSilentSamples(networkSamples); // inform others of the mismatch auto sendingNode = DependencyManager::get()->nodeWithUUID(message.getSourceID()); - emit mismatchedAudioCodec(sendingNode, _selectedCodecName); + emit mismatchedAudioCodec(sendingNode, _selectedCodecName, codecInPacket); } } break; diff --git a/libraries/audio/src/InboundAudioStream.h b/libraries/audio/src/InboundAudioStream.h index af79ff6164..1290d43ef8 100644 --- a/libraries/audio/src/InboundAudioStream.h +++ b/libraries/audio/src/InboundAudioStream.h @@ -182,7 +182,7 @@ public: void cleanupCodec(); signals: - void mismatchedAudioCodec(SharedNodePointer sendingNode, const QString& desiredCodec); + void mismatchedAudioCodec(SharedNodePointer sendingNode, const QString& currentCodec, const QString& recievedCodec); public slots: /// This function should be called every second for all the stats to function properly. If dynamic jitter buffers From 03a47af628a02a7b27dd01543a5a2c44d77d3e4a Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 2 Aug 2016 15:38:04 -0700 Subject: [PATCH 09/27] if the HMD isn't on someone's head, don't take input from the controllers --- plugins/oculus/src/OculusControllerManager.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/oculus/src/OculusControllerManager.cpp b/plugins/oculus/src/OculusControllerManager.cpp index b3b1b20b2b..1916326ad5 100644 --- a/plugins/oculus/src/OculusControllerManager.cpp +++ b/plugins/oculus/src/OculusControllerManager.cpp @@ -179,6 +179,13 @@ void OculusControllerManager::RemoteDevice::focusOutEvent() { } void OculusControllerManager::TouchDevice::update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) { + ovrSessionStatus status; + if (OVR_SUCCESS(ovr_GetSessionStatus(_parent._session, &status)) && + (ovrFalse == status.HmdMounted)) { + // if the HMD isn't on someone's head, don't take input from the controllers + return; + } + _poseStateMap.clear(); _buttonPressedMap.clear(); From d00c1f62fcecca4385f45e624cf3d1f3d43af7be Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 2 Aug 2016 15:40:19 -0700 Subject: [PATCH 10/27] fixes --- .../controllers/handControllerPointer.js | 25 ---------- scripts/system/controllers/teleport.js | 50 ++++++++----------- 2 files changed, 21 insertions(+), 54 deletions(-) diff --git a/scripts/system/controllers/handControllerPointer.js b/scripts/system/controllers/handControllerPointer.js index 3f1fbb27de..4d6e9d7f60 100644 --- a/scripts/system/controllers/handControllerPointer.js +++ b/scripts/system/controllers/handControllerPointer.js @@ -508,28 +508,3 @@ Script.scriptEnding.connect(function () { Script.clearInterval(settingsChecker); OffscreenFlags.navigationFocusDisabled = false; }); - -var isDisabled = false; -var handleHandMessages = function(channel, message, sender) { - var data; - if (sender === MyAvatar.sessionUUID) { - if (channel === 'Hifi-Hand-Pointer-Disabler') { - if (message === 'both') { - isDisabled = 'both'; - } - if (message === 'left') { - isDisabled = 'left'; - } - if (message === 'right') { - isDisabled = 'right' - } - if (message === 'none') { - isDisabled = false; - } - - } - } -} - -Messages.subscribe('Hifi-Hand-Pointer-Disabler'); -Messages.messageReceived.connect(handleHandMessages); \ No newline at end of file diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index d8c56b36ca..84ef8fe815 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -64,6 +64,10 @@ function ThumbPad(hand) { this.buttonPress = function(value) { _thisPad.buttonValue = value; + if (value === 0) { + Script.clearTimeout(activationTimeout); + activationTimeout = null; + } }; } @@ -128,6 +132,9 @@ function Teleporter() { if (inTeleportMode === true) { return; } + if (isDisabled === 'both') { + return; + } inTeleportMode = true; if (this.smoothArrivalInterval !== null) { Script.clearInterval(this.smoothArrivalInterval); @@ -135,6 +142,9 @@ function Teleporter() { if (fadeSphereInterval !== null) { Script.clearInterval(fadeSphereInterval); } + if (activationTimeout !== null) { + Script.clearInterval(activationTimeout); + } this.teleportHand = hand; this.initialize(); Script.update.connect(this.update); @@ -221,8 +231,9 @@ function Teleporter() { } this.exitTeleportMode = function(value) { - if(activationTimeout!==null){ + if (activationTimeout !== null) { Script.clearTimeout(activationTimeout); + activationTimeout = null; } if (this.updateConnected === true) { Script.update.disconnect(this.update); @@ -230,6 +241,7 @@ function Teleporter() { this.disableMappings(); this.turnOffOverlayBeams(); + this.updateConnected = null; Script.setTimeout(function() { @@ -594,7 +606,6 @@ function registerMappings() { teleportMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(leftPad.buttonPress); teleportMapping.from(Controller.Standard.LeftPrimaryThumb) - // .when(leftTrigger.down) .to(function(value) { if (isDisabled === 'left' || isDisabled === 'both') { return; @@ -602,15 +613,18 @@ function registerMappings() { if (activationTimeout !== null) { return } + if (leftTrigger.down()) { + return; + } activationTimeout = Script.setTimeout(function() { - teleporter.enterTeleportMode('left') + Script.clearTimeout(activationTimeout); activationTimeout = null; + teleporter.enterTeleportMode('left') }, TELEPORT_DELAY) return; }); teleportMapping.from(Controller.Standard.RightPrimaryThumb) - // .when(rightTrigger.down) .to(function(value) { if (isDisabled === 'right' || isDisabled === 'both') { return; @@ -618,6 +632,9 @@ function registerMappings() { if (activationTimeout !== null) { return } + if (rightTrigger.down()) { + return; + } activationTimeout = Script.setTimeout(function() { teleporter.enterTeleportMode('right') Script.clearTimeout(activationTimeout); @@ -625,31 +642,6 @@ function registerMappings() { }, TELEPORT_DELAY) return; }); - // teleportMapping.from(Controller.Standard.RT).when(Controller.Standard.RightPrimaryThumb).to(function(value) { - // if (isDisabled === true) { - // return; - // } - // if (activationTimeout !== null) { - // return - // } - // activationTimeout = Script.setTimeout(function() { - // teleporter.enterTeleportMode('right') - // Script.clearTimeout(activationTimeout); - // activationTimeout = null; - // }, TELEPORT_DELAY) - // return; - // }); - // teleportMapping.from(Controller.Standard.LT).when(Controller.Standard.LeftPrimaryThumb).to(function(value) { - // if (isDisabled === true) { - // return; - // } - // activationTimeout = Script.setTimeout(function() { - // teleporter.enterTeleportMode('left') - // Script.clearTimeout(activationTimeout); - // activationTimeout = null; - // }, TELEPORT_DELAY) - // return; - // }); } From 8541d4bd41278e1ca4c85fc910d2dfe66f7cabe1 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 2 Aug 2016 15:41:28 -0700 Subject: [PATCH 11/27] small change to protect --- scripts/system/controllers/teleport.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index 84ef8fe815..4421b7151a 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -65,8 +65,11 @@ function ThumbPad(hand) { this.buttonPress = function(value) { _thisPad.buttonValue = value; if (value === 0) { - Script.clearTimeout(activationTimeout); - activationTimeout = null; + if (activationTimeout !== null) { + Script.clearTimeout(activationTimeout); + activationTimeout = null; + } + } }; From 3a2b0ffa08966805d852947cc6b8fbc596ffa6aa Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Wed, 3 Aug 2016 00:47:28 +0200 Subject: [PATCH 12/27] Fixes the handControllerGrab `Hifi-Hand-Grab` message. Was broken since the hotspot changes to handControllerGrab.js. --- scripts/system/controllers/handControllerGrab.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index c023278a3b..cca1c0838a 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1267,7 +1267,7 @@ function MyController(hand) { if (this.triggerSmoothedGrab()) { this.grabbedHotspot = potentialEquipHotspot; this.grabbedEntity = potentialEquipHotspot.entityID; - this.setState(STATE_HOLD, "eqipping '" + entityPropertiesCache.getProps(this.grabbedEntity).name + "'"); + this.setState(STATE_HOLD, "equipping '" + entityPropertiesCache.getProps(this.grabbedEntity).name + "'"); return; } } @@ -2354,9 +2354,20 @@ var handleHandMessages = function(channel, message, sender) { try { data = JSON.parse(message); var selectedController = (data.hand === 'left') ? leftController : rightController; + var hotspotIndex = data.hotspotIndex !== undefined ? parseInt(data.hotspotIndex) : 0; selectedController.release(); + var wearableEntity = data.entityID; + entityPropertiesCache.addEntity(wearableEntity); + selectedController.grabbedEntity = wearableEntity; + var hotspots = selectedController.collectEquipHotspots(selectedController.grabbedEntity); + if (hotspots.length > 0) { + if (hotspotIndex >= hotspots.length) { + hotspotIndex = 0; + } + selectedController.grabbedHotspot = hotspots[hotspotIndex]; + } selectedController.setState(STATE_HOLD, "Hifi-Hand-Grab msg received"); - selectedController.grabbedEntity = data.entityID; + selectedController.nearGrabbingEnter(); } catch (e) { print("WARNING: error parsing Hifi-Hand-Grab message"); From 8c43c122499bcdd1d22c660648b0908f06a876a8 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 2 Aug 2016 16:49:24 -0700 Subject: [PATCH 13/27] clear pose before short-circuiting update --- plugins/oculus/src/OculusControllerManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/oculus/src/OculusControllerManager.cpp b/plugins/oculus/src/OculusControllerManager.cpp index 1916326ad5..e13637c435 100644 --- a/plugins/oculus/src/OculusControllerManager.cpp +++ b/plugins/oculus/src/OculusControllerManager.cpp @@ -179,6 +179,9 @@ void OculusControllerManager::RemoteDevice::focusOutEvent() { } void OculusControllerManager::TouchDevice::update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) { + _poseStateMap.clear(); + _buttonPressedMap.clear(); + ovrSessionStatus status; if (OVR_SUCCESS(ovr_GetSessionStatus(_parent._session, &status)) && (ovrFalse == status.HmdMounted)) { @@ -186,9 +189,6 @@ void OculusControllerManager::TouchDevice::update(float deltaTime, const control return; } - _poseStateMap.clear(); - _buttonPressedMap.clear(); - int numTrackedControllers = 0; static const auto REQUIRED_HAND_STATUS = ovrStatus_OrientationTracked & ovrStatus_PositionTracked; auto tracking = ovr_GetTrackingState(_parent._session, 0, false); From 1ce7623f413c351c5c455f9e4b8b9b44f4c6e128 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 2 Aug 2016 18:19:58 -0700 Subject: [PATCH 14/27] added deadzones to oculus touch movements --- .../resources/controllers/oculus_touch.json | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/interface/resources/controllers/oculus_touch.json b/interface/resources/controllers/oculus_touch.json index 001d5b8716..755a709050 100644 --- a/interface/resources/controllers/oculus_touch.json +++ b/interface/resources/controllers/oculus_touch.json @@ -6,8 +6,17 @@ { "from": "OculusTouch.X", "to": "Standard.LeftPrimaryThumb" }, { "from": "OculusTouch.Y", "to": "Standard.LeftSecondaryThumb" }, - { "from": "OculusTouch.LY", "filters": "invert", "to": "Standard.LY" }, - { "from": "OculusTouch.LX", "to": "Standard.LX" }, + { "from": "OculusTouch.LY", "to": "Standard.LY", + "filters": [ + { "type": "deadZone", "min": 0.05 }, + "invert" + ] + }, + { "from": "OculusTouch.LX", "to": "Standard.LX", + "filters": [ + { "type": "deadZone", "min": 0.05 } + ] + }, { "from": "OculusTouch.LT", "to": "Standard.LTClick", "peek": true, "filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ] @@ -17,8 +26,17 @@ { "from": "OculusTouch.LeftGrip", "to": "Standard.LeftGrip" }, { "from": "OculusTouch.LeftHand", "to": "Standard.LeftHand" }, - { "from": "OculusTouch.RY", "filters": "invert", "to": "Standard.RY" }, - { "from": "OculusTouch.RX", "to": "Standard.RX" }, + { "from": "OculusTouch.RY", "to": "Standard.RY", + "filters": [ + { "type": "deadZone", "min": 0.05 }, + "invert" + ] + }, + { "from": "OculusTouch.RX", "to": "Standard.RX", + "filters": [ + { "type": "deadZone", "min": 0.05 } + ] + }, { "from": "OculusTouch.RT", "to": "Standard.RTClick", "peek": true, "filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ] From 88ebeaa4cb22782236df68375b851dd22b2edeee Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 2 Aug 2016 18:46:47 -0700 Subject: [PATCH 15/27] start no movement mode. using actual keys since avatar speed doesnt work with gtting stuck --- .../resources/controllers/oculus_touch.json | 4 +- .../controllers/handControllerPointer.js | 144 +++++++++++++----- scripts/system/controllers/teleport.js | 50 +++++- 3 files changed, 157 insertions(+), 41 deletions(-) diff --git a/interface/resources/controllers/oculus_touch.json b/interface/resources/controllers/oculus_touch.json index 6fc7daf1f8..aa709de77d 100644 --- a/interface/resources/controllers/oculus_touch.json +++ b/interface/resources/controllers/oculus_touch.json @@ -2,9 +2,7 @@ "name": "Oculus Touch to Standard", "channels": [ { "from": "OculusTouch.A", "to": "Standard.RightPrimaryThumb" }, - { "from": "OculusTouch.B", "to": "Standard.RightSecondaryThumb" }, - // { "from": "OculusTouch.X", "to": "Standard.LeftPrimaryThumb" }, - // { "from": "OculusTouch.Y", "to": "Standard.LeftSecondaryThumb" }, + { "from": "OculusTouch.X", "to": "Standard.LeftPrimaryThumb" }, { "from": "OculusTouch.LY", "filters": "invert", "to": "Standard.LY" }, { "from": "OculusTouch.LX", "to": "Standard.LX" }, diff --git a/scripts/system/controllers/handControllerPointer.js b/scripts/system/controllers/handControllerPointer.js index 4d6e9d7f60..fe561e0dd0 100644 --- a/scripts/system/controllers/handControllerPointer.js +++ b/scripts/system/controllers/handControllerPointer.js @@ -23,12 +23,12 @@ // UTILITIES ------------- // -function ignore() { } +function ignore() {} // Utility to make it easier to setup and disconnect cleanly. function setupHandler(event, handler) { event.connect(handler); - Script.scriptEnding.connect(function () { + Script.scriptEnding.connect(function() { event.disconnect(handler); }); } @@ -36,10 +36,10 @@ function setupHandler(event, handler) { // If some capability is not available until expiration milliseconds after the last update. function TimeLock(expiration) { var last = 0; - this.update = function (optionalNow) { + this.update = function(optionalNow) { last = optionalNow || Date.now(); }; - this.expired = function (optionalNow) { + this.expired = function(optionalNow) { return ((optionalNow || Date.now()) - last) > expiration; }; } @@ -52,13 +52,17 @@ function Trigger(label) { that.label = label; that.TRIGGER_SMOOTH_RATIO = 0.1; // Time averaging of trigger - 0.0 disables smoothing that.TRIGGER_OFF_VALUE = 0.10; - that.TRIGGER_ON_VALUE = that.TRIGGER_OFF_VALUE + 0.05; // Squeezed just enough to activate search or near grab + that.TRIGGER_ON_VALUE = that.TRIGGER_OFF_VALUE + 0.05; // Squeezed just enough to activate search or near grab that.rawTriggerValue = 0; - that.triggerValue = 0; // rolling average of trigger value + that.triggerValue = 0; // rolling average of trigger value that.triggerClicked = false; - that.triggerClick = function (value) { that.triggerClicked = value; }; - that.triggerPress = function (value) { that.rawTriggerValue = value; }; - that.updateSmoothedTrigger = function () { // e.g., call once/update for effect + that.triggerClick = function(value) { + that.triggerClicked = value; + }; + that.triggerPress = function(value) { + that.rawTriggerValue = value; + }; + that.updateSmoothedTrigger = function() { // e.g., call once/update for effect var triggerValue = that.rawTriggerValue; // smooth out trigger value that.triggerValue = (that.triggerValue * that.TRIGGER_SMOOTH_RATIO) + @@ -66,19 +70,19 @@ function Trigger(label) { OffscreenFlags.navigationFocusDisabled = that.triggerValue != 0.0; }; // Current smoothed state, without hysteresis. Answering booleans. - that.triggerSmoothedClick = function () { + that.triggerSmoothedClick = function() { return that.triggerClicked; }; - that.triggerSmoothedSqueezed = function () { + that.triggerSmoothedSqueezed = function() { return that.triggerValue > that.TRIGGER_ON_VALUE; }; - that.triggerSmoothedReleased = function () { + that.triggerSmoothedReleased = function() { return that.triggerValue < that.TRIGGER_OFF_VALUE; }; // This part is not from handControllerGrab.js that.state = null; // tri-state: falsey, 'partial', 'full' - that.update = function () { // update state, called from an update function + that.update = function() { // update state, called from an update function var state = that.state; that.updateSmoothedTrigger(); @@ -96,10 +100,10 @@ function Trigger(label) { that.state = state; }; // Answer a controller source function (answering either 0.0 or 1.0). - that.partial = function () { + that.partial = function() { return that.state ? 1.0 : 0.0; // either 'partial' or 'full' }; - that.full = function () { + that.full = function() { return (that.state === 'full') ? 1.0 : 0.0; }; } @@ -115,6 +119,7 @@ function updateFieldOfView() { // SHIMS ---------- // var weMovedReticle = false; + function ignoreMouseActivity() { // If we're paused, or if change in cursor position is from this script, not the hardware mouse. if (!Reticle.allowMouseCapture) { @@ -132,13 +137,16 @@ function ignoreMouseActivity() { return true; } var MARGIN = 25; -var reticleMinX = MARGIN, reticleMaxX, reticleMinY = MARGIN, reticleMaxY; +var reticleMinX = MARGIN, + reticleMaxX, reticleMinY = MARGIN, + reticleMaxY; + function updateRecommendedArea() { var dims = Controller.getViewportDimensions(); reticleMaxX = dims.x - MARGIN; reticleMaxY = dims.y - MARGIN; } -var setReticlePosition = function (point2d) { +var setReticlePosition = function(point2d) { weMovedReticle = true; point2d.x = Math.max(reticleMinX, Math.min(point2d.x, reticleMaxX)); point2d.y = Math.max(reticleMinY, Math.min(point2d.y, reticleMaxY)); @@ -154,6 +162,7 @@ function findRayIntersection(pickRay) { } return result; } + function isPointingAtOverlay(optionalHudPosition2d) { return Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(optionalHudPosition2d || Reticle.position); } @@ -161,6 +170,7 @@ function isPointingAtOverlay(optionalHudPosition2d) { // Generalized HUD utilities, with or without HMD: // This "var" is for documentation. Do not change the value! var PLANAR_PERPENDICULAR_HUD_DISTANCE = 1; + function calculateRayUICollisionPoint(position, direction) { // Answer the 3D intersection of the HUD by the given ray, or falsey if no intersection. if (HMD.active) { @@ -180,6 +190,7 @@ function calculateRayUICollisionPoint(position, direction) { return Vec3.sum(position, Vec3.multiply(scale, direction)); } var DEGREES_TO_HALF_RADIANS = Math.PI / 360; + function overlayFromWorldPoint(point) { // Answer the 2d pixel-space location in the HUD that covers the given 3D point. // REQUIRES: that the 3d point be on the hud surface! @@ -199,7 +210,10 @@ function overlayFromWorldPoint(point) { var verticalFraction = 1 - (cameraY / hudHeight + 0.5); var horizontalPixels = size.x * horizontalFraction; var verticalPixels = size.y * verticalFraction; - return { x: horizontalPixels, y: verticalPixels }; + return { + x: horizontalPixels, + y: verticalPixels + }; } function activeHudPoint2d(activeHand) { // if controller is valid, update reticle position and answer 2d point. Otherwise falsey. @@ -209,14 +223,14 @@ function activeHudPoint2d(activeHand) { // if controller is valid, update reticl return; // Controller is cradled. } var controllerPosition = Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, controllerPose.translation), - MyAvatar.position); + MyAvatar.position); // This gets point direction right, but if you want general quaternion it would be more complicated: var controllerDirection = Quat.getUp(Quat.multiply(MyAvatar.orientation, controllerPose.rotation)); var hudPoint3d = calculateRayUICollisionPoint(controllerPosition, controllerDirection); if (!hudPoint3d) { if (Menu.isOptionChecked("Overlays")) { // With our hud resetting strategy, hudPoint3d should be valid here - print('Controller is parallel to HUD'); // so let us know that our assumptions are wrong. + print('Controller is parallel to HUD'); // so let us know that our assumptions are wrong. } return; } @@ -231,12 +245,17 @@ function activeHudPoint2d(activeHand) { // if controller is valid, update reticl // MOUSE ACTIVITY -------- // var isSeeking = false; -var averageMouseVelocity = 0, lastIntegration = 0, lastMouse; +var averageMouseVelocity = 0, + lastIntegration = 0, + lastMouse; var WEIGHTING = 1 / 20; // simple moving average over last 20 samples var ONE_MINUS_WEIGHTING = 1 - WEIGHTING; var AVERAGE_MOUSE_VELOCITY_FOR_SEEK_TO = 20; + function isShakingMouse() { // True if the person is waving the mouse around trying to find it. - var now = Date.now(), mouse = Reticle.position, isShaking = false; + var now = Date.now(), + mouse = Reticle.position, + isShaking = false; if (lastIntegration && (lastIntegration !== now)) { var velocity = Vec3.length(Vec3.subtract(mouse, lastMouse)) / (now - lastIntegration); averageMouseVelocity = (ONE_MINUS_WEIGHTING * averageMouseVelocity) + (WEIGHTING * velocity); @@ -250,6 +269,7 @@ function isShakingMouse() { // True if the person is waving the mouse around try } var NON_LINEAR_DIVISOR = 2; var MINIMUM_SEEK_DISTANCE = 0.1; + function updateSeeking(doNotStartSeeking) { if (!doNotStartSeeking && (!Reticle.visible || isShakingMouse())) { if (!isSeeking) { @@ -268,6 +288,7 @@ function updateSeeking(doNotStartSeeking) { return; // E.g., if parallel to location in HUD } var copy = Reticle.position; + function updateDimension(axis) { var distanceBetween = lookAt2D[axis] - Reticle.position[axis]; var move = distanceBetween / NON_LINEAR_DIVISOR; @@ -277,7 +298,8 @@ function updateSeeking(doNotStartSeeking) { copy[axis] += move; return true; } - var okX = !updateDimension('x'), okY = !updateDimension('y'); // Evaluate both. Don't short-circuit. + var okX = !updateDimension('x'), + okY = !updateDimension('y'); // Evaluate both. Don't short-circuit. if (okX && okY) { print('Finished seeking mouse'); isSeeking = false; @@ -300,16 +322,19 @@ function updateMouseActivity(isClick) { handControllerLockOut.update(now); Reticle.visible = true; } + function expireMouseCursor(now) { if (!isPointingAtOverlay() && mouseCursorActivity.expired(now)) { Reticle.visible = false; } } + function hudReticleDistance() { // 3d distance from camera to the reticle position on hud // (The camera is only in the center of the sphere on reset.) var reticlePositionOnHUD = HMD.worldPointFromOverlay(Reticle.position); return Vec3.distance(reticlePositionOnHUD, HMD.position); } + function onMouseMove() { // Display cursor at correct depth (as in depthReticle.js), and updateMouseActivity. if (ignoreMouseActivity()) { @@ -327,6 +352,7 @@ function onMouseMove() { } updateMouseActivity(); // After the above, just in case the depth movement is awkward when becoming visible. } + function onMouseClick() { updateMouseActivity(true); } @@ -345,6 +371,7 @@ var LEFT_HUD_LASER = 1; var RIGHT_HUD_LASER = 2; var BOTH_HUD_LASERS = LEFT_HUD_LASER + RIGHT_HUD_LASER; var activeHudLaser = RIGHT_HUD_LASER; + function toggleHand() { // unequivocally switch which hand controls mouse position if (activeHand === Controller.Standard.RightHand) { activeHand = Controller.Standard.LeftHand; @@ -357,8 +384,9 @@ function toggleHand() { // unequivocally switch which hand controls mouse positi } clearSystemLaser(); } + function makeToggleAction(hand) { // return a function(0|1) that makes the specified hand control mouse when 1 - return function (on) { + return function(on) { if (on && (activeHand !== hand)) { toggleHand(); } @@ -378,7 +406,7 @@ function isPointingAtOverlayStartedNonFullTrigger(trigger) { // true if isPointingAtOverlay AND we were NOT full triggered when we became so. // The idea is to not count clicks when we're full-triggering and reach the edge of a window. var lockedIn = false; - return function () { + return function() { if (trigger !== activeTrigger) { return lockedIn = false; } @@ -398,26 +426,28 @@ clickMapping.from(leftTrigger.full).when(isPointingAtOverlayStartedNonFullTrigge // clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(Controller.Actions.ContextMenu); // except that we first update the reticle position from the appropriate hand position, before invoking the ContextMenu. var wantsMenu = 0; -clickMapping.from(function () { return wantsMenu; }).to(Controller.Actions.ContextMenu); -clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(function (clicked) { +clickMapping.from(function() { + return wantsMenu; +}).to(Controller.Actions.ContextMenu); +clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(function(clicked) { if (clicked) { activeHudPoint2d(Controller.Standard.RightHand); } wantsMenu = clicked; }); -clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(function (clicked) { +clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(function(clicked) { if (clicked) { activeHudPoint2d(Controller.Standard.LeftHand); } wantsMenu = clicked; }); -clickMapping.from(Controller.Hardware.Keyboard.RightMouseClicked).peek().to(function () { +clickMapping.from(Controller.Hardware.Keyboard.RightMouseClicked).peek().to(function() { // Allow the reticle depth to be set correctly: // Wait a tick for the context menu to be displayed, and then simulate a (non-hand-controller) mouse move // so that the system updates qml state (Reticle.pointingAtSystemOverlay) before it gives us a mouseMove. // We don't want the system code to always do this for us, because, e.g., we do not want to get a mouseMove // after the Left/RightSecondaryThumb gives us a context menu. Only from the mouse. - Script.setTimeout(function () { + Script.setTimeout(function() { Reticle.setPosition(Reticle.position); }, 0); }); @@ -429,10 +459,25 @@ clickMapping.enable(); // VISUAL AID ----------- // Same properties as handControllerGrab search sphere var LASER_ALPHA = 0.5; -var LASER_SEARCH_COLOR_XYZW = {x: 10 / 255, y: 10 / 255, z: 255 / 255, w: LASER_ALPHA}; -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 LASER_SEARCH_COLOR_XYZW = { + x: 10 / 255, + y: 10 / 255, + z: 255 / 255, + w: LASER_ALPHA +}; +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; + function clearSystemLaser() { if (!systemLaserOn) { return; @@ -440,8 +485,12 @@ function clearSystemLaser() { HMD.disableHandLasers(BOTH_HUD_LASERS); systemLaserOn = false; weMovedReticle = true; - Reticle.position = { x: -1, y: -1 }; + Reticle.position = { + x: -1, + y: -1 + }; } + function setColoredLaser() { // answer trigger state if lasers supported, else falsey. var color = (activeTrigger.state === 'full') ? LASER_TRIGGER_COLOR_XYZW : LASER_SEARCH_COLOR_XYZW; return HMD.setHandLasers(activeHudLaser, true, color, SYSTEM_LASER_DIRECTION) && activeTrigger.state; @@ -451,6 +500,7 @@ function setColoredLaser() { // answer trigger state if lasers supported, else f // function update() { var now = Date.now(); + function off() { expireMouseCursor(); clearSystemLaser(); @@ -504,7 +554,31 @@ function checkSettings() { checkSettings(); var settingsChecker = Script.setInterval(checkSettings, SETTINGS_CHANGE_RECHECK_INTERVAL); -Script.scriptEnding.connect(function () { +Script.scriptEnding.connect(function() { Script.clearInterval(settingsChecker); OffscreenFlags.navigationFocusDisabled = false; }); + +var isDisabled = false; +var handleHandMessages = function(channel, message, sender) { + var data; + if (sender === MyAvatar.sessionUUID) { + if (channel === 'Hifi-Hand-Pointer-Disabler') { + if (message === 'both') { + isDisabled = 'both'; + } + if (message === 'left') { + isDisabled = 'left'; + } + if (message === 'right') { + isDisabled = 'right'; + } + if (message === 'none') { + isDisabled = false; + } + } + } +} + +Messages.subscribe('Hifi-Hand-Pointer-Disabler'); +Messages.messageReceived.connect(handleHandMessages); \ No newline at end of file diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index 4421b7151a..40de57cb41 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -58,6 +58,9 @@ var COLORS_TELEPORT_CANNOT_TELEPORT = { blue: 141 }; + +var MAX_AVATAR_SPEED = 0.25; + function ThumbPad(hand) { this.hand = hand; var _thisPad = this; @@ -265,7 +268,6 @@ function Teleporter() { return; } teleporter.leftRay(); - //|| leftTrigger.buttonValue === 0 if ((leftPad.buttonValue === 0) && inTeleportMode === true) { _this.teleport(); return; @@ -276,7 +278,6 @@ function Teleporter() { return; } teleporter.rightRay(); - //|| rightTrigger.buttonValue === 0 if ((rightPad.buttonValue === 0) && inTeleportMode === true) { _this.teleport(); return; @@ -589,6 +590,15 @@ function getJointData() { return allJointData; }; +function getAvatarSpeed() { + return Vec3.length(MyAvatar.velocity) +} + +function hasPressedMovementButtonLately() { + + return; +} + var leftPad = new ThumbPad('left'); var rightPad = new ThumbPad('right'); var leftTrigger = new Trigger('left'); @@ -599,6 +609,26 @@ var mappingName, teleportMapping; var activationTimeout = null; var TELEPORT_DELAY = 800; +var lastMovementPress = new Date(); + +function pressedAMovementButton() { + print('PRESSED A MOVEMENT BUTTON!!') + lastMovementPress = new Date(); +} + +function hasMovedRecently() { + var dif = new Date().getTime() - lastMovementPress.getTime(); + + var secondsBetween = dif / 1000; + secondsBetween = Math.abs(secondsBetween); + print('seconds between: '+secondsBetween) + if (secondsBetween < 0.5) { + return true + } else { + return false + } +} + function registerMappings() { mappingName = 'Hifi-Teleporter-Dev-' + Math.random(); teleportMapping = Controller.newMapping(mappingName); @@ -608,6 +638,9 @@ function registerMappings() { teleportMapping.from(Controller.Standard.RightPrimaryThumb).peek().to(rightPad.buttonPress); teleportMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(leftPad.buttonPress); + teleportMapping.from(Controller.Standard.LY).peek().to(pressedAMovementButton); + teleportMapping.from(Controller.Standard.LX).peek().to(pressedAMovementButton); + teleportMapping.from(Controller.Standard.LeftPrimaryThumb) .to(function(value) { if (isDisabled === 'left' || isDisabled === 'both') { @@ -619,8 +652,13 @@ function registerMappings() { if (leftTrigger.down()) { return; } + if (hasMovedRecently() === true) { + return; + } + // if (getAvatarSpeed() >= MAX_AVATAR_SPEED) { + // return; + // } activationTimeout = Script.setTimeout(function() { - Script.clearTimeout(activationTimeout); activationTimeout = null; teleporter.enterTeleportMode('left') @@ -638,6 +676,12 @@ function registerMappings() { if (rightTrigger.down()) { return; } + if (hasMovedRecently() === true) { + return; + } + // if (getAvatarSpeed() >= MAX_AVATAR_SPEED) { + // return; + // } activationTimeout = Script.setTimeout(function() { teleporter.enterTeleportMode('right') Script.clearTimeout(activationTimeout); From 364eb992fb831b10e4a7c84730a49655582c9655 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 2 Aug 2016 18:53:36 -0700 Subject: [PATCH 16/27] no teleport while moving --- scripts/system/controllers/teleport.js | 28 ++++++-------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index 40de57cb41..73dae3c6b2 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -594,10 +594,6 @@ function getAvatarSpeed() { return Vec3.length(MyAvatar.velocity) } -function hasPressedMovementButtonLately() { - - return; -} var leftPad = new ThumbPad('left'); var rightPad = new ThumbPad('right'); @@ -609,20 +605,11 @@ var mappingName, teleportMapping; var activationTimeout = null; var TELEPORT_DELAY = 800; -var lastMovementPress = new Date(); +function isMoving() { -function pressedAMovementButton() { - print('PRESSED A MOVEMENT BUTTON!!') - lastMovementPress = new Date(); -} - -function hasMovedRecently() { - var dif = new Date().getTime() - lastMovementPress.getTime(); - - var secondsBetween = dif / 1000; - secondsBetween = Math.abs(secondsBetween); - print('seconds between: '+secondsBetween) - if (secondsBetween < 0.5) { + var LY = Controller.getValue(Controller.Standard.LY); + var LX = Controller.getValue(Controller.Standard.LX); + if (LY !== 0 || LX !== 0) { return true } else { return false @@ -638,9 +625,6 @@ function registerMappings() { teleportMapping.from(Controller.Standard.RightPrimaryThumb).peek().to(rightPad.buttonPress); teleportMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(leftPad.buttonPress); - teleportMapping.from(Controller.Standard.LY).peek().to(pressedAMovementButton); - teleportMapping.from(Controller.Standard.LX).peek().to(pressedAMovementButton); - teleportMapping.from(Controller.Standard.LeftPrimaryThumb) .to(function(value) { if (isDisabled === 'left' || isDisabled === 'both') { @@ -652,7 +636,7 @@ function registerMappings() { if (leftTrigger.down()) { return; } - if (hasMovedRecently() === true) { + if (isMoving() === true) { return; } // if (getAvatarSpeed() >= MAX_AVATAR_SPEED) { @@ -676,7 +660,7 @@ function registerMappings() { if (rightTrigger.down()) { return; } - if (hasMovedRecently() === true) { + if (isMoving() === true) { return; } // if (getAvatarSpeed() >= MAX_AVATAR_SPEED) { From 9d56c697e7a709a659d50e67462e12ed26dde924 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 2 Aug 2016 19:02:20 -0700 Subject: [PATCH 17/27] no delay! --- scripts/system/controllers/teleport.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index 73dae3c6b2..bf3ea11f2d 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -603,7 +603,7 @@ var rightTrigger = new Trigger('right'); var mappingName, teleportMapping; var activationTimeout = null; -var TELEPORT_DELAY = 800; +var TELEPORT_DELAY = 0; function isMoving() { From 8f76c43bc1187c08b56eee43f41bc28941f449de Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 2 Aug 2016 19:49:58 -0700 Subject: [PATCH 18/27] if call to ovr_GetSessionStatus fails, also don't take input from controllers --- plugins/oculus/src/OculusControllerManager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/oculus/src/OculusControllerManager.cpp b/plugins/oculus/src/OculusControllerManager.cpp index e13637c435..b3754805db 100644 --- a/plugins/oculus/src/OculusControllerManager.cpp +++ b/plugins/oculus/src/OculusControllerManager.cpp @@ -183,8 +183,7 @@ void OculusControllerManager::TouchDevice::update(float deltaTime, const control _buttonPressedMap.clear(); ovrSessionStatus status; - if (OVR_SUCCESS(ovr_GetSessionStatus(_parent._session, &status)) && - (ovrFalse == status.HmdMounted)) { + if (!OVR_SUCCESS(ovr_GetSessionStatus(_parent._session, &status)) || (ovrFalse == status.HmdMounted)) { // if the HMD isn't on someone's head, don't take input from the controllers return; } From fed39d90569e68c7a751144ca8339678cf65b914 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 2 Aug 2016 21:26:04 -0700 Subject: [PATCH 19/27] cleanup dead code --- scripts/system/controllers/teleport.js | 148 +++---------------------- 1 file changed, 16 insertions(+), 132 deletions(-) diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index bf3ea11f2d..5cd8460172 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -1,21 +1,13 @@ // Created by james b. pollack @imgntn on 7/2/2016 // Copyright 2016 High Fidelity, Inc. // -// Creates a beam and target and then teleports you there when you let go of either activation button. +// Creates a beam and target and then teleports you there. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html var inTeleportMode = false; -var currentFadeSphereOpacity = 1; -var fadeSphereInterval = null; -var fadeSphereUpdateInterval = null; -//milliseconds between fading one-tenth -- so this is a half second fade total -var USE_FADE_MODE = false; -var USE_FADE_OUT = true; -var FADE_OUT_INTERVAL = 25; - // instant // var NUMBER_OF_STEPS = 0; // var SMOOTH_ARRIVAL_SPACING = 0; @@ -36,16 +28,13 @@ var NUMBER_OF_STEPS = 6; // var SMOOTH_ARRIVAL_SPACING = 10; // var NUMBER_OF_STEPS = 20; - var TARGET_MODEL_URL = Script.resolvePath("../assets/models/teleport.fbx"); var TARGET_MODEL_DIMENSIONS = { x: 1.15, y: 0.5, z: 1.15 - }; - var COLORS_TELEPORT_CAN_TELEPORT = { red: 97, green: 247, @@ -58,7 +47,6 @@ var COLORS_TELEPORT_CANNOT_TELEPORT = { blue: 141 }; - var MAX_AVATAR_SPEED = 0.25; function ThumbPad(hand) { @@ -75,7 +63,6 @@ function ThumbPad(hand) { } }; - } function Trigger(hand) { @@ -101,7 +88,6 @@ function Teleporter() { this.targetOverlay = null; this.updateConnected = null; this.smoothArrivalInterval = null; - this.fadeSphere = null; this.teleportHand = null; this.initialize = function() { @@ -141,86 +127,22 @@ function Teleporter() { if (isDisabled === 'both') { return; } + inTeleportMode = true; + if (this.smoothArrivalInterval !== null) { Script.clearInterval(this.smoothArrivalInterval); } - if (fadeSphereInterval !== null) { - Script.clearInterval(fadeSphereInterval); - } if (activationTimeout !== null) { Script.clearInterval(activationTimeout); } + this.teleportHand = hand; this.initialize(); Script.update.connect(this.update); this.updateConnected = true; }; - this.createFadeSphere = function(avatarHead) { - var sphereProps = { - position: avatarHead, - size: -1, - color: { - red: 0, - green: 0, - blue: 0, - }, - alpha: 1, - solid: true, - visible: true, - ignoreRayIntersection: true, - drawInFront: false - }; - - currentFadeSphereOpacity = 10; - - _this.fadeSphere = Overlays.addOverlay("sphere", sphereProps); - Script.clearInterval(fadeSphereInterval) - Script.update.connect(_this.updateFadeSphere); - if (USE_FADE_OUT === true) { - this.fadeSphereOut(); - } - - - }; - - this.fadeSphereOut = function() { - - fadeSphereInterval = Script.setInterval(function() { - if (currentFadeSphereOpacity <= 0) { - Script.clearInterval(fadeSphereInterval); - _this.deleteFadeSphere(); - fadeSphereInterval = null; - return; - } - if (currentFadeSphereOpacity > 0) { - currentFadeSphereOpacity = currentFadeSphereOpacity - 1; - } - - Overlays.editOverlay(_this.fadeSphere, { - alpha: currentFadeSphereOpacity / 10 - }) - - }, FADE_OUT_INTERVAL); - }; - - - this.updateFadeSphere = function() { - var headPosition = MyAvatar.getHeadPosition(); - Overlays.editOverlay(_this.fadeSphere, { - position: headPosition - }) - }; - - this.deleteFadeSphere = function() { - if (_this.fadeSphere !== null) { - Script.update.disconnect(_this.updateFadeSphere); - Overlays.deleteOverlay(_this.fadeSphere); - _this.fadeSphere = null; - } - - }; this.deleteTargetOverlay = function() { if (this.targetOverlay === null) { @@ -288,14 +210,12 @@ function Teleporter() { this.rightRay = function() { - var rightPosition = Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, Controller.getPoseValue(Controller.Standard.RightHand).translation), MyAvatar.position); var rightControllerRotation = Controller.getPoseValue(Controller.Standard.RightHand).rotation; var rightRotation = Quat.multiply(MyAvatar.orientation, rightControllerRotation) - var rightFinal = Quat.multiply(rightRotation, Quat.angleAxis(90, { x: 1, y: 0, @@ -335,14 +255,12 @@ function Teleporter() { var leftRotation = Quat.multiply(MyAvatar.orientation, Controller.getPoseValue(Controller.Standard.LeftHand).rotation) - var leftFinal = Quat.multiply(leftRotation, Quat.angleAxis(90, { x: 1, y: 0, z: 0 })); - var leftPickRay = { origin: leftPosition, direction: Quat.getUp(leftRotation), @@ -364,7 +282,6 @@ function Teleporter() { this.createTargetOverlay(); } - } else { this.deleteTargetOverlay(); @@ -378,7 +295,7 @@ function Teleporter() { start: closePoint, end: farPoint, color: color, - ignoreRayIntersection: true, // always ignore this + ignoreRayIntersection: true, visible: true, alpha: 1, solid: true, @@ -390,14 +307,9 @@ function Teleporter() { } else { var success = Overlays.editOverlay(this.rightOverlayLine, { - lineWidth: 50, start: closePoint, end: farPoint, - color: color, - visible: true, - ignoreRayIntersection: true, // always ignore this - alpha: 1, - glow: 1.0 + color: color }); } }; @@ -405,7 +317,7 @@ function Teleporter() { this.leftLineOn = function(closePoint, farPoint, color) { if (this.leftOverlayLine === null) { var lineProperties = { - ignoreRayIntersection: true, // always ignore this + ignoreRayIntersection: true, start: closePoint, end: farPoint, color: color, @@ -422,11 +334,7 @@ function Teleporter() { var success = Overlays.editOverlay(this.leftOverlayLine, { start: closePoint, end: farPoint, - color: color, - visible: true, - alpha: 1, - solid: true, - glow: 1.0 + color: color }); } }; @@ -479,16 +387,11 @@ function Teleporter() { this.exitTeleportMode(); } if (this.intersection !== null) { - if (USE_FADE_MODE === true) { - this.createFadeSphere(); - } var offset = getAvatarFootOffset(); this.intersection.intersection.y += offset; this.exitTeleportMode(); this.smoothArrival(); - } - }; @@ -498,12 +401,8 @@ function Teleporter() { return midpoint }; - - this.getArrivalPoints = function(startPoint, endPoint) { var arrivalPoints = []; - - var i; var lastPoint; @@ -516,9 +415,9 @@ function Teleporter() { arrivalPoints.push(newPoint); } - arrivalPoints.push(endPoint) + arrivalPoints.push(endPoint); - return arrivalPoints + return arrivalPoints; }; this.smoothArrival = function() { @@ -529,7 +428,6 @@ function Teleporter() { Script.clearInterval(_this.smoothArrivalInterval); return; } - var landingPoint = _this.arrivalPoints.shift(); MyAvatar.position = landingPoint; @@ -537,8 +435,7 @@ function Teleporter() { _this.deleteTargetOverlay(); } - - }, SMOOTH_ARRIVAL_SPACING) + }, SMOOTH_ARRIVAL_SPACING); } } @@ -563,14 +460,14 @@ function getAvatarFootOffset() { toe = d.translation.y; } if (jointName === "RightToe_End") { - toeTop = d.translation.y + toeTop = d.translation.y; } }) var myPosition = MyAvatar.position; var offset = upperLeg + lowerLeg + foot + toe + toeTop; offset = offset / 100; - return offset + return offset; }; function getJointData() { @@ -590,11 +487,6 @@ function getJointData() { return allJointData; }; -function getAvatarSpeed() { - return Vec3.length(MyAvatar.velocity) -} - - var leftPad = new ThumbPad('left'); var rightPad = new ThumbPad('right'); var leftTrigger = new Trigger('left'); @@ -606,13 +498,12 @@ var activationTimeout = null; var TELEPORT_DELAY = 0; function isMoving() { - var LY = Controller.getValue(Controller.Standard.LY); var LX = Controller.getValue(Controller.Standard.LX); if (LY !== 0 || LX !== 0) { - return true + return true; } else { - return false + return false; } } @@ -639,9 +530,6 @@ function registerMappings() { if (isMoving() === true) { return; } - // if (getAvatarSpeed() >= MAX_AVATAR_SPEED) { - // return; - // } activationTimeout = Script.setTimeout(function() { Script.clearTimeout(activationTimeout); activationTimeout = null; @@ -663,9 +551,7 @@ function registerMappings() { if (isMoving() === true) { return; } - // if (getAvatarSpeed() >= MAX_AVATAR_SPEED) { - // return; - // } + activationTimeout = Script.setTimeout(function() { teleporter.enterTeleportMode('right') Script.clearTimeout(activationTimeout); @@ -673,7 +559,6 @@ function registerMappings() { }, TELEPORT_DELAY) return; }); - } registerMappings(); @@ -689,7 +574,6 @@ function cleanup() { teleporter.disableMappings(); teleporter.deleteTargetOverlay(); teleporter.turnOffOverlayBeams(); - teleporter.deleteFadeSphere(); if (teleporter.updateConnected !== null) { Script.update.disconnect(teleporter.update); } From 5ad58991400c44df176d34e145c4d7ff2188649d Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 2 Aug 2016 21:26:48 -0700 Subject: [PATCH 20/27] revert pointer changes --- .../controllers/handControllerPointer.js | 144 +++++------------- 1 file changed, 35 insertions(+), 109 deletions(-) diff --git a/scripts/system/controllers/handControllerPointer.js b/scripts/system/controllers/handControllerPointer.js index fe561e0dd0..4d6e9d7f60 100644 --- a/scripts/system/controllers/handControllerPointer.js +++ b/scripts/system/controllers/handControllerPointer.js @@ -23,12 +23,12 @@ // UTILITIES ------------- // -function ignore() {} +function ignore() { } // Utility to make it easier to setup and disconnect cleanly. function setupHandler(event, handler) { event.connect(handler); - Script.scriptEnding.connect(function() { + Script.scriptEnding.connect(function () { event.disconnect(handler); }); } @@ -36,10 +36,10 @@ function setupHandler(event, handler) { // If some capability is not available until expiration milliseconds after the last update. function TimeLock(expiration) { var last = 0; - this.update = function(optionalNow) { + this.update = function (optionalNow) { last = optionalNow || Date.now(); }; - this.expired = function(optionalNow) { + this.expired = function (optionalNow) { return ((optionalNow || Date.now()) - last) > expiration; }; } @@ -52,17 +52,13 @@ function Trigger(label) { that.label = label; that.TRIGGER_SMOOTH_RATIO = 0.1; // Time averaging of trigger - 0.0 disables smoothing that.TRIGGER_OFF_VALUE = 0.10; - that.TRIGGER_ON_VALUE = that.TRIGGER_OFF_VALUE + 0.05; // Squeezed just enough to activate search or near grab + that.TRIGGER_ON_VALUE = that.TRIGGER_OFF_VALUE + 0.05; // Squeezed just enough to activate search or near grab that.rawTriggerValue = 0; - that.triggerValue = 0; // rolling average of trigger value + that.triggerValue = 0; // rolling average of trigger value that.triggerClicked = false; - that.triggerClick = function(value) { - that.triggerClicked = value; - }; - that.triggerPress = function(value) { - that.rawTriggerValue = value; - }; - that.updateSmoothedTrigger = function() { // e.g., call once/update for effect + that.triggerClick = function (value) { that.triggerClicked = value; }; + that.triggerPress = function (value) { that.rawTriggerValue = value; }; + that.updateSmoothedTrigger = function () { // e.g., call once/update for effect var triggerValue = that.rawTriggerValue; // smooth out trigger value that.triggerValue = (that.triggerValue * that.TRIGGER_SMOOTH_RATIO) + @@ -70,19 +66,19 @@ function Trigger(label) { OffscreenFlags.navigationFocusDisabled = that.triggerValue != 0.0; }; // Current smoothed state, without hysteresis. Answering booleans. - that.triggerSmoothedClick = function() { + that.triggerSmoothedClick = function () { return that.triggerClicked; }; - that.triggerSmoothedSqueezed = function() { + that.triggerSmoothedSqueezed = function () { return that.triggerValue > that.TRIGGER_ON_VALUE; }; - that.triggerSmoothedReleased = function() { + that.triggerSmoothedReleased = function () { return that.triggerValue < that.TRIGGER_OFF_VALUE; }; // This part is not from handControllerGrab.js that.state = null; // tri-state: falsey, 'partial', 'full' - that.update = function() { // update state, called from an update function + that.update = function () { // update state, called from an update function var state = that.state; that.updateSmoothedTrigger(); @@ -100,10 +96,10 @@ function Trigger(label) { that.state = state; }; // Answer a controller source function (answering either 0.0 or 1.0). - that.partial = function() { + that.partial = function () { return that.state ? 1.0 : 0.0; // either 'partial' or 'full' }; - that.full = function() { + that.full = function () { return (that.state === 'full') ? 1.0 : 0.0; }; } @@ -119,7 +115,6 @@ function updateFieldOfView() { // SHIMS ---------- // var weMovedReticle = false; - function ignoreMouseActivity() { // If we're paused, or if change in cursor position is from this script, not the hardware mouse. if (!Reticle.allowMouseCapture) { @@ -137,16 +132,13 @@ function ignoreMouseActivity() { return true; } var MARGIN = 25; -var reticleMinX = MARGIN, - reticleMaxX, reticleMinY = MARGIN, - reticleMaxY; - +var reticleMinX = MARGIN, reticleMaxX, reticleMinY = MARGIN, reticleMaxY; function updateRecommendedArea() { var dims = Controller.getViewportDimensions(); reticleMaxX = dims.x - MARGIN; reticleMaxY = dims.y - MARGIN; } -var setReticlePosition = function(point2d) { +var setReticlePosition = function (point2d) { weMovedReticle = true; point2d.x = Math.max(reticleMinX, Math.min(point2d.x, reticleMaxX)); point2d.y = Math.max(reticleMinY, Math.min(point2d.y, reticleMaxY)); @@ -162,7 +154,6 @@ function findRayIntersection(pickRay) { } return result; } - function isPointingAtOverlay(optionalHudPosition2d) { return Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(optionalHudPosition2d || Reticle.position); } @@ -170,7 +161,6 @@ function isPointingAtOverlay(optionalHudPosition2d) { // Generalized HUD utilities, with or without HMD: // This "var" is for documentation. Do not change the value! var PLANAR_PERPENDICULAR_HUD_DISTANCE = 1; - function calculateRayUICollisionPoint(position, direction) { // Answer the 3D intersection of the HUD by the given ray, or falsey if no intersection. if (HMD.active) { @@ -190,7 +180,6 @@ function calculateRayUICollisionPoint(position, direction) { return Vec3.sum(position, Vec3.multiply(scale, direction)); } var DEGREES_TO_HALF_RADIANS = Math.PI / 360; - function overlayFromWorldPoint(point) { // Answer the 2d pixel-space location in the HUD that covers the given 3D point. // REQUIRES: that the 3d point be on the hud surface! @@ -210,10 +199,7 @@ function overlayFromWorldPoint(point) { var verticalFraction = 1 - (cameraY / hudHeight + 0.5); var horizontalPixels = size.x * horizontalFraction; var verticalPixels = size.y * verticalFraction; - return { - x: horizontalPixels, - y: verticalPixels - }; + return { x: horizontalPixels, y: verticalPixels }; } function activeHudPoint2d(activeHand) { // if controller is valid, update reticle position and answer 2d point. Otherwise falsey. @@ -223,14 +209,14 @@ function activeHudPoint2d(activeHand) { // if controller is valid, update reticl return; // Controller is cradled. } var controllerPosition = Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, controllerPose.translation), - MyAvatar.position); + MyAvatar.position); // This gets point direction right, but if you want general quaternion it would be more complicated: var controllerDirection = Quat.getUp(Quat.multiply(MyAvatar.orientation, controllerPose.rotation)); var hudPoint3d = calculateRayUICollisionPoint(controllerPosition, controllerDirection); if (!hudPoint3d) { if (Menu.isOptionChecked("Overlays")) { // With our hud resetting strategy, hudPoint3d should be valid here - print('Controller is parallel to HUD'); // so let us know that our assumptions are wrong. + print('Controller is parallel to HUD'); // so let us know that our assumptions are wrong. } return; } @@ -245,17 +231,12 @@ function activeHudPoint2d(activeHand) { // if controller is valid, update reticl // MOUSE ACTIVITY -------- // var isSeeking = false; -var averageMouseVelocity = 0, - lastIntegration = 0, - lastMouse; +var averageMouseVelocity = 0, lastIntegration = 0, lastMouse; var WEIGHTING = 1 / 20; // simple moving average over last 20 samples var ONE_MINUS_WEIGHTING = 1 - WEIGHTING; var AVERAGE_MOUSE_VELOCITY_FOR_SEEK_TO = 20; - function isShakingMouse() { // True if the person is waving the mouse around trying to find it. - var now = Date.now(), - mouse = Reticle.position, - isShaking = false; + var now = Date.now(), mouse = Reticle.position, isShaking = false; if (lastIntegration && (lastIntegration !== now)) { var velocity = Vec3.length(Vec3.subtract(mouse, lastMouse)) / (now - lastIntegration); averageMouseVelocity = (ONE_MINUS_WEIGHTING * averageMouseVelocity) + (WEIGHTING * velocity); @@ -269,7 +250,6 @@ function isShakingMouse() { // True if the person is waving the mouse around try } var NON_LINEAR_DIVISOR = 2; var MINIMUM_SEEK_DISTANCE = 0.1; - function updateSeeking(doNotStartSeeking) { if (!doNotStartSeeking && (!Reticle.visible || isShakingMouse())) { if (!isSeeking) { @@ -288,7 +268,6 @@ function updateSeeking(doNotStartSeeking) { return; // E.g., if parallel to location in HUD } var copy = Reticle.position; - function updateDimension(axis) { var distanceBetween = lookAt2D[axis] - Reticle.position[axis]; var move = distanceBetween / NON_LINEAR_DIVISOR; @@ -298,8 +277,7 @@ function updateSeeking(doNotStartSeeking) { copy[axis] += move; return true; } - var okX = !updateDimension('x'), - okY = !updateDimension('y'); // Evaluate both. Don't short-circuit. + var okX = !updateDimension('x'), okY = !updateDimension('y'); // Evaluate both. Don't short-circuit. if (okX && okY) { print('Finished seeking mouse'); isSeeking = false; @@ -322,19 +300,16 @@ function updateMouseActivity(isClick) { handControllerLockOut.update(now); Reticle.visible = true; } - function expireMouseCursor(now) { if (!isPointingAtOverlay() && mouseCursorActivity.expired(now)) { Reticle.visible = false; } } - function hudReticleDistance() { // 3d distance from camera to the reticle position on hud // (The camera is only in the center of the sphere on reset.) var reticlePositionOnHUD = HMD.worldPointFromOverlay(Reticle.position); return Vec3.distance(reticlePositionOnHUD, HMD.position); } - function onMouseMove() { // Display cursor at correct depth (as in depthReticle.js), and updateMouseActivity. if (ignoreMouseActivity()) { @@ -352,7 +327,6 @@ function onMouseMove() { } updateMouseActivity(); // After the above, just in case the depth movement is awkward when becoming visible. } - function onMouseClick() { updateMouseActivity(true); } @@ -371,7 +345,6 @@ var LEFT_HUD_LASER = 1; var RIGHT_HUD_LASER = 2; var BOTH_HUD_LASERS = LEFT_HUD_LASER + RIGHT_HUD_LASER; var activeHudLaser = RIGHT_HUD_LASER; - function toggleHand() { // unequivocally switch which hand controls mouse position if (activeHand === Controller.Standard.RightHand) { activeHand = Controller.Standard.LeftHand; @@ -384,9 +357,8 @@ function toggleHand() { // unequivocally switch which hand controls mouse positi } clearSystemLaser(); } - function makeToggleAction(hand) { // return a function(0|1) that makes the specified hand control mouse when 1 - return function(on) { + return function (on) { if (on && (activeHand !== hand)) { toggleHand(); } @@ -406,7 +378,7 @@ function isPointingAtOverlayStartedNonFullTrigger(trigger) { // true if isPointingAtOverlay AND we were NOT full triggered when we became so. // The idea is to not count clicks when we're full-triggering and reach the edge of a window. var lockedIn = false; - return function() { + return function () { if (trigger !== activeTrigger) { return lockedIn = false; } @@ -426,28 +398,26 @@ clickMapping.from(leftTrigger.full).when(isPointingAtOverlayStartedNonFullTrigge // clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(Controller.Actions.ContextMenu); // except that we first update the reticle position from the appropriate hand position, before invoking the ContextMenu. var wantsMenu = 0; -clickMapping.from(function() { - return wantsMenu; -}).to(Controller.Actions.ContextMenu); -clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(function(clicked) { +clickMapping.from(function () { return wantsMenu; }).to(Controller.Actions.ContextMenu); +clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(function (clicked) { if (clicked) { activeHudPoint2d(Controller.Standard.RightHand); } wantsMenu = clicked; }); -clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(function(clicked) { +clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(function (clicked) { if (clicked) { activeHudPoint2d(Controller.Standard.LeftHand); } wantsMenu = clicked; }); -clickMapping.from(Controller.Hardware.Keyboard.RightMouseClicked).peek().to(function() { +clickMapping.from(Controller.Hardware.Keyboard.RightMouseClicked).peek().to(function () { // Allow the reticle depth to be set correctly: // Wait a tick for the context menu to be displayed, and then simulate a (non-hand-controller) mouse move // so that the system updates qml state (Reticle.pointingAtSystemOverlay) before it gives us a mouseMove. // We don't want the system code to always do this for us, because, e.g., we do not want to get a mouseMove // after the Left/RightSecondaryThumb gives us a context menu. Only from the mouse. - Script.setTimeout(function() { + Script.setTimeout(function () { Reticle.setPosition(Reticle.position); }, 0); }); @@ -459,25 +429,10 @@ clickMapping.enable(); // VISUAL AID ----------- // Same properties as handControllerGrab search sphere var LASER_ALPHA = 0.5; -var LASER_SEARCH_COLOR_XYZW = { - x: 10 / 255, - y: 10 / 255, - z: 255 / 255, - w: LASER_ALPHA -}; -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 LASER_SEARCH_COLOR_XYZW = {x: 10 / 255, y: 10 / 255, z: 255 / 255, w: LASER_ALPHA}; +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; - function clearSystemLaser() { if (!systemLaserOn) { return; @@ -485,12 +440,8 @@ function clearSystemLaser() { HMD.disableHandLasers(BOTH_HUD_LASERS); systemLaserOn = false; weMovedReticle = true; - Reticle.position = { - x: -1, - y: -1 - }; + Reticle.position = { x: -1, y: -1 }; } - function setColoredLaser() { // answer trigger state if lasers supported, else falsey. var color = (activeTrigger.state === 'full') ? LASER_TRIGGER_COLOR_XYZW : LASER_SEARCH_COLOR_XYZW; return HMD.setHandLasers(activeHudLaser, true, color, SYSTEM_LASER_DIRECTION) && activeTrigger.state; @@ -500,7 +451,6 @@ function setColoredLaser() { // answer trigger state if lasers supported, else f // function update() { var now = Date.now(); - function off() { expireMouseCursor(); clearSystemLaser(); @@ -554,31 +504,7 @@ function checkSettings() { checkSettings(); var settingsChecker = Script.setInterval(checkSettings, SETTINGS_CHANGE_RECHECK_INTERVAL); -Script.scriptEnding.connect(function() { +Script.scriptEnding.connect(function () { Script.clearInterval(settingsChecker); OffscreenFlags.navigationFocusDisabled = false; }); - -var isDisabled = false; -var handleHandMessages = function(channel, message, sender) { - var data; - if (sender === MyAvatar.sessionUUID) { - if (channel === 'Hifi-Hand-Pointer-Disabler') { - if (message === 'both') { - isDisabled = 'both'; - } - if (message === 'left') { - isDisabled = 'left'; - } - if (message === 'right') { - isDisabled = 'right'; - } - if (message === 'none') { - isDisabled = false; - } - } - } -} - -Messages.subscribe('Hifi-Hand-Pointer-Disabler'); -Messages.messageReceived.connect(handleHandMessages); \ No newline at end of file From 458e43fadc782322dd389c1c753ee7c8a75dc821 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 3 Aug 2016 10:18:57 -0700 Subject: [PATCH 21/27] added dead zones to hydras, style fixes --- interface/resources/controllers/hydra.json | 21 ++++++++++++++----- .../resources/controllers/oculus_touch.json | 12 ++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/interface/resources/controllers/hydra.json b/interface/resources/controllers/hydra.json index 716d283a86..1dc6e44477 100644 --- a/interface/resources/controllers/hydra.json +++ b/interface/resources/controllers/hydra.json @@ -1,15 +1,26 @@ { "name": "Hydra to Standard", "channels": [ - { "from": "Hydra.LY", "filters": "invert", "to": "Standard.LY" }, - { "from": "Hydra.LX", "to": "Standard.LX" }, + { "from": "Hydra.LY", "to": "Standard.LY", + "filters": [ + { "type": "deadZone", "min": 0.05 }, + "invert" + ] + }, + { "from": "Hydra.LX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.LX" }, { "from": "Hydra.LT", "to": "Standard.LTClick", "peek": true, "filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ] }, - { "from": "Hydra.LT", "to": "Standard.LT" }, - { "from": "Hydra.RY", "filters": "invert", "to": "Standard.RY" }, - { "from": "Hydra.RX", "to": "Standard.RX" }, + { "from": "Hydra.LT", "to": "Standard.LT" }, + + { "from": "Hydra.RY", "to": "Standard.RY", + "filters": [ + { "type": "deadZone", "min": 0.05 }, + "invert" + ] + }, + { "from": "Hydra.RX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.RX" }, { "from": "Hydra.RT", "to": "Standard.RTClick", "peek": true, "filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ] diff --git a/interface/resources/controllers/oculus_touch.json b/interface/resources/controllers/oculus_touch.json index 755a709050..91c3a03303 100644 --- a/interface/resources/controllers/oculus_touch.json +++ b/interface/resources/controllers/oculus_touch.json @@ -12,11 +12,7 @@ "invert" ] }, - { "from": "OculusTouch.LX", "to": "Standard.LX", - "filters": [ - { "type": "deadZone", "min": 0.05 } - ] - }, + { "from": "OculusTouch.LX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.LX" }, { "from": "OculusTouch.LT", "to": "Standard.LTClick", "peek": true, "filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ] @@ -32,11 +28,7 @@ "invert" ] }, - { "from": "OculusTouch.RX", "to": "Standard.RX", - "filters": [ - { "type": "deadZone", "min": 0.05 } - ] - }, + { "from": "OculusTouch.RX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.RX" }, { "from": "OculusTouch.RT", "to": "Standard.RTClick", "peek": true, "filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ] From f24c92f3a1f6311516d4627e33764731eeab0e40 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 3 Aug 2016 15:43:31 -0700 Subject: [PATCH 22/27] Bug fix for avatar debug marker rendering. "Developer > Hands > Show Hand Targets" works again "Developer > Avatar > Draw Position" works again --- libraries/render-utils/src/AnimDebugDraw.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/render-utils/src/AnimDebugDraw.cpp b/libraries/render-utils/src/AnimDebugDraw.cpp index 11c43eaee4..e4e27a1b3d 100644 --- a/libraries/render-utils/src/AnimDebugDraw.cpp +++ b/libraries/render-utils/src/AnimDebugDraw.cpp @@ -374,8 +374,6 @@ void AnimDebugDraw::update() { } } } - data._vertexBuffer->resize(sizeof(Vertex) * numVerts); - data._vertexBuffer->setSubData(0, vertices); // draw markers from shared DebugDraw singleton for (auto& iter : markerMap) { @@ -403,6 +401,9 @@ void AnimDebugDraw::update() { } DebugDraw::getInstance().clearRays(); + data._vertexBuffer->resize(sizeof(Vertex) * numVerts); + data._vertexBuffer->setSubData(0, vertices); + assert((!numVerts && !v) || (numVerts == (v - &vertices[0]))); render::Item::Bound theBound; From 4c258b95682e49ad15f9bca28f705e2c8a85e824 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 Aug 2016 10:16:08 -0700 Subject: [PATCH 23/27] fix bug which caused getValue for a non-existent key to return the integer 2 --- libraries/shared/src/SettingManager.cpp | 7 +++---- libraries/shared/src/SettingManager.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libraries/shared/src/SettingManager.cpp b/libraries/shared/src/SettingManager.cpp index abb8525b03..2ccee513da 100644 --- a/libraries/shared/src/SettingManager.cpp +++ b/libraries/shared/src/SettingManager.cpp @@ -70,11 +70,10 @@ namespace Setting { QVariant handleValue = UNSET_VALUE; if (handle->isSet()) { handleValue = handle->getVariant(); + withWriteLock([&] { + _pendingChanges[key] = handleValue; + }); } - - withWriteLock([&] { - _pendingChanges[key] = handleValue; - }); } static const int SAVE_INTERVAL_MSEC = 5 * 1000; // 5 sec diff --git a/libraries/shared/src/SettingManager.h b/libraries/shared/src/SettingManager.h index 1f309c966f..ffdd4ba42a 100644 --- a/libraries/shared/src/SettingManager.h +++ b/libraries/shared/src/SettingManager.h @@ -46,7 +46,7 @@ namespace Setting { private: QHash _handles; QPointer _saveTimer = nullptr; - const QVariant UNSET_VALUE { QUuid::createUuid().variant() }; + const QVariant UNSET_VALUE { QUuid::createUuid() }; QHash _pendingChanges; friend class Interface; From 45c21ca52391d7590737519b02abfc47a404b30a Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 Aug 2016 13:37:08 -0700 Subject: [PATCH 24/27] make UNSET_VALUE still work while still returning and empty string value for undefined keys --- libraries/shared/src/SettingHandle.cpp | 6 +++++- libraries/shared/src/SettingManager.cpp | 9 +++++---- libraries/shared/src/SettingManager.h | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/libraries/shared/src/SettingHandle.cpp b/libraries/shared/src/SettingHandle.cpp index 13f9ea48ce..ae0f54104e 100644 --- a/libraries/shared/src/SettingHandle.cpp +++ b/libraries/shared/src/SettingHandle.cpp @@ -89,7 +89,11 @@ void Settings::setValue(const QString& name, const QVariant& value) { } QVariant Settings::value(const QString& name, const QVariant& defaultValue) const { - return _manager->value(name, defaultValue); + QVariant result = _manager->value(name, defaultValue); + if (result == _manager->unsetValue()) { + return QVariant(QString()); + } + return result; } diff --git a/libraries/shared/src/SettingManager.cpp b/libraries/shared/src/SettingManager.cpp index 2ccee513da..a42e62c1c8 100644 --- a/libraries/shared/src/SettingManager.cpp +++ b/libraries/shared/src/SettingManager.cpp @@ -53,7 +53,7 @@ namespace Setting { const auto& key = handle->getKey(); withWriteLock([&] { QVariant loadedValue; - if (_pendingChanges.contains(key)) { + if (_pendingChanges.contains(key) && _pendingChanges[key] != UNSET_VALUE) { loadedValue = _pendingChanges[key]; } else { loadedValue = value(key); @@ -70,10 +70,11 @@ namespace Setting { QVariant handleValue = UNSET_VALUE; if (handle->isSet()) { handleValue = handle->getVariant(); - withWriteLock([&] { - _pendingChanges[key] = handleValue; - }); } + + withWriteLock([&] { + _pendingChanges[key] = handleValue; + }); } static const int SAVE_INTERVAL_MSEC = 5 * 1000; // 5 sec diff --git a/libraries/shared/src/SettingManager.h b/libraries/shared/src/SettingManager.h index ffdd4ba42a..836c522342 100644 --- a/libraries/shared/src/SettingManager.h +++ b/libraries/shared/src/SettingManager.h @@ -28,6 +28,7 @@ namespace Setting { public: void customDeleter() override; + QVariant unsetValue() { return UNSET_VALUE; } protected: ~Manager(); From 981a8d76facb774a1264c0861ba5456b0acd3446 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 Aug 2016 13:47:43 -0700 Subject: [PATCH 25/27] code review --- libraries/shared/src/SettingHandle.cpp | 2 +- libraries/shared/src/SettingManager.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/shared/src/SettingHandle.cpp b/libraries/shared/src/SettingHandle.cpp index ae0f54104e..71427d1554 100644 --- a/libraries/shared/src/SettingHandle.cpp +++ b/libraries/shared/src/SettingHandle.cpp @@ -91,7 +91,7 @@ void Settings::setValue(const QString& name, const QVariant& value) { QVariant Settings::value(const QString& name, const QVariant& defaultValue) const { QVariant result = _manager->value(name, defaultValue); if (result == _manager->unsetValue()) { - return QVariant(QString()); + return defaultValue; } return result; } diff --git a/libraries/shared/src/SettingManager.h b/libraries/shared/src/SettingManager.h index 836c522342..e785c5f147 100644 --- a/libraries/shared/src/SettingManager.h +++ b/libraries/shared/src/SettingManager.h @@ -28,7 +28,7 @@ namespace Setting { public: void customDeleter() override; - QVariant unsetValue() { return UNSET_VALUE; } + const QVariant& unsetValue() { return UNSET_VALUE; } protected: ~Manager(); From a2441ca84c4b66bb66639c6ccf33599efe2890b3 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 Aug 2016 14:09:12 -0700 Subject: [PATCH 26/27] back out some uneeded chagnes --- libraries/shared/src/SettingHandle.cpp | 6 +----- libraries/shared/src/SettingManager.h | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/libraries/shared/src/SettingHandle.cpp b/libraries/shared/src/SettingHandle.cpp index 71427d1554..13f9ea48ce 100644 --- a/libraries/shared/src/SettingHandle.cpp +++ b/libraries/shared/src/SettingHandle.cpp @@ -89,11 +89,7 @@ void Settings::setValue(const QString& name, const QVariant& value) { } QVariant Settings::value(const QString& name, const QVariant& defaultValue) const { - QVariant result = _manager->value(name, defaultValue); - if (result == _manager->unsetValue()) { - return defaultValue; - } - return result; + return _manager->value(name, defaultValue); } diff --git a/libraries/shared/src/SettingManager.h b/libraries/shared/src/SettingManager.h index e785c5f147..ffdd4ba42a 100644 --- a/libraries/shared/src/SettingManager.h +++ b/libraries/shared/src/SettingManager.h @@ -28,7 +28,6 @@ namespace Setting { public: void customDeleter() override; - const QVariant& unsetValue() { return UNSET_VALUE; } protected: ~Manager(); From 3ca1ee1d82ca9292ad2e26a5d907c3e576332887 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 Aug 2016 17:39:41 -0700 Subject: [PATCH 27/27] Fix some group-related code to handle CamelCase usernames --- domain-server/src/DomainGatekeeper.cpp | 2 +- domain-server/src/DomainServerSettingsManager.cpp | 12 ++++++------ domain-server/src/DomainServerSettingsManager.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/domain-server/src/DomainGatekeeper.cpp b/domain-server/src/DomainGatekeeper.cpp index 8f8c8e001c..c827e79223 100644 --- a/domain-server/src/DomainGatekeeper.cpp +++ b/domain-server/src/DomainGatekeeper.cpp @@ -182,7 +182,7 @@ NodePermissions DomainGatekeeper::setPermissionsForUser(bool isLocalUser, QStrin GroupRank rank = _server->_settingsManager.getGroupRank(groupID, rankID); #ifdef WANT_DEBUG - qDebug() << "| user-permissions: user is in group:" << groupID << " rank:" + qDebug() << "| user-permissions: user " << verifiedUsername << "is in group:" << groupID << " rank:" << rank.name << "so:" << userPerms; #endif } diff --git a/domain-server/src/DomainServerSettingsManager.cpp b/domain-server/src/DomainServerSettingsManager.cpp index dc49bc6126..47187fac5c 100644 --- a/domain-server/src/DomainServerSettingsManager.cpp +++ b/domain-server/src/DomainServerSettingsManager.cpp @@ -356,7 +356,7 @@ void DomainServerSettingsManager::initializeGroupPermissions(NodePermissionsMap& if (nameKey.first.toLower() != groupNameLower) { continue; } - QUuid groupID = _groupIDs[groupNameLower]; + QUuid groupID = _groupIDs[groupNameLower.toLower()]; QUuid rankID = nameKey.second; GroupRank rank = _groupRanks[groupID][rankID]; if (rank.order == 0) { @@ -1477,14 +1477,14 @@ void DomainServerSettingsManager::apiGetGroupRanksErrorCallback(QNetworkReply& r void DomainServerSettingsManager::recordGroupMembership(const QString& name, const QUuid groupID, QUuid rankID) { if (rankID != QUuid()) { - _groupMembership[name][groupID] = rankID; + _groupMembership[name.toLower()][groupID] = rankID; } else { - _groupMembership[name].remove(groupID); + _groupMembership[name.toLower()].remove(groupID); } } QUuid DomainServerSettingsManager::isGroupMember(const QString& name, const QUuid& groupID) { - const QHash& groupsForName = _groupMembership[name]; + const QHash& groupsForName = _groupMembership[name.toLower()]; if (groupsForName.contains(groupID)) { return groupsForName[groupID]; } @@ -1528,7 +1528,7 @@ void DomainServerSettingsManager::debugDumpGroupsState() { qDebug() << "_groupIDs:"; foreach (QString groupName, _groupIDs.keys()) { - qDebug() << "| " << groupName << "==>" << _groupIDs[groupName]; + qDebug() << "| " << groupName << "==>" << _groupIDs[groupName.toLower()]; } qDebug() << "_groupNames:"; @@ -1548,7 +1548,7 @@ void DomainServerSettingsManager::debugDumpGroupsState() { qDebug() << "_groupMembership"; foreach (QString userName, _groupMembership.keys()) { - QHash& groupsForUser = _groupMembership[userName]; + QHash& groupsForUser = _groupMembership[userName.toLower()]; QString line = ""; foreach (QUuid groupID, groupsForUser.keys()) { line += " g=" + groupID.toString() + ",r=" + groupsForUser[groupID].toString(); diff --git a/domain-server/src/DomainServerSettingsManager.h b/domain-server/src/DomainServerSettingsManager.h index 144589326c..c067377ffc 100644 --- a/domain-server/src/DomainServerSettingsManager.h +++ b/domain-server/src/DomainServerSettingsManager.h @@ -84,7 +84,7 @@ public: QList getBlacklistGroupIDs(); // these are used to locally cache the result of calling "api/v1/groups/.../is_member/..." on metaverse's api - void clearGroupMemberships(const QString& name) { _groupMembership[name].clear(); } + void clearGroupMemberships(const QString& name) { _groupMembership[name.toLower()].clear(); } void recordGroupMembership(const QString& name, const QUuid groupID, QUuid rankID); QUuid isGroupMember(const QString& name, const QUuid& groupID); // returns rank or -1 if not a member