mirror of
https://github.com/overte-org/overte.git
synced 2025-08-16 15:32:14 +02:00
Add Pointers API function that disables hover events for nominated items
This commit is contained in:
parent
9a382ebb86
commit
ee2936d133
6 changed files with 34 additions and 0 deletions
|
@ -24,6 +24,10 @@ 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()) {
|
||||
|
|
|
@ -191,6 +191,14 @@ 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.
|
||||
|
|
|
@ -52,6 +52,12 @@ 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);
|
||||
}
|
||||
|
@ -96,6 +102,11 @@ 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);
|
||||
|
||||
Pointer::PickedObject hoveredObject = getHoveredObject(pickResult);
|
||||
PointerEvent hoveredEvent = buildPointerEvent(hoveredObject, pickResult);
|
||||
hoveredEvent.setType(PointerEvent::Move);
|
||||
|
|
|
@ -54,6 +54,8 @@ 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;
|
||||
|
@ -102,6 +104,7 @@ private:
|
|||
|
||||
PointerEvent::Button chooseButton(const std::string& button);
|
||||
|
||||
QVector<QUuid> _nonHoverItems;
|
||||
};
|
||||
|
||||
#endif // hifi_Pick_h
|
||||
|
|
|
@ -108,6 +108,13 @@ 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) {
|
||||
|
|
|
@ -34,6 +34,7 @@ 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;
|
||||
|
|
Loading…
Reference in a new issue