From fb969964f3663131c88925a2571427a590d46fe4 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Fri, 20 Oct 2017 14:37:10 -0700 Subject: [PATCH] generalized scripting interfaces --- interface/src/Application.cpp | 12 +- .../LaserPointerScriptingInterface.cpp | 105 +------------ .../raypick/LaserPointerScriptingInterface.h | 7 +- .../src/raypick/PickScriptingInterface.cpp | 107 ++++++++++++++ .../src/raypick/PickScriptingInterface.h | 65 ++++++++ .../src/raypick/PointerScriptingInterface.cpp | 139 ++++++++++++++++++ .../src/raypick/PointerScriptingInterface.h | 46 ++++++ .../src/raypick/RayPickScriptingInterface.cpp | 50 +------ .../src/raypick/RayPickScriptingInterface.h | 31 +--- libraries/pointers/src/pointers/Pick.h | 7 + .../pointers/src/pointers/PickManager.cpp | 6 +- libraries/pointers/src/pointers/PickManager.h | 11 +- .../pointers/src/pointers/PointerManager.cpp | 2 +- .../pointers/src/pointers/PointerManager.h | 2 +- .../controllers/controllerDispatcher.js | 12 +- .../controllerModules/farActionGrabEntity.js | 8 +- .../controllerModules/farTrigger.js | 2 +- .../controllerModules/hudOverlayPointer.js | 2 +- .../controllerModules/inEditMode.js | 6 +- .../controllerModules/overlayLaserInput.js | 4 +- .../controllers/controllerModules/teleport.js | 10 +- .../controllerModules/webEntityLaserInput.js | 4 +- scripts/system/controllers/grab.js | 8 +- scripts/system/libraries/touchEventUtils.js | 2 +- 24 files changed, 417 insertions(+), 231 deletions(-) create mode 100644 interface/src/raypick/PickScriptingInterface.cpp create mode 100644 interface/src/raypick/PickScriptingInterface.h create mode 100644 interface/src/raypick/PointerScriptingInterface.cpp create mode 100644 interface/src/raypick/PointerScriptingInterface.h diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3476700904..26e659e118 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -197,6 +197,8 @@ #include #include #include +#include +#include #include #include @@ -696,6 +698,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); return previousSessionCrashed; } @@ -1825,14 +1829,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo DependencyManager::get()->setShouldPickHUDOperator([&]() { return DependencyManager::get()->isHMDMode(); }); // Setup the mouse ray pick and related operators - DependencyManager::get()->setMouseRayPickID(DependencyManager::get()->addPick(RAY, std::make_shared( - PickFilter(RayPickScriptingInterface::PICK_ENTITIES() | RayPickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()), 0.0f, true))); + DependencyManager::get()->setMouseRayPickID(DependencyManager::get()->addPick(PickQuery::Ray, std::make_shared( + PickFilter(PickScriptingInterface::PICK_ENTITIES() | PickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()), 0.0f, true))); DependencyManager::get()->setMouseRayPickResultOperator([&](QUuid rayPickID) { RayToEntityIntersectionResult entityResult; entityResult.intersects = false; QVariantMap result = DependencyManager::get()->getPrevPickResult(rayPickID); if (result["type"].isValid()) { - entityResult.intersects = result["type"] != RayPickScriptingInterface::INTERSECTED_NONE(); + entityResult.intersects = result["type"] != PickScriptingInterface::INTERSECTED_NONE(); if (entityResult.intersects) { entityResult.intersection = vec3FromVariant(result["intersection"]); entityResult.distance = result["distance"].toFloat(); @@ -5798,6 +5802,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe scriptEngine->registerGlobalObject("RayPick", DependencyManager::get().data()); scriptEngine->registerGlobalObject("LaserPointers", DependencyManager::get().data()); + scriptEngine->registerGlobalObject("Picks", DependencyManager::get().data()); + scriptEngine->registerGlobalObject("Pointers", DependencyManager::get().data()); // Caches scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get().data()); diff --git a/interface/src/raypick/LaserPointerScriptingInterface.cpp b/interface/src/raypick/LaserPointerScriptingInterface.cpp index 779f9ff605..8f8f9d921a 100644 --- a/interface/src/raypick/LaserPointerScriptingInterface.cpp +++ b/interface/src/raypick/LaserPointerScriptingInterface.cpp @@ -15,6 +15,7 @@ #include +#include "PointerScriptingInterface.h" #include "Application.h" void LaserPointerScriptingInterface::setIgnoreItems(const QUuid& uid, const QScriptValue& ignoreItems) const { @@ -25,109 +26,9 @@ void LaserPointerScriptingInterface::setIncludeItems(const QUuid& uid, const QSc } QUuid LaserPointerScriptingInterface::createLaserPointer(const QVariant& properties) const { - QVariantMap propertyMap = properties.toMap(); - - bool faceAvatar = false; - if (propertyMap["faceAvatar"].isValid()) { - faceAvatar = propertyMap["faceAvatar"].toBool(); - } - - bool centerEndY = true; - if (propertyMap["centerEndY"].isValid()) { - centerEndY = propertyMap["centerEndY"].toBool(); - } - - bool lockEnd = false; - if (propertyMap["lockEnd"].isValid()) { - lockEnd = propertyMap["lockEnd"].toBool(); - } - - bool enabled = false; - if (propertyMap["enabled"].isValid()) { - enabled = propertyMap["enabled"].toBool(); - } - - LaserPointer::RenderStateMap renderStates; - if (propertyMap["renderStates"].isValid()) { - QList renderStateVariants = propertyMap["renderStates"].toList(); - for (QVariant& renderStateVariant : renderStateVariants) { - if (renderStateVariant.isValid()) { - QVariantMap renderStateMap = renderStateVariant.toMap(); - if (renderStateMap["name"].isValid()) { - std::string name = renderStateMap["name"].toString().toStdString(); - renderStates[name] = buildRenderState(renderStateMap); - } - } - } - } - - LaserPointer::DefaultRenderStateMap defaultRenderStates; - if (propertyMap["defaultRenderStates"].isValid()) { - QList renderStateVariants = propertyMap["defaultRenderStates"].toList(); - for (QVariant& renderStateVariant : renderStateVariants) { - if (renderStateVariant.isValid()) { - QVariantMap renderStateMap = renderStateVariant.toMap(); - if (renderStateMap["name"].isValid() && renderStateMap["distance"].isValid()) { - std::string name = renderStateMap["name"].toString().toStdString(); - float distance = renderStateMap["distance"].toFloat(); - defaultRenderStates[name] = std::pair(distance, buildRenderState(renderStateMap)); - } - } - } - } - - return DependencyManager::get()->addPointer(std::make_shared(properties, renderStates, defaultRenderStates, faceAvatar, centerEndY, lockEnd, enabled)); + return DependencyManager::get()->createLaserPointer(properties); } void LaserPointerScriptingInterface::editRenderState(const QUuid& uid, const QString& renderState, const QVariant& properties) const { - QVariantMap propMap = properties.toMap(); - - QVariant startProps; - if (propMap["start"].isValid()) { - startProps = propMap["start"]; - } - - QVariant pathProps; - if (propMap["path"].isValid()) { - pathProps = propMap["path"]; - } - - QVariant endProps; - if (propMap["end"].isValid()) { - endProps = propMap["end"]; - } - - DependencyManager::get()->editRenderState(uid, renderState.toStdString(), startProps, pathProps, endProps); -} - -RenderState LaserPointerScriptingInterface::buildRenderState(const QVariantMap& propMap) { - QUuid startID; - if (propMap["start"].isValid()) { - QVariantMap startMap = propMap["start"].toMap(); - if (startMap["type"].isValid()) { - startMap.remove("visible"); - startID = qApp->getOverlays().addOverlay(startMap["type"].toString(), startMap); - } - } - - QUuid pathID; - if (propMap["path"].isValid()) { - QVariantMap pathMap = propMap["path"].toMap(); - // right now paths must be line3ds - if (pathMap["type"].isValid() && pathMap["type"].toString() == "line3d") { - pathMap.remove("visible"); - pathID = qApp->getOverlays().addOverlay(pathMap["type"].toString(), pathMap); - } - } - - QUuid endID; - if (propMap["end"].isValid()) { - QVariantMap endMap = propMap["end"].toMap(); - if (endMap["type"].isValid()) { - endMap.remove("visible"); - endID = qApp->getOverlays().addOverlay(endMap["type"].toString(), endMap); - } - } - - return RenderState(startID, pathID, endID); + DependencyManager::get()->editRenderState(uid, renderState, properties); } \ No newline at end of file diff --git a/interface/src/raypick/LaserPointerScriptingInterface.h b/interface/src/raypick/LaserPointerScriptingInterface.h index b2e46f66d6..1116da1528 100644 --- a/interface/src/raypick/LaserPointerScriptingInterface.h +++ b/interface/src/raypick/LaserPointerScriptingInterface.h @@ -16,8 +16,6 @@ #include "DependencyManager.h" #include -#include "LaserPointer.h" - class LaserPointerScriptingInterface : public QObject, public Dependency { Q_OBJECT SINGLETON_DEPENDENCY @@ -29,7 +27,7 @@ public slots: Q_INVOKABLE void removeLaserPointer(const QUuid& uid) const { DependencyManager::get()->removePointer(uid); } Q_INVOKABLE void editRenderState(const QUuid& uid, const QString& renderState, const QVariant& properties) const; Q_INVOKABLE void setRenderState(const QUuid& uid, const QString& renderState) const { DependencyManager::get()->setRenderState(uid, renderState.toStdString()); } - Q_INVOKABLE QVariantMap getPrevRayPickResult(QUuid uid) const { return DependencyManager::get()->getPrevRayPickResult(uid); } + Q_INVOKABLE QVariantMap getPrevRayPickResult(QUuid uid) const { return DependencyManager::get()->getPrevPickResult(uid); } Q_INVOKABLE void setPrecisionPicking(const QUuid& uid, bool precisionPicking) const { DependencyManager::get()->setPrecisionPicking(uid, precisionPicking); } Q_INVOKABLE void setLaserLength(const QUuid& uid, float laserLength) const { DependencyManager::get()->setLength(uid, laserLength); } @@ -38,9 +36,6 @@ public slots: Q_INVOKABLE void setLockEndUUID(const QUuid& uid, const QUuid& objectID, bool isOverlay) const { DependencyManager::get()->setLockEndUUID(uid, objectID, isOverlay); } -private: - static RenderState buildRenderState(const QVariantMap& propMap); - }; #endif // hifi_LaserPointerScriptingInterface_h diff --git a/interface/src/raypick/PickScriptingInterface.cpp b/interface/src/raypick/PickScriptingInterface.cpp new file mode 100644 index 0000000000..99f7ac2515 --- /dev/null +++ b/interface/src/raypick/PickScriptingInterface.cpp @@ -0,0 +1,107 @@ +// +// Created by Sam Gondelman 10/20/2017 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "PickScriptingInterface.h" + +#include +#include "GLMHelpers.h" + +#include + +#include "StaticRayPick.h" +#include "JointRayPick.h" +#include "MouseRayPick.h" + +QUuid PickScriptingInterface::createPick(const PickQuery::PickType type, const QVariant& properties) { + switch (type) { + case PickQuery::PickType::Ray: + return createRayPick(properties); + default: + return QUuid(); + } +} + +QUuid PickScriptingInterface::createRayPick(const QVariant& properties) { + QVariantMap propMap = properties.toMap(); + + bool enabled = false; + if (propMap["enabled"].isValid()) { + enabled = propMap["enabled"].toBool(); + } + + PickFilter filter = PickFilter(); + if (propMap["filter"].isValid()) { + filter = PickFilter(propMap["filter"].toUInt()); + } + + float maxDistance = 0.0f; + if (propMap["maxDistance"].isValid()) { + maxDistance = propMap["maxDistance"].toFloat(); + } + + if (propMap["joint"].isValid()) { + std::string jointName = propMap["joint"].toString().toStdString(); + + if (jointName != "Mouse") { + // x = upward, y = forward, z = lateral + glm::vec3 posOffset = Vectors::ZERO; + if (propMap["posOffset"].isValid()) { + posOffset = vec3FromVariant(propMap["posOffset"]); + } + + glm::vec3 dirOffset = Vectors::UP; + if (propMap["dirOffset"].isValid()) { + dirOffset = vec3FromVariant(propMap["dirOffset"]); + } + + return DependencyManager::get()->addPick(PickQuery::Ray, std::make_shared(jointName, posOffset, dirOffset, filter, maxDistance, enabled)); + + } else { + return DependencyManager::get()->addPick(PickQuery::Ray, std::make_shared(filter, maxDistance, enabled)); + } + } else if (propMap["position"].isValid()) { + glm::vec3 position = vec3FromVariant(propMap["position"]); + + glm::vec3 direction = -Vectors::UP; + if (propMap["direction"].isValid()) { + direction = vec3FromVariant(propMap["direction"]); + } + + return DependencyManager::get()->addPick(PickQuery::Ray, std::make_shared(position, direction, filter, maxDistance, enabled)); + } + + return QUuid(); +} + +void PickScriptingInterface::enablePick(const QUuid& uid) { + DependencyManager::get()->enablePick(uid); +} + +void PickScriptingInterface::disablePick(const QUuid& uid) { + DependencyManager::get()->disablePick(uid); +} + +void PickScriptingInterface::removePick(const QUuid& uid) { + DependencyManager::get()->removePick(uid); +} + +QVariantMap PickScriptingInterface::getPrevPickResult(const QUuid& uid) { + return DependencyManager::get()->getPrevPickResult(uid); +} + +void PickScriptingInterface::setPrecisionPicking(const QUuid& uid, const bool precisionPicking) { + DependencyManager::get()->setPrecisionPicking(uid, precisionPicking); +} + +void PickScriptingInterface::setIgnoreItems(const QUuid& uid, const QScriptValue& ignoreItems) { + DependencyManager::get()->setIgnoreItems(uid, qVectorQUuidFromScriptValue(ignoreItems)); +} + +void PickScriptingInterface::setIncludeItems(const QUuid& uid, const QScriptValue& includeItems) { + DependencyManager::get()->setIncludeItems(uid, qVectorQUuidFromScriptValue(includeItems)); +} diff --git a/interface/src/raypick/PickScriptingInterface.h b/interface/src/raypick/PickScriptingInterface.h new file mode 100644 index 0000000000..462b64dbd1 --- /dev/null +++ b/interface/src/raypick/PickScriptingInterface.h @@ -0,0 +1,65 @@ +// +// Created by Sam Gondelman 10/20/2017 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#ifndef hifi_PickScriptingInterface_h +#define hifi_PickScriptingInterface_h + +#include + +#include +#include +#include + +class PickScriptingInterface : public QObject, public Dependency { + Q_OBJECT + Q_PROPERTY(unsigned int PICK_NOTHING READ PICK_NOTHING CONSTANT) + Q_PROPERTY(unsigned int PICK_ENTITIES READ PICK_ENTITIES CONSTANT) + Q_PROPERTY(unsigned int PICK_OVERLAYS READ PICK_OVERLAYS CONSTANT) + Q_PROPERTY(unsigned int PICK_AVATARS READ PICK_AVATARS CONSTANT) + Q_PROPERTY(unsigned int PICK_HUD READ PICK_HUD CONSTANT) + Q_PROPERTY(unsigned int PICK_COARSE READ PICK_COARSE CONSTANT) + Q_PROPERTY(unsigned int PICK_INCLUDE_INVISIBLE READ PICK_INCLUDE_INVISIBLE CONSTANT) + Q_PROPERTY(unsigned int PICK_INCLUDE_NONCOLLIDABLE READ PICK_INCLUDE_NONCOLLIDABLE CONSTANT) + Q_PROPERTY(unsigned int PICK_ALL_INTERSECTIONS READ PICK_ALL_INTERSECTIONS CONSTANT) + Q_PROPERTY(unsigned int INTERSECTED_NONE READ INTERSECTED_NONE CONSTANT) + Q_PROPERTY(unsigned int INTERSECTED_ENTITY READ INTERSECTED_ENTITY CONSTANT) + Q_PROPERTY(unsigned int INTERSECTED_OVERLAY READ INTERSECTED_OVERLAY CONSTANT) + Q_PROPERTY(unsigned int INTERSECTED_AVATAR READ INTERSECTED_AVATAR CONSTANT) + Q_PROPERTY(unsigned int INTERSECTED_HUD READ INTERSECTED_HUD CONSTANT) + SINGLETON_DEPENDENCY + +public: + QUuid createRayPick(const QVariant& properties); + +public slots: + Q_INVOKABLE QUuid createPick(const PickQuery::PickType type, const QVariant& properties); + Q_INVOKABLE void enablePick(const QUuid& uid); + Q_INVOKABLE void disablePick(const QUuid& uid); + Q_INVOKABLE void removePick(const QUuid& uid); + Q_INVOKABLE QVariantMap getPrevPickResult(const QUuid& uid); + + Q_INVOKABLE void setPrecisionPicking(const QUuid& uid, const bool precisionPicking); + Q_INVOKABLE void setIgnoreItems(const QUuid& uid, const QScriptValue& ignoreEntities); + Q_INVOKABLE void setIncludeItems(const QUuid& uid, const QScriptValue& includeEntities); + + static constexpr unsigned int PICK_NOTHING() { return 0; } + static constexpr unsigned int PICK_ENTITIES() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_ENTITIES); } + static constexpr unsigned int PICK_OVERLAYS() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_OVERLAYS); } + static constexpr unsigned int PICK_AVATARS() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_AVATARS); } + static constexpr unsigned int PICK_HUD() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_HUD); } + static constexpr unsigned int PICK_COARSE() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_COARSE); } + static constexpr unsigned int PICK_INCLUDE_INVISIBLE() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_INCLUDE_INVISIBLE); } + static constexpr unsigned int PICK_INCLUDE_NONCOLLIDABLE() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_INCLUDE_NONCOLLIDABLE); } + static constexpr unsigned int PICK_ALL_INTERSECTIONS() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_ALL_INTERSECTIONS); } + static constexpr unsigned int INTERSECTED_NONE() { return IntersectionType::NONE; } + static constexpr unsigned int INTERSECTED_ENTITY() { return IntersectionType::ENTITY; } + static constexpr unsigned int INTERSECTED_OVERLAY() { return IntersectionType::OVERLAY; } + static constexpr unsigned int INTERSECTED_AVATAR() { return IntersectionType::AVATAR; } + static constexpr unsigned int INTERSECTED_HUD() { return IntersectionType::HUD; } +}; + +#endif // hifi_PickScriptingInterface_h \ No newline at end of file diff --git a/interface/src/raypick/PointerScriptingInterface.cpp b/interface/src/raypick/PointerScriptingInterface.cpp new file mode 100644 index 0000000000..4e5d5f414f --- /dev/null +++ b/interface/src/raypick/PointerScriptingInterface.cpp @@ -0,0 +1,139 @@ +// +// Created by Sam Gondelman 10/20/2017 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "PointerScriptingInterface.h" + +#include + +#include + +#include "Application.h" + +void PointerScriptingInterface::setIgnoreItems(const QUuid& uid, const QScriptValue& ignoreItems) const { + DependencyManager::get()->setIgnoreItems(uid, qVectorQUuidFromScriptValue(ignoreItems)); +} +void PointerScriptingInterface::setIncludeItems(const QUuid& uid, const QScriptValue& includeItems) const { + DependencyManager::get()->setIncludeItems(uid, qVectorQUuidFromScriptValue(includeItems)); +} + +QUuid PointerScriptingInterface::createPointer(const PickQuery::PickType type, const QVariant& properties) const { + switch (type) { + case PickQuery::PickType::Ray: + return createLaserPointer(properties); + default: + return QUuid(); + } +} + +QUuid PointerScriptingInterface::createLaserPointer(const QVariant& properties) const { + QVariantMap propertyMap = properties.toMap(); + + bool faceAvatar = false; + if (propertyMap["faceAvatar"].isValid()) { + faceAvatar = propertyMap["faceAvatar"].toBool(); + } + + bool centerEndY = true; + if (propertyMap["centerEndY"].isValid()) { + centerEndY = propertyMap["centerEndY"].toBool(); + } + + bool lockEnd = false; + if (propertyMap["lockEnd"].isValid()) { + lockEnd = propertyMap["lockEnd"].toBool(); + } + + bool enabled = false; + if (propertyMap["enabled"].isValid()) { + enabled = propertyMap["enabled"].toBool(); + } + + LaserPointer::RenderStateMap renderStates; + if (propertyMap["renderStates"].isValid()) { + QList renderStateVariants = propertyMap["renderStates"].toList(); + for (QVariant& renderStateVariant : renderStateVariants) { + if (renderStateVariant.isValid()) { + QVariantMap renderStateMap = renderStateVariant.toMap(); + if (renderStateMap["name"].isValid()) { + std::string name = renderStateMap["name"].toString().toStdString(); + renderStates[name] = buildRenderState(renderStateMap); + } + } + } + } + + LaserPointer::DefaultRenderStateMap defaultRenderStates; + if (propertyMap["defaultRenderStates"].isValid()) { + QList renderStateVariants = propertyMap["defaultRenderStates"].toList(); + for (QVariant& renderStateVariant : renderStateVariants) { + if (renderStateVariant.isValid()) { + QVariantMap renderStateMap = renderStateVariant.toMap(); + if (renderStateMap["name"].isValid() && renderStateMap["distance"].isValid()) { + std::string name = renderStateMap["name"].toString().toStdString(); + float distance = renderStateMap["distance"].toFloat(); + defaultRenderStates[name] = std::pair(distance, buildRenderState(renderStateMap)); + } + } + } + } + + return DependencyManager::get()->addPointer(std::make_shared(properties, renderStates, defaultRenderStates, faceAvatar, centerEndY, lockEnd, enabled)); +} + +void PointerScriptingInterface::editRenderState(const QUuid& uid, const QString& renderState, const QVariant& properties) const { + QVariantMap propMap = properties.toMap(); + + QVariant startProps; + if (propMap["start"].isValid()) { + startProps = propMap["start"]; + } + + QVariant pathProps; + if (propMap["path"].isValid()) { + pathProps = propMap["path"]; + } + + QVariant endProps; + if (propMap["end"].isValid()) { + endProps = propMap["end"]; + } + + DependencyManager::get()->editRenderState(uid, renderState.toStdString(), startProps, pathProps, endProps); +} + +RenderState PointerScriptingInterface::buildRenderState(const QVariantMap& propMap) { + QUuid startID; + if (propMap["start"].isValid()) { + QVariantMap startMap = propMap["start"].toMap(); + if (startMap["type"].isValid()) { + startMap.remove("visible"); + startID = qApp->getOverlays().addOverlay(startMap["type"].toString(), startMap); + } + } + + QUuid pathID; + if (propMap["path"].isValid()) { + QVariantMap pathMap = propMap["path"].toMap(); + // right now paths must be line3ds + if (pathMap["type"].isValid() && pathMap["type"].toString() == "line3d") { + pathMap.remove("visible"); + pathID = qApp->getOverlays().addOverlay(pathMap["type"].toString(), pathMap); + } + } + + QUuid endID; + if (propMap["end"].isValid()) { + QVariantMap endMap = propMap["end"].toMap(); + if (endMap["type"].isValid()) { + endMap.remove("visible"); + endID = qApp->getOverlays().addOverlay(endMap["type"].toString(), endMap); + } + } + + return RenderState(startID, pathID, endID); +} \ No newline at end of file diff --git a/interface/src/raypick/PointerScriptingInterface.h b/interface/src/raypick/PointerScriptingInterface.h new file mode 100644 index 0000000000..8a3a316d9e --- /dev/null +++ b/interface/src/raypick/PointerScriptingInterface.h @@ -0,0 +1,46 @@ +// +// Created by Sam Gondelman 10/20/2017 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#ifndef hifi_PointerScriptingInterface_h +#define hifi_PointerScriptingInterface_h + +#include + +#include "DependencyManager.h" +#include + +#include "LaserPointer.h" + +class PointerScriptingInterface : public QObject, public Dependency { + Q_OBJECT + SINGLETON_DEPENDENCY + +public: + QUuid createLaserPointer(const QVariant& properties) const; + +public slots: + Q_INVOKABLE QUuid createPointer(const PickQuery::PickType type, const QVariant& properties) const; + Q_INVOKABLE void enablePointer(const QUuid& uid) const { DependencyManager::get()->enablePointer(uid); } + Q_INVOKABLE void disablePointer(const QUuid& uid) const { DependencyManager::get()->disablePointer(uid); } + Q_INVOKABLE void removePointer(const QUuid& uid) const { DependencyManager::get()->removePointer(uid); } + Q_INVOKABLE void editRenderState(const QUuid& uid, const QString& renderState, const QVariant& properties) const; + Q_INVOKABLE void setRenderState(const QUuid& uid, const QString& renderState) const { DependencyManager::get()->setRenderState(uid, renderState.toStdString()); } + Q_INVOKABLE QVariantMap getPrevPickResult(QUuid uid) const { return DependencyManager::get()->getPrevPickResult(uid); } + + Q_INVOKABLE void setPrecisionPicking(const QUuid& uid, bool precisionPicking) const { DependencyManager::get()->setPrecisionPicking(uid, precisionPicking); } + Q_INVOKABLE void setLaserLength(const QUuid& uid, float laserLength) const { DependencyManager::get()->setLength(uid, laserLength); } + Q_INVOKABLE void setIgnoreItems(const QUuid& uid, const QScriptValue& ignoreEntities) const; + Q_INVOKABLE void setIncludeItems(const QUuid& uid, const QScriptValue& includeEntities) const; + + Q_INVOKABLE void setLockEndUUID(const QUuid& uid, const QUuid& objectID, bool isOverlay) const { DependencyManager::get()->setLockEndUUID(uid, objectID, isOverlay); } + +private: + static RenderState buildRenderState(const QVariantMap& propMap); + +}; + +#endif // hifi_PointerScriptingInterface_h diff --git a/interface/src/raypick/RayPickScriptingInterface.cpp b/interface/src/raypick/RayPickScriptingInterface.cpp index 8913138c36..92bf3ec521 100644 --- a/interface/src/raypick/RayPickScriptingInterface.cpp +++ b/interface/src/raypick/RayPickScriptingInterface.cpp @@ -21,55 +21,7 @@ #include "MouseRayPick.h" QUuid RayPickScriptingInterface::createRayPick(const QVariant& properties) { - QVariantMap propMap = properties.toMap(); - - bool enabled = false; - if (propMap["enabled"].isValid()) { - enabled = propMap["enabled"].toBool(); - } - - PickFilter filter = PickFilter(); - if (propMap["filter"].isValid()) { - filter = PickFilter(propMap["filter"].toUInt()); - } - - float maxDistance = 0.0f; - if (propMap["maxDistance"].isValid()) { - maxDistance = propMap["maxDistance"].toFloat(); - } - - if (propMap["joint"].isValid()) { - std::string jointName = propMap["joint"].toString().toStdString(); - - if (jointName != "Mouse") { - // x = upward, y = forward, z = lateral - glm::vec3 posOffset = Vectors::ZERO; - if (propMap["posOffset"].isValid()) { - posOffset = vec3FromVariant(propMap["posOffset"]); - } - - glm::vec3 dirOffset = Vectors::UP; - if (propMap["dirOffset"].isValid()) { - dirOffset = vec3FromVariant(propMap["dirOffset"]); - } - - return DependencyManager::get()->addPick(RAY, std::make_shared(jointName, posOffset, dirOffset, filter, maxDistance, enabled)); - - } else { - return DependencyManager::get()->addPick(RAY, std::make_shared(filter, maxDistance, enabled)); - } - } else if (propMap["position"].isValid()) { - glm::vec3 position = vec3FromVariant(propMap["position"]); - - glm::vec3 direction = -Vectors::UP; - if (propMap["direction"].isValid()) { - direction = vec3FromVariant(propMap["direction"]); - } - - return DependencyManager::get()->addPick(RAY, std::make_shared(position, direction, filter, maxDistance, enabled)); - } - - return QUuid(); + return DependencyManager::get()->createRayPick(properties); } void RayPickScriptingInterface::enableRayPick(const QUuid& uid) { diff --git a/interface/src/raypick/RayPickScriptingInterface.h b/interface/src/raypick/RayPickScriptingInterface.h index ebfc3fb9fe..ed837afe49 100644 --- a/interface/src/raypick/RayPickScriptingInterface.h +++ b/interface/src/raypick/RayPickScriptingInterface.h @@ -17,22 +17,10 @@ #include #include "RayPick.h" +#include "PickScriptingInterface.h" + class RayPickScriptingInterface : public QObject, public Dependency { Q_OBJECT - Q_PROPERTY(unsigned int PICK_NOTHING READ PICK_NOTHING CONSTANT) - Q_PROPERTY(unsigned int PICK_ENTITIES READ PICK_ENTITIES CONSTANT) - Q_PROPERTY(unsigned int PICK_OVERLAYS READ PICK_OVERLAYS CONSTANT) - Q_PROPERTY(unsigned int PICK_AVATARS READ PICK_AVATARS CONSTANT) - Q_PROPERTY(unsigned int PICK_HUD READ PICK_HUD CONSTANT) - Q_PROPERTY(unsigned int PICK_COARSE READ PICK_COARSE CONSTANT) - Q_PROPERTY(unsigned int PICK_INCLUDE_INVISIBLE READ PICK_INCLUDE_INVISIBLE CONSTANT) - Q_PROPERTY(unsigned int PICK_INCLUDE_NONCOLLIDABLE READ PICK_INCLUDE_NONCOLLIDABLE CONSTANT) - Q_PROPERTY(unsigned int PICK_ALL_INTERSECTIONS READ PICK_ALL_INTERSECTIONS CONSTANT) - Q_PROPERTY(unsigned int INTERSECTED_NONE READ INTERSECTED_NONE CONSTANT) - Q_PROPERTY(unsigned int INTERSECTED_ENTITY READ INTERSECTED_ENTITY CONSTANT) - Q_PROPERTY(unsigned int INTERSECTED_OVERLAY READ INTERSECTED_OVERLAY CONSTANT) - Q_PROPERTY(unsigned int INTERSECTED_AVATAR READ INTERSECTED_AVATAR CONSTANT) - Q_PROPERTY(unsigned int INTERSECTED_HUD READ INTERSECTED_HUD CONSTANT) SINGLETON_DEPENDENCY public slots: @@ -45,21 +33,6 @@ public slots: Q_INVOKABLE void setPrecisionPicking(const QUuid& uid, const bool precisionPicking); Q_INVOKABLE void setIgnoreItems(const QUuid& uid, const QScriptValue& ignoreEntities); Q_INVOKABLE void setIncludeItems(const QUuid& uid, const QScriptValue& includeEntities); - - static constexpr unsigned int PICK_NOTHING() { return 0; } - static constexpr unsigned int PICK_ENTITIES() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_ENTITIES); } - static constexpr unsigned int PICK_OVERLAYS() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_OVERLAYS); } - static constexpr unsigned int PICK_AVATARS() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_AVATARS); } - static constexpr unsigned int PICK_HUD() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_HUD); } - static constexpr unsigned int PICK_COARSE() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_COARSE); } - static constexpr unsigned int PICK_INCLUDE_INVISIBLE() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_INCLUDE_INVISIBLE); } - static constexpr unsigned int PICK_INCLUDE_NONCOLLIDABLE() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_INCLUDE_NONCOLLIDABLE); } - static constexpr unsigned int PICK_ALL_INTERSECTIONS() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_ALL_INTERSECTIONS); } - static constexpr unsigned int INTERSECTED_NONE() { return IntersectionType::NONE; } - static constexpr unsigned int INTERSECTED_ENTITY() { return IntersectionType::ENTITY; } - static constexpr unsigned int INTERSECTED_OVERLAY() { return IntersectionType::OVERLAY; } - static constexpr unsigned int INTERSECTED_AVATAR() { return IntersectionType::AVATAR; } - static constexpr unsigned int INTERSECTED_HUD() { return IntersectionType::HUD; } }; #endif // hifi_RayPickScriptingInterface_h diff --git a/libraries/pointers/src/pointers/Pick.h b/libraries/pointers/src/pointers/Pick.h index 6ac0d6781e..5dcaba2bb8 100644 --- a/libraries/pointers/src/pointers/Pick.h +++ b/libraries/pointers/src/pointers/Pick.h @@ -130,9 +130,16 @@ public: using PickResultPointer = std::shared_ptr; class PickQuery : protected ReadWriteLockable { + Q_GADGET public: PickQuery(const PickFilter& filter, const float maxDistance, const bool enabled); + enum PickType { + Ray = 0, + Stylus + }; + Q_ENUM(PickType) + void enable(bool enabled = true); void disable() { enable(false); } diff --git a/libraries/pointers/src/pointers/PickManager.cpp b/libraries/pointers/src/pointers/PickManager.cpp index d6c2f44212..571f9f04cd 100644 --- a/libraries/pointers/src/pointers/PickManager.cpp +++ b/libraries/pointers/src/pointers/PickManager.cpp @@ -11,7 +11,7 @@ PickManager::PickManager() { setShouldPickHUDOperator([]() { return false; }); } -QUuid PickManager::addPick(PickType type, const std::shared_ptr pick) { +QUuid PickManager::addPick(PickQuery::PickType type, const std::shared_ptr pick) { QUuid id = QUuid::createUuid(); withWriteLock([&] { _picks[type][id] = pick; @@ -84,11 +84,11 @@ void PickManager::setIncludeItems(const QUuid& uid, const QVector& includ } void PickManager::update() { - QHash>> cachedPicks; + QHash>> cachedPicks; withReadLock([&] { cachedPicks = _picks; }); bool shouldPickHUD = _shouldPickHUDOperator(); - _rayPickCacheOptimizer.update(cachedPicks[RAY], shouldPickHUD); + _rayPickCacheOptimizer.update(cachedPicks[PickQuery::Ray], shouldPickHUD); } \ No newline at end of file diff --git a/libraries/pointers/src/pointers/PickManager.h b/libraries/pointers/src/pointers/PickManager.h index 07c8d914f3..f09f44621a 100644 --- a/libraries/pointers/src/pointers/PickManager.h +++ b/libraries/pointers/src/pointers/PickManager.h @@ -16,11 +16,6 @@ #include "Pick.h" #include "PickCacheOptimizer.h" -enum PickType { - RAY = 0, - STYLUS -}; - class PickManager : public Dependency, protected ReadWriteLockable { SINGLETON_DEPENDENCY @@ -29,7 +24,7 @@ public: void update(); - QUuid addPick(PickType type, const std::shared_ptr pick); + QUuid addPick(PickQuery::PickType type, const std::shared_ptr pick); void removePick(const QUuid& uid); void enablePick(const QUuid& uid) const; void disablePick(const QUuid& uid) const; @@ -46,8 +41,8 @@ protected: std::function _shouldPickHUDOperator; std::shared_ptr findPick(const QUuid& uid) const; - QHash>> _picks; - QHash _typeMap; + QHash>> _picks; + QHash _typeMap; PickCacheOptimizer _rayPickCacheOptimizer; }; diff --git a/libraries/pointers/src/pointers/PointerManager.cpp b/libraries/pointers/src/pointers/PointerManager.cpp index f2c2756d6f..a475ba4d83 100644 --- a/libraries/pointers/src/pointers/PointerManager.cpp +++ b/libraries/pointers/src/pointers/PointerManager.cpp @@ -61,7 +61,7 @@ void PointerManager::editRenderState(const QUuid& uid, const std::string& state, } } -const QVariantMap PointerManager::getPrevRayPickResult(const QUuid& uid) const { +const QVariantMap PointerManager::getPrevPickResult(const QUuid& uid) const { auto pointer = find(uid); if (pointer) { return pointer->getPrevPickResult(); diff --git a/libraries/pointers/src/pointers/PointerManager.h b/libraries/pointers/src/pointers/PointerManager.h index 1841e66f7b..db08199949 100644 --- a/libraries/pointers/src/pointers/PointerManager.h +++ b/libraries/pointers/src/pointers/PointerManager.h @@ -30,7 +30,7 @@ public: void disablePointer(const QUuid& uid) const; void setRenderState(const QUuid& uid, const std::string& renderState) const; void editRenderState(const QUuid& uid, const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps) const; - const QVariantMap getPrevRayPickResult(const QUuid& uid) const; + const QVariantMap getPrevPickResult(const QUuid& uid) const; void setPrecisionPicking(const QUuid& uid, const bool precisionPicking) const; void setIgnoreItems(const QUuid& uid, const QVector& ignoreEntities) const; diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index 2deef5f9fa..3bc423450e 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -252,7 +252,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); length: 1000 }; - if (rayPicks[h].type === RayPick.INTERSECTED_ENTITY) { + if (rayPicks[h].type === Picks.INTERSECTED_ENTITY) { // XXX check to make sure this one isn't already in nearbyEntityProperties? if (rayPicks[h].distance < NEAR_GRAB_PICK_RADIUS * sensorScaleFactor) { var nearEntityID = rayPicks[h].objectID; @@ -390,35 +390,35 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); this.leftControllerRayPick = RayPick.createRayPick({ joint: "_CONTROLLER_LEFTHAND", - filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS, + filter: Picks.PICK_ENTITIES | Picks.PICK_OVERLAYS, enabled: true, maxDistance: DEFAULT_SEARCH_SPHERE_DISTANCE, posOffset: getGrabPointSphereOffset(Controller.Standard.LeftHand, true) }); this.leftControllerHudRayPick = RayPick.createRayPick({ joint: "_CONTROLLER_LEFTHAND", - filter: RayPick.PICK_HUD, + filter: Picks.PICK_HUD, enabled: true, maxDistance: DEFAULT_SEARCH_SPHERE_DISTANCE, posOffset: getGrabPointSphereOffset(Controller.Standard.LeftHand, true) }); this.rightControllerRayPick = RayPick.createRayPick({ joint: "_CONTROLLER_RIGHTHAND", - filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS, + filter: Picks.PICK_ENTITIES | Picks.PICK_OVERLAYS, enabled: true, maxDistance: DEFAULT_SEARCH_SPHERE_DISTANCE, posOffset: getGrabPointSphereOffset(Controller.Standard.RightHand, true) }); this.rightControllerHudRayPick = RayPick.createRayPick({ joint: "_CONTROLLER_RIGHTHAND", - filter: RayPick.PICK_HUD, + filter: Picks.PICK_HUD, enabled: true, maxDistance: DEFAULT_SEARCH_SPHERE_DISTANCE, posOffset: getGrabPointSphereOffset(Controller.Standard.RightHand, true) }); this.mouseRayPick = RayPick.createRayPick({ joint: "Mouse", - filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS, + filter: Picks.PICK_ENTITIES | Picks.PICK_OVERLAYS, enabled: true }); diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntity.js b/scripts/system/controllers/controllerModules/farActionGrabEntity.js index 2ef7b1efeb..79a7b70bae 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntity.js @@ -376,8 +376,8 @@ Script.include("/~/system/libraries/controllers.js"); var entityType = entityProperty.type; var hudRayPick = controllerData.hudRayPicks[this.hand]; var point2d = this.calculateNewReticlePosition(hudRayPick.intersection); - if ((intersection.type === RayPick.INTERSECTED_ENTITY && entityType === "Web") || - intersection.type === RayPick.INTERSECTED_OVERLAY || Window.isPointOnDesktopWindow(point2d)) { + if ((intersection.type === Picks.INTERSECTED_ENTITY && entityType === "Web") || + intersection.type === Picks.INTERSECTED_OVERLAY || Window.isPointOnDesktopWindow(point2d)) { return true; } return false; @@ -497,7 +497,7 @@ Script.include("/~/system/libraries/controllers.js"); } var rayPickInfo = controllerData.rayPicks[this.hand]; - if (rayPickInfo.type === RayPick.INTERSECTED_ENTITY) { + if (rayPickInfo.type === Picks.INTERSECTED_ENTITY) { if (controllerData.triggerClicks[this.hand]) { var entityID = rayPickInfo.objectID; var targetProps = Entities.getEntityProperties(entityID, [ @@ -581,7 +581,7 @@ Script.include("/~/system/libraries/controllers.js"); this.fullEnd = fullEnd; this.laserPointer = LaserPointers.createLaserPointer({ joint: (this.hand === RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND", - filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS, + filter: Picks.PICK_ENTITIES | Picks.PICK_OVERLAYS, maxDistance: PICK_MAX_DISTANCE, posOffset: getGrabPointSphereOffset(this.handToController(), true), renderStates: renderStates, diff --git a/scripts/system/controllers/controllerModules/farTrigger.js b/scripts/system/controllers/controllerModules/farTrigger.js index a683044e6e..7975889bc8 100644 --- a/scripts/system/controllers/controllerModules/farTrigger.js +++ b/scripts/system/controllers/controllerModules/farTrigger.js @@ -196,7 +196,7 @@ Script.include("/~/system/libraries/controllers.js"); this.fullEnd = fullEnd; this.laserPointer = LaserPointers.createLaserPointer({ joint: (this.hand === RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND", - filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS, + filter: Picks.PICK_ENTITIES | Picks.PICK_OVERLAYS, maxDistance: PICK_MAX_DISTANCE, posOffset: getGrabPointSphereOffset(this.handToController(), true), renderStates: renderStates, diff --git a/scripts/system/controllers/controllerModules/hudOverlayPointer.js b/scripts/system/controllers/controllerModules/hudOverlayPointer.js index fe1dedefb8..d579ce2611 100644 --- a/scripts/system/controllers/controllerModules/hudOverlayPointer.js +++ b/scripts/system/controllers/controllerModules/hudOverlayPointer.js @@ -216,7 +216,7 @@ this.fullEnd = fullEnd; this.laserPointer = LaserPointers.createLaserPointer({ joint: (this.hand === RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND", - filter: RayPick.PICK_HUD, + filter: Picks.PICK_HUD, maxDistance: PICK_MAX_DISTANCE, posOffset: getGrabPointSphereOffset(this.handToController(), true), renderStates: renderStates, diff --git a/scripts/system/controllers/controllerModules/inEditMode.js b/scripts/system/controllers/controllerModules/inEditMode.js index 5049185827..34247b1d9d 100644 --- a/scripts/system/controllers/controllerModules/inEditMode.js +++ b/scripts/system/controllers/controllerModules/inEditMode.js @@ -153,12 +153,12 @@ Script.include("/~/system/libraries/utils.js"); this.sendPickData = function(controllerData) { if (controllerData.triggerClicks[this.hand] && !this.triggerClicked) { var intersection = controllerData.rayPicks[this.hand]; - if (intersection.type === RayPick.INTERSECTED_ENTITY) { + if (intersection.type === Picks.INTERSECTED_ENTITY) { Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ method: "selectEntity", entityID: intersection.objectID })); - } else if (intersection.type === RayPick.INTERSECTED_OVERLAY) { + } else if (intersection.type === Picks.INTERSECTED_OVERLAY) { Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ method: "selectOverlay", overlayID: intersection.objectID @@ -243,7 +243,7 @@ Script.include("/~/system/libraries/utils.js"); this.laserPointer = LaserPointers.createLaserPointer({ joint: (this.hand === RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND", - filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS, + filter: Picks.PICK_ENTITIES | Picks.PICK_OVERLAYS, maxDistance: PICK_MAX_DISTANCE, posOffset: getGrabPointSphereOffset(this.handToController(), true), renderStates: renderStates, diff --git a/scripts/system/controllers/controllerModules/overlayLaserInput.js b/scripts/system/controllers/controllerModules/overlayLaserInput.js index 7c86a01c5d..0747985c7b 100644 --- a/scripts/system/controllers/controllerModules/overlayLaserInput.js +++ b/scripts/system/controllers/controllerModules/overlayLaserInput.js @@ -301,7 +301,7 @@ Script.include("/~/system/libraries/controllers.js"); this.shouldExit = function(controllerData) { var intersection = controllerData.rayPicks[this.hand]; - var offOverlay = (intersection.type !== RayPick.INTERSECTED_OVERLAY); + var offOverlay = (intersection.type !== Picks.INTERSECTED_OVERLAY); var triggerOff = (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE); if (triggerOff) { this.deleteContextOverlay(); @@ -375,7 +375,7 @@ Script.include("/~/system/libraries/controllers.js"); this.fullEnd = fullEnd; this.laserPointer = LaserPointers.createLaserPointer({ joint: (this.hand === RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND", - filter: RayPick.PICK_OVERLAYS, + filter: Picks.PICK_OVERLAYS, maxDistance: PICK_MAX_DISTANCE, posOffset: getGrabPointSphereOffset(this.handToController(), true), renderStates: renderStates, diff --git a/scripts/system/controllers/controllerModules/teleport.js b/scripts/system/controllers/controllerModules/teleport.js index 86ad9c56ca..1fb867675e 100644 --- a/scripts/system/controllers/controllerModules/teleport.js +++ b/scripts/system/controllers/controllerModules/teleport.js @@ -149,7 +149,7 @@ Script.include("/~/system/libraries/controllers.js"); this.teleportRayHandVisible = LaserPointers.createLaserPointer({ joint: (_this.hand === RIGHT_HAND) ? "RightHand" : "LeftHand", - filter: RayPick.PICK_ENTITIES, + filter: Picks.PICK_ENTITIES, faceAvatar: true, centerEndY: false, renderStates: teleportRenderStates, @@ -157,14 +157,14 @@ Script.include("/~/system/libraries/controllers.js"); }); this.teleportRayHandInvisible = LaserPointers.createLaserPointer({ joint: (_this.hand === RIGHT_HAND) ? "RightHand" : "LeftHand", - filter: RayPick.PICK_ENTITIES | RayPick.PICK_INCLUDE_INVISIBLE, + filter: Picks.PICK_ENTITIES | Picks.PICK_INCLUDE_INVISIBLE, faceAvatar: true, centerEndY: false, renderStates: teleportRenderStates }); this.teleportRayHeadVisible = LaserPointers.createLaserPointer({ joint: "Avatar", - filter: RayPick.PICK_ENTITIES, + filter: Picks.PICK_ENTITIES, faceAvatar: true, centerEndY: false, renderStates: teleportRenderStates, @@ -172,7 +172,7 @@ Script.include("/~/system/libraries/controllers.js"); }); this.teleportRayHeadInvisible = LaserPointers.createLaserPointer({ joint: "Avatar", - filter: RayPick.PICK_ENTITIES | RayPick.PICK_INCLUDE_INVISIBLE, + filter: Picks.PICK_ENTITIES | Picks.PICK_INCLUDE_INVISIBLE, faceAvatar: true, centerEndY: false, renderStates: teleportRenderStates @@ -397,7 +397,7 @@ Script.include("/~/system/libraries/controllers.js"); // you can't teleport there. var MAX_ANGLE_FROM_UP_TO_TELEPORT = 70; function getTeleportTargetType(result) { - if (result.type === RayPick.INTERSECTED_NONE) { + if (result.type === Picks.INTERSECTED_NONE) { return TARGET.NONE; } diff --git a/scripts/system/controllers/controllerModules/webEntityLaserInput.js b/scripts/system/controllers/controllerModules/webEntityLaserInput.js index 339f248547..0076e1c865 100644 --- a/scripts/system/controllers/controllerModules/webEntityLaserInput.js +++ b/scripts/system/controllers/controllerModules/webEntityLaserInput.js @@ -386,7 +386,7 @@ Script.include("/~/system/libraries/controllers.js"); var entityProperty = Entities.getEntityProperties(intersection.objectID); var entityType = entityProperty.type; - if ((intersection.type === RayPick.INTERSECTED_ENTITY && entityType === "Web")) { + if ((intersection.type === Picks.INTERSECTED_ENTITY && entityType === "Web")) { return true; } return false; @@ -454,7 +454,7 @@ Script.include("/~/system/libraries/controllers.js"); this.laserPointer = LaserPointers.createLaserPointer({ joint: (this.hand === RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND", - filter: RayPick.PICK_ENTITIES, + filter: Picks.PICK_ENTITIES, maxDistance: PICK_MAX_DISTANCE, posOffset: getGrabPointSphereOffset(this.handToController(), true), renderStates: renderStates, diff --git a/scripts/system/controllers/grab.js b/scripts/system/controllers/grab.js index a1846e7ad7..7e575e38b0 100644 --- a/scripts/system/controllers/grab.js +++ b/scripts/system/controllers/grab.js @@ -260,14 +260,14 @@ function Grabber() { this.mouseRayOverlays = RayPick.createRayPick({ joint: "Mouse", - filter: RayPick.PICK_OVERLAYS, + filter: Picks.PICK_OVERLAYS, enabled: true }); RayPick.setIncludeItems(this.mouseRayOverlays, [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID]); var renderStates = [{name: "grabbed", end: beacon}]; this.mouseRayEntities = LaserPointers.createLaserPointer({ joint: "Mouse", - filter: RayPick.PICK_ENTITIES, + filter: Picks.PICK_ENTITIES, faceAvatar: true, enabled: true, renderStates: renderStates @@ -321,12 +321,12 @@ Grabber.prototype.pressEvent = function(event) { } var overlayResult = RayPick.getPrevRayPickResult(this.mouseRayOverlays); - if (overlayResult.type != RayPick.INTERSECTED_NONE) { + if (overlayResult.type != Picks.INTERSECTED_NONE) { return; } var pickResults = LaserPointers.getPrevRayPickResult(this.mouseRayEntities); - if (pickResults.type == RayPick.INTERSECTED_NONE) { + if (pickResults.type == Picks.INTERSECTED_NONE) { LaserPointers.setRenderState(this.mouseRayEntities, ""); return; } diff --git a/scripts/system/libraries/touchEventUtils.js b/scripts/system/libraries/touchEventUtils.js index fbd56e16ae..7d19181c2a 100644 --- a/scripts/system/libraries/touchEventUtils.js +++ b/scripts/system/libraries/touchEventUtils.js @@ -130,7 +130,7 @@ function sendTouchMoveEventToTouchTarget(hand, touchTarget) { } function composeTouchTargetFromIntersection(intersection) { - var isEntity = (intersection.type === RayPick.INTERSECTED_ENTITY); + var isEntity = (intersection.type === Picks.INTERSECTED_ENTITY); var objectID = intersection.objectID; var worldPos = intersection.intersection; var props = null;