mirror of
https://github.com/lubosz/overte.git
synced 2025-04-10 15:57:39 +02:00
Replace Pointers API function setNonHoverItems() with setDoesHover()
This commit is contained in:
parent
403dd3d7d0
commit
e0e6fc711b
8 changed files with 77 additions and 83 deletions
|
@ -24,10 +24,6 @@ void PointerScriptingInterface::setIncludeItems(unsigned int uid, const QScriptV
|
|||
DependencyManager::get<PointerManager>()->setIncludeItems(uid, qVectorQUuidFromScriptValue(includeItems));
|
||||
}
|
||||
|
||||
void PointerScriptingInterface::setNonHoverItems(unsigned int uid, const QScriptValue& nonHoverItems) const {
|
||||
DependencyManager::get<PointerManager>()->setNonHoverItems(uid, qVectorQUuidFromScriptValue(nonHoverItems));
|
||||
}
|
||||
|
||||
unsigned int PointerScriptingInterface::createPointer(const PickQuery::PickType& type, const QVariant& properties) {
|
||||
// Interaction with managers should always happen on the main thread
|
||||
if (QThread::currentThread() != qApp->thread()) {
|
||||
|
@ -179,4 +175,8 @@ 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);
|
||||
}
|
||||
|
|
|
@ -191,14 +191,6 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE void setIncludeItems(unsigned int uid, const QScriptValue& includeEntities) const;
|
||||
|
||||
/**jsdoc
|
||||
* Sets a list of Entity IDs, Overlay IDs, and/or Avatar IDs that the pointer should not send hover events to.
|
||||
* @function Pointers.setNonHoverItems
|
||||
* @param {number} uid - The ID of the Pointer, as returned by {@link Pointers.createPointer}.
|
||||
* @param {Uuid[]} nonHoverItems - A list of IDs to that hover events should not be sent to.
|
||||
*/
|
||||
Q_INVOKABLE void setNonHoverItems(unsigned int uid, const QScriptValue& nonHoverItems) const;
|
||||
|
||||
/**jsdoc
|
||||
* Lock a Pointer onto a specific object (overlay, entity, or avatar). Optionally, provide an offset in object-space, otherwise the Pointer will lock on to the center of the object.
|
||||
* Not used by Stylus Pointers.
|
||||
|
@ -210,6 +202,14 @@ 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
|
||||
|
|
|
@ -52,12 +52,6 @@ void Pointer::setIncludeItems(const QVector<QUuid>& includeItems) const {
|
|||
DependencyManager::get<PickManager>()->setIncludeItems(_pickUID, includeItems);
|
||||
}
|
||||
|
||||
void Pointer::setNonHoverItems(const QVector<QUuid>& nonHoverItems) {
|
||||
withWriteLock([&] {
|
||||
_nonHoverItems = nonHoverItems;
|
||||
});
|
||||
}
|
||||
|
||||
bool Pointer::isLeftHand() const {
|
||||
return DependencyManager::get<PickManager>()->isLeftHand(_pickUID);
|
||||
}
|
||||
|
@ -70,6 +64,12 @@ 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,11 +101,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin
|
|||
}
|
||||
|
||||
// Hover events
|
||||
bool doHover = shouldHover(pickResult);
|
||||
|
||||
auto pickResultMap = pickResult->toVariantMap();
|
||||
auto uuid = QUuid(pickResultMap.value("objectID", "").toString());
|
||||
doHover = doHover && !_nonHoverItems.contains(uuid);
|
||||
bool doHover = _hover && shouldHover(pickResult);
|
||||
|
||||
Pointer::PickedObject hoveredObject = getHoveredObject(pickResult);
|
||||
PointerEvent hoveredEvent = buildPointerEvent(hoveredObject, pickResult);
|
||||
|
@ -240,7 +236,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin
|
|||
}
|
||||
|
||||
// if we disable the pointer or disable hovering, send hoverEnd events after triggerEnd
|
||||
if (_hover && ((!_enabled && _prevEnabled) || (!doHover && _prevDoHover))) {
|
||||
if ((_hover || _prevHover) && ((!_enabled && _prevEnabled) || (!doHover && _prevDoHover))) {
|
||||
if (_prevHoveredObject.type == ENTITY) {
|
||||
emit pointerManager->hoverEndEntity(_prevHoveredObject.objectID, hoveredEvent);
|
||||
} else if (_prevHoveredObject.type == OVERLAY) {
|
||||
|
@ -253,6 +249,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin
|
|||
_prevHoveredObject = hoveredObject;
|
||||
_prevButtons = buttons;
|
||||
_prevEnabled = _enabled;
|
||||
_prevHover = _hover;
|
||||
_prevDoHover = doHover;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,8 +54,6 @@ public:
|
|||
virtual void setIgnoreItems(const QVector<QUuid>& ignoreItems) const;
|
||||
virtual void setIncludeItems(const QVector<QUuid>& includeItems) const;
|
||||
|
||||
void setNonHoverItems(const QVector<QUuid>& nonHoverItems);
|
||||
|
||||
bool isLeftHand() const;
|
||||
bool isRightHand() const;
|
||||
bool isMouse() const;
|
||||
|
@ -64,6 +62,8 @@ public:
|
|||
virtual void setLength(float length) {}
|
||||
virtual void setLockEndUUID(const QUuid& objectID, bool isOverlay, const glm::mat4& offsetMat = glm::mat4()) {}
|
||||
|
||||
void setDoesHover(bool hover);
|
||||
|
||||
void update(unsigned int pointerID);
|
||||
virtual void updateVisuals(const PickResultPointer& pickResult) = 0;
|
||||
void generatePointerEvents(unsigned int pointerID, const PickResultPointer& pickResult);
|
||||
|
@ -99,12 +99,11 @@ private:
|
|||
PickedObject _prevHoveredObject;
|
||||
Buttons _prevButtons;
|
||||
bool _prevEnabled { false };
|
||||
bool _prevHover { false };
|
||||
bool _prevDoHover { false };
|
||||
std::unordered_map<std::string, PickedObject> _triggeredObjects;
|
||||
|
||||
PointerEvent::Button chooseButton(const std::string& button);
|
||||
|
||||
QVector<QUuid> _nonHoverItems;
|
||||
};
|
||||
|
||||
#endif // hifi_Pick_h
|
||||
|
|
|
@ -108,13 +108,6 @@ void PointerManager::setIncludeItems(unsigned int uid, const QVector<QUuid>& inc
|
|||
}
|
||||
}
|
||||
|
||||
void PointerManager::setNonHoverItems(unsigned int uid, const QVector<QUuid>& nonHoverItems) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
pointer->setNonHoverItems(nonHoverItems);
|
||||
}
|
||||
}
|
||||
|
||||
void PointerManager::setLength(unsigned int uid, float length) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
|
@ -129,6 +122,13 @@ 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) {
|
||||
|
|
|
@ -34,10 +34,10 @@ public:
|
|||
void setPrecisionPicking(unsigned int uid, bool precisionPicking) const;
|
||||
void setIgnoreItems(unsigned int uid, const QVector<QUuid>& ignoreEntities) const;
|
||||
void setIncludeItems(unsigned int uid, const QVector<QUuid>& includeEntities) const;
|
||||
void setNonHoverItems(unsigned int uid, const QVector<QUuid>& nonHoverItems) const;
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -46,10 +46,10 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
this.tabletID = null;
|
||||
this.TABLET_UI_UUIDS = [];
|
||||
this.blacklist = [];
|
||||
this.leftPointerNonHoverItem = null;
|
||||
this.leftPointerNonHoverItemChanged = false;
|
||||
this.rightPointerNonHoverItem = null;
|
||||
this.rightPointerNonHoverItemChanged = false;
|
||||
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
|
||||
|
@ -163,26 +163,14 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
}
|
||||
};
|
||||
|
||||
this.setNonHoverItems = function () {
|
||||
if (_this.leftPointerNonHoverItemChanged) {
|
||||
if (_this.leftPointerNonHoverItem === null) {
|
||||
Pointers.setNonHoverItems(_this.leftPointer, []);
|
||||
} else if (_this.isTabletID(_this.leftPointerNonHoverItem)) {
|
||||
Pointers.setNonHoverItems(_this.leftPointer, _this.TABLET_UI_UUIDS);
|
||||
} else {
|
||||
Pointers.setNonHoverItems(_this.leftPointer, [_this.leftPointerNonHoverItem]);
|
||||
}
|
||||
_this.leftPointerNonHoverItemChanged = false;
|
||||
this.updateHovering = function () {
|
||||
if (_this.leftPointerDoesHoverChanged) {
|
||||
Pointers.setDoesHover(_this.leftPointer, _this.leftPointerDoesHover);
|
||||
_this.leftPointerDoesHoverChanged = false;
|
||||
}
|
||||
if (_this.rightPointerNonHoverItemChanged) {
|
||||
if (_this.rightPointerNonHoverItem === null) {
|
||||
Pointers.setNonHoverItems(_this.rightPointer, []);
|
||||
} else if (_this.isTabletID(_this.rightPointerNonHoverItem)) {
|
||||
Pointers.setNonHoverItems(_this.rightPointer, _this.TABLET_UI_UUIDS);
|
||||
} else {
|
||||
Pointers.setNonHoverItems(_this.rightPointer, [_this.rightPointerNonHoverItem]);
|
||||
}
|
||||
_this.rightPointerNonHoverItemChanged = false;
|
||||
if (_this.rightPointerDoesHoverChanged) {
|
||||
Pointers.setDoesHover(_this.rightPointer, _this.rightPointerDoesHover);
|
||||
_this.rightPointerDoesHoverChanged = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -358,15 +346,15 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
_this.markSlots(candidatePlugin, orderedPluginName);
|
||||
_this.pointerManager.makePointerVisible(candidatePlugin.parameters.handLaser);
|
||||
|
||||
if (candidatePlugin.parameters.handLaser.nonHoverItem !== undefined) {
|
||||
if (candidatePlugin.parameters.handLaser.doesHover !== undefined) {
|
||||
if (candidatePlugin.parameters.handLaser.hand === LEFT_HAND
|
||||
&& _this.leftPointerNonHoverItem !== candidatePlugin.parameters.handLaser.nonHoverItem) {
|
||||
_this.leftPointerNonHoverItem = candidatePlugin.parameters.handLaser.nonHoverItem;
|
||||
_this.leftPointerNonHoverItemChanged = true;
|
||||
&& _this.leftPointerDoesHover !== candidatePlugin.parameters.handLaser.doesHover) {
|
||||
_this.leftPointerDoesHover = candidatePlugin.parameters.handLaser.doesHover;
|
||||
_this.leftPointerDoesHoverChanged = true;
|
||||
} else if (candidatePlugin.parameters.handLaser.hand === RIGHT_HAND
|
||||
&& _this.rightPointerNonHoverItem !== candidatePlugin.parameters.handLaser.nonHoverItem) {
|
||||
_this.rightPointerNonHoverItem = candidatePlugin.parameters.handLaser.nonHoverItem;
|
||||
_this.rightPointerNonHoverItemChanged = true;
|
||||
&& _this.rightPointerDoesHover !== candidatePlugin.parameters.handLaser.doesHover) {
|
||||
_this.rightPointerDoesHover = candidatePlugin.parameters.handLaser.doesHover;
|
||||
_this.rightPointerDoesHoverChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,15 +390,15 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
var runningness = plugin.run(controllerData, deltaTime);
|
||||
|
||||
if (runningness.active) {
|
||||
if (plugin.parameters.handLaser.nonHoverItem !== undefined) {
|
||||
if (plugin.parameters.handLaser.doesHover !== undefined) {
|
||||
if (plugin.parameters.handLaser.hand === LEFT_HAND
|
||||
&& _this.leftPointerNonHoverItem !== plugin.parameters.handLaser.nonHoverItem) {
|
||||
_this.leftPointerNonHoverItem = plugin.parameters.handLaser.nonHoverItem;
|
||||
_this.leftPointerNonHoverItemChanged = true;
|
||||
&& _this.leftPointerDoesHover !== plugin.parameters.handLaser.doesHover) {
|
||||
_this.leftPointerDoesHover = plugin.parameters.handLaser.doesHover;
|
||||
_this.leftPointerDoesHoverChanged = true;
|
||||
} else if (plugin.parameters.handLaser.hand === RIGHT_HAND
|
||||
&& _this.rightPointerNonHoverItem !== plugin.parameters.handLaser.nonHoverItem) {
|
||||
_this.rightPointerNonHoverItem = plugin.parameters.handLaser.nonHoverItem;
|
||||
_this.rightPointerNonHoverItemChanged = true;
|
||||
&& _this.rightPointerDoesHover !== plugin.parameters.handLaser.doesHover) {
|
||||
_this.rightPointerDoesHover = plugin.parameters.handLaser.doesHover;
|
||||
_this.rightPointerDoesHoverChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -421,6 +409,17 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
delete _this.runningPluginNames[runningPluginName];
|
||||
_this.markSlots(plugin, false);
|
||||
_this.pointerManager.makePointerInvisible(plugin.parameters.handLaser);
|
||||
|
||||
if (plugin.parameters.handLaser.doesHover !== undefined) {
|
||||
if (plugin.parameters.handLaser.hand === LEFT_HAND && !_this.leftPointerDoesHover) {
|
||||
_this.leftPointerDoesHover = true;
|
||||
_this.leftPointerDoesHoverChanged = true;
|
||||
} else if (plugin.parameters.handLaser.hand === RIGHT_HAND && !_this.rightPointerDoesHover) {
|
||||
_this.rightPointerDoesHover = true;
|
||||
_this.rightPointerDoesHoverChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
print("controllerDispatcher stopping " + runningPluginName);
|
||||
}
|
||||
|
@ -433,8 +432,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
}
|
||||
}
|
||||
_this.pointerManager.updatePointersRenderState(controllerData.triggerClicks, controllerData.triggerValues);
|
||||
|
||||
_this.setNonHoverItems();
|
||||
_this.updateHovering();
|
||||
|
||||
if (PROFILE) {
|
||||
Script.endProfileRange("dispatch.run");
|
||||
|
|
|
@ -90,7 +90,7 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
this.hoverItem = null;
|
||||
|
||||
this.isTabletID = function (uuid) {
|
||||
return [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID, HMD.homeButtonHightlightID].indexOf(uuid) !== -1;
|
||||
return [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID, HMD.homeButtonHighlightID].indexOf(uuid) !== -1;
|
||||
};
|
||||
|
||||
this.isReady = function(controllerData) {
|
||||
|
@ -105,19 +105,19 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
}
|
||||
|
||||
if (pointingAt !== this.getOtherModule().hoverItem) {
|
||||
this.parameters.handLaser.doesHover = true;
|
||||
this.hoverItem = pointingAt;
|
||||
this.getOtherModule().parameters.handLaser.nonHoverItem = pointingAt;
|
||||
} else {
|
||||
this.parameters.handLaser.doesHover = false;
|
||||
this.hoverItem = null;
|
||||
this.getOtherModule().parameters.handLaser.nonHoverItem = null;
|
||||
}
|
||||
|
||||
return makeRunningValues(true, [], []);
|
||||
}
|
||||
}
|
||||
|
||||
this.parameters.handLaser.doesHover = false;
|
||||
this.hoverItem = null;
|
||||
this.getOtherModule().parameters.handLaser.nonHoverItem = null;
|
||||
|
||||
return makeRunningValues(false, [], []);
|
||||
};
|
||||
|
@ -135,11 +135,11 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
}
|
||||
|
||||
if (pointingAt !== this.getOtherModule().hoverItem || isTriggerPressed) {
|
||||
this.parameters.handLaser.doesHover = true;
|
||||
this.hoverItem = pointingAt;
|
||||
this.getOtherModule().parameters.handLaser.nonHoverItem = pointingAt;
|
||||
} else {
|
||||
this.parameters.handLaser.doesHover = false;
|
||||
this.hoverItem = null;
|
||||
this.getOtherModule().parameters.handLaser.nonHoverItem = null;
|
||||
}
|
||||
|
||||
return makeRunningValues(true, [], []);
|
||||
|
@ -147,8 +147,8 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
this.deleteContextOverlay();
|
||||
this.running = false;
|
||||
|
||||
this.parameters.handLaser.doesHover = false;
|
||||
this.hoverItem = null;
|
||||
this.getOtherModule().parameters.handLaser.nonHoverItem = null;
|
||||
|
||||
return makeRunningValues(false, [], []);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue