Revert "Display both lasers on tablet and Web surfaces"

(cherry picked from commit 455090d2b9)
This commit is contained in:
John Conklin II 2018-01-19 15:15:52 -08:00 committed by SamGondelman
parent 623d552549
commit 1529fea983
8 changed files with 25 additions and 141 deletions

View file

@ -175,8 +175,4 @@ QVariantMap PointerScriptingInterface::getPrevPickResult(unsigned int uid) const
result = pickResult->toVariantMap();
}
return result;
}
void PointerScriptingInterface::setDoesHover(unsigned int uid, bool hover) const {
DependencyManager::get<PointerManager>()->setDoesHover(uid, hover);
}
}

View file

@ -202,14 +202,6 @@ public:
*/
Q_INVOKABLE void setLockEndUUID(unsigned int uid, const QUuid& objectID, bool isOverlay, const glm::mat4& offsetMat = glm::mat4()) const { DependencyManager::get<PointerManager>()->setLockEndUUID(uid, objectID, isOverlay, offsetMat); }
/**jsdoc
* Sets whether or not a pointer should generate hover events.
* @function Pointers.setDoesHover
* @param {boolean} uid - The ID of the Pointer, as returned by {@link Pointers.createPointer}.
* @param {boolean} hover - If <code>true</code> then the pointer generates hover events, otherwise it does not.
*/
Q_INVOKABLE void setDoesHover(unsigned int uid, bool hove) const;
/**jsdoc
* Check if a Pointer is associated with the left hand.
* @function Pointers.isLeftHand

View file

@ -64,12 +64,6 @@ bool Pointer::isMouse() const {
return DependencyManager::get<PickManager>()->isMouse(_pickUID);
}
void Pointer::setDoesHover(bool doesHover) {
withWriteLock([&] {
_hover = doesHover;
});
}
void Pointer::update(unsigned int pointerID) {
// This only needs to be a read lock because update won't change any of the properties that can be modified from scripts
withReadLock([&] {
@ -101,8 +95,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin
}
// Hover events
bool doHover = _hover && shouldHover(pickResult);
bool doHover = shouldHover(pickResult);
Pointer::PickedObject hoveredObject = getHoveredObject(pickResult);
PointerEvent hoveredEvent = buildPointerEvent(hoveredObject, pickResult);
hoveredEvent.setType(PointerEvent::Move);
@ -111,7 +104,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin
hoveredEvent.setMoveOnHoverLeave(moveOnHoverLeave);
// if shouldHover && !_prevDoHover, only send hoverBegin
if (_enabled && doHover && !_prevDoHover) {
if (_enabled && _hover && doHover && !_prevDoHover) {
if (hoveredObject.type == ENTITY) {
emit pointerManager->hoverBeginEntity(hoveredObject.objectID, hoveredEvent);
} else if (hoveredObject.type == OVERLAY) {
@ -119,7 +112,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin
} else if (hoveredObject.type == HUD) {
emit pointerManager->hoverBeginHUD(hoveredEvent);
}
} else if (_enabled && doHover) {
} else if (_enabled && _hover && doHover) {
if (hoveredObject.type == OVERLAY) {
if (_prevHoveredObject.type == OVERLAY) {
if (hoveredObject.objectID == _prevHoveredObject.objectID) {
@ -236,7 +229,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin
}
// if we disable the pointer or disable hovering, send hoverEnd events after triggerEnd
if ((!_enabled && _prevEnabled) || (!doHover && _prevDoHover)) {
if (_hover && ((!_enabled && _prevEnabled) || (!doHover && _prevDoHover))) {
if (_prevHoveredObject.type == ENTITY) {
emit pointerManager->hoverEndEntity(_prevHoveredObject.objectID, hoveredEvent);
} else if (_prevHoveredObject.type == OVERLAY) {

View file

@ -62,8 +62,6 @@ public:
virtual void setLength(float length) {}
virtual void setLockEndUUID(const QUuid& objectID, bool isOverlay, const glm::mat4& offsetMat = glm::mat4()) {}
virtual void setDoesHover(bool hover);
void update(unsigned int pointerID);
virtual void updateVisuals(const PickResultPointer& pickResult) = 0;
void generatePointerEvents(unsigned int pointerID, const PickResultPointer& pickResult);
@ -103,6 +101,7 @@ private:
std::unordered_map<std::string, PickedObject> _triggeredObjects;
PointerEvent::Button chooseButton(const std::string& button);
};
#endif // hifi_Pick_h

View file

@ -122,13 +122,6 @@ void PointerManager::setLockEndUUID(unsigned int uid, const QUuid& objectID, boo
}
}
void PointerManager::setDoesHover(unsigned int uid, bool hover) const {
auto pointer = find(uid);
if (pointer) {
pointer->setDoesHover(hover);
}
}
bool PointerManager::isLeftHand(unsigned int uid) {
auto pointer = find(uid);
if (pointer) {

View file

@ -37,7 +37,6 @@ public:
void setLength(unsigned int uid, float length) const;
void setLockEndUUID(unsigned int uid, const QUuid& objectID, bool isOverlay, const glm::mat4& offsetMat = glm::mat4()) const;
void setDoesHover(unsigned int uid, bool hover) const;
void update();

View file

@ -44,12 +44,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
this.highVarianceCount = 0;
this.veryhighVarianceCount = 0;
this.tabletID = null;
this.TABLET_UI_UUIDS = [];
this.blacklist = [];
this.leftPointerDoesHover = true;
this.leftPointerDoesHoverChanged = false;
this.rightPointerDoesHover = true;
this.rightPointerDoesHoverChanged = false;
this.pointerManager = new PointerManager();
// a module can occupy one or more "activity" slots while it's running. If all the required slots for a module are
@ -127,10 +122,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
return getControllerWorldLocation(Controller.Standard.RightHand, true);
};
this.isTabletID = function (uuid) {
return _this.TABLET_UI_UUIDS.indexOf(uuid) !== -1;
};
this.updateTimings = function () {
_this.intervalCount++;
var thisInterval = Date.now();
@ -157,35 +148,11 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
this.setIgnorePointerItems = function() {
if (HMD.tabletID !== this.tabletID) {
this.tabletID = HMD.tabletID;
this.TABLET_UI_UUIDS = [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID, HMD.homeButtonHighlightID];
Pointers.setIgnoreItems(_this.leftPointer, _this.blacklist);
Pointers.setIgnoreItems(_this.rightPointer, _this.blacklist);
}
};
this.updateDoesHover = function(handLaser, doesHover) {
if (handLaser.doesHover !== undefined) {
if (handLaser.hand === LEFT_HAND && _this.leftPointerDoesHover !== doesHover) {
_this.leftPointerDoesHover = doesHover;
_this.leftPointerDoesHoverChanged = true;
} else if (handLaser.hand === RIGHT_HAND && _this.rightPointerDoesHover !== doesHover) {
_this.rightPointerDoesHover = doesHover;
_this.rightPointerDoesHoverChanged = true;
}
}
}
this.updateHovering = function () {
if (_this.leftPointerDoesHoverChanged) {
Pointers.setDoesHover(_this.leftPointer, _this.leftPointerDoesHover);
_this.leftPointerDoesHoverChanged = false;
}
if (_this.rightPointerDoesHoverChanged) {
Pointers.setDoesHover(_this.rightPointer, _this.rightPointerDoesHover);
_this.rightPointerDoesHoverChanged = false;
}
};
this.update = function () {
try {
_this.updateInternal();
@ -357,8 +324,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
_this.runningPluginNames[orderedPluginName] = true;
_this.markSlots(candidatePlugin, orderedPluginName);
_this.pointerManager.makePointerVisible(candidatePlugin.parameters.handLaser);
_this.updateDoesHover(candidatePlugin.parameters.handLaser,
candidatePlugin.parameters.handLaser.doesHover);
if (DEBUG) {
print("controllerDispatcher running " + orderedPluginName);
}
@ -389,15 +354,12 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
Script.beginProfileRange("dispatch.run." + runningPluginName);
}
var runningness = plugin.run(controllerData, deltaTime);
if (runningness.active) {
_this.updateDoesHover(plugin.parameters.handLaser, plugin.parameters.handLaser.doesHover);
} else {
if (!runningness.active) {
// plugin is finished running, for now. remove it from the list
// of running plugins and mark its activity-slots as "not in use"
delete _this.runningPluginNames[runningPluginName];
_this.markSlots(plugin, false);
_this.pointerManager.makePointerInvisible(plugin.parameters.handLaser);
_this.updateDoesHover(plugin.parameters.handLaser, true);
if (DEBUG) {
print("controllerDispatcher stopping " + runningPluginName);
}
@ -410,8 +372,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
}
}
_this.pointerManager.updatePointersRenderState(controllerData.triggerClicks, controllerData.triggerValues);
_this.updateHovering();
if (PROFILE) {
Script.endProfileRange("dispatch.run");
}

View file

@ -87,89 +87,41 @@ Script.include("/~/system/libraries/controllers.js");
return MyAvatar.getDominantHand() === "right" ? 1 : 0;
};
this.letOtherHandRunFirst = function (controllerData, pointingAt) {
// If both hands are ready to run, let the other hand run first if it is the dominant hand so that it gets the
// highlight.
var isOtherTriggerPressed = controllerData.triggerValues[this.otherHand] > TRIGGER_OFF_VALUE;
var isLetOtherHandRunFirst = !this.getOtherModule().running
&& this.getDominantHand() === this.otherHand
&& (this.parameters.handLaser.allwaysOn || isOtherTriggerPressed);
if (isLetOtherHandRunFirst) {
var otherHandPointingAt = controllerData.rayPicks[this.otherHand].objectID;
if (this.isTabletID(otherHandPointingAt)) {
otherHandPointingAt = HMD.tabletID;
}
isLetOtherHandRunFirst = pointingAt === otherHandPointingAt;
}
return isLetOtherHandRunFirst;
};
this.hoverItem = null;
this.isTabletID = function (uuid) {
return [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID, HMD.homeButtonHighlightID].indexOf(uuid) !== -1;
};
this.dominantHandOverride = false;
this.isReady = function(controllerData) {
if (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)) {
var otherModuleRunning = this.getOtherModule().running;
otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand.
var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE
&& controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE;
if ((!otherModuleRunning || isTriggerPressed)
&& (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData))) {
this.updateAllwaysOn();
var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE;
if (isTriggerPressed) {
this.dominantHandOverride = true; // Override dominant hand.
this.getOtherModule().dominantHandOverride = false;
}
if (this.parameters.handLaser.allwaysOn || isTriggerPressed) {
var pointingAt = controllerData.rayPicks[this.hand].objectID;
if (this.isTabletID(pointingAt)) {
pointingAt = HMD.tabletID;
}
if (!this.letOtherHandRunFirst(controllerData, pointingAt)) {
if (pointingAt !== this.getOtherModule().hoverItem) {
this.parameters.handLaser.doesHover = true;
this.hoverItem = pointingAt;
} else {
this.parameters.handLaser.doesHover = false;
this.hoverItem = null;
}
return makeRunningValues(true, [], []);
}
return makeRunningValues(true, [], []);
}
}
this.parameters.handLaser.doesHover = false;
this.hoverItem = null;
return makeRunningValues(false, [], []);
};
this.run = function(controllerData, deltaTime) {
var otherModuleRunning = this.getOtherModule().running;
otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand.
otherModuleRunning = otherModuleRunning || this.getOtherModule().dominantHandOverride; // Override dominant hand.
var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData);
var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE;
if (!grabModuleNeedsToRun && (isTriggerPressed || this.parameters.handLaser.allwaysOn
if (!otherModuleRunning && !grabModuleNeedsToRun && (controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE
|| this.parameters.handLaser.allwaysOn
&& (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)))) {
this.running = true;
var pointingAt = controllerData.rayPicks[this.hand].objectID;
if (this.isTabletID(pointingAt)) {
pointingAt = HMD.tabletID;
}
if (pointingAt !== this.getOtherModule().hoverItem || isTriggerPressed) {
this.parameters.handLaser.doesHover = true;
this.hoverItem = pointingAt;
} else {
this.parameters.handLaser.doesHover = false;
this.hoverItem = null;
}
return makeRunningValues(true, [], []);
}
this.deleteContextOverlay();
this.running = false;
this.parameters.handLaser.doesHover = false;
this.hoverItem = null;
this.dominantHandOverride = false;
return makeRunningValues(false, [], []);
};
}