From 7750e86c135185cbd7b637e9de295ccb477a0801 Mon Sep 17 00:00:00 2001 From: David Kelly Date: Tue, 20 Dec 2016 13:47:58 -0800 Subject: [PATCH 01/12] Only send machine fingerprint when not logged in While at it, no longer grabbing it at all when starting up, as that was just a dev thing. Should consider not sending MAC address too, but we may revisit that later. --- interface/src/Application.cpp | 4 ---- libraries/networking/src/NodeList.cpp | 5 ++--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 691c5051b1..9598e81299 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -66,7 +66,6 @@ #include #include #include -#include #include #include #include @@ -614,9 +613,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us - // TODO: This is temporary, while developing - FingerprintUtils::getMachineFingerprint(); - // End TODO auto nodeList = DependencyManager::get(); // Set up a watchdog thread to intentionally crash the application on deadlocks diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 98798ba1b5..4c3ff29270 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -373,9 +373,8 @@ void NodeList::sendDomainServerCheckIn() { packetStream << hardwareAddress; - // add in machine fingerprint - QUuid machineFingerprint = FingerprintUtils::getMachineFingerprint(); - packetStream << machineFingerprint; + auto accountManager = DependencyManager::get(); + packetStream << (accountManager->isLoggedIn() ? QUuid() : FingerprintUtils::getMachineFingerprint()); } // pack our data to send to the domain-server including From 938734d3fc3b5ac3b00da8a330f34695d80d8c95 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Mon, 19 Dec 2016 15:10:03 -0800 Subject: [PATCH 02/12] Grip controllers can grab objects, slight delay on search beam --- .../system/controllers/handControllerGrab.js | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 0cf46f43b0..ee810108c2 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1118,19 +1118,18 @@ function MyController(hand) { }; this.off = function(deltaTime, timestamp) { - if (this.triggerSmoothedReleased()) { + + if (this.triggerSmoothedReleased() && this.secondaryReleased()) { this.waitForTriggerRelease = false; } - if (!this.waitForTriggerRelease && this.triggerSmoothedSqueezed()) { + if (!this.waitForTriggerRelease && (this.triggerSmoothedSqueezed() || this.secondarySqueezed())) { this.lastPickTime = 0; this.startingHandRotation = getControllerWorldLocation(this.handToController(), true).orientation; - if (this.triggerSmoothedSqueezed()) { - this.setState(STATE_SEARCHING, "trigger squeeze detected"); - return; - } + this.searchStartTime = Date.now(); + this.setState(STATE_SEARCHING, "trigger squeeze detected"); + return; } - var controllerLocation = getControllerWorldLocation(this.handToController(), true); var worldHandPosition = controllerLocation.position; @@ -1469,6 +1468,9 @@ function MyController(hand) { this.search = function(deltaTime, timestamp) { var _this = this; var name; + var FAR_SEARCH_DELAY = 350; // msecs before search beam appears + + var farSearching = this.triggerSmoothedSqueezed() && (Date.now() - this.searchStartTime > FAR_SEARCH_DELAY); this.grabbedEntity = null; this.grabbedOverlay = null; @@ -1477,7 +1479,7 @@ function MyController(hand) { this.checkForStrayChildren(); - if (this.triggerSmoothedReleased()) { + if ((this.triggerSmoothedReleased() && this.secondaryReleased())) { this.setState(STATE_OFF, "trigger released"); return; } @@ -1496,7 +1498,7 @@ function MyController(hand) { var potentialEquipHotspot = this.chooseBestEquipHotspot(candidateHotSpotEntities); if (potentialEquipHotspot) { - if (this.triggerSmoothedGrab() && holdEnabled) { + if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && holdEnabled) { this.grabbedHotspot = potentialEquipHotspot; this.grabbedEntity = potentialEquipHotspot.entityID; this.setState(STATE_HOLD, "equipping '" + entityPropertiesCache.getProps(this.grabbedEntity).name + "'"); @@ -1539,7 +1541,8 @@ function MyController(hand) { // potentialNearTriggerEntity = entity; } } else { - if (this.triggerSmoothedGrab() && nearGrabEnabled) { + // If near something grabbable, grab it! + if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && nearGrabEnabled) { var props = entityPropertiesCache.getProps(entity); var grabProps = entityPropertiesCache.getGrabProps(entity); var refCount = grabProps.refCount ? grabProps.refCount : 0; @@ -1629,7 +1632,7 @@ function MyController(hand) { // potentialFarTriggerEntity = entity; } } else if (this.entityIsDistanceGrabbable(rayPickInfo.entityID, handPosition)) { - if (this.triggerSmoothedGrab() && !isEditing() && farGrabEnabled) { + if (this.triggerSmoothedGrab() && !isEditing() && farGrabEnabled && farSearching) { this.grabbedEntity = entity; this.setState(STATE_DISTANCE_HOLDING, "distance hold '" + name + "'"); return; @@ -1706,7 +1709,7 @@ function MyController(hand) { equipHotspotBuddy.highlightHotspot(potentialEquipHotspot); } - if (farGrabEnabled) { + if (farGrabEnabled && farSearching) { this.searchIndicatorOn(rayPickInfo.searchRay); } Reticle.setVisible(false); @@ -2145,7 +2148,7 @@ function MyController(hand) { this.grabPointSphereOff(); - if (this.state == STATE_NEAR_GRABBING && !this.triggerClicked) { + if (this.state == STATE_NEAR_GRABBING && (!this.triggerClicked && this.secondaryReleased())) { this.callEntityMethodOnGrabbed("releaseGrab"); this.setState(STATE_OFF, "trigger released"); return; @@ -2648,7 +2651,7 @@ function MyController(hand) { this.grabbedOverlay = null; this.grabbedHotspot = null; - if (this.triggerSmoothedGrab()) { + if (this.triggerSmoothedGrab() || this.secondarySqueezed()) { this.waitForTriggerRelease = true; } }; From 250d0717884008c993c6ee7317df21e387ad0aad Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Mon, 19 Dec 2016 17:05:34 -0800 Subject: [PATCH 03/12] grip squeezes fingers too --- scripts/system/controllers/squeezeHands.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/system/controllers/squeezeHands.js b/scripts/system/controllers/squeezeHands.js index f06529f2b2..1e94c29521 100644 --- a/scripts/system/controllers/squeezeHands.js +++ b/scripts/system/controllers/squeezeHands.js @@ -53,9 +53,9 @@ function animStateHandler(props) { } function update(dt) { - var leftTrigger = normalizeControllerValue(Controller.getValue(Controller.Standard.LT)); - var rightTrigger = normalizeControllerValue(Controller.getValue(Controller.Standard.RT)); - + var leftTrigger = clamp(Controller.getValue(Controller.Standard.LT) + Controller.getValue(Controller.Standard.LeftGrip), 0, 1); + var rightTrigger = clamp(Controller.getValue(Controller.Standard.RT) + Controller.getValue(Controller.Standard.RightGrip), 0, 1); + // Average last few trigger values together for a bit of smoothing var tau = clamp(dt / TRIGGER_SMOOTH_TIMESCALE, 0, 1); lastLeftTrigger = lerp(leftTrigger, lastLeftTrigger, tau); From 13e03b35cc39b0498230e910de8d92278c22fe47 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Tue, 20 Dec 2016 13:23:28 -0800 Subject: [PATCH 04/12] removed initial delay for seek beams --- scripts/system/controllers/handControllerGrab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index ee810108c2..f75fcd1e9b 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1468,7 +1468,7 @@ function MyController(hand) { this.search = function(deltaTime, timestamp) { var _this = this; var name; - var FAR_SEARCH_DELAY = 350; // msecs before search beam appears + var FAR_SEARCH_DELAY = 0; // msecs before search beam appears var farSearching = this.triggerSmoothedSqueezed() && (Date.now() - this.searchStartTime > FAR_SEARCH_DELAY); From 0a024616cc1ca939fb99ddf5e95279898fcc303e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 20 Dec 2016 14:21:23 -0800 Subject: [PATCH 05/12] add special equip for oculus style grab --- .../system/controllers/handControllerGrab.js | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index f75fcd1e9b..d17ff0582e 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -823,7 +823,7 @@ function MyController(hand) { if (this.hand === RIGHT_HAND && this.state === STATE_SEARCHING && this.getOtherHandController().state === STATE_SEARCHING) { this.maybeScaleMyAvatar(); } - + if (this.ignoreInput()) { this.turnOffVisualizations(); return; @@ -1063,11 +1063,16 @@ function MyController(hand) { this.secondaryPress = function(value) { _this.rawSecondaryValue = value; - // The value to check if we will allow the release function to be called - var allowReleaseValue = 0.1; - if (value > 0 && _this.state == STATE_HOLD) { - _this.release(); + if (_this.state == STATE_HOLD && !this.secondaryHeldEquip) { + // when using the index trigger click equip + // any click on the middle finger trigger should release + // check if the middle finger trigger is pressed past the threshold + var allowReleaseValue = 0.1; + if (value > allowReleaseValue) { + _this.release(); + } } + }; this.updateSmoothedTrigger = function() { @@ -1095,6 +1100,12 @@ function MyController(hand) { this.secondaryReleased = function() { return _this.rawSecondaryValue < BUMPER_ON_VALUE; + + if (_this.state == STATE_HOLD && this.secondaryHeldEquip) { + // when using the middle finger hold equip, the equip is + // dropped when the middle finger trigger is released + _this.release(); + } }; // this.triggerOrsecondarySqueezed = function () { @@ -1502,6 +1513,10 @@ function MyController(hand) { this.grabbedHotspot = potentialEquipHotspot; this.grabbedEntity = potentialEquipHotspot.entityID; this.setState(STATE_HOLD, "equipping '" + entityPropertiesCache.getProps(this.grabbedEntity).name + "'"); + + // handle the Oculus Touch equip where the middle finger trigger is held + this.secondaryHeldEquip = this.secondarySqueezed && !this.triggerSmoothedGrab; + return; } } From 8cd13eaedf84ed8d9517ff94a88c206806c22191 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 20 Dec 2016 14:25:26 -0800 Subject: [PATCH 06/12] always unequip on secondary release --- .../system/controllers/handControllerGrab.js | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index d17ff0582e..628d568ddd 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1062,17 +1062,6 @@ function MyController(hand) { this.secondaryPress = function(value) { _this.rawSecondaryValue = value; - - if (_this.state == STATE_HOLD && !this.secondaryHeldEquip) { - // when using the index trigger click equip - // any click on the middle finger trigger should release - // check if the middle finger trigger is pressed past the threshold - var allowReleaseValue = 0.1; - if (value > allowReleaseValue) { - _this.release(); - } - } - }; this.updateSmoothedTrigger = function() { @@ -1101,9 +1090,9 @@ function MyController(hand) { this.secondaryReleased = function() { return _this.rawSecondaryValue < BUMPER_ON_VALUE; - if (_this.state == STATE_HOLD && this.secondaryHeldEquip) { - // when using the middle finger hold equip, the equip is - // dropped when the middle finger trigger is released + if (_this.state == STATE_HOLD) { + // if we were holding something, the release of the + // secondary trigger releases it _this.release(); } }; @@ -1514,9 +1503,6 @@ function MyController(hand) { this.grabbedEntity = potentialEquipHotspot.entityID; this.setState(STATE_HOLD, "equipping '" + entityPropertiesCache.getProps(this.grabbedEntity).name + "'"); - // handle the Oculus Touch equip where the middle finger trigger is held - this.secondaryHeldEquip = this.secondarySqueezed && !this.triggerSmoothedGrab; - return; } } From 4a25b727d88927c1b0294c3dae3dfd97c00734e8 Mon Sep 17 00:00:00 2001 From: David Kelly Date: Tue, 20 Dec 2016 14:26:45 -0800 Subject: [PATCH 07/12] Add comment back, with interest --- libraries/networking/src/NodeList.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 4c3ff29270..4606c44cd1 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -373,6 +373,7 @@ void NodeList::sendDomainServerCheckIn() { packetStream << hardwareAddress; + // now add the machine fingerprint - a null UUID if logged in, real one if not logged in auto accountManager = DependencyManager::get(); packetStream << (accountManager->isLoggedIn() ? QUuid() : FingerprintUtils::getMachineFingerprint()); } From c3d736dd16c1543413c523827ae3a6d36a34368a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 20 Dec 2016 14:30:08 -0800 Subject: [PATCH 08/12] return after release, duh --- scripts/system/controllers/handControllerGrab.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 628d568ddd..5f42882194 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1088,13 +1088,15 @@ function MyController(hand) { }; this.secondaryReleased = function() { - return _this.rawSecondaryValue < BUMPER_ON_VALUE; + var released = _this.rawSecondaryValue < BUMPER_ON_VALUE; - if (_this.state == STATE_HOLD) { + if (released) { // if we were holding something, the release of the // secondary trigger releases it _this.release(); } + + return released; }; // this.triggerOrsecondarySqueezed = function () { From 4fcccb545559e741f159890882b09b19870c8b5c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 20 Dec 2016 14:32:47 -0800 Subject: [PATCH 09/12] check for release of equip in this.nearGrabbing --- .../system/controllers/handControllerGrab.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 5f42882194..040b083a69 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1088,15 +1088,7 @@ function MyController(hand) { }; this.secondaryReleased = function() { - var released = _this.rawSecondaryValue < BUMPER_ON_VALUE; - - if (released) { - // if we were holding something, the release of the - // secondary trigger releases it - _this.release(); - } - - return released; + return _this.rawSecondaryValue < BUMPER_ON_VALUE; }; // this.triggerOrsecondarySqueezed = function () { @@ -2159,6 +2151,13 @@ function MyController(hand) { if (this.state == STATE_HOLD) { + if (this.secondaryReleased()) { + // we have an equipped object and the secondary trigger was released + // short-circuit the other checks and release it + this.release() + return; + } + var dropDetected = this.dropGestureProcess(deltaTime); if (this.triggerSmoothedReleased()) { From ebd347fc15e683d6b57ae66a07e31f5dc3460d76 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 20 Dec 2016 14:46:55 -0800 Subject: [PATCH 10/12] only respect release of secondary for hold once pressed --- scripts/system/controllers/handControllerGrab.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 040b083a69..1f536b9567 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1470,6 +1470,7 @@ function MyController(hand) { this.grabbedOverlay = null; this.isInitialGrab = false; this.shouldResetParentOnRelease = false; + this.preparingHoldRelease = false; this.checkForStrayChildren(); @@ -2151,10 +2152,19 @@ function MyController(hand) { if (this.state == STATE_HOLD) { - if (this.secondaryReleased()) { + if (this.secondarySqueezed()) { + // this.secondaryReleased() will always be true when not depressed + // so we cannot simply rely on that for release - ensure that the + // trigger was first "prepared" by being pushed in before the release + this.preparingHoldRelease = true; + } + + if (this.preparingHoldRelease && this.secondaryReleased()) { // we have an equipped object and the secondary trigger was released // short-circuit the other checks and release it - this.release() + this.preparingHoldRelease = false; + + this.release(); return; } From 3f4faec15ff7aef8e0971e12dc47ee3e158f52fd Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 20 Dec 2016 16:14:59 -0800 Subject: [PATCH 11/12] Fix idententity packet in AC --- libraries/avatars/src/AvatarHashMap.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp index ffb945df4c..241568aab3 100644 --- a/libraries/avatars/src/AvatarHashMap.cpp +++ b/libraries/avatars/src/AvatarHashMap.cpp @@ -134,11 +134,16 @@ void AvatarHashMap::processAvatarIdentityPacket(QSharedPointer // make sure this isn't for an ignored avatar auto nodeList = DependencyManager::get(); static auto EMPTY = QUuid(); - if (identity.uuid == _avatarHash.value(EMPTY)->getSessionUUID()) { - // We add MyAvatar to _avatarHash with an empty UUID. Code relies on this. In order to correctly handle an - // identity packet for ourself (such as when we are assigned a sessionDisplayName by the mixer upon joining), - // we make things match here. - identity.uuid = EMPTY; + + { + QWriteLocker locker(&_hashLock); + auto me = _avatarHash.find(EMPTY); + if ((me != _avatarHash.end()) && (identity.uuid == me.value()->getSessionUUID())) { + // We add MyAvatar to _avatarHash with an empty UUID. Code relies on this. In order to correctly handle an + // identity packet for ourself (such as when we are assigned a sessionDisplayName by the mixer upon joining), + // we make things match here. + identity.uuid = EMPTY; + } } if (!nodeList->isIgnoringNode(identity.uuid)) { // mesh URL for a UUID, find avatar in our list From a6e353d75f034005437297e3eb3aa9c21d49b743 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 20 Dec 2016 16:25:23 -0800 Subject: [PATCH 12/12] read lock, not write --- libraries/avatars/src/AvatarHashMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp index 241568aab3..8871769261 100644 --- a/libraries/avatars/src/AvatarHashMap.cpp +++ b/libraries/avatars/src/AvatarHashMap.cpp @@ -136,7 +136,7 @@ void AvatarHashMap::processAvatarIdentityPacket(QSharedPointer static auto EMPTY = QUuid(); { - QWriteLocker locker(&_hashLock); + QReadLocker locker(&_hashLock); auto me = _avatarHash.find(EMPTY); if ((me != _avatarHash.end()) && (identity.uuid == me.value()->getSessionUUID())) { // We add MyAvatar to _avatarHash with an empty UUID. Code relies on this. In order to correctly handle an