From 5ce8f566cc3eba5bae9a46de2a708cfebac0d5bb Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Fri, 25 Jan 2019 11:10:11 -0800 Subject: [PATCH] more overlay wip --- .../resources/qml/+android/Web3DSurface.qml | 2 +- interface/resources/qml/Web3DSurface.qml | 2 +- interface/src/Application.cpp | 3 +- interface/src/InterfaceParentFinder.cpp | 9 - interface/src/LoginStateManager.cpp | 10 +- interface/src/LoginStateManager.h | 2 +- interface/src/avatar/OtherAvatar.h | 1 - interface/src/raypick/LaserPointer.cpp | 1 + interface/src/raypick/ParabolaPick.cpp | 10 +- interface/src/raypick/ParabolaPointer.cpp | 1 + interface/src/raypick/PathPointer.cpp | 80 +-- interface/src/raypick/PathPointer.h | 6 +- .../src/raypick/PickScriptingInterface.cpp | 9 +- .../src/raypick/PickScriptingInterface.h | 16 +- .../src/raypick/PointerScriptingInterface.cpp | 22 +- .../src/raypick/PointerScriptingInterface.h | 16 +- interface/src/raypick/RayPick.cpp | 37 +- interface/src/raypick/RayPick.h | 4 - .../src/raypick/RayPickScriptingInterface.h | 9 +- interface/src/raypick/StylusPick.cpp | 60 +-- interface/src/raypick/StylusPick.h | 1 - interface/src/raypick/StylusPointer.cpp | 57 +- interface/src/raypick/StylusPointer.h | 8 +- .../src/scripting/HMDScriptingInterface.h | 12 +- .../scripting/KeyboardScriptingInterface.cpp | 4 +- .../scripting/KeyboardScriptingInterface.h | 3 +- .../scripting/SelectionScriptingInterface.cpp | 47 +- .../scripting/SelectionScriptingInterface.h | 12 +- interface/src/ui/ApplicationOverlay.cpp | 4 +- interface/src/ui/Keyboard.cpp | 505 ++++++++---------- interface/src/ui/Keyboard.h | 38 +- interface/src/ui/LoginDialog.h | 2 +- .../ui/overlays/ContextOverlayInterface.cpp | 78 +-- .../src/ui/overlays/ContextOverlayInterface.h | 13 +- interface/src/ui/overlays/Overlay.cpp | 31 -- interface/src/ui/overlays/Overlay.h | 26 +- .../src/ui/overlays/OverlayTransformNode.cpp | 13 - .../src/ui/overlays/OverlayTransformNode.h | 21 - interface/src/ui/overlays/Overlays.h | 10 +- interface/src/ui/overlays/OverlaysPayload.cpp | 22 +- .../entities/src/EntityScriptingInterface.cpp | 9 + .../entities/src/EntityScriptingInterface.h | 29 +- libraries/entities/src/GrabPropertyGroup.h | 4 +- .../GraphicsScriptingInterface.cpp | 8 +- libraries/pointers/src/Pick.h | 2 +- libraries/pointers/src/PickCacheOptimizer.h | 23 +- libraries/pointers/src/Pointer.cpp | 20 +- libraries/pointers/src/Pointer.h | 2 +- libraries/pointers/src/PointerManager.cpp | 4 +- libraries/pointers/src/PointerManager.h | 2 +- .../render-utils/src/RenderCommonTask.cpp | 8 +- libraries/render-utils/src/RenderCommonTask.h | 10 +- .../render-utils/src/RenderDeferredTask.cpp | 52 +- .../render-utils/src/RenderForwardTask.cpp | 29 +- libraries/render/src/render/HighlightStage.h | 2 +- .../src/render/RenderFetchCullSortTask.cpp | 28 +- .../src/render/RenderFetchCullSortTask.h | 2 - libraries/render/src/render/Scene.h | 4 +- libraries/script-engine/src/ScriptUUID.h | 2 +- libraries/shared/src/PickFilter.h | 11 +- libraries/shared/src/PointerEvent.cpp | 4 +- libraries/shared/src/RegisteredMetaTypes.h | 4 +- 62 files changed, 611 insertions(+), 855 deletions(-) delete mode 100644 interface/src/ui/overlays/OverlayTransformNode.cpp delete mode 100644 interface/src/ui/overlays/OverlayTransformNode.h diff --git a/interface/resources/qml/+android/Web3DSurface.qml b/interface/resources/qml/+android/Web3DSurface.qml index d7b8306d6c..c4a613222e 100644 --- a/interface/resources/qml/+android/Web3DSurface.qml +++ b/interface/resources/qml/+android/Web3DSurface.qml @@ -1,5 +1,5 @@ // -// Web3DOverlay.qml +// Web3DSurface.qml // // Created by Gabriel Calero & Cristian Duarte on Jun 22, 2018 // Copyright 2016 High Fidelity, Inc. diff --git a/interface/resources/qml/Web3DSurface.qml b/interface/resources/qml/Web3DSurface.qml index fdd5d8a7c6..32c19daf14 100644 --- a/interface/resources/qml/Web3DSurface.qml +++ b/interface/resources/qml/Web3DSurface.qml @@ -1,5 +1,5 @@ // -// Web3DOverlay.qml +// Web3DSurface.qml // // Created by David Rowe on 16 Dec 2016. // Copyright 2016 High Fidelity, Inc. diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5dc283e8b4..f0b119b940 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -203,7 +203,6 @@ #include "ui/Stats.h" #include "ui/AnimStats.h" #include "ui/UpdateDialog.h" -#include "ui/overlays/Overlays.h" #include "ui/DomainConnectionModel.h" #include "ui/Keyboard.h" #include "Util.h" @@ -4900,7 +4899,7 @@ void Application::idle() { setKeyboardFocusEntity(UNKNOWN_ENTITY_ID); setKeyboardFocusLocalEntity(UNKNOWN_ENTITY_ID); } else { - // update position of highlight overlay + // update position of highlight object if (!_keyboardFocusedEntity.get().isInvalidID()) { auto entity = getEntities()->getTree()->findEntityByID(_keyboardFocusedEntity.get()); if (entity && !_keyboardFocusHighlightID.isNull()) { diff --git a/interface/src/InterfaceParentFinder.cpp b/interface/src/InterfaceParentFinder.cpp index b9be58f04b..33328f54cc 100644 --- a/interface/src/InterfaceParentFinder.cpp +++ b/interface/src/InterfaceParentFinder.cpp @@ -50,15 +50,6 @@ SpatiallyNestableWeakPointer InterfaceParentFinder::find(QUuid parentID, bool& s return avatarManager->getMyAvatar(); } - // search overlays - auto& overlays = qApp->getOverlays(); - auto overlay = overlays.getOverlay(parentID); - parent = std::dynamic_pointer_cast(overlay); // this will return nullptr for non-3d overlays - if (!parent.expired()) { - success = true; - return parent; - } - success = false; return parent; } diff --git a/interface/src/LoginStateManager.cpp b/interface/src/LoginStateManager.cpp index 8811303f7d..0a09d33775 100644 --- a/interface/src/LoginStateManager.cpp +++ b/interface/src/LoginStateManager.cpp @@ -170,7 +170,7 @@ void LoginStateManager::setUp() { const unsigned int leftHand = 0; QVariantMap leftPointerProperties { { "joint", "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND" }, - { "filter", PickScriptingInterface::PICK_OVERLAYS() }, + { "filter", PickScriptingInterface::PICK_LOCAL_ENTITIES() }, { "triggers", leftPointerTriggerProperties }, { "posOffset", vec3toVariant(grabPointSphereOffsetLeft + malletOffset) }, { "hover", true }, @@ -197,7 +197,7 @@ void LoginStateManager::setUp() { rightPointerTriggerProperties = QList({rtClick1, rtClick2}); QVariantMap rightPointerProperties{ { "joint", "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" }, - { "filter", PickScriptingInterface::PICK_OVERLAYS() }, + { "filter", PickScriptingInterface::PICK_LOCAL_ENTITIES() }, { "triggers", rightPointerTriggerProperties }, { "posOffset", vec3toVariant(grabPointSphereOffsetRight + malletOffset) }, { "hover", true }, @@ -212,7 +212,7 @@ void LoginStateManager::setUp() { pointers->enablePointer(_rightLoginPointerID); } -void LoginStateManager::update(const QString dominantHand, const QUuid loginOverlayID) { +void LoginStateManager::update(const QString& dominantHand, const QUuid& loginEntityID) { if (!isSetUp()) { return; } @@ -224,8 +224,8 @@ void LoginStateManager::update(const QString dominantHand, const QUuid loginOver if (pointers && raypicks) { const auto rightObjectID = raypicks->getPrevRayPickResult(_rightLoginPointerID)["objectID"].toUuid(); const auto leftObjectID = raypicks->getPrevRayPickResult(_leftLoginPointerID)["objectID"].toUuid(); - const QString leftMode = (leftObjectID.isNull() || leftObjectID != loginOverlayID) ? "" : "full"; - const QString rightMode = (rightObjectID.isNull() || rightObjectID != loginOverlayID) ? "" : "full"; + const QString leftMode = (leftObjectID.isNull() || leftObjectID != loginEntityID) ? "" : "full"; + const QString rightMode = (rightObjectID.isNull() || rightObjectID != loginEntityID) ? "" : "full"; pointers->setRenderState(_leftLoginPointerID, leftMode); pointers->setRenderState(_rightLoginPointerID, rightMode); if (_dominantHand == "left" && !leftObjectID.isNull()) { diff --git a/interface/src/LoginStateManager.h b/interface/src/LoginStateManager.h index ad25e87ee6..b898303ba6 100644 --- a/interface/src/LoginStateManager.h +++ b/interface/src/LoginStateManager.h @@ -26,7 +26,7 @@ public: void setUp(); void tearDown(); - void update(const QString dominantHand, const QUuid loginOverlayID); + void update(const QString& dominantHand, const QUuid& loginObjectID); bool isSetUp() const { return (_leftLoginPointerID > PointerEvent::INVALID_POINTER_ID) && (_rightLoginPointerID > PointerEvent::INVALID_POINTER_ID); } diff --git a/interface/src/avatar/OtherAvatar.h b/interface/src/avatar/OtherAvatar.h index 8e31609e3e..d4628a0478 100644 --- a/interface/src/avatar/OtherAvatar.h +++ b/interface/src/avatar/OtherAvatar.h @@ -16,7 +16,6 @@ #include #include "InterfaceLogging.h" -#include "ui/overlays/Overlays.h" class AvatarManager; class AvatarMotionState; diff --git a/interface/src/raypick/LaserPointer.cpp b/interface/src/raypick/LaserPointer.cpp index 3319f01b57..694c420426 100644 --- a/interface/src/raypick/LaserPointer.cpp +++ b/interface/src/raypick/LaserPointer.cpp @@ -247,6 +247,7 @@ PointerEvent LaserPointer::buildPointerEvent(const PickedObject& target, const P glm::vec3 LaserPointer::findIntersection(const PickedObject& pickedObject, const glm::vec3& origin, const glm::vec3& direction) { switch (pickedObject.type) { case ENTITY: + case LOCAL_ENTITY: return RayPick::intersectRayWithEntityXYPlane(pickedObject.objectID, origin, direction); default: return glm::vec3(NAN); diff --git a/interface/src/raypick/ParabolaPick.cpp b/interface/src/raypick/ParabolaPick.cpp index 5349f8a113..7a0eed96a8 100644 --- a/interface/src/raypick/ParabolaPick.cpp +++ b/interface/src/raypick/ParabolaPick.cpp @@ -67,7 +67,15 @@ PickResultPointer ParabolaPick::getEntityIntersection(const PickParabola& pick) DependencyManager::get()->evalParabolaIntersectionVector(pick, searchFilter, getIncludeItemsAs(), getIgnoreItemsAs()); if (entityRes.intersects) { - return std::make_shared(IntersectionType::ENTITY, entityRes.entityID, entityRes.distance, entityRes.parabolicDistance, entityRes.intersection, pick, entityRes.surfaceNormal, entityRes.extraInfo); + IntersectionType type = IntersectionType::ENTITY; + if (getFilter().doesPickLocalEntities()) { + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_ENTITY_HOST_TYPE; + if (DependencyManager::get()->getEntityProperties(entityRes.entityID, desiredProperties).getEntityHostType() == entity::HostType::LOCAL) { + type = IntersectionType::LOCAL_ENTITY; + } + } + return std::make_shared(type, entityRes.entityID, entityRes.distance, entityRes.parabolicDistance, entityRes.intersection, pick, entityRes.surfaceNormal, entityRes.extraInfo); } } return std::make_shared(pick.toVariantMap()); diff --git a/interface/src/raypick/ParabolaPointer.cpp b/interface/src/raypick/ParabolaPointer.cpp index 771d5c20de..389f6ed286 100644 --- a/interface/src/raypick/ParabolaPointer.cpp +++ b/interface/src/raypick/ParabolaPointer.cpp @@ -322,6 +322,7 @@ glm::vec3 ParabolaPointer::findIntersection(const PickedObject& pickedObject, co // TODO: implement switch (pickedObject.type) { case ENTITY: + case LOCAL_ENTITY: //return ParabolaPick::intersectParabolaWithEntityXYPlane(pickedObject.objectID, origin, velocity, acceleration); default: return glm::vec3(NAN); diff --git a/interface/src/raypick/PathPointer.cpp b/interface/src/raypick/PathPointer.cpp index 3cd444c0b3..6f94d25594 100644 --- a/interface/src/raypick/PathPointer.cpp +++ b/interface/src/raypick/PathPointer.cpp @@ -199,6 +199,7 @@ void PathPointer::editRenderState(const std::string& state, const QVariant& star } void PathPointer::updateRenderState(const QUuid& id, const QVariant& props) { + // FIXME: we have to keep using the Overlays interface here, because existing scripts use overlay properties to define pointers if (!id.isNull() && props.isValid()) { QVariantMap propMap = props.toMap(); propMap.remove("visible"); @@ -243,65 +244,79 @@ Pointer::Buttons PathPointer::getPressedButtons(const PickResultPointer& pickRes return toReturn; } -StartEndRenderState::StartEndRenderState(const OverlayID& startID, const OverlayID& endID) : +StartEndRenderState::StartEndRenderState(const QUuid& startID, const QUuid& endID) : _startID(startID), _endID(endID) { + auto entityScriptingInterface = DependencyManager::get(); if (!_startID.isNull()) { - _startDim = vec3FromVariant(qApp->getOverlays().getProperty(_startID, "dimensions").value); - _startIgnoreRays = qApp->getOverlays().getProperty(_startID, "ignorePickIntersection").value.toBool(); + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_DIMENSIONS; + desiredProperties += PROP_IGNORE_PICK_INTERSECTION; + auto properties = entityScriptingInterface->getEntityProperties(_startID, desiredProperties); + _startDim = properties.getDimensions(); + _startIgnorePicks = properties.getIgnorePickIntersection(); } if (!_endID.isNull()) { - _endDim = vec3FromVariant(qApp->getOverlays().getProperty(_endID, "dimensions").value); - _endRot = quatFromVariant(qApp->getOverlays().getProperty(_endID, "rotation").value); - _endIgnoreRays = qApp->getOverlays().getProperty(_endID, "ignorePickIntersection").value.toBool(); + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_DIMENSIONS; + desiredProperties += PROP_ROTATION; + desiredProperties += PROP_IGNORE_PICK_INTERSECTION; + auto properties = entityScriptingInterface->getEntityProperties(_endID, desiredProperties); + _endDim = properties.getDimensions(); + _endRot = properties.getRotation(); + _endIgnorePicks = properties.getIgnorePickIntersection(); } } void StartEndRenderState::cleanup() { + auto entityScriptingInterface = DependencyManager::get(); if (!_startID.isNull()) { - qApp->getOverlays().deleteOverlay(_startID); + entityScriptingInterface->deleteEntity(_startID); } if (!_endID.isNull()) { - qApp->getOverlays().deleteOverlay(_endID); + entityScriptingInterface->deleteEntity(_endID); } } void StartEndRenderState::disable() { + auto entityScriptingInterface = DependencyManager::get(); if (!getStartID().isNull()) { - QVariantMap startProps; - startProps.insert("visible", false); - startProps.insert("ignorePickIntersection", true); - qApp->getOverlays().editOverlay(getStartID(), startProps); + EntityItemProperties properties; + properties.setVisible(false); + properties.setIgnorePickIntersection(true); + entityScriptingInterface->editEntity(getStartID(), properties); } if (!getEndID().isNull()) { - QVariantMap endProps; - endProps.insert("visible", false); - endProps.insert("ignorePickIntersection", true); - qApp->getOverlays().editOverlay(getEndID(), endProps); + EntityItemProperties properties; + properties.setVisible(false); + properties.setIgnorePickIntersection(true); + entityScriptingInterface->editEntity(getEndID(), properties); } _enabled = false; } void StartEndRenderState::update(const glm::vec3& origin, const glm::vec3& end, const glm::vec3& surfaceNormal, float parentScale, bool distanceScaleEnd, bool centerEndY, bool faceAvatar, bool followNormal, float followNormalStrength, float distance, const PickResultPointer& pickResult) { + auto entityScriptingInterface = DependencyManager::get(); if (!getStartID().isNull()) { - QVariantMap startProps; - startProps.insert("position", vec3toVariant(origin)); - startProps.insert("visible", true); - startProps.insert("dimensions", vec3toVariant(getStartDim() * parentScale)); - startProps.insert("ignorePickIntersection", doesStartIgnoreRays()); - qApp->getOverlays().editOverlay(getStartID(), startProps); + EntityItemProperties properties; + properties.setPosition(origin); + properties.setVisible(true); + properties.setDimensions(getStartDim() * parentScale); + properties.setIgnorePickIntersection(doesStartIgnorePicks()); + entityScriptingInterface->editEntity(getStartID(), properties); } if (!getEndID().isNull()) { - QVariantMap endProps; - glm::vec3 dim = vec3FromVariant(qApp->getOverlays().getProperty(getEndID(), "dimensions").value); + EntityItemProperties properties; + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_DIMENSIONS; + glm::vec3 dim = entityScriptingInterface->getEntityProperties(getEndID(), desiredProperties).getDimensions(); if (distanceScaleEnd) { dim = getEndDim() * glm::distance(origin, end); - endProps.insert("dimensions", vec3toVariant(dim)); } else { dim = getEndDim() * parentScale; - endProps.insert("dimensions", vec3toVariant(dim)); } + properties.setDimensions(dim); glm::quat normalQuat = Quat().lookAtSimple(Vectors::ZERO, surfaceNormal); normalQuat = normalQuat * glm::quat(glm::vec3(-M_PI_2, 0, 0)); @@ -337,11 +352,11 @@ void StartEndRenderState::update(const glm::vec3& origin, const glm::vec3& end, _avgEndRot = rotation; } } - endProps.insert("position", vec3toVariant(position)); - endProps.insert("rotation", quatToVariant(rotation)); - endProps.insert("visible", true); - endProps.insert("ignorePickIntersection", doesEndIgnoreRays()); - qApp->getOverlays().editOverlay(getEndID(), endProps); + properties.setPosition(position); + properties.setRotation(rotation); + properties.setVisible(true); + properties.setIgnorePickIntersection(doesEndIgnorePicks()); + entityScriptingInterface->editEntity(getEndID(), properties); } _enabled = true; } @@ -349,9 +364,8 @@ void StartEndRenderState::update(const glm::vec3& origin, const glm::vec3& end, glm::vec2 PathPointer::findPos2D(const PickedObject& pickedObject, const glm::vec3& origin) { switch (pickedObject.type) { case ENTITY: + case LOCAL_ENTITY: return RayPick::projectOntoEntityXYPlane(pickedObject.objectID, origin); - case OVERLAY: - return RayPick::projectOntoOverlayXYPlane(pickedObject.objectID, origin); case HUD: return DependencyManager::get()->calculatePos2DFromHUD(origin); default: diff --git a/interface/src/raypick/PathPointer.h b/interface/src/raypick/PathPointer.h index 759d46842e..4b0625ef0f 100644 --- a/interface/src/raypick/PathPointer.h +++ b/interface/src/raypick/PathPointer.h @@ -12,8 +12,6 @@ #include #include -#include "ui/overlays/Overlay.h" - #include #include @@ -78,7 +76,7 @@ public: virtual ~PathPointer(); void setRenderState(const std::string& state) override; - // You cannot use editRenderState to change the type of any part of the pointer. You can only edit the properties of the existing overlays. + // You cannot use editRenderState to change the type of any part of the pointer. You can only edit the properties of the existing parts. void editRenderState(const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps) override; void setLength(float length) override; @@ -119,7 +117,7 @@ protected: bool shouldHover(const PickResultPointer& pickResult) override { return _currentRenderState != ""; } bool shouldTrigger(const PickResultPointer& pickResult) override { return _currentRenderState != ""; } - void updateRenderStateOverlay(const OverlayID& id, const QVariant& props); + void updateRenderState(const QUuid& id, const QVariant& props); virtual void editRenderStatePath(const std::string& state, const QVariant& pathProps) = 0; PickedObject getHoveredObject(const PickResultPointer& pickResult) override; diff --git a/interface/src/raypick/PickScriptingInterface.cpp b/interface/src/raypick/PickScriptingInterface.cpp index e8f84e63fe..ce01db3a56 100644 --- a/interface/src/raypick/PickScriptingInterface.cpp +++ b/interface/src/raypick/PickScriptingInterface.cpp @@ -26,7 +26,6 @@ #include "avatar/AvatarManager.h" #include "NestableTransformNode.h" #include "avatars-renderer/AvatarTransformNode.h" -#include "ui/overlays/OverlayTransformNode.h" #include "EntityTransformNode.h" #include @@ -61,7 +60,7 @@ PickFilter getPickFilter(unsigned int filter) { * @property {boolean} [enabled=false] If this Pick should start enabled or not. Disabled Picks do not updated their pick results. * @property {number} [filter=0] The filter for this Pick to use, constructed using filter flags combined using bitwise OR. * @property {number} [maxDistance=0.0] The max distance at which this Pick will intersect. 0.0 = no max. < 0.0 is invalid. - * @property {Uuid} parentID - The ID of the parent, either an avatar, an entity, an overlay, or a pick. + * @property {Uuid} parentID - The ID of the parent, either an avatar, an entity, or a pick. * @property {number} [parentJointIndex=0] - The joint of the parent to parent to, for example, the joints on the model of an avatar. (default = 0, no joint) * @property {string} joint - If "Mouse," parents the pick to the mouse. If "Avatar," parents the pick to MyAvatar's head. Otherwise, parents to the joint of the given name on MyAvatar. * @property {Vec3} [posOffset=Vec3.ZERO] Only for Joint Ray Picks. A local joint position offset, in meters. x = upward, y = forward, z = lateral @@ -161,7 +160,7 @@ unsigned int PickScriptingInterface::createStylusPick(const QVariant& properties * @property {boolean} [enabled=false] If this Pick should start enabled or not. Disabled Picks do not updated their pick results. * @property {number} [filter=0] The filter for this Pick to use, constructed using filter flags combined using bitwise OR. * @property {number} [maxDistance=0.0] The max distance at which this Pick will intersect. 0.0 = no max. < 0.0 is invalid. - * @property {Uuid} parentID - The ID of the parent, either an avatar, an entity, an overlay, or a pick. + * @property {Uuid} parentID - The ID of the parent, either an avatar, an entity, or a pick. * @property {number} [parentJointIndex=0] - The joint of the parent to parent to, for example, the joints on the model of an avatar. (default = 0, no joint) * @property {string} joint - If "Mouse," parents the pick to the mouse. If "Avatar," parents the pick to MyAvatar's head. Otherwise, parents to the joint of the given name on MyAvatar. * @property {Vec3} [posOffset=Vec3.ZERO] Only for Joint Parabola Picks. A local joint position offset, in meters. x = upward, y = forward, z = lateral @@ -264,7 +263,7 @@ unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properti * The depth is measured in world space, but will scale with the parent if defined. * @property {CollisionMask} [collisionGroup=8] - The type of object this collision pick collides as. Objects whose collision masks overlap with the pick's collision group * will be considered colliding with the pick. -* @property {Uuid} parentID - The ID of the parent, either an avatar, an entity, an overlay, or a pick. +* @property {Uuid} parentID - The ID of the parent, either an avatar, an entity, or a pick. * @property {number} [parentJointIndex=0] - The joint of the parent to parent to, for example, the joints on the model of an avatar. (default = 0, no joint) * @property {string} joint - If "Mouse," parents the pick to the mouse. If "Avatar," parents the pick to MyAvatar's head. Otherwise, parents to the joint of the given name on MyAvatar. * @property {boolean} [scaleWithParent=true] If true, the collision pick's dimensions and threshold will adjust according to the scale of the parent. @@ -415,8 +414,6 @@ void PickScriptingInterface::setParentTransform(std::shared_ptr pick, NestableType nestableType = sharedNestablePointer->getNestableType(); if (nestableType == NestableType::Avatar) { pick->parentTransform = std::make_shared(std::static_pointer_cast(sharedNestablePointer), parentJointIndex); - } else if (nestableType == NestableType::Overlay) { - pick->parentTransform = std::make_shared(std::static_pointer_cast(sharedNestablePointer), parentJointIndex); } else if (nestableType == NestableType::Entity) { pick->parentTransform = std::make_shared(std::static_pointer_cast(sharedNestablePointer), parentJointIndex); } else { diff --git a/interface/src/raypick/PickScriptingInterface.h b/interface/src/raypick/PickScriptingInterface.h index e795068cd3..80cf238010 100644 --- a/interface/src/raypick/PickScriptingInterface.h +++ b/interface/src/raypick/PickScriptingInterface.h @@ -46,7 +46,8 @@ * * @property {number} INTERSECTED_NONE An intersection type. Intersected nothing with the given filter flags. Read-only. * @property {number} INTERSECTED_ENTITY An intersection type. Intersected an entity. Read-only. - * @property {number} INTERSECTED_OVERLAY An intersection type. Intersected an overlay. Read-only. + * @property {number} INTERSECTED_LOCAL_ENTITY An intersection type. Intersected a local entity. + * @property {number} INTERSECTED_OVERLAY An intersection type. Intersected an entity (3D Overlays no longer exist). Read-only. * @property {number} INTERSECTED_AVATAR An intersection type. Intersected an avatar. Read-only. * @property {number} INTERSECTED_HUD An intersection type. Intersected the HUD sphere. Read-only. * @property {number} perFrameTimeBudget - The max number of usec to spend per frame updating Pick results. @@ -76,6 +77,7 @@ class PickScriptingInterface : public QObject, public Dependency { 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_LOCAL_ENTITY READ INTERSECTED_LOCAL_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) @@ -211,7 +213,7 @@ public: Q_INVOKABLE void setPrecisionPicking(unsigned int uid, bool precisionPicking); /**jsdoc - * Sets a list of Entity IDs, Overlay IDs, and/or Avatar IDs to ignore during intersection. Not used by Stylus Picks. + * Sets a list of Entity IDs and/or Avatar IDs to ignore during intersection. Not used by Stylus Picks. * @function Picks.setIgnoreItems * @param {number} uid The ID of the Pick, as returned by {@link Picks.createPick}. * @param {Uuid[]} ignoreItems A list of IDs to ignore. @@ -219,7 +221,7 @@ public: Q_INVOKABLE void setIgnoreItems(unsigned int uid, const QScriptValue& ignoreItems); /**jsdoc - * Sets a list of Entity IDs, Overlay IDs, and/or Avatar IDs to include during intersection, instead of intersecting with everything. Stylus + * Sets a list of Entity IDs and/or Avatar IDs to include during intersection, instead of intersecting with everything. Stylus * Picks only intersect with objects in their include list. * @function Picks.setIncludeItems * @param {number} uid The ID of the Pick, as returned by {@link Picks.createPick}. @@ -348,7 +350,13 @@ public slots: * @function Picks.INTERSECTED_OVERLAY * @returns {number} */ - static constexpr unsigned int INTERSECTED_OVERLAY() { return IntersectionType::OVERLAY; } + static constexpr unsigned int INTERSECTED_LOCAL_ENTITY() { return IntersectionType::LOCAL_ENTITY; } + + /**jsdoc + * @function Picks.INTERSECTED_OVERLAY + * @returns {number} + */ + static constexpr unsigned int INTERSECTED_OVERLAY() { return INTERSECTED_LOCAL_ENTITY(); } /**jsdoc * @function Picks.INTERSECTED_AVATAR diff --git a/interface/src/raypick/PointerScriptingInterface.cpp b/interface/src/raypick/PointerScriptingInterface.cpp index 0009536479..19c20f0c06 100644 --- a/interface/src/raypick/PointerScriptingInterface.cpp +++ b/interface/src/raypick/PointerScriptingInterface.cpp @@ -99,7 +99,7 @@ unsigned int PointerScriptingInterface::createStylus(const QVariant& properties) } } - return DependencyManager::get()->addPointer(std::make_shared(properties, StylusPointer::buildStylusOverlay(propertyMap), hover, enabled, modelPositionOffset, + return DependencyManager::get()->addPointer(std::make_shared(properties, StylusPointer::buildStylus(propertyMap), hover, enabled, modelPositionOffset, modelRotationOffset, modelDimensions)); } @@ -116,15 +116,15 @@ unsigned int PointerScriptingInterface::createStylus(const QVariant& properties) * * @typedef {object} Pointers.RayPointerRenderState * @property {string} name When using {@link Pointers.createPointer}, the name of this render state, used by {@link Pointers.setRenderState} and {@link Pointers.editRenderState} - * @property {Overlays.OverlayProperties|QUuid} [start] When using {@link Pointers.createPointer}, an optionally defined overlay to represent the beginning of the Ray Pointer, + * @property {Overlays.OverlayProperties|QUuid} [start] When using {@link Pointers.createPointer}, an optionally defined object to represent the beginning of the Ray Pointer, * using the properties you would normally pass to {@link Overlays.addOverlay}, plus the type (as a type field). - * When returned from {@link Pointers.getPointerProperties}, the ID of the created overlay if it exists, or a null ID otherwise. - * @property {Overlays.OverlayProperties|QUuid} [path] When using {@link Pointers.createPointer}, an optionally defined overlay to represent the path of the Ray Pointer, + * When returned from {@link Pointers.getPointerProperties}, the ID of the created object if it exists, or a null ID otherwise. + * @property {Overlays.OverlayProperties|QUuid} [path] When using {@link Pointers.createPointer}, an optionally defined object to represent the path of the Ray Pointer, * using the properties you would normally pass to {@link Overlays.addOverlay}, plus the type (as a type field), which must be "line3d". - * When returned from {@link Pointers.getPointerProperties}, the ID of the created overlay if it exists, or a null ID otherwise. - * @property {Overlays.OverlayProperties|QUuid} [end] When using {@link Pointers.createPointer}, an optionally defined overlay to represent the end of the Ray Pointer, + * When returned from {@link Pointers.getPointerProperties}, the ID of the created object if it exists, or a null ID otherwise. + * @property {Overlays.OverlayProperties|QUuid} [end] When using {@link Pointers.createPointer}, an optionally defined object to represent the end of the Ray Pointer, * using the properties you would normally pass to {@link Overlays.addOverlay}, plus the type (as a type field). - * When returned from {@link Pointers.getPointerProperties}, the ID of the created overlay if it exists, or a null ID otherwise. + * When returned from {@link Pointers.getPointerProperties}, the ID of the created object if it exists, or a null ID otherwise. */ /**jsdoc * A set of properties that can be passed to {@link Pointers.createPointer} to create a new Pointer. Contains the relevant {@link Picks.PickProperties} to define the underlying Pick. @@ -271,14 +271,14 @@ unsigned int PointerScriptingInterface::createLaserPointer(const QVariant& prope * * @typedef {object} Pointers.ParabolaPointerRenderState * @property {string} name When using {@link Pointers.createPointer}, the name of this render state, used by {@link Pointers.setRenderState} and {@link Pointers.editRenderState} -* @property {Overlays.OverlayProperties|QUuid} [start] When using {@link Pointers.createPointer}, an optionally defined overlay to represent the beginning of the Parabola Pointer, +* @property {Overlays.OverlayProperties|QUuid} [start] When using {@link Pointers.createPointer}, an optionally defined object to represent the beginning of the Parabola Pointer, * using the properties you would normally pass to {@link Overlays.addOverlay}, plus the type (as a type field). -* When returned from {@link Pointers.getPointerProperties}, the ID of the created overlay if it exists, or a null ID otherwise. +* When returned from {@link Pointers.getPointerProperties}, the ID of the created object if it exists, or a null ID otherwise. * @property {Pointers.ParabolaProperties} [path] When using {@link Pointers.createPointer}, the optionally defined rendering properties of the parabolic path defined by the Parabola Pointer. * Not defined in {@link Pointers.getPointerProperties}. -* @property {Overlays.OverlayProperties|QUuid} [end] When using {@link Pointers.createPointer}, an optionally defined overlay to represent the end of the Parabola Pointer, +* @property {Overlays.OverlayProperties|QUuid} [end] When using {@link Pointers.createPointer}, an optionally defined object to represent the end of the Parabola Pointer, * using the properties you would normally pass to {@link Overlays.addOverlay}, plus the type (as a type field). -* When returned from {@link Pointers.getPointerProperties}, the ID of the created overlay if it exists, or a null ID otherwise. +* When returned from {@link Pointers.getPointerProperties}, the ID of the created object if it exists, or a null ID otherwise. */ /**jsdoc * A set of properties that can be passed to {@link Pointers.createPointer} to create a new Pointer. Contains the relevant {@link Picks.PickProperties} to define the underlying Pick. diff --git a/interface/src/raypick/PointerScriptingInterface.h b/interface/src/raypick/PointerScriptingInterface.h index a21c1f2470..1ccc8893a2 100644 --- a/interface/src/raypick/PointerScriptingInterface.h +++ b/interface/src/raypick/PointerScriptingInterface.h @@ -16,7 +16,7 @@ /**jsdoc * The Pointers API lets you create and manage objects for repeatedly calculating intersections in different ways, as well as the visual representation of those objects. - * Pointers can also be configured to automatically generate {@link PointerEvent}s on {@link Entities} and {@link Overlays}. + * Pointers can also be configured to automatically generate {@link PointerEvent}s on {@link Entities}. * * @namespace Pointers * @@ -39,7 +39,7 @@ public: * @typedef {object} Pointers.Trigger * @property {Controller.Standard|Controller.Actions|function} action This can be a built-in Controller action, like Controller.Standard.LTClick, or a function that evaluates to >= 1.0 when you want to trigger button. * @property {string} button Which button to trigger. "Primary", "Secondary", "Tertiary", and "Focus" are currently supported. Only "Primary" will trigger clicks on web surfaces. If "Focus" is triggered, - * it will try to set the entity or overlay focus to the object at which the Pointer is aimed. Buttons besides the first three will still trigger events, but event.button will be "None". + * it will try to set the entity focus to the object at which the Pointer is aimed. Buttons besides the first three will still trigger events, but event.button will be "None". */ /**jsdoc @@ -153,7 +153,7 @@ public: Q_INVOKABLE void setLength(unsigned int uid, float length) const { DependencyManager::get()->setLength(uid, length); } /**jsdoc - * Sets a list of Entity IDs, Overlay IDs, and/or Avatar IDs to ignore during intersection. Not used by Stylus Pointers. + * Sets a list of Entity IDs and/or Avatar IDs to ignore during intersection. Not used by Stylus Pointers. * @function Pointers.setIgnoreItems * @param {number} uid The ID of the Pointer, as returned by {@link Pointers.createPointer}. * @param {Uuid[]} ignoreItems A list of IDs to ignore. @@ -161,7 +161,7 @@ public: Q_INVOKABLE void setIgnoreItems(unsigned int uid, const QScriptValue& ignoreEntities) const; /**jsdoc - * Sets a list of Entity IDs, Overlay IDs, and/or Avatar IDs to include during intersection, instead of intersecting with everything. Stylus + * Sets a list of Entity IDs and/or Avatar IDs to include during intersection, instead of intersecting with everything. Stylus * Pointers only intersect with objects in their include list. * @function Pointers.setIncludeItems * @param {number} uid The ID of the Pointer, as returned by {@link Pointers.createPointer}. @@ -171,15 +171,15 @@ public: /**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. + * Lock a Pointer onto a specific object (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. * @function Pointers.setLockEndUUID * @param {number} uid The ID of the Pointer, as returned by {@link Pointers.createPointer}. * @param {Uuid} objectID The ID of the object to which to lock on. - * @param {boolean} isOverlay False for entities or avatars, true for overlays + * @param {boolean} isAvatar False for entities, true for avatars * @param {Mat4} [offsetMat] The offset matrix to use if you do not want to lock on to the center of the object. */ - Q_INVOKABLE void setLockEndUUID(unsigned int uid, const QUuid& objectID, bool isOverlay, const glm::mat4& offsetMat = glm::mat4()) const { DependencyManager::get()->setLockEndUUID(uid, objectID, isOverlay, offsetMat); } + Q_INVOKABLE void setLockEndUUID(unsigned int uid, const QUuid& objectID, bool isAvatar, const glm::mat4& offsetMat = glm::mat4()) const { DependencyManager::get()->setLockEndUUID(uid, objectID, isAvatar, offsetMat); } /**jsdoc @@ -211,7 +211,7 @@ public: * @function Pointers.getPointerProperties * @param {number} uid The ID of the Pointer, as returned by {@link Pointers.createPointer}. * @returns {Pointers.LaserPointerProperties|Pointers.StylusPointerProperties|Pointers.ParabolaPointerProperties} The information about the Pointer. - * Currently only includes renderStates and defaultRenderStates with associated overlay IDs. + * Currently only includes renderStates and defaultRenderStates with associated entity IDs. */ Q_INVOKABLE QVariantMap getPointerProperties(unsigned int uid) const; }; diff --git a/interface/src/raypick/RayPick.cpp b/interface/src/raypick/RayPick.cpp index 507e45b470..e35f4584a6 100644 --- a/interface/src/raypick/RayPick.cpp +++ b/interface/src/raypick/RayPick.cpp @@ -9,7 +9,6 @@ #include "Application.h" #include "EntityScriptingInterface.h" -#include "ui/overlays/Overlays.h" #include "avatar/AvatarManager.h" #include "scripting/HMDScriptingInterface.h" #include "DependencyManager.h" @@ -37,19 +36,15 @@ PickResultPointer RayPick::getEntityIntersection(const PickRay& pick) { DependencyManager::get()->evalRayIntersectionVector(pick, searchFilter, getIncludeItemsAs(), getIgnoreItemsAs()); if (entityRes.intersects) { - return std::make_shared(IntersectionType::ENTITY, entityRes.entityID, entityRes.distance, entityRes.intersection, pick, entityRes.surfaceNormal, entityRes.extraInfo); - } else { - return std::make_shared(pick.toVariantMap()); - } -} - -PickResultPointer RayPick::getOverlayIntersection(const PickRay& pick) { - bool precisionPicking = !(getFilter().isCoarse() || DependencyManager::get()->getForceCoarsePicking()); - RayToOverlayIntersectionResult overlayRes = - qApp->getOverlays().findRayIntersectionVector(pick, precisionPicking, - getIncludeItemsAs(), getIgnoreItemsAs(), !getFilter().doesPickInvisible(), !getFilter().doesPickNonCollidable()); - if (overlayRes.intersects) { - return std::make_shared(IntersectionType::OVERLAY, overlayRes.overlayID, overlayRes.distance, overlayRes.intersection, pick, overlayRes.surfaceNormal, overlayRes.extraInfo); + IntersectionType type = IntersectionType::ENTITY; + if (getFilter().doesPickLocalEntities()) { + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_ENTITY_HOST_TYPE; + if (DependencyManager::get()->getEntityProperties(entityRes.entityID, desiredProperties).getEntityHostType() == entity::HostType::LOCAL) { + type = IntersectionType::LOCAL_ENTITY; + } + } + return std::make_shared(type, entityRes.entityID, entityRes.distance, entityRes.intersection, pick, entityRes.surfaceNormal, entityRes.extraInfo); } else { return std::make_shared(pick.toVariantMap()); } @@ -88,12 +83,6 @@ glm::vec3 RayPick::intersectRayWithXYPlane(const glm::vec3& origin, const glm::v return origin + t * direction; } -glm::vec3 RayPick::intersectRayWithOverlayXYPlane(const QUuid& overlayID, const glm::vec3& origin, const glm::vec3& direction) { - glm::vec3 position = vec3FromVariant(qApp->getOverlays().getProperty(overlayID, "position").value); - glm::quat rotation = quatFromVariant(qApp->getOverlays().getProperty(overlayID, "rotation").value); - return intersectRayWithXYPlane(origin, direction, position, rotation, ENTITY_ITEM_DEFAULT_REGISTRATION_POINT); -} - glm::vec3 RayPick::intersectRayWithEntityXYPlane(const QUuid& entityID, const glm::vec3& origin, const glm::vec3& direction) { auto props = DependencyManager::get()->getEntityProperties(entityID); return intersectRayWithXYPlane(origin, direction, props.getPosition(), props.getRotation(), props.getRegistrationPoint()); @@ -112,14 +101,6 @@ glm::vec2 RayPick::projectOntoXYPlane(const glm::vec3& worldPos, const glm::vec3 return pos2D; } -glm::vec2 RayPick::projectOntoOverlayXYPlane(const QUuid& overlayID, const glm::vec3& worldPos, bool unNormalized) { - glm::vec3 position = vec3FromVariant(qApp->getOverlays().getProperty(overlayID, "position").value); - glm::quat rotation = quatFromVariant(qApp->getOverlays().getProperty(overlayID, "rotation").value); - glm::vec3 dimensions = glm::vec3(vec2FromVariant(qApp->getOverlays().getProperty(overlayID, "dimensions").value), 0.01f); - - return projectOntoXYPlane(worldPos, position, rotation, dimensions, ENTITY_ITEM_DEFAULT_REGISTRATION_POINT, unNormalized); -} - glm::vec2 RayPick::projectOntoEntityXYPlane(const QUuid& entityID, const glm::vec3& worldPos, bool unNormalized) { auto props = DependencyManager::get()->getEntityProperties(entityID); return projectOntoXYPlane(worldPos, props.getPosition(), props.getRotation(), props.getDimensions(), props.getRegistrationPoint(), unNormalized); diff --git a/interface/src/raypick/RayPick.h b/interface/src/raypick/RayPick.h index ba67ceebb1..a781795e55 100644 --- a/interface/src/raypick/RayPick.h +++ b/interface/src/raypick/RayPick.h @@ -12,7 +12,6 @@ #include class EntityItemID; -class OverlayID; class RayPickResult : public PickResult { public: @@ -78,16 +77,13 @@ public: PickResultPointer getDefaultResult(const QVariantMap& pickVariant) const override { return std::make_shared(pickVariant); } PickResultPointer getEntityIntersection(const PickRay& pick) override; - PickResultPointer getOverlayIntersection(const PickRay& pick) override; PickResultPointer getAvatarIntersection(const PickRay& pick) override; PickResultPointer getHUDIntersection(const PickRay& pick) override; Transform getResultTransform() const override; // These are helper functions for projecting and intersecting rays static glm::vec3 intersectRayWithEntityXYPlane(const QUuid& entityID, const glm::vec3& origin, const glm::vec3& direction); - static glm::vec3 intersectRayWithOverlayXYPlane(const QUuid& overlayID, const glm::vec3& origin, const glm::vec3& direction); static glm::vec2 projectOntoEntityXYPlane(const QUuid& entityID, const glm::vec3& worldPos, bool unNormalized = true); - static glm::vec2 projectOntoOverlayXYPlane(const QUuid& overlayID, const glm::vec3& worldPos, bool unNormalized = true); private: static glm::vec3 intersectRayWithXYPlane(const glm::vec3& origin, const glm::vec3& direction, const glm::vec3& point, const glm::quat& rotation, const glm::vec3& registration); diff --git a/interface/src/raypick/RayPickScriptingInterface.h b/interface/src/raypick/RayPickScriptingInterface.h index 3ad0efd439..f8c47ba4cf 100644 --- a/interface/src/raypick/RayPickScriptingInterface.h +++ b/interface/src/raypick/RayPickScriptingInterface.h @@ -53,6 +53,7 @@ class RayPickScriptingInterface : public QObject, public Dependency { 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_LOCAL_ENTITY READ INTERSECTED_LOCAL_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) @@ -202,7 +203,13 @@ public slots: * @function RayPick.INTERSECTED_OVERLAY * @returns {number} */ - static unsigned int INTERSECTED_OVERLAY() { return PickScriptingInterface::INTERSECTED_OVERLAY(); } + static unsigned int INTERSECTED_LOCAL_ENTITY() { return PickScriptingInterface::INTERSECTED_LOCAL_ENTITY(); } + + /**jsdoc + * @function RayPick.INTERSECTED_OVERLAY + * @returns {number} + */ + static unsigned int INTERSECTED_OVERLAY() { return PickScriptingInterface::INTERSECTED_LOCAL_ENTITY(); } /**jsdoc * @function RayPick.INTERSECTED_AVATAR diff --git a/interface/src/raypick/StylusPick.cpp b/interface/src/raypick/StylusPick.cpp index 0a76180be8..a9dbf9b950 100644 --- a/interface/src/raypick/StylusPick.cpp +++ b/interface/src/raypick/StylusPick.cpp @@ -11,8 +11,6 @@ #include -#include "ui/overlays/Base3DOverlay.h" - #include "Application.h" #include #include "avatar/AvatarManager.h" @@ -148,7 +146,13 @@ PickResultPointer StylusPick::getEntityIntersection(const StylusTip& pick) { continue; } - if (!entity->getVisible() && !getFilter().doesPickInvisible()) { + bool visible = entity->getVisible(); + bool collisionless = entity->getCollisionless(); + if ((!visible && !getFilter().doesPickInvisible()) || (visible && !getFilter().doesPickVisible()) || + (!collisionless && !getFilter().doesPickCollidable()) || (collisionless && !getFilter().doesPickNonCollidable()) || + (entity->isLocalEntity() && !getFilter().doesPickLocalEntities()) || + (entity->isAvatarEntity() && !getFilter().doesPickAvatarEntities()) || + (entity->isDomainEntity() && !getFilter().doesPickDomainEntities())) { continue; } @@ -161,47 +165,15 @@ PickResultPointer StylusPick::getEntityIntersection(const StylusTip& pick) { glm::vec2 pos2D = RayPick::projectOntoEntityXYPlane(target, intersection, false); if (pos2D == glm::clamp(pos2D, glm::vec2(0), glm::vec2(1))) { - results.push_back(StylusPickResult(IntersectionType::ENTITY, target, distance, intersection, pick, normal)); - } - } - - StylusPickResult nearestTarget(pick.toVariantMap()); - for (const auto& result : results) { - if (result.distance < nearestTarget.distance) { - nearestTarget = result; - } - } - return std::make_shared(nearestTarget); -} - -PickResultPointer StylusPick::getOverlayIntersection(const StylusTip& pick) { - std::vector results; - for (const auto& target : getIncludeItems()) { - if (target.isNull()) { - continue; - } - - auto overlay = qApp->getOverlays().getOverlay(target); - // Don't interact with non-3D or invalid overlays - if (!overlay || !overlay->is3D()) { - continue; - } - - if (!overlay->getVisible() && !getFilter().doesPickInvisible()) { - continue; - } - - auto overlay3D = std::static_pointer_cast(overlay); - const auto overlayRotation = overlay3D->getWorldOrientation(); - const auto overlayPosition = overlay3D->getWorldPosition(); - - glm::vec3 normal = overlayRotation * Vectors::UNIT_Z; - float distance = glm::dot(pick.position - overlayPosition, normal); - glm::vec3 intersection = pick.position - (normal * distance); - - glm::vec2 pos2D = RayPick::projectOntoOverlayXYPlane(target, intersection, false); - if (pos2D == glm::clamp(pos2D, glm::vec2(0), glm::vec2(1))) { - results.push_back(StylusPickResult(IntersectionType::OVERLAY, target, distance, intersection, pick, normal)); + IntersectionType type = IntersectionType::ENTITY; + if (getFilter().doesPickLocalEntities()) { + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_ENTITY_HOST_TYPE; + if (DependencyManager::get()->getEntityProperties(target, desiredProperties).getEntityHostType() == entity::HostType::LOCAL) { + type = IntersectionType::LOCAL_ENTITY; + } + } + results.push_back(StylusPickResult(type, target, distance, intersection, pick, normal)); } } diff --git a/interface/src/raypick/StylusPick.h b/interface/src/raypick/StylusPick.h index 14821c0ce5..9d5dc10b67 100644 --- a/interface/src/raypick/StylusPick.h +++ b/interface/src/raypick/StylusPick.h @@ -63,7 +63,6 @@ public: StylusTip getMathematicalPick() const override; PickResultPointer getDefaultResult(const QVariantMap& pickVariant) const override; PickResultPointer getEntityIntersection(const StylusTip& pick) override; - PickResultPointer getOverlayIntersection(const StylusTip& pick) override; PickResultPointer getAvatarIntersection(const StylusTip& pick) override; PickResultPointer getHUDIntersection(const StylusTip& pick) override; Transform getResultTransform() const override; diff --git a/interface/src/raypick/StylusPointer.cpp b/interface/src/raypick/StylusPointer.cpp index 867f896763..3cdcb9c3a5 100644 --- a/interface/src/raypick/StylusPointer.cpp +++ b/interface/src/raypick/StylusPointer.cpp @@ -27,10 +27,10 @@ static const float TOUCH_HYSTERESIS = 0.001f; static const QString DEFAULT_STYLUS_MODEL_URL = PathUtils::resourcesUrl() + "/meshes/tablet-stylus-fat.fbx"; -StylusPointer::StylusPointer(const QVariant& props, const OverlayID& stylusOverlay, bool hover, bool enabled, +StylusPointer::StylusPointer(const QVariant& props, const QUuid& stylus, bool hover, bool enabled, const glm::vec3& modelPositionOffset, const glm::quat& modelRotationOffset, const glm::vec3& modelDimensions) : Pointer(DependencyManager::get()->createStylusPick(props), enabled, hover), - _stylusOverlay(stylusOverlay), + _stylus(stylus), _modelPositionOffset(modelPositionOffset), _modelDimensions(modelDimensions), _modelRotationOffset(modelRotationOffset) @@ -38,13 +38,14 @@ StylusPointer::StylusPointer(const QVariant& props, const OverlayID& stylusOverl } StylusPointer::~StylusPointer() { - if (!_stylusOverlay.isNull()) { - qApp->getOverlays().deleteOverlay(_stylusOverlay); + if (!_stylus.isNull()) { + DependencyManager::get()->deleteEntity(_stylus); } } -OverlayID StylusPointer::buildStylusOverlay(const QVariantMap& properties) { - QVariantMap overlayProperties; +QUuid StylusPointer::buildStylus(const QVariantMap& properties) { + // FIXME: we have to keep using the Overlays interface here, because existing scripts use overlay properties to define pointers + QVariantMap propertiesMap; QString modelUrl = DEFAULT_STYLUS_MODEL_URL; @@ -56,15 +57,15 @@ OverlayID StylusPointer::buildStylusOverlay(const QVariantMap& properties) { } } // TODO: make these configurable per pointer - overlayProperties["name"] = "stylus"; - overlayProperties["url"] = modelUrl; - overlayProperties["loadPriority"] = 10.0f; - overlayProperties["solid"] = true; - overlayProperties["visible"] = false; - overlayProperties["ignorePickIntersection"] = true; - overlayProperties["drawInFront"] = false; + propertiesMap["name"] = "stylus"; + propertiesMap["url"] = modelUrl; + propertiesMap["loadPriority"] = 10.0f; + propertiesMap["solid"] = true; + propertiesMap["visible"] = false; + propertiesMap["ignorePickIntersection"] = true; + propertiesMap["drawInFront"] = false; - return qApp->getOverlays().addOverlay("model", overlayProperties); + return qApp->getOverlays().addOverlay("model", propertiesMap); } void StylusPointer::updateVisuals(const PickResultPointer& pickResult) { @@ -83,25 +84,25 @@ void StylusPointer::updateVisuals(const PickResultPointer& pickResult) { } void StylusPointer::show(const StylusTip& tip) { - if (!_stylusOverlay.isNull()) { - QVariantMap props; + if (!_stylus.isNull()) { auto modelOrientation = tip.orientation * _modelRotationOffset; auto sensorToWorldScale = DependencyManager::get()->getMyAvatar()->getSensorToWorldScale(); auto modelPositionOffset = modelOrientation * (_modelPositionOffset * sensorToWorldScale); - props["position"] = vec3toVariant(tip.position + modelPositionOffset); - props["rotation"] = quatToVariant(modelOrientation); - props["dimensions"] = vec3toVariant(sensorToWorldScale * _modelDimensions); - props["visible"] = true; - qApp->getOverlays().editOverlay(_stylusOverlay, props); + EntityItemProperties properties; + properties.setPosition(tip.position + modelPositionOffset); + properties.setRotation(modelOrientation); + properties.setDimensions(sensorToWorldScale * _modelDimensions); + properties.setVisible(true); + DependencyManager::get()->editEntity(_stylus, properties); } _showing = true; } void StylusPointer::hide() { - if (!_stylusOverlay.isNull()) { - QVariantMap props; - props.insert("visible", false); - qApp->getOverlays().editOverlay(_stylusOverlay, props); + if (!_stylus.isNull()) { + EntityItemProperties properties; + properties.setVisible(false); + DependencyManager::get()->editEntity(_stylus, properties); } _showing = false; } @@ -234,9 +235,8 @@ QVariantMap StylusPointer::toVariantMap() const { glm::vec3 StylusPointer::findIntersection(const PickedObject& pickedObject, const glm::vec3& origin, const glm::vec3& direction) { switch (pickedObject.type) { case ENTITY: + case LOCAL_ENTITY: return RayPick::intersectRayWithEntityXYPlane(pickedObject.objectID, origin, direction); - case OVERLAY: - return RayPick::intersectRayWithOverlayXYPlane(pickedObject.objectID, origin, direction); default: return glm::vec3(NAN); } @@ -245,9 +245,8 @@ glm::vec3 StylusPointer::findIntersection(const PickedObject& pickedObject, cons glm::vec2 StylusPointer::findPos2D(const PickedObject& pickedObject, const glm::vec3& origin) { switch (pickedObject.type) { case ENTITY: + case LOCAL_ENTITY: return RayPick::projectOntoEntityXYPlane(pickedObject.objectID, origin); - case OVERLAY: - return RayPick::projectOntoOverlayXYPlane(pickedObject.objectID, origin); case HUD: return DependencyManager::get()->calculatePos2DFromHUD(origin); default: diff --git a/interface/src/raypick/StylusPointer.h b/interface/src/raypick/StylusPointer.h index 64e2a38bed..7d43df2379 100644 --- a/interface/src/raypick/StylusPointer.h +++ b/interface/src/raypick/StylusPointer.h @@ -12,8 +12,6 @@ #include #include -#include "ui/overlays/Overlay.h" - #include "StylusPick.h" class StylusPointer : public Pointer { @@ -21,7 +19,7 @@ class StylusPointer : public Pointer { using Ptr = std::shared_ptr; public: - StylusPointer(const QVariant& props, const OverlayID& stylusOverlay, bool hover, bool enabled, + StylusPointer(const QVariant& props, const QUuid& stylus, bool hover, bool enabled, const glm::vec3& modelPositionOffset, const glm::quat& modelRotationOffset, const glm::vec3& modelDimensions); ~StylusPointer(); @@ -36,7 +34,7 @@ public: QVariantMap toVariantMap() const override; - static OverlayID buildStylusOverlay(const QVariantMap& properties); + static QUuid buildStylus(const QVariantMap& properties); protected: PickedObject getHoveredObject(const PickResultPointer& pickResult) override; @@ -74,7 +72,7 @@ private: RenderState _renderState { EVENTS_ON }; - const OverlayID _stylusOverlay; + QUuid _stylus; static bool isWithinBounds(float distance, float min, float max, float hysteresis); static glm::vec3 findIntersection(const PickedObject& pickedObject, const glm::vec3& origin, const glm::vec3& direction); diff --git a/interface/src/scripting/HMDScriptingInterface.h b/interface/src/scripting/HMDScriptingInterface.h index 81f85409cc..11b1c50073 100644 --- a/interface/src/scripting/HMDScriptingInterface.h +++ b/interface/src/scripting/HMDScriptingInterface.h @@ -53,12 +53,12 @@ class QScriptEngine; * @property {boolean} tabletContextualMode - true if the tablet has been opened in contextual mode, otherwise * false. In contextual mode, the tablet has been opened at a specific world position and orientation rather * than at a position and orientation relative to the user. Read-only. - * @property {Uuid} tabletID - The UUID of the tablet body model overlay. - * @property {Uuid} tabletScreenID - The UUID of the tablet's screen overlay. - * @property {Uuid} homeButtonID - The UUID of the tablet's "home" button overlay. - * @property {Uuid} homeButtonHighlightID - The UUID of the tablet's "home" button highlight overlay. - * @property {Uuid} miniTabletID - The UUID of the mini tablet's body model overlay. null if not in HMD mode. - * @property {Uuid} miniTabletScreenID - The UUID of the mini tablet's screen overlay. null if not in HMD mode. + * @property {Uuid} tabletID - The UUID of the tablet body model entity. + * @property {Uuid} tabletScreenID - The UUID of the tablet's screen entity. + * @property {Uuid} homeButtonID - The UUID of the tablet's "home" button entity. + * @property {Uuid} homeButtonHighlightID - The UUID of the tablet's "home" button highlight entity. + * @property {Uuid} miniTabletID - The UUID of the mini tablet's body model entity. null if not in HMD mode. + * @property {Uuid} miniTabletScreenID - The UUID of the mini tablet's screen entity. null if not in HMD mode. * @property {number} miniTabletHand - The hand that the mini tablet is displayed on: 0 for left hand, * 1 for right hand, -1 if not in HMD mode. * @property {bool} miniTabletEnabled=true - true if the mini tablet is enabled to be displayed, otherwise diff --git a/interface/src/scripting/KeyboardScriptingInterface.cpp b/interface/src/scripting/KeyboardScriptingInterface.cpp index ccf123efed..b031f2d749 100644 --- a/interface/src/scripting/KeyboardScriptingInterface.cpp +++ b/interface/src/scripting/KeyboardScriptingInterface.cpp @@ -64,6 +64,6 @@ bool KeyboardScriptingInterface::getPreferMalletsOverLasers() const { return DependencyManager::get()->getPreferMalletsOverLasers(); } -bool KeyboardScriptingInterface::containsID(OverlayID overlayID) const { - return DependencyManager::get()->containsID(overlayID); +bool KeyboardScriptingInterface::containsID(const QUuid& id) const { + return DependencyManager::get()->containsID(id); } diff --git a/interface/src/scripting/KeyboardScriptingInterface.h b/interface/src/scripting/KeyboardScriptingInterface.h index acee10669e..bc8f2f60bd 100644 --- a/interface/src/scripting/KeyboardScriptingInterface.h +++ b/interface/src/scripting/KeyboardScriptingInterface.h @@ -16,7 +16,6 @@ #include #include "DependencyManager.h" -#include "ui/overlays/Overlay.h" /**jsdoc * The Keyboard API provides facilities to use 3D Physical keyboard. @@ -46,7 +45,7 @@ public: Q_INVOKABLE void disableRightMallet(); Q_INVOKABLE void setLeftHandLaser(unsigned int leftHandLaser); Q_INVOKABLE void setRightHandLaser(unsigned int rightHandLaser); - Q_INVOKABLE bool containsID(OverlayID overlayID) const; + Q_INVOKABLE bool containsID(const QUuid& overlayID) const; private: bool getPreferMalletsOverLasers() const; bool isRaised() const; diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index 4a8a72b16d..c15b5cde11 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -40,19 +40,6 @@ bool GameplayObjects::removeFromGameplayObjects(const EntityItemID& entityID) { return true; } -bool GameplayObjects::addToGameplayObjects(const OverlayID& overlayID) { - containsData = true; - if (std::find(_overlayIDs.begin(), _overlayIDs.end(), overlayID) == _overlayIDs.end()) { - _overlayIDs.push_back(overlayID); - } - return true; -} -bool GameplayObjects::removeFromGameplayObjects(const OverlayID& overlayID) { - _overlayIDs.erase(std::remove(_overlayIDs.begin(), _overlayIDs.end(), overlayID), _overlayIDs.end()); - return true; -} - - SelectionScriptingInterface::SelectionScriptingInterface() { } @@ -64,7 +51,6 @@ SelectionScriptingInterface::SelectionScriptingInterface() { * * "avatar" * "entity" - * "overlay" * * * @typedef {string} Selection.ItemType @@ -72,20 +58,16 @@ SelectionScriptingInterface::SelectionScriptingInterface() { bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const QString& itemType, const QUuid& id) { if (itemType == "avatar") { return addToGameplayObjects(listName, (QUuid)id); - } else if (itemType == "entity") { + } else if (itemType == "entity" || itemType == "overlay") { return addToGameplayObjects(listName, (EntityItemID)id); - } else if (itemType == "overlay") { - return addToGameplayObjects(listName, (OverlayID)id); } return false; } bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& listName, const QString& itemType, const QUuid& id) { if (itemType == "avatar") { return removeFromGameplayObjects(listName, (QUuid)id); - } else if (itemType == "entity") { + } else if (itemType == "entity" || itemType == "overlay") { return removeFromGameplayObjects(listName, (EntityItemID)id); - } else if (itemType == "overlay") { - return removeFromGameplayObjects(listName, (OverlayID)id); } return false; } @@ -253,12 +235,6 @@ void SelectionScriptingInterface::printList(const QString& listName) { qDebug() << j << ';'; } qDebug() << ""; - - qDebug() << "Overlay IDs:"; - for (auto k : (*currentList).getOverlayIDs()) { - qDebug() << k << ';'; - } - qDebug() << ""; } else { qDebug() << "List named " << listName << " empty"; @@ -272,7 +248,6 @@ void SelectionScriptingInterface::printList(const QString& listName) { * @typedef {object} Selection.SelectedItemsList * @property {Uuid[]} avatars - The IDs of the avatars in the selection. * @property {Uuid[]} entities - The IDs of the entities in the selection. - * @property {Uuid[]} overlays - The IDs of the overlays in the selection. */ QVariantMap SelectionScriptingInterface::getSelectedItemsList(const QString& listName) const { QReadLocker lock(&_selectionListsLock); @@ -281,7 +256,6 @@ QVariantMap SelectionScriptingInterface::getSelectedItemsList(const QString& lis if (currentList != _selectedItemsListMap.end()) { QList avatarIDs; QList entityIDs; - QList overlayIDs; if ((*currentList).getContainsData()) { if (!(*currentList).getAvatarIDs().empty()) { @@ -294,15 +268,9 @@ QVariantMap SelectionScriptingInterface::getSelectedItemsList(const QString& lis entityIDs.push_back((QUuid)j ); } } - if (!(*currentList).getOverlayIDs().empty()) { - for (auto j : (*currentList).getOverlayIDs()) { - overlayIDs.push_back((QUuid)j); - } - } } list["avatars"] = (avatarIDs); list["entities"] = (entityIDs); - list["overlays"] = (overlayIDs); return list; } @@ -379,7 +347,6 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { render::ItemIDs finalList; render::ItemID currentID; auto entityTreeRenderer = DependencyManager::get(); - auto& overlays = qApp->getOverlays(); for (QUuid& currentAvatarID : thisList.getAvatarIDs()) { auto avatar = std::static_pointer_cast(DependencyManager::get()->getAvatarBySessionID(currentAvatarID)); @@ -398,16 +365,6 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { } } - for (OverlayID& currentOverlayID : thisList.getOverlayIDs()) { - auto overlay = overlays.getOverlay(currentOverlayID); - if (overlay != NULL) { - currentID = overlay->getRenderItemID(); - if (currentID != render::Item::INVALID_ITEM_ID) { - finalList.push_back(currentID); - } - } - } - render::Selection selection(_listName.toStdString(), finalList); transaction.resetSelection(selection); diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 83aec63ee2..dc95b1ea24 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -19,7 +19,6 @@ #include #include "RenderableEntityItem.h" -#include "ui/overlays/Overlay.h" #include #include @@ -37,15 +36,10 @@ public: bool addToGameplayObjects(const EntityItemID& entityID); bool removeFromGameplayObjects(const EntityItemID& entityID); - std::vector getOverlayIDs() const { return _overlayIDs; } - bool addToGameplayObjects(const OverlayID& overlayID); - bool removeFromGameplayObjects(const OverlayID& overlayID); - private: bool containsData { false }; std::vector _avatarIDs; std::vector _entityIDs; - std::vector _overlayIDs; }; @@ -83,7 +77,7 @@ protected: }; /**jsdoc - * The Selection API provides a means of grouping together avatars, entities, and overlays in named lists. + * The Selection API provides a means of grouping together avatars and entities in named lists. * @namespace Selection * * @hifi-interface @@ -174,14 +168,14 @@ public: Q_INVOKABLE bool clearSelectedItemsList(const QString& listName); /**jsdoc - * Print out the list of avatars, entities, and overlays in a selection to the debug log (not the script log). + * Print out the list of avatars and entities in a selection to the debug log (not the script log). * @function Selection.printList * @param {string} listName - The name of the selection list. */ Q_INVOKABLE void printList(const QString& listName); /**jsdoc - * Get the list of avatars, entities, and overlays stored in a selection list. + * Get the list of avatars and entities stored in a selection list. * @function Selection.getSelectedItemsList * @param {string} listName - The name of the selection list. * @returns {Selection.SelectedItemsList} The content of a selection list. If the list name doesn't exist, the function diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 3579776213..8f21965c56 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -134,9 +134,7 @@ void ApplicationOverlay::renderOverlays(RenderArgs* renderArgs) { batch.resetViewTransform(); // Render all of the Script based "HUD" aka 2D overlays. - // note: we call them HUD, as opposed to 2D, only because there are some cases of 3D HUD overlays, like the - // cameral controls for the edit.js - qApp->getOverlays().renderHUD(renderArgs); + qApp->getOverlays().render(renderArgs); } void ApplicationOverlay::renderDomainConnectionStatusBorder(RenderArgs* renderArgs) { diff --git a/interface/src/ui/Keyboard.cpp b/interface/src/ui/Keyboard.cpp index 9e9a319802..01d21a211a 100644 --- a/interface/src/ui/Keyboard.cpp +++ b/interface/src/ui/Keyboard.cpp @@ -33,11 +33,6 @@ #include #include -#include "ui/overlays/Overlays.h" -#include "ui/overlays/Overlay.h" -#include "ui/overlays/ModelOverlay.h" -#include "ui/overlays/Cube3DOverlay.h" -#include "ui/overlays/Text3DOverlay.h" #include "avatar/AvatarManager.h" #include "avatar/MyAvatar.h" #include "avatar/AvatarManager.h" @@ -120,21 +115,21 @@ std::pair calculateKeyboardPositionAndOrientation() { float sensorToWorldScale = myAvatar->getSensorToWorldScale(); QUuid tabletID = hmd->getCurrentTabletFrameID(); if (!tabletID.isNull() && hmd->getShouldShowTablet()) { - Overlays& overlays = qApp->getOverlays(); - auto tabletOverlay = std::dynamic_pointer_cast(overlays.getOverlay(tabletID)); - if (tabletOverlay) { - auto tablet = DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system"); - bool landscapeMode = tablet->getLandscape(); - glm::vec3 keyboardOffset = landscapeMode ? KEYBOARD_TABLET_LANDSCAPE_OFFSET : KEYBOARD_TABLET_OFFSET; - glm::vec3 keyboardDegreesOffset = landscapeMode ? KEYBOARD_TABLET_LANDSCAPE_DEGREES_OFFSET : KEYBOARD_TABLET_DEGREES_OFFSET; - glm::vec3 tabletWorldPosition = tabletOverlay->getWorldPosition(); - glm::quat tabletWorldOrientation = tabletOverlay->getWorldOrientation(); - glm::vec3 scaledKeyboardTabletOffset = keyboardOffset * sensorToWorldScale; + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_POSITION; + desiredProperties += PROP_ROTATION; + auto properties = DependencyManager::get()->getEntityProperties(tabletID, desiredProperties); - keyboardLocation.first = tabletWorldPosition + (tabletWorldOrientation * scaledKeyboardTabletOffset); - keyboardLocation.second = tabletWorldOrientation * glm::quat(glm::radians(keyboardDegreesOffset)); - } + auto tablet = DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system"); + bool landscapeMode = tablet->getLandscape(); + glm::vec3 keyboardOffset = landscapeMode ? KEYBOARD_TABLET_LANDSCAPE_OFFSET : KEYBOARD_TABLET_OFFSET; + glm::vec3 keyboardDegreesOffset = landscapeMode ? KEYBOARD_TABLET_LANDSCAPE_DEGREES_OFFSET : KEYBOARD_TABLET_DEGREES_OFFSET; + glm::vec3 tabletWorldPosition = properties.getPosition(); + glm::quat tabletWorldOrientation = properties.getRotation(); + glm::vec3 scaledKeyboardTabletOffset = keyboardOffset * sensorToWorldScale; + keyboardLocation.first = tabletWorldPosition + (tabletWorldOrientation * scaledKeyboardTabletOffset); + keyboardLocation.second = tabletWorldOrientation * glm::quat(glm::radians(keyboardDegreesOffset)); } else { glm::vec3 avatarWorldPosition = myAvatar->getWorldPosition(); glm::quat avatarWorldOrientation = myAvatar->getWorldOrientation(); @@ -148,32 +143,25 @@ std::pair calculateKeyboardPositionAndOrientation() { } void Key::saveDimensionsAndLocalPosition() { - Overlays& overlays = qApp->getOverlays(); - auto model3DOverlay = std::dynamic_pointer_cast(overlays.getOverlay(_keyID)); + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_LOCAL_POSITION; + desiredProperties += PROP_DIMENSIONS; + auto properties = DependencyManager::get()->getEntityProperties(_keyID, desiredProperties); - if (model3DOverlay) { - _originalLocalPosition = model3DOverlay->getLocalPosition(); - _originalDimensions = model3DOverlay->getDimensions(); - _currentLocalPosition = _originalLocalPosition; - } + _originalLocalPosition = properties.getLocalPosition(); + _originalDimensions = properties.getDimensions(); + _currentLocalPosition = _originalLocalPosition; } void Key::scaleKey(float sensorToWorldScale) { - Overlays& overlays = qApp->getOverlays(); - auto model3DOverlay = std::dynamic_pointer_cast(overlays.getOverlay(_keyID)); + glm::vec3 scaledLocalPosition = _originalLocalPosition * sensorToWorldScale; + glm::vec3 scaledDimensions = _originalDimensions * sensorToWorldScale; + _currentLocalPosition = scaledLocalPosition; - if (model3DOverlay) { - glm::vec3 scaledLocalPosition = _originalLocalPosition * sensorToWorldScale; - glm::vec3 scaledDimensions = _originalDimensions * sensorToWorldScale; - _currentLocalPosition = scaledLocalPosition; - - QVariantMap properties { - { "dimensions", vec3toVariant(scaledDimensions) }, - { "localPosition", vec3toVariant(scaledLocalPosition) } - }; - - overlays.editOverlay(_keyID, properties); - } + EntityItemProperties properties; + properties.setDimensions(scaledDimensions); + properties.setLocalPosition(scaledLocalPosition); + DependencyManager::get()->editEntity(_keyID, properties); } void Key::startTimer(int time) { @@ -262,21 +250,21 @@ void Keyboard::createKeyboard() { QVariantMap leftStylusProperties { { "hand", LEFT_HAND_CONTROLLER_INDEX }, - { "filter", PickScriptingInterface::PICK_OVERLAYS() }, + { "filter", PickScriptingInterface::PICK_LOCAL_ENTITIES() }, { "model", modelProperties }, { "tipOffset", vec3toVariant(MALLET_TIP_OFFSET) } }; QVariantMap rightStylusProperties { { "hand", RIGHT_HAND_CONTROLLER_INDEX }, - { "filter", PickScriptingInterface::PICK_OVERLAYS() }, + { "filter", PickScriptingInterface::PICK_LOCAL_ENTITIES() }, { "model", modelProperties }, { "tipOffset", vec3toVariant(MALLET_TIP_OFFSET) } }; - _leftHandStylus = pointerManager->addPointer(std::make_shared(leftStylusProperties, StylusPointer::buildStylusOverlay(leftStylusProperties), true, true, + _leftHandStylus = pointerManager->addPointer(std::make_shared(leftStylusProperties, StylusPointer::buildStylus(leftStylusProperties), true, true, MALLET_POSITION_OFFSET, MALLET_ROTATION_OFFSET, MALLET_MODEL_DIMENSIONS)); - _rightHandStylus = pointerManager->addPointer(std::make_shared(rightStylusProperties, StylusPointer::buildStylusOverlay(rightStylusProperties), true, true, + _rightHandStylus = pointerManager->addPointer(std::make_shared(rightStylusProperties, StylusPointer::buildStylus(rightStylusProperties), true, true, MALLET_POSITION_OFFSET, MALLET_ROTATION_OFFSET, MALLET_MODEL_DIMENSIONS)); pointerManager->disablePointer(_rightHandStylus); @@ -312,93 +300,70 @@ void Keyboard::setRaised(bool raised) { } void Keyboard::updateTextDisplay() { - Overlays& overlays = qApp->getOverlays(); - auto myAvatar = DependencyManager::get()->getMyAvatar(); + auto entityScriptingInterface = DependencyManager::get(); float sensorToWorldScale = myAvatar->getSensorToWorldScale(); - float textWidth = (float) overlays.textSize(_textDisplay.overlayID, _typedCharacters).width(); + float textWidth = (float)entityScriptingInterface->textSize(_textDisplay.entityID, _typedCharacters).width(); glm::vec3 scaledDimensions = _textDisplay.dimensions; scaledDimensions *= sensorToWorldScale; float leftMargin = (scaledDimensions.x / 2); scaledDimensions.x += textWidth; - - QVariantMap textDisplayProperties { - { "dimensions", vec3toVariant(scaledDimensions) }, - { "leftMargin", leftMargin }, - { "text", _typedCharacters }, - { "lineHeight", (_textDisplay.lineHeight * sensorToWorldScale) } - }; - - overlays.editOverlay(_textDisplay.overlayID, textDisplayProperties); + EntityItemProperties properties; + properties.setDimensions(scaledDimensions); + properties.setLeftMargin(leftMargin); + properties.setText(_typedCharacters); + properties.setLineHeight(_textDisplay.lineHeight * sensorToWorldScale); + entityScriptingInterface->editEntity(_textDisplay.entityID, properties); } void Keyboard::raiseKeyboardAnchor(bool raise) const { - Overlays& overlays = qApp->getOverlays(); - OverlayID anchorOverlayID = _anchor.overlayID; - auto anchorOverlay = std::dynamic_pointer_cast(overlays.getOverlay(anchorOverlayID)); - if (anchorOverlay) { + auto entityScriptingInterface = DependencyManager::get(); + + EntityItemProperties properties; + properties.setVisible(raise); + + entityScriptingInterface->editEntity(_textDisplay.entityID, properties); + entityScriptingInterface->editEntity(_backPlate.entityID, properties); + + if (_resetKeyboardPositionOnRaise) { std::pair keyboardLocation = calculateKeyboardPositionAndOrientation(); - if (_resetKeyboardPositionOnRaise) { - anchorOverlay->setWorldPosition(keyboardLocation.first); - anchorOverlay->setWorldOrientation(keyboardLocation.second); - } - anchorOverlay->setVisible(raise); - - QVariantMap textDisplayProperties { - { "visible", raise } - }; - - overlays.editOverlay(_textDisplay.overlayID, textDisplayProperties); - - auto backPlateOverlay = std::dynamic_pointer_cast(overlays.getOverlay(_backPlate.overlayID)); - - if (backPlateOverlay) { - backPlateOverlay->setVisible(raise); - } + properties.setPosition(keyboardLocation.first); + properties.setRotation(keyboardLocation.second); } + entityScriptingInterface->editEntity(_anchor.entityID, properties); } void Keyboard::scaleKeyboard(float sensorToWorldScale) { - Overlays& overlays = qApp->getOverlays(); + auto entityScriptingInterface = DependencyManager::get(); - glm::vec3 scaledDimensions = _anchor.originalDimensions * sensorToWorldScale; - auto volume3DOverlay = std::dynamic_pointer_cast(overlays.getOverlay(_anchor.overlayID)); - - if (volume3DOverlay) { - volume3DOverlay->setDimensions(scaledDimensions); + { + EntityItemProperties properties; + properties.setDimensions(_anchor.originalDimensions * sensorToWorldScale); + entityScriptingInterface->editEntity(_anchor.entityID, properties); } - for (auto& keyboardLayer: _keyboardLayers) { + for (auto& keyboardLayer : _keyboardLayers) { for (auto iter = keyboardLayer.begin(); iter != keyboardLayer.end(); iter++) { iter.value().scaleKey(sensorToWorldScale); } } + { + EntityItemProperties properties; + properties.setLocalPosition(_textDisplay.localPosition * sensorToWorldScale); + properties.setDimensions(_textDisplay.dimensions * sensorToWorldScale); + properties.setLineHeight(_textDisplay.lineHeight * sensorToWorldScale); + entityScriptingInterface->editEntity(_textDisplay.entityID, properties); + } - - glm::vec3 scaledLocalPosition = _textDisplay.localPosition * sensorToWorldScale; - glm::vec3 textDisplayScaledDimensions = _textDisplay.dimensions * sensorToWorldScale; - - QVariantMap textDisplayProperties { - { "localPosition", vec3toVariant(scaledLocalPosition) }, - { "dimensions", vec3toVariant(textDisplayScaledDimensions) }, - { "lineHeight", (_textDisplay.lineHeight * sensorToWorldScale) } - }; - - overlays.editOverlay(_textDisplay.overlayID, textDisplayProperties); - - - glm::vec3 backPlateScaledDimensions = _backPlate.dimensions * sensorToWorldScale; - glm::vec3 backPlateScaledLocalPosition = _backPlate.localPosition * sensorToWorldScale; - - QVariantMap backPlateProperties { - { "localPosition", vec3toVariant(backPlateScaledLocalPosition) }, - { "dimensions", vec3toVariant(backPlateScaledDimensions) } - }; - - overlays.editOverlay(_backPlate.overlayID, backPlateProperties); + { + EntityItemProperties properties; + properties.setLocalPosition(_backPlate.localPosition * sensorToWorldScale); + properties.setDimensions(_backPlate.dimensions * sensorToWorldScale); + entityScriptingInterface->editEntity(_backPlate.entityID, properties); + } } void Keyboard::startLayerSwitchTimer() { @@ -419,13 +384,12 @@ void Keyboard::raiseKeyboard(bool raise) const { if (_keyboardLayers.empty()) { return; } - Overlays& overlays = qApp->getOverlays(); + const auto& keyboardLayer = _keyboardLayers[_layerIndex]; + EntityItemProperties properties; + properties.setVisible(raise); for (auto iter = keyboardLayer.begin(); iter != keyboardLayer.end(); iter++) { - auto base3DOverlay = std::dynamic_pointer_cast(overlays.getOverlay(iter.key())); - if (base3DOverlay) { - base3DOverlay->setVisible(raise); - } + DependencyManager::get()->editEntity(iter.key(), properties); } } @@ -465,19 +429,15 @@ bool Keyboard::getPreferMalletsOverLasers() const { } void Keyboard::switchToLayer(int layerIndex) { + auto entityScriptingInterface = DependencyManager::get(); if (layerIndex >= 0 && layerIndex < (int)_keyboardLayers.size()) { - Overlays& overlays = qApp->getOverlays(); + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_POSITION; + desiredProperties += PROP_ROTATION; + auto oldProperties = entityScriptingInterface->getEntityProperties(_anchor.entityID, desiredProperties); - OverlayID currentAnchorOverlayID = _anchor.overlayID; - - glm::vec3 currentOverlayPosition; - glm::quat currentOverlayOrientation; - - auto currentAnchorOverlay = std::dynamic_pointer_cast(overlays.getOverlay(currentAnchorOverlayID)); - if (currentAnchorOverlay) { - currentOverlayPosition = currentAnchorOverlay->getWorldPosition(); - currentOverlayOrientation = currentAnchorOverlay->getWorldOrientation(); - } + glm::vec3 currentPosition = oldProperties.getPosition(); + glm::quat currentOrientation = oldProperties.getRotation(); raiseKeyboardAnchor(false); raiseKeyboard(false); @@ -487,19 +447,17 @@ void Keyboard::switchToLayer(int layerIndex) { raiseKeyboardAnchor(true); raiseKeyboard(true); - OverlayID newAnchorOverlayID = _anchor.overlayID; - auto newAnchorOverlay = std::dynamic_pointer_cast(overlays.getOverlay(newAnchorOverlayID)); - if (newAnchorOverlay) { - newAnchorOverlay->setWorldPosition(currentOverlayPosition); - newAnchorOverlay->setWorldOrientation(currentOverlayOrientation); - } + EntityItemProperties properties; + properties.setPosition(currentPosition); + properties.setRotation(currentOrientation); + entityScriptingInterface->editEntity(_anchor.entityID, properties); startLayerSwitchTimer(); } } -bool Keyboard::shouldProcessOverlayAndPointerEvent(const PointerEvent& event, const OverlayID& overlayID) const { - return (shouldProcessPointerEvent(event) && shouldProcessOverlay(overlayID)); +bool Keyboard::shouldProcessEntityAndPointerEvent(const PointerEvent& event, const QUuid& id) const { + return (shouldProcessPointerEvent(event) && shouldProcessEntity(id)); } bool Keyboard::shouldProcessPointerEvent(const PointerEvent& event) const { @@ -510,14 +468,14 @@ bool Keyboard::shouldProcessPointerEvent(const PointerEvent& event) const { return ((isStylusEvent && preferMalletsOverLasers) || (isLaserEvent && !preferMalletsOverLasers)); } -void Keyboard::handleTriggerBegin(const OverlayID& overlayID, const PointerEvent& event) { +void Keyboard::handleTriggerBegin(const QUuid& id, const PointerEvent& event) { auto buttonType = event.getButton(); - if (!shouldProcessOverlayAndPointerEvent(event, overlayID) || buttonType != PointerEvent::PrimaryButton) { + if (!shouldProcessEntityAndPointerEvent(event, id) || buttonType != PointerEvent::PrimaryButton) { return; } auto& keyboardLayer = _keyboardLayers[_layerIndex]; - auto search = keyboardLayer.find(overlayID); + auto search = keyboardLayer.find(id); if (search == keyboardLayer.end()) { return; @@ -533,13 +491,9 @@ void Keyboard::handleTriggerBegin(const OverlayID& overlayID, const PointerEvent auto userInputMapper = DependencyManager::get(); userInputMapper->triggerHapticPulse(PULSE_STRENGTH, PULSE_DURATION, handIndex); - Overlays& overlays = qApp->getOverlays(); - auto base3DOverlay = std::dynamic_pointer_cast(overlays.getOverlay(overlayID)); - - glm::vec3 keyWorldPosition; - if (base3DOverlay) { - keyWorldPosition = base3DOverlay->getWorldPosition(); - } + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_POSITION; + glm::vec3 keyWorldPosition = DependencyManager::get()->getEntityProperties(id, desiredProperties).getPosition(); AudioInjectorOptions audioOptions; audioOptions.localOnly = true; @@ -601,7 +555,7 @@ void Keyboard::handleTriggerBegin(const OverlayID& overlayID, const PointerEvent key.startTimer(KEY_PRESS_TIMEOUT_MS); } auto selection = DependencyManager::get(); - selection->addToSelectedItemsList(KEY_PRESSED_HIGHLIGHT, "overlay", overlayID); + selection->addToSelectedItemsList(KEY_PRESSED_HIGHLIGHT, "entity", id); } } @@ -617,25 +571,23 @@ void Keyboard::setRightHandLaser(unsigned int rightHandLaser) { }); } -void Keyboard::handleTriggerEnd(const OverlayID& overlayID, const PointerEvent& event) { - if (!shouldProcessOverlayAndPointerEvent(event, overlayID)) { +void Keyboard::handleTriggerEnd(const QUuid& id, const PointerEvent& event) { + if (!shouldProcessEntityAndPointerEvent(event, id)) { return; } auto& keyboardLayer = _keyboardLayers[_layerIndex]; - auto search = keyboardLayer.find(overlayID); + auto search = keyboardLayer.find(id); if (search == keyboardLayer.end()) { return; } - Key& key = search.value();; - Overlays& overlays = qApp->getOverlays(); - auto base3DOverlay = std::dynamic_pointer_cast(overlays.getOverlay(overlayID)); + Key& key = search.value(); - if (base3DOverlay) { - base3DOverlay->setLocalPosition(key.getCurrentLocalPosition()); - } + EntityItemProperties properties; + properties.setLocalPosition(key.getCurrentLocalPosition()); + DependencyManager::get()->editEntity(id, properties); key.setIsPressed(false); if (key.timerFinished() && getPreferMalletsOverLasers()) { @@ -643,78 +595,79 @@ void Keyboard::handleTriggerEnd(const OverlayID& overlayID, const PointerEvent& } auto selection = DependencyManager::get(); - selection->removeFromSelectedItemsList(KEY_PRESSED_HIGHLIGHT, "overlay", overlayID); + selection->removeFromSelectedItemsList(KEY_PRESSED_HIGHLIGHT, "entity", id); } -void Keyboard::handleTriggerContinue(const OverlayID& overlayID, const PointerEvent& event) { - if (!shouldProcessOverlayAndPointerEvent(event, overlayID)) { +void Keyboard::handleTriggerContinue(const QUuid& id, const PointerEvent& event) { + if (!shouldProcessEntityAndPointerEvent(event, id)) { return; } auto& keyboardLayer = _keyboardLayers[_layerIndex]; - auto search = keyboardLayer.find(overlayID); + auto search = keyboardLayer.find(id); if (search == keyboardLayer.end()) { return; } Key& key = search.value(); - Overlays& overlays = qApp->getOverlays(); - if (!key.isPressed() && getPreferMalletsOverLasers()) { - auto base3DOverlay = std::dynamic_pointer_cast(overlays.getOverlay(overlayID)); + unsigned int pointerID = event.getID(); + auto pointerManager = DependencyManager::get(); + auto pickResult = pointerManager->getPrevPickResult(pointerID); + auto stylusPickResult = std::dynamic_pointer_cast(pickResult); + float distance = stylusPickResult->distance; - if (base3DOverlay) { - unsigned int pointerID = event.getID(); - auto pointerManager = DependencyManager::get(); - auto pickResult = pointerManager->getPrevPickResult(pointerID); - auto stylusPickResult = std::dynamic_pointer_cast(pickResult); - float distance = stylusPickResult->distance; + static const float PENATRATION_THRESHOLD = 0.025f; + if (distance < PENATRATION_THRESHOLD) { + static const float Z_OFFSET = 0.002f; - static const float PENATRATION_THRESHOLD = 0.025f; - if (distance < PENATRATION_THRESHOLD) { - static const float Z_OFFSET = 0.002f; - glm::quat overlayOrientation = base3DOverlay->getWorldOrientation(); - glm::vec3 overlayYAxis = overlayOrientation * Z_AXIS; - glm::vec3 overlayYOffset = overlayYAxis * Z_OFFSET; - glm::vec3 localPosition = key.getCurrentLocalPosition() - overlayYOffset; - base3DOverlay->setLocalPosition(localPosition); - key.setIsPressed(true); - } + auto entityScriptingInterface = DependencyManager::get(); + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_ROTATION; + glm::quat orientation = entityScriptingInterface->getEntityProperties(id, desiredProperties).getRotation(); + glm::vec3 yAxis = orientation * Z_AXIS; + glm::vec3 yOffset = yAxis * Z_OFFSET; + glm::vec3 localPosition = key.getCurrentLocalPosition() - yOffset; + + EntityItemProperties properties; + properties.setLocalPosition(localPosition); + entityScriptingInterface->editEntity(id, properties); + key.setIsPressed(true); } } } -void Keyboard::handleHoverBegin(const OverlayID& overlayID, const PointerEvent& event) { - if (!shouldProcessOverlayAndPointerEvent(event, overlayID)) { +void Keyboard::handleHoverBegin(const QUuid& id, const PointerEvent& event) { + if (!shouldProcessEntityAndPointerEvent(event, id)) { return; } auto& keyboardLayer = _keyboardLayers[_layerIndex]; - auto search = keyboardLayer.find(overlayID); + auto search = keyboardLayer.find(id); if (search == keyboardLayer.end()) { return; } auto selection = DependencyManager::get(); - selection->addToSelectedItemsList(KEY_HOVER_HIGHLIGHT, "overlay", overlayID); + selection->addToSelectedItemsList(KEY_HOVER_HIGHLIGHT, "entity", id); } -void Keyboard::handleHoverEnd(const OverlayID& overlayID, const PointerEvent& event) { - if (!shouldProcessOverlayAndPointerEvent(event, overlayID)) { +void Keyboard::handleHoverEnd(const QUuid& id, const PointerEvent& event) { + if (!shouldProcessEntityAndPointerEvent(event, id)) { return; } auto& keyboardLayer = _keyboardLayers[_layerIndex]; - auto search = keyboardLayer.find(overlayID); + auto search = keyboardLayer.find(id); if (search == keyboardLayer.end()) { return; } auto selection = DependencyManager::get(); - selection->removeFromSelectedItemsList(KEY_HOVER_HIGHLIGHT, "overlay", overlayID); + selection->removeFromSelectedItemsList(KEY_HOVER_HIGHLIGHT, "entity", id); } void Keyboard::disableStylus() { @@ -752,7 +705,6 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) { } clearKeyboardKeys(); - Overlays& overlays = qApp->getOverlays(); auto requestData = request->getData(); QVector includeItems; @@ -776,54 +728,58 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) { return; } - QVariantMap anchorProperties { - { "name", "KeyboardAnchor"}, - { "isSolid", true }, - { "visible", false }, - { "grabbable", true }, - { "ignorePickIntersection", false }, - { "dimensions", anchorObject["dimensions"].toVariant() }, - { "position", anchorObject["position"].toVariant() }, - { "orientation", anchorObject["rotation"].toVariant() } - }; + auto entityScriptingInterface = DependencyManager::get(); + { + glm::vec3 dimensions = vec3FromVariant(anchorObject["dimensions"].toVariant()); - glm::vec3 dimensions = vec3FromVariant(anchorObject["dimensions"].toVariant()); + EntityItemProperties properties; + properties.setType(EntityTypes::Box); + properties.setName("KeyboardAnchor"); + properties.setVisible(false); + properties.getGrab().setGrabbable(true); + properties.setIgnorePickIntersection(false); + properties.setDimensions(dimensions); + properties.setPosition(vec3FromVariant(anchorObject["position"].toVariant())); + properties.setRotation(quatFromVariant(anchorObject["rotation"].toVariant())); - Anchor anchor; - anchor.overlayID = overlays.addOverlay("cube", anchorProperties); - anchor.originalDimensions = dimensions; - _anchor = anchor; + Anchor anchor; + anchor.entityID = entityScriptingInterface->addEntity(properties, "local"); + anchor.originalDimensions = dimensions; + _anchor = anchor; + } - QJsonObject backPlateObject = jsonObject["backPlate"].toObject(); + { + QJsonObject backPlateObject = jsonObject["backPlate"].toObject(); + glm::vec3 dimensions = vec3FromVariant(backPlateObject["dimensions"].toVariant()); - QVariantMap backPlateProperties { - { "name", "backPlate"}, - { "isSolid", true }, - { "visible", true }, - { "grabbable", false }, - { "alpha", 0.0 }, - { "ignoreRayIntersection", false}, - { "dimensions", backPlateObject["dimensions"].toVariant() }, - { "position", backPlateObject["position"].toVariant() }, - { "orientation", backPlateObject["rotation"].toVariant() }, - { "parentID", _anchor.overlayID } - }; + EntityItemProperties properties; + properties.setType(EntityTypes::Box); + properties.setName("BackPlate"); + properties.setVisible(true); + properties.getGrab().setGrabbable(false); + properties.setAlpha(0.0f); + properties.setIgnorePickIntersection(false); + properties.setDimensions(dimensions); + properties.setPosition(vec3FromVariant(backPlateObject["position"].toVariant())); + properties.setRotation(quatFromVariant(backPlateObject["rotation"].toVariant())); + properties.setParentID(_anchor.entityID); - BackPlate backPlate; - backPlate.overlayID = overlays.addOverlay("cube", backPlateProperties); - backPlate.dimensions = vec3FromVariant(backPlateObject["dimensions"].toVariant()); - backPlate.localPosition = vec3FromVariant(overlays.getProperty(backPlate.overlayID, "localPosition").value); - _backPlate = backPlate; + BackPlate backPlate; + backPlate.entityID = entityScriptingInterface->addEntity(properties, "local"); + backPlate.dimensions = dimensions; + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_LOCAL_POSITION; + backPlate.localPosition = entityScriptingInterface->getEntityProperties(backPlate.entityID, desiredProperties).getLocalPosition(); + _backPlate = backPlate; + } const QJsonArray& keyboardLayers = jsonObject["layers"].toArray(); int keyboardLayerCount = keyboardLayers.size(); _keyboardLayers.reserve(keyboardLayerCount); - - for (int keyboardLayerIndex = 0; keyboardLayerIndex < keyboardLayerCount; keyboardLayerIndex++) { const QJsonValue& keyboardLayer = keyboardLayers[keyboardLayerIndex].toArray(); - QHash keyboardLayerKeys; + QHash keyboardLayerKeys; foreach (const QJsonValue& keyboardKeyValue, keyboardLayer.toArray()) { QVariantMap textureMap; @@ -841,21 +797,6 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) { QString modelUrl = keyboardKeyValue["modelURL"].toString(); QString url = (useResourcePath ? (resourcePath + modelUrl) : modelUrl); - QVariantMap properties { - { "dimensions", keyboardKeyValue["dimensions"].toVariant() }, - { "position", keyboardKeyValue["position"].toVariant() }, - { "visible", false }, - { "isSolid", true }, - { "emissive", true }, - { "parentID", _anchor.overlayID }, - { "url", url }, - { "textures", textureMap }, - { "grabbable", false }, - { "localOrientation", keyboardKeyValue["localOrientation"].toVariant() } - }; - - OverlayID overlayID = overlays.addOverlay("model", properties); - QString keyType = keyboardKeyValue["type"].toString(); QString keyString = keyboardKeyValue["key"].toString(); @@ -869,48 +810,65 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) { key.setSwitchToLayerIndex(switchToLayer); } } - key.setID(overlayID); + + EntityItemProperties properties; + properties.setType(EntityTypes::Model); + properties.setDimensions(vec3FromVariant(keyboardKeyValue["dimensions"].toVariant())); + properties.setPosition(vec3FromVariant(keyboardKeyValue["position"].toVariant())); + properties.setVisible(false); + properties.setEmissive(true); + properties.setParentID(_anchor.entityID); + properties.setModelURL(url); + properties.setTextures(QVariant(textureMap).toString()); + properties.getGrab().setGrabbable(false); + properties.setLocalRotation(quatFromVariant(keyboardKeyValue["localOrientation"].toVariant())); + QUuid id = entityScriptingInterface->addEntity(properties, "local"); + key.setID(id); key.setKeyString(keyString); key.saveDimensionsAndLocalPosition(); includeItems.append(key.getID()); _itemsToIgnore.append(key.getID()); - keyboardLayerKeys.insert(overlayID, key); + keyboardLayerKeys.insert(id, key); } _keyboardLayers.push_back(keyboardLayerKeys); } - TextDisplay textDisplay; - QJsonObject displayTextObject = jsonObject["textDisplay"].toObject(); + { + QJsonObject displayTextObject = jsonObject["textDisplay"].toObject(); + glm::vec3 dimensions = vec3FromVariant(displayTextObject["dimensions"].toVariant()); + glm::vec3 localPosition = vec3FromVariant(displayTextObject["localPosition"].toVariant()); + float lineHeight = (float)displayTextObject["lineHeight"].toDouble(); - QVariantMap displayTextProperties { - { "dimensions", displayTextObject["dimensions"].toVariant() }, - { "localPosition", displayTextObject["localPosition"].toVariant() }, - { "localOrientation", displayTextObject["localOrientation"].toVariant() }, - { "leftMargin", displayTextObject["leftMargin"].toVariant() }, - { "rightMargin", displayTextObject["rightMargin"].toVariant() }, - { "topMargin", displayTextObject["topMargin"].toVariant() }, - { "bottomMargin", displayTextObject["bottomMargin"].toVariant() }, - { "lineHeight", displayTextObject["lineHeight"].toVariant() }, - { "visible", false }, - { "emissive", true }, - { "grabbable", false }, - { "text", ""}, - { "parentID", _anchor.overlayID } - }; + EntityItemProperties properties; + properties.setType(EntityTypes::Text); + properties.setDimensions(dimensions); + properties.setLocalPosition(localPosition); + properties.setLocalRotation(quatFromVariant(displayTextObject["localOrientation"].toVariant())); + properties.setLeftMargin((float)displayTextObject["leftMargin"].toDouble()); + properties.setRightMargin((float)displayTextObject["rightMargin"].toDouble()); + properties.setTopMargin((float)displayTextObject["topMargin"].toDouble()); + properties.setBottomMargin((float)displayTextObject["bottomMargin"].toDouble()); + properties.setLineHeight((float)displayTextObject["lineHeight"].toDouble()); + properties.setVisible(false); + properties.setEmissive(true); + properties.getGrab().setGrabbable(false); + properties.setText(""); + properties.setParentID(_anchor.entityID); - textDisplay.overlayID = overlays.addOverlay("text3d", displayTextProperties); - textDisplay.localPosition = vec3FromVariant(displayTextObject["localPosition"].toVariant()); - textDisplay.dimensions = vec3FromVariant(displayTextObject["dimensions"].toVariant()); - textDisplay.lineHeight = (float) displayTextObject["lineHeight"].toDouble(); - - _textDisplay = textDisplay; + TextDisplay textDisplay; + textDisplay.entityID = entityScriptingInterface->addEntity(properties, "local"); + textDisplay.localPosition = localPosition; + textDisplay.dimensions = dimensions; + textDisplay.lineHeight = lineHeight; + _textDisplay = textDisplay; + } _ignoreItemsLock.withWriteLock([&] { - _itemsToIgnore.append(_textDisplay.overlayID); - _itemsToIgnore.append(_anchor.overlayID); + _itemsToIgnore.append(_textDisplay.entityID); + _itemsToIgnore.append(_anchor.entityID); }); _layerIndex = 0; auto pointerManager = DependencyManager::get(); @@ -922,34 +880,33 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) { } -OverlayID Keyboard::getAnchorID() { - return _ignoreItemsLock.resultWithReadLock([&] { - return _anchor.overlayID; +QUuid Keyboard::getAnchorID() { + return _ignoreItemsLock.resultWithReadLock([&] { + return _anchor.entityID; }); } -bool Keyboard::shouldProcessOverlay(const OverlayID& overlayID) const { - return (!_keyboardLayers.empty() && isLayerSwitchTimerFinished() && overlayID != _backPlate.overlayID); +bool Keyboard::shouldProcessEntity(const QUuid& id) const { + return (!_keyboardLayers.empty() && isLayerSwitchTimerFinished() && id != _backPlate.entityID); } -QVector Keyboard::getKeysID() { - return _ignoreItemsLock.resultWithReadLock>([&] { +QVector Keyboard::getKeysID() { + return _ignoreItemsLock.resultWithReadLock>([&] { return _itemsToIgnore; }); } void Keyboard::clearKeyboardKeys() { - Overlays& overlays = qApp->getOverlays(); - + auto entityScriptingInterface = DependencyManager::get(); for (const auto& keyboardLayer: _keyboardLayers) { for (auto iter = keyboardLayer.begin(); iter != keyboardLayer.end(); iter++) { - overlays.deleteOverlay(iter.key()); + entityScriptingInterface->deleteEntity(iter.key()); } } - overlays.deleteOverlay(_anchor.overlayID); - overlays.deleteOverlay(_textDisplay.overlayID); - overlays.deleteOverlay(_backPlate.overlayID); + entityScriptingInterface->deleteEntity(_anchor.entityID); + entityScriptingInterface->deleteEntity(_textDisplay.entityID); + entityScriptingInterface->deleteEntity(_backPlate.entityID); _keyboardLayers.clear(); @@ -989,8 +946,8 @@ void Keyboard::disableRightMallet() { pointerManager->disablePointer(_rightHandStylus); } -bool Keyboard::containsID(OverlayID overlayID) const { +bool Keyboard::containsID(const QUuid& id) const { return resultWithReadLock([&] { - return _itemsToIgnore.contains(overlayID) || _backPlate.overlayID == overlayID; + return _itemsToIgnore.contains(id) || _backPlate.entityID == id; }); } diff --git a/interface/src/ui/Keyboard.h b/interface/src/ui/Keyboard.h index bcb6ef1a22..dcb9deac4e 100644 --- a/interface/src/ui/Keyboard.h +++ b/interface/src/ui/Keyboard.h @@ -25,8 +25,6 @@ #include #include -#include "ui/overlays/Overlay.h" - class PointerEvent; @@ -47,8 +45,8 @@ public: static Key::Type getKeyTypeFromString(const QString& keyTypeString); - OverlayID getID() const { return _keyID; } - void setID(OverlayID overlayID) { _keyID = overlayID; } + QUuid getID() const { return _keyID; } + void setID(const QUuid& id) { _keyID = id; } void startTimer(int time); bool timerFinished(); @@ -77,7 +75,7 @@ private: int _switchToLayer { 0 }; bool _pressed { false }; - OverlayID _keyID; + QUuid _keyID; QString _keyString; glm::vec3 _originalLocalPosition; @@ -111,35 +109,35 @@ public: bool getUse3DKeyboard() const; void setUse3DKeyboard(bool use); - bool containsID(OverlayID overlayID) const; + bool containsID(const QUuid& id) const; void loadKeyboardFile(const QString& keyboardFile); - QVector getKeysID(); - OverlayID getAnchorID(); + QVector getKeysID(); + QUuid getAnchorID(); public slots: - void handleTriggerBegin(const OverlayID& overlayID, const PointerEvent& event); - void handleTriggerEnd(const OverlayID& overlayID, const PointerEvent& event); - void handleTriggerContinue(const OverlayID& overlayID, const PointerEvent& event); - void handleHoverBegin(const OverlayID& overlayID, const PointerEvent& event); - void handleHoverEnd(const OverlayID& overlayID, const PointerEvent& event); + void handleTriggerBegin(const QUuid& id, const PointerEvent& event); + void handleTriggerEnd(const QUuid& id, const PointerEvent& event); + void handleTriggerContinue(const QUuid& id, const PointerEvent& event); + void handleHoverBegin(const QUuid& id, const PointerEvent& event); + void handleHoverEnd(const QUuid& id, const PointerEvent& event); void scaleKeyboard(float sensorToWorldScale); private: struct Anchor { - OverlayID overlayID; + QUuid entityID; glm::vec3 originalDimensions; }; struct BackPlate { - OverlayID overlayID; + QUuid entityID; glm::vec3 dimensions; glm::vec3 localPosition; }; struct TextDisplay { float lineHeight; - OverlayID overlayID; + QUuid entityID; glm::vec3 localPosition; glm::vec3 dimensions; }; @@ -153,9 +151,9 @@ private: void clearKeyboardKeys(); void switchToLayer(int layerIndex); void updateTextDisplay(); - bool shouldProcessOverlayAndPointerEvent(const PointerEvent& event, const OverlayID& overlayID) const; + bool shouldProcessEntityAndPointerEvent(const PointerEvent& event, const QUuid& id) const; bool shouldProcessPointerEvent(const PointerEvent& event) const; - bool shouldProcessOverlay(const OverlayID& overlayID) const; + bool shouldProcessEntity(const QUuid& id) const; void startLayerSwitchTimer(); bool isLayerSwitchTimerFinished() const; @@ -184,8 +182,8 @@ private: Anchor _anchor; BackPlate _backPlate; - QVector _itemsToIgnore; - std::vector> _keyboardLayers; + QVector _itemsToIgnore; + std::vector> _keyboardLayers; }; #endif diff --git a/interface/src/ui/LoginDialog.h b/interface/src/ui/LoginDialog.h index 2714d654bf..66773b638b 100644 --- a/interface/src/ui/LoginDialog.h +++ b/interface/src/ui/LoginDialog.h @@ -18,7 +18,7 @@ class QNetworkReply; -extern const QUrl OVERLAY_LOGIN_DIALOG; +extern const QUrl LOGIN_DIALOG; class LoginDialog : public OffscreenQmlDialog { Q_OBJECT diff --git a/interface/src/ui/overlays/ContextOverlayInterface.cpp b/interface/src/ui/overlays/ContextOverlayInterface.cpp index aecfdba3b8..5e6a9b116b 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.cpp +++ b/interface/src/ui/overlays/ContextOverlayInterface.cpp @@ -60,11 +60,12 @@ ContextOverlayInterface::ContextOverlayInterface() { QUuid tabletFrameID = _hmdScriptingInterface->getCurrentTabletFrameID(); auto myAvatar = DependencyManager::get()->getMyAvatar(); glm::quat cameraOrientation = qApp->getCamera().getOrientation(); - QVariantMap props; + + EntityItemProperties properties; float sensorToWorldScale = myAvatar->getSensorToWorldScale(); - props.insert("position", vec3toVariant(myAvatar->getEyePosition() + glm::quat(glm::radians(glm::vec3(0.0f, CONTEXT_OVERLAY_TABLET_OFFSET, 0.0f))) * ((CONTEXT_OVERLAY_TABLET_DISTANCE * sensorToWorldScale) * (cameraOrientation * Vectors::FRONT)))); - props.insert("orientation", quatToVariant(cameraOrientation * glm::quat(glm::radians(glm::vec3(0.0f, CONTEXT_OVERLAY_TABLET_ORIENTATION, 0.0f))))); - qApp->getOverlays().editOverlay(tabletFrameID, props); + properties.setPosition(myAvatar->getEyePosition() + glm::quat(glm::radians(glm::vec3(0.0f, CONTEXT_OVERLAY_TABLET_OFFSET, 0.0f))) * ((CONTEXT_OVERLAY_TABLET_DISTANCE * sensorToWorldScale) * (cameraOrientation * Vectors::FRONT))); + properties.setRotation(cameraOrientation * glm::quat(glm::radians(glm::vec3(0.0f, CONTEXT_OVERLAY_TABLET_ORIENTATION, 0.0f)))); + DependencyManager::get()->editEntity(tabletFrameID, properties); _contextOverlayJustClicked = false; } }); @@ -93,7 +94,6 @@ static const float CONTEXT_OVERLAY_HOVERED_ALPHA = 1.0f; static const float CONTEXT_OVERLAY_UNHOVERED_PULSEMIN = 0.6f; static const float CONTEXT_OVERLAY_UNHOVERED_PULSEMAX = 1.0f; static const float CONTEXT_OVERLAY_UNHOVERED_PULSEPERIOD = 1.0f; -static const float CONTEXT_OVERLAY_UNHOVERED_COLORPULSE = 1.0f; void ContextOverlayInterface::setEnabled(bool enabled) { _enabled = enabled; @@ -192,22 +192,28 @@ bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID& } // Finally, setup and draw the Context Overlay - if (_contextOverlayID == UNKNOWN_OVERLAY_ID || !qApp->getOverlays().isAddedOverlay(_contextOverlayID)) { - _contextOverlay = std::make_shared(); - _contextOverlay->setAlpha(CONTEXT_OVERLAY_UNHOVERED_ALPHA); - _contextOverlay->setPulseMin(CONTEXT_OVERLAY_UNHOVERED_PULSEMIN); - _contextOverlay->setPulseMax(CONTEXT_OVERLAY_UNHOVERED_PULSEMAX); - _contextOverlay->setColorPulse(CONTEXT_OVERLAY_UNHOVERED_COLORPULSE); - _contextOverlay->setIgnorePickIntersection(false); - _contextOverlay->setDrawInFront(true); - _contextOverlay->setURL(PathUtils::resourcesUrl() + "images/inspect-icon.png"); - _contextOverlay->setIsFacingAvatar(true); - _contextOverlayID = qApp->getOverlays().addOverlay(_contextOverlay); + auto entityScriptingInterface = DependencyManager::get(); + if (_contextOverlayID == UNKNOWN_ENTITY_ID || !entityScriptingInterface->isAddedEntity(_contextOverlayID)) { + EntityItemProperties properties; + properties.setType(EntityTypes::Image); + properties.setAlpha(CONTEXT_OVERLAY_UNHOVERED_ALPHA); + properties.getPulse().setMin(CONTEXT_OVERLAY_UNHOVERED_PULSEMIN); + properties.getPulse().setMax(CONTEXT_OVERLAY_UNHOVERED_PULSEMAX); + properties.getPulse().setColorMode(PulseMode::IN_PHASE); + properties.setIgnorePickIntersection(false); + properties.setRenderLayer(RenderLayer::FRONT); + properties.setImageURL(PathUtils::resourcesUrl() + "images/inspect-icon.png"); + properties.setBillboardMode(BillboardMode::FULL); + + _contextOverlayID = entityScriptingInterface->addEntity(properties, "local"); } - _contextOverlay->setWorldPosition(contextOverlayPosition); - _contextOverlay->setDimensions(contextOverlayDimensions); - _contextOverlay->setWorldOrientation(entityProperties.getRotation()); - _contextOverlay->setVisible(true); + + EntityItemProperties properties; + properties.setPosition(contextOverlayPosition); + properties.setDimensions(glm::vec3(contextOverlayDimensions, 0.01f)); + properties.setRotation(entityProperties.getRotation()); + properties.setVisible(true); + entityScriptingInterface->editEntity(_contextOverlayID, properties); return true; } @@ -227,15 +233,13 @@ bool ContextOverlayInterface::contextOverlayFilterPassed(const EntityItemID& ent } bool ContextOverlayInterface::destroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event) { - if (_contextOverlayID != UNKNOWN_OVERLAY_ID) { + if (_contextOverlayID != UNKNOWN_ENTITY_ID) { qCDebug(context_overlay) << "Destroying Context Overlay on top of entity with ID: " << entityItemID; disableEntityHighlight(entityItemID); setCurrentEntityWithContextOverlay(QUuid()); _entityMarketplaceID.clear(); - // Destroy the Context Overlay - qApp->getOverlays().deleteOverlay(_contextOverlayID); - _contextOverlay = NULL; - _contextOverlayID = UNKNOWN_OVERLAY_ID; + DependencyManager::get()->deleteEntity(_contextOverlayID); + _contextOverlayID = UNKNOWN_ENTITY_ID; return true; } return false; @@ -254,22 +258,26 @@ void ContextOverlayInterface::contextOverlays_mousePressOnOverlay(const OverlayI } void ContextOverlayInterface::contextOverlays_hoverEnterOverlay(const OverlayID& overlayID, const PointerEvent& event) { - if (_contextOverlayID != UNKNOWN_OVERLAY_ID && _contextOverlay) { + if (_contextOverlayID != UNKNOWN_ENTITY_ID) { qCDebug(context_overlay) << "Started hovering over Context Overlay. Overlay ID:" << overlayID; - _contextOverlay->setColor(CONTEXT_OVERLAY_COLOR); - _contextOverlay->setColorPulse(0.0f); // pulse off - _contextOverlay->setPulsePeriod(0.0f); // pulse off - _contextOverlay->setAlpha(CONTEXT_OVERLAY_HOVERED_ALPHA); + EntityItemProperties properties; + properties.setColor(CONTEXT_OVERLAY_COLOR); + properties.getPulse().setColorMode(PulseMode::NONE); + properties.getPulse().setPeriod(0.0f); + properties.setAlpha(CONTEXT_OVERLAY_HOVERED_ALPHA); + DependencyManager::get()->editEntity(_contextOverlayID, properties); } } void ContextOverlayInterface::contextOverlays_hoverLeaveOverlay(const OverlayID& overlayID, const PointerEvent& event) { - if (_contextOverlayID != UNKNOWN_OVERLAY_ID && _contextOverlay) { + if (_contextOverlayID != UNKNOWN_ENTITY_ID) { qCDebug(context_overlay) << "Stopped hovering over Context Overlay. Overlay ID:" << overlayID; - _contextOverlay->setColor(CONTEXT_OVERLAY_COLOR); - _contextOverlay->setColorPulse(CONTEXT_OVERLAY_UNHOVERED_COLORPULSE); - _contextOverlay->setPulsePeriod(CONTEXT_OVERLAY_UNHOVERED_PULSEPERIOD); - _contextOverlay->setAlpha(CONTEXT_OVERLAY_UNHOVERED_ALPHA); + EntityItemProperties properties; + properties.setColor(CONTEXT_OVERLAY_COLOR); + properties.getPulse().setColorMode(PulseMode::IN_PHASE); + properties.getPulse().setPeriod(CONTEXT_OVERLAY_UNHOVERED_PULSEPERIOD); + properties.setAlpha(CONTEXT_OVERLAY_UNHOVERED_ALPHA); + DependencyManager::get()->editEntity(_contextOverlayID, properties); } } diff --git a/interface/src/ui/overlays/ContextOverlayInterface.h b/interface/src/ui/overlays/ContextOverlayInterface.h index 48b14e1a91..2c6607a664 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.h +++ b/interface/src/ui/overlays/ContextOverlayInterface.h @@ -22,8 +22,6 @@ #include "avatar/AvatarManager.h" #include "EntityScriptingInterface.h" -#include "ui/overlays/Image3DOverlay.h" -#include "ui/overlays/Overlays.h" #include "scripting/HMDScriptingInterface.h" #include "scripting/SelectionScriptingInterface.h" #include "scripting/WalletScriptingInterface.h" @@ -43,8 +41,7 @@ class ContextOverlayInterface : public QObject, public Dependency { QSharedPointer _hmdScriptingInterface; QSharedPointer _tabletScriptingInterface; QSharedPointer _selectionScriptingInterface; - OverlayID _contextOverlayID { UNKNOWN_OVERLAY_ID }; - std::shared_ptr _contextOverlay { nullptr }; + QUuid _contextOverlayID { UNKNOWN_ENTITY_ID }; public: ContextOverlayInterface(); Q_INVOKABLE QUuid getCurrentEntityWithContextOverlay() { return _currentEntityWithContextOverlay; } @@ -83,12 +80,12 @@ private: enum { MAX_SELECTION_COUNT = 16 }; - bool _verboseLogging{ true }; + bool _verboseLogging { true }; bool _enabled { true }; - EntityItemID _mouseDownEntity{}; + EntityItemID _mouseDownEntity; quint64 _mouseDownEntityTimestamp; - EntityItemID _currentEntityWithContextOverlay{}; - EntityItemID _lastInspectedEntity{}; + EntityItemID _currentEntityWithContextOverlay; + EntityItemID _lastInspectedEntity; QString _entityMarketplaceID; bool _contextOverlayJustClicked { false }; diff --git a/interface/src/ui/overlays/Overlay.cpp b/interface/src/ui/overlays/Overlay.cpp index 1bf94adfa0..cf55c87114 100644 --- a/interface/src/ui/overlays/Overlay.cpp +++ b/interface/src/ui/overlays/Overlay.cpp @@ -215,37 +215,6 @@ void Overlay::removeFromScene(Overlay::Pointer overlay, const render::ScenePoint render::Item::clearID(_renderItemID); } -QScriptValue OverlayIDtoScriptValue(QScriptEngine* engine, const OverlayID& id) { - return quuidToScriptValue(engine, id); -} - -void OverlayIDfromScriptValue(const QScriptValue &object, OverlayID& id) { - quuidFromScriptValue(object, id); -} - -QVector qVectorOverlayIDFromScriptValue(const QScriptValue& array) { - if (!array.isArray()) { - return QVector(); - } - QVector newVector; - int length = array.property("length").toInteger(); - newVector.reserve(length); - for (int i = 0; i < length; i++) { - newVector << OverlayID(array.property(i).toString()); - } - return newVector; -} - -void Overlay::addMaterial(graphics::MaterialLayer material, const std::string& parentMaterialName) { - std::lock_guard lock(_materialsLock); - _materials[parentMaterialName].push(material); -} - -void Overlay::removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) { - std::lock_guard lock(_materialsLock); - _materials[parentMaterialName].remove(material); -} - render::ItemKey Overlay::getKey() { auto builder = render::ItemKey::Builder().withTypeShape().withTypeMeta(); diff --git a/interface/src/ui/overlays/Overlay.h b/interface/src/ui/overlays/Overlay.h index 8e430f7e85..068e1b7641 100644 --- a/interface/src/ui/overlays/Overlay.h +++ b/interface/src/ui/overlays/Overlay.h @@ -13,13 +13,6 @@ #include -class OverlayID : public QUuid { -public: - OverlayID() : QUuid() {} - OverlayID(QString v) : QUuid(v) {} - OverlayID(QUuid v) : QUuid(v) {} -}; - class Overlay : public QObject { Q_OBJECT @@ -32,8 +25,8 @@ public: Overlay(const Overlay* overlay); ~Overlay(); - virtual OverlayID getOverlayID() const { return _overlayID; } - virtual void setOverlayID(OverlayID overlayID) { _overlayID = overlayID; } + virtual QUuid getID() const { return _id; } + virtual void setID(const QUuid& id) { _id = id; } virtual void update(float deltatime) {} virtual void render(RenderArgs* args) = 0; @@ -51,7 +44,6 @@ public: // getters virtual QString getType() const = 0; - virtual bool is3D() const = 0; bool isLoaded() { return _isLoaded; } bool getVisible() const { return _visible; } virtual bool isTransparent() { return getAlphaPulse() != 0.0f || getAlpha() != 1.0f; }; @@ -92,9 +84,6 @@ public: unsigned int getStackOrder() const { return _stackOrder; } void setStackOrder(unsigned int stackOrder) { _stackOrder = stackOrder; } - virtual void addMaterial(graphics::MaterialLayer material, const std::string& parentMaterialName); - virtual void removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName); - protected: float updatePulse(); @@ -121,11 +110,8 @@ protected: static const glm::u8vec3 DEFAULT_OVERLAY_COLOR; static const float DEFAULT_ALPHA; - std::unordered_map _materials; - std::mutex _materialsLock; - private: - OverlayID _overlayID; // only used for non-3d overlays + QUuid _id; }; namespace render { @@ -136,10 +122,4 @@ namespace render { template <> uint32_t metaFetchMetaSubItems(const Overlay::Pointer& overlay, ItemIDs& subItems); } -Q_DECLARE_METATYPE(OverlayID); -Q_DECLARE_METATYPE(QVector); -QScriptValue OverlayIDtoScriptValue(QScriptEngine* engine, const OverlayID& id); -void OverlayIDfromScriptValue(const QScriptValue& object, OverlayID& id); -QVector qVectorOverlayIDFromScriptValue(const QScriptValue& array); - #endif // hifi_Overlay_h diff --git a/interface/src/ui/overlays/OverlayTransformNode.cpp b/interface/src/ui/overlays/OverlayTransformNode.cpp deleted file mode 100644 index 817b6af305..0000000000 --- a/interface/src/ui/overlays/OverlayTransformNode.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// -// Created by Sabrina Shanman 9/5/2018 -// Copyright 2018 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 "OverlayTransformNode.h" - -template<> -glm::vec3 BaseNestableTransformNode::getActualScale(const std::shared_ptr& nestablePointer) const { - return nestablePointer->getBounds().getScale(); -} \ No newline at end of file diff --git a/interface/src/ui/overlays/OverlayTransformNode.h b/interface/src/ui/overlays/OverlayTransformNode.h deleted file mode 100644 index 11c3415828..0000000000 --- a/interface/src/ui/overlays/OverlayTransformNode.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// Created by Sabrina Shanman 9/5/2018 -// Copyright 2018 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_OverlayTransformNode_h -#define hifi_OverlayTransformNode_h - -#include "NestableTransformNode.h" - -#include "Base3DOverlay.h" - -// For 3D overlays only -class OverlayTransformNode : public BaseNestableTransformNode { -public: - OverlayTransformNode(std::weak_ptr spatiallyNestable, int jointIndex) : BaseNestableTransformNode(spatiallyNestable, jointIndex) {}; -}; - -#endif // hifi_OverlayTransformNode_h \ No newline at end of file diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index d39c847457..2a8812f69e 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -37,7 +37,7 @@ class PickRay; * @typedef {object} Overlays.RayToOverlayIntersectionResult * @property {boolean} intersects - true if the {@link PickRay} intersected with a 3D overlay, otherwise * false. - * @property {Uuid} overlayID - The UUID of the overlay that was intersected. + * @property {Uuid} overlayID - The UUID of the local entity that was intersected. * @property {number} distance - The distance from the {@link PickRay} origin to the intersection point. * @property {Vec3} surfaceNormal - The normal of the overlay surface at the intersection point. * @property {Vec3} intersection - The position of the intersection point. @@ -46,7 +46,7 @@ class PickRay; class RayToOverlayIntersectionResult { public: bool intersects { false }; - QUuid overlayID { UNKNOWN_OVERLAY_ID }; + QUuid overlayID; float distance { 0.0f }; BoxFace face { UNKNOWN_FACE }; glm::vec3 surfaceNormal; @@ -60,7 +60,7 @@ void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& object, R class ParabolaToOverlayIntersectionResult { public: bool intersects { false }; - QUuid overlayID { UNKNOWN_OVERLAY_ID }; + QUuid overlayID; float distance { 0.0f }; float parabolicDistance { 0.0f }; BoxFace face { UNKNOWN_FACE }; @@ -715,8 +715,8 @@ private: PointerEvent calculateOverlayPointerEvent(const QUuid& id, const PickRay& ray, const RayToOverlayIntersectionResult& rayPickResult, QMouseEvent* event, PointerEvent::EventType eventType); - QUuid _currentClickingOnOverlayID { UNKNOWN_OVERLAY_ID }; - QUuid _currentHoverOverOverlayID { UNKNOWN_OVERLAY_ID }; + QUuid _currentClickingOnOverlayID; + QUuid _currentHoverOverOverlayID; private slots: void mousePressPointerEvent(const QUuid& id, const PointerEvent& event); diff --git a/interface/src/ui/overlays/OverlaysPayload.cpp b/interface/src/ui/overlays/OverlaysPayload.cpp index 37fadef0b4..0d1bcdd071 100644 --- a/interface/src/ui/overlays/OverlaysPayload.cpp +++ b/interface/src/ui/overlays/OverlaysPayload.cpp @@ -8,27 +8,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include -#include - -#include -#include -#include -#include - -#include "Image3DOverlay.h" -#include "Circle3DOverlay.h" -#include "Cube3DOverlay.h" -#include "ImageOverlay.h" -#include "Line3DOverlay.h" -#include "ModelOverlay.h" -#include "Overlays.h" -#include "Rectangle3DOverlay.h" -#include "Sphere3DOverlay.h" -#include "Grid3DOverlay.h" -#include "TextOverlay.h" -#include "Text3DOverlay.h" - +#include "Overlay.h" namespace render { template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay) { diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 17fed5ff54..20af206162 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -1038,6 +1038,15 @@ bool EntityScriptingInterface::isLoaded(const QUuid& id) { return toReturn; } +bool EntityScriptingInterface::isAddedEntity(const QUuid& id) { + bool toReturn = false; + _entityTree->withReadLock([&] { + EntityItemPointer entity = _entityTree->findEntityByEntityItemID(id); + toReturn = (bool)entity; + }); + return toReturn; +} + QSizeF EntityScriptingInterface::textSize(const QUuid& id, const QString& text) { return EntityTree::textSize(id, text); } diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index 7b6a191e1e..0cdc71c8ff 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -1306,11 +1306,11 @@ public slots: /**jsdoc - * Get the IDs of entities, overlays, and avatars that are directly parented to an entity, overlay, or avatar model. Recurse on the IDs returned by the function to get all descendants of an entity, overlay, or avatar. + * Get the IDs of entities and avatars that are directly parented to an entity or avatar model. Recurse on the IDs returned by the function to get all descendants of an entity or avatar. * @function Entities.getChildrenIDs - * @param {Uuid} parentID - The ID of the entity, overlay, or avatar to get the children IDs of. - * @returns {Uuid[]} An array of entity, overlay, and avatar IDs that are parented directly to the parentID - * entity, overlay, or avatar. Does not include children's children, etc. The array is empty if no children can be found or + * @param {Uuid} parentID - The ID of the entity or avatar to get the children IDs of. + * @returns {Uuid[]} An array of entity and avatar IDs that are parented directly to the parentID + * entity or avatar. Does not include children's children, etc. The array is empty if no children can be found or * parentID cannot be found. * @example Report the children of an entity. * function createEntity(description, position, parent) { @@ -1336,12 +1336,12 @@ public slots: Q_INVOKABLE QVector getChildrenIDs(const QUuid& parentID); /**jsdoc - * Get the IDs of entities, overlays, and avatars that are directly parented to an entity, overlay, or avatar model's joint. + * Get the IDs of entities and avatars that are directly parented to an entity or avatar model's joint. * @function Entities.getChildrenIDsOfJoint - * @param {Uuid} parentID - The ID of the entity, overlay, or avatar to get the children IDs of. + * @param {Uuid} parentID - The ID of the entity or avatar to get the children IDs of. * @param {number} jointIndex - Integer number of the model joint to get the children IDs of. - * @returns {Uuid[]} An array of entity, overlay, and avatar IDs that are parented directly to the parentID - * entity, overlay, or avatar at the jointIndex joint. Does not include children's children, etc. The + * @returns {Uuid[]} An array of entity and avatar IDs that are parented directly to the parentID + * entity or avatar at the jointIndex joint. Does not include children's children, etc. The * array is empty if no children can be found or parentID cannot be found. * @example Report the children of your avatar's right hand. * function createEntity(description, position, parent) { @@ -1371,11 +1371,11 @@ public slots: Q_INVOKABLE QVector getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex); /**jsdoc - * Check whether an entity or overlay has an entity as an ancestor (parent, parent's parent, etc.). + * Check whether an entity has an entity as an ancestor (parent, parent's parent, etc.). * @function Entities.isChildOfParent - * @param {Uuid} childID - The ID of the child entity or overlay to test for being a child, grandchild, etc. + * @param {Uuid} childID - The ID of the child entity to test for being a child, grandchild, etc. * @param {Uuid} parentID - The ID of the parent entity to test for being a parent, grandparent, etc. - * @returns {boolean} true if the childID entity or overlay has the parentID entity + * @returns {boolean} true if the childID entity has the parentID entity * as a parent or grandparent etc., otherwise false. * @example Check that a grandchild entity is a child of its grandparent. * function createEntity(description, position, parent) { @@ -1400,12 +1400,11 @@ public slots: Q_INVOKABLE bool isChildOfParent(const QUuid& childID, const QUuid& parentID); /**jsdoc - * Get the type — entity, overlay, or avatar — of an in-world item. + * Get the type — entity or avatar — of an in-world item. * @function Entities.getNestableType * @param {Uuid} entityID - The ID of the item to get the type of. - * @returns {string} The type of the item: "entity" if the item is an entity, "overlay" if the - * the item is an overlay, "avatar" if the item is an avatar; otherwise "unknown" if the item - * cannot be found. + * @returns {string} The type of the item: "entity" if the item is an entity, "avatar" + * if the item is an avatar; otherwise "unknown" if the item cannot be found. * @example Print some nestable types. * var entity = Entities.addEntity({ * type: "Sphere", diff --git a/libraries/entities/src/GrabPropertyGroup.h b/libraries/entities/src/GrabPropertyGroup.h index 33550fef3d..d76ac46a81 100644 --- a/libraries/entities/src/GrabPropertyGroup.h +++ b/libraries/entities/src/GrabPropertyGroup.h @@ -64,9 +64,9 @@ static const glm::vec3 INITIAL_EQUIPPABLE_INDICATOR_OFFSET { glm::vec3(0.0f) }; * @property {string} equippableIndicatorURL="" - If non-empty, this model will be used to indicate that an * entity is equippable, rather than the default. * @property {Vec3} equippableIndicatorScale=1,1,1 - If equippableIndicatorURL is non-empty, this controls the - scale of the displayed overlay. + scale of the displayed indicator. * @property {Vec3} equippableIndicatorOffset=0,0,0 - If equippableIndicatorURL is non-empty, this controls the - relative offset of the displayed overlay from the equippable entity. + relative offset of the displayed object from the equippable entity. */ diff --git a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp index 67f79db6b7..aa8e954e0a 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp +++ b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp @@ -36,12 +36,12 @@ void GraphicsScriptingInterface::jsThrowError(const QString& error) { } } -bool GraphicsScriptingInterface::canUpdateModel(QUuid uuid, int meshIndex, int partNumber) { +bool GraphicsScriptingInterface::canUpdateModel(const QUuid& uuid, int meshIndex, int partNumber) { auto provider = getModelProvider(uuid); return provider && provider->canReplaceModelMeshPart(meshIndex, partNumber); } -bool GraphicsScriptingInterface::updateModel(QUuid uuid, const scriptable::ScriptableModelPointer& model) { +bool GraphicsScriptingInterface::updateModel(const QUuid& uuid, const scriptable::ScriptableModelPointer& model) { if (!model) { jsThrowError("null model argument"); } @@ -69,7 +69,7 @@ bool GraphicsScriptingInterface::updateModel(QUuid uuid, const scriptable::Scrip return provider->replaceScriptableModelMeshPart(base, -1, -1); } -scriptable::ModelProviderPointer GraphicsScriptingInterface::getModelProvider(QUuid uuid) { +scriptable::ModelProviderPointer GraphicsScriptingInterface::getModelProvider(const QUuid& uuid) { QString error; if (auto appProvider = DependencyManager::get()) { if (auto provider = appProvider->lookupModelProvider(uuid)) { @@ -107,7 +107,7 @@ scriptable::ScriptableModelPointer GraphicsScriptingInterface::newModel(const sc return modelWrapper; } -scriptable::ScriptableModelPointer GraphicsScriptingInterface::getModel(QUuid uuid) { +scriptable::ScriptableModelPointer GraphicsScriptingInterface::getModel(const QUuid& uuid) { QString error; bool success; QString providerType = "unknown"; diff --git a/libraries/pointers/src/Pick.h b/libraries/pointers/src/Pick.h index 2db8aa95f5..ecb6188a9a 100644 --- a/libraries/pointers/src/Pick.h +++ b/libraries/pointers/src/Pick.h @@ -23,6 +23,7 @@ enum IntersectionType { NONE = 0, ENTITY, + LOCAL_ENTITY, AVATAR, HUD }; @@ -175,7 +176,6 @@ public: virtual T getMathematicalPick() const = 0; virtual PickResultPointer getDefaultResult(const QVariantMap& pickVariant) const = 0; virtual PickResultPointer getEntityIntersection(const T& pick) = 0; - virtual PickResultPointer getOverlayIntersection(const T& pick) = 0; virtual PickResultPointer getAvatarIntersection(const T& pick) = 0; virtual PickResultPointer getHUDIntersection(const T& pick) = 0; diff --git a/libraries/pointers/src/PickCacheOptimizer.h b/libraries/pointers/src/PickCacheOptimizer.h index e91283f02c..0bbdfea8e4 100644 --- a/libraries/pointers/src/PickCacheOptimizer.h +++ b/libraries/pointers/src/PickCacheOptimizer.h @@ -37,7 +37,7 @@ template class PickCacheOptimizer { public: - QVector4D update(std::unordered_map>& picks, uint32_t& nextToUpdate, uint64_t expiry, bool shouldPickHUD); + QVector3D update(std::unordered_map>& picks, uint32_t& nextToUpdate, uint64_t expiry, bool shouldPickHUD); protected: typedef std::unordered_map> PickCache; @@ -67,9 +67,9 @@ void PickCacheOptimizer::cacheResult(const bool needToCompareResults, const P } template -QVector4D PickCacheOptimizer::update(std::unordered_map>& picks, +QVector3D PickCacheOptimizer::update(std::unordered_map>& picks, uint32_t& nextToUpdate, uint64_t expiry, bool shouldPickHUD) { - QVector4D numIntersectionsComputed; + QVector3D numIntersectionsComputed; PickCache results; const uint32_t INVALID_PICK_ID = 0; auto itr = picks.begin(); @@ -88,7 +88,7 @@ QVector4D PickCacheOptimizer::update(std::unordered_mapisEnabled() || pick->getMaxDistance() < 0.0f || !mathematicalPick) { pick->setPickResult(res); } else { - if (pick->getFilter().doesPickDomainEntities() || pick->getFilter().doesPickAvatarEntities()) { + if (pick->getFilter().doesPickDomainEntities() || pick->getFilter().doesPickAvatarEntities() || pick->getFilter().doesPickLocalEntities()) { PickCacheKey entityKey = { pick->getFilter().getEntityFlags(), pick->getIncludeItems(), pick->getIgnoreItems() }; if (!checkAndCompareCachedResults(mathematicalPick, results, res, entityKey)) { PickResultPointer entityRes = pick->getEntityIntersection(mathematicalPick); @@ -99,22 +99,11 @@ QVector4D PickCacheOptimizer::update(std::unordered_mapgetFilter().doesPickLocalEntities()) { - PickCacheKey overlayKey = { pick->getFilter().getOverlayFlags(), pick->getIncludeItems(), pick->getIgnoreItems() }; - if (!checkAndCompareCachedResults(mathematicalPick, results, res, overlayKey)) { - PickResultPointer overlayRes = pick->getOverlayIntersection(mathematicalPick); - numIntersectionsComputed[1]++; - if (overlayRes) { - cacheResult(overlayRes->doesIntersect(), overlayRes, overlayKey, res, mathematicalPick, results, pick); - } - } - } - if (pick->getFilter().doesPickAvatars()) { PickCacheKey avatarKey = { pick->getFilter().getAvatarFlags(), pick->getIncludeItems(), pick->getIgnoreItems() }; if (!checkAndCompareCachedResults(mathematicalPick, results, res, avatarKey)) { PickResultPointer avatarRes = pick->getAvatarIntersection(mathematicalPick); - numIntersectionsComputed[2]++; + numIntersectionsComputed[1]++; if (avatarRes) { cacheResult(avatarRes->doesIntersect(), avatarRes, avatarKey, res, mathematicalPick, results, pick); } @@ -126,7 +115,7 @@ QVector4D PickCacheOptimizer::update(std::unordered_mapgetFilter().getHUDFlags(), QVector(), QVector() }; if (!checkAndCompareCachedResults(mathematicalPick, results, res, hudKey)) { PickResultPointer hudRes = pick->getHUDIntersection(mathematicalPick); - numIntersectionsComputed[3]++; + numIntersectionsComputed[2]++; if (hudRes) { cacheResult(true, hudRes, hudKey, res, mathematicalPick, results, pick); } diff --git a/libraries/pointers/src/Pointer.cpp b/libraries/pointers/src/Pointer.cpp index 26460cbdd7..c08a3c2be6 100644 --- a/libraries/pointers/src/Pointer.cpp +++ b/libraries/pointers/src/Pointer.cpp @@ -109,14 +109,14 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin if (_enabled && _hover && doHover && !_prevDoHover) { if (hoveredObject.type == ENTITY) { emit pointerManager->hoverBeginEntity(hoveredObject.objectID, hoveredEvent); - } else if (hoveredObject.type == OVERLAY) { + } else if (hoveredObject.type == LOCAL_ENTITY) { emit pointerManager->hoverBeginOverlay(hoveredObject.objectID, hoveredEvent); } else if (hoveredObject.type == HUD) { emit pointerManager->hoverBeginHUD(hoveredEvent); } } else if (_enabled && _hover && doHover) { - if (hoveredObject.type == OVERLAY) { - if (_prevHoveredObject.type == OVERLAY) { + if (hoveredObject.type == LOCAL_ENTITY) { + if (_prevHoveredObject.type == LOCAL_ENTITY) { if (hoveredObject.objectID == _prevHoveredObject.objectID) { emit pointerManager->hoverContinueOverlay(hoveredObject.objectID, hoveredEvent); } else { @@ -150,7 +150,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin } } else { emit pointerManager->hoverBeginEntity(hoveredObject.objectID, hoveredEvent); - if (_prevHoveredObject.type == OVERLAY) { + if (_prevHoveredObject.type == LOCAL_ENTITY) { emit pointerManager->hoverEndOverlay(_prevHoveredObject.objectID, hoveredEvent); } else if (_prevHoveredObject.type == HUD) { emit pointerManager->hoverEndHUD(hoveredEvent); @@ -166,7 +166,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin emit pointerManager->hoverBeginHUD(hoveredEvent); if (_prevHoveredObject.type == ENTITY) { emit pointerManager->hoverEndEntity(_prevHoveredObject.objectID, hoveredEvent); - } else if (_prevHoveredObject.type == OVERLAY) { + } else if (_prevHoveredObject.type == LOCAL_ENTITY) { emit pointerManager->hoverEndOverlay(_prevHoveredObject.objectID, hoveredEvent); } } @@ -175,7 +175,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin if (hoveredObject.type == NONE) { if (_prevHoveredObject.type == ENTITY) { emit pointerManager->hoverEndEntity(_prevHoveredObject.objectID, hoveredEvent); - } else if (_prevHoveredObject.type == OVERLAY) { + } else if (_prevHoveredObject.type == LOCAL_ENTITY) { emit pointerManager->hoverEndOverlay(_prevHoveredObject.objectID, hoveredEvent); } else if (_prevHoveredObject.type == HUD) { emit pointerManager->hoverEndHUD(hoveredEvent); @@ -191,7 +191,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin hoveredEvent.setShouldFocus(button == SHOULD_FOCUS_BUTTON); if (hoveredObject.type == ENTITY) { emit pointerManager->triggerBeginEntity(hoveredObject.objectID, hoveredEvent); - } else if (hoveredObject.type == OVERLAY) { + } else if (hoveredObject.type == LOCAL_ENTITY) { emit pointerManager->triggerBeginOverlay(hoveredObject.objectID, hoveredEvent); } else if (hoveredObject.type == HUD) { emit pointerManager->triggerBeginHUD(hoveredEvent); @@ -207,7 +207,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin triggeredEvent.setButton(chooseButton(button)); if (_triggeredObjects[button].type == ENTITY) { emit pointerManager->triggerContinueEntity(_triggeredObjects[button].objectID, triggeredEvent); - } else if (_triggeredObjects[button].type == OVERLAY) { + } else if (_triggeredObjects[button].type == LOCAL_ENTITY) { emit pointerManager->triggerContinueOverlay(_triggeredObjects[button].objectID, triggeredEvent); } else if (_triggeredObjects[button].type == HUD) { emit pointerManager->triggerContinueHUD(triggeredEvent); @@ -222,7 +222,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin triggeredEvent.setButton(chooseButton(button)); if (_triggeredObjects[button].type == ENTITY) { emit pointerManager->triggerEndEntity(_triggeredObjects[button].objectID, triggeredEvent); - } else if (_triggeredObjects[button].type == OVERLAY) { + } else if (_triggeredObjects[button].type == LOCAL_ENTITY) { emit pointerManager->triggerEndOverlay(_triggeredObjects[button].objectID, triggeredEvent); } else if (_triggeredObjects[button].type == HUD) { emit pointerManager->triggerEndHUD(triggeredEvent); @@ -234,7 +234,7 @@ void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPoin if (_hover && ((!_enabled && _prevEnabled) || (!doHover && _prevDoHover))) { if (_prevHoveredObject.type == ENTITY) { emit pointerManager->hoverEndEntity(_prevHoveredObject.objectID, hoveredEvent); - } else if (_prevHoveredObject.type == OVERLAY) { + } else if (_prevHoveredObject.type == LOCAL_ENTITY) { emit pointerManager->hoverEndOverlay(_prevHoveredObject.objectID, hoveredEvent); } else if (_prevHoveredObject.type == HUD) { emit pointerManager->hoverEndHUD(hoveredEvent); diff --git a/libraries/pointers/src/Pointer.h b/libraries/pointers/src/Pointer.h index 173163374f..28d7e42e8f 100644 --- a/libraries/pointers/src/Pointer.h +++ b/libraries/pointers/src/Pointer.h @@ -62,7 +62,7 @@ public: // Pointers can choose to implement these virtual void setLength(float length) {} - virtual void setLockEndUUID(const QUuid& objectID, bool isOverlay, const glm::mat4& offsetMat = glm::mat4()) {} + virtual void setLockEndUUID(const QUuid& objectID, bool isAvatar, const glm::mat4& offsetMat = glm::mat4()) {} void update(unsigned int pointerID); virtual void updateVisuals(const PickResultPointer& pickResult) = 0; diff --git a/libraries/pointers/src/PointerManager.cpp b/libraries/pointers/src/PointerManager.cpp index 72e4b417cd..ca8dfb3f26 100644 --- a/libraries/pointers/src/PointerManager.cpp +++ b/libraries/pointers/src/PointerManager.cpp @@ -124,10 +124,10 @@ void PointerManager::setLength(unsigned int uid, float length) const { } } -void PointerManager::setLockEndUUID(unsigned int uid, const QUuid& objectID, bool isOverlay, const glm::mat4& offsetMat) const { +void PointerManager::setLockEndUUID(unsigned int uid, const QUuid& objectID, bool isAvatar, const glm::mat4& offsetMat) const { auto pointer = find(uid); if (pointer) { - pointer->setLockEndUUID(objectID, isOverlay, offsetMat); + pointer->setLockEndUUID(objectID, isAvatar, offsetMat); } } diff --git a/libraries/pointers/src/PointerManager.h b/libraries/pointers/src/PointerManager.h index 2d0b2a107e..6c1581b09b 100644 --- a/libraries/pointers/src/PointerManager.h +++ b/libraries/pointers/src/PointerManager.h @@ -37,7 +37,7 @@ public: void setIncludeItems(unsigned int uid, const QVector& includeEntities) 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 setLockEndUUID(unsigned int uid, const QUuid& objectID, bool isAvatar, const glm::mat4& offsetMat = glm::mat4()) const; void update(); diff --git a/libraries/render-utils/src/RenderCommonTask.cpp b/libraries/render-utils/src/RenderCommonTask.cpp index 40724cbf5a..64037d64b6 100644 --- a/libraries/render-utils/src/RenderCommonTask.cpp +++ b/libraries/render-utils/src/RenderCommonTask.cpp @@ -45,13 +45,13 @@ void EndGPURangeTimer::run(const render::RenderContextPointer& renderContext, co config->setGPUBatchRunTime(timer->getGPUAverage(), timer->getBatchAverage()); } -DrawOverlay3D::DrawOverlay3D(bool opaque) : +DrawLayered3D::DrawLayered3D(bool opaque) : _shapePlumber(std::make_shared()), _opaquePass(opaque) { initForwardPipelines(*_shapePlumber); } -void DrawOverlay3D::run(const RenderContextPointer& renderContext, const Inputs& inputs) { +void DrawLayered3D::run(const RenderContextPointer& renderContext, const Inputs& inputs) { assert(renderContext->args); assert(renderContext->args->hasViewFrustum()); @@ -70,7 +70,7 @@ void DrawOverlay3D::run(const RenderContextPointer& renderContext, const Inputs& // Needs to be distinct from the other batch because using the clear call // while stereo is enabled triggers a warning if (_opaquePass) { - gpu::doInBatch("DrawOverlay3D::run::clear", args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawLayered3D::run::clear", args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.clearFramebuffer(gpu::Framebuffer::BUFFER_DEPTH, glm::vec4(), 1.f, 0, false); }); @@ -78,7 +78,7 @@ void DrawOverlay3D::run(const RenderContextPointer& renderContext, const Inputs& if (!inItems.empty()) { // Render the items - gpu::doInBatch("DrawOverlay3D::main", args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch("DrawLayered3D::main", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; batch.setViewportTransform(args->_viewport); batch.setStateScissorRect(args->_viewport); diff --git a/libraries/render-utils/src/RenderCommonTask.h b/libraries/render-utils/src/RenderCommonTask.h index 29f195ffff..4f8f53257d 100644 --- a/libraries/render-utils/src/RenderCommonTask.h +++ b/libraries/render-utils/src/RenderCommonTask.h @@ -40,7 +40,7 @@ public: protected: }; -class DrawOverlay3DConfig : public render::Job::Config { +class DrawLayered3DConfig : public render::Job::Config { Q_OBJECT Q_PROPERTY(int numDrawn READ getNumDrawn NOTIFY numDrawnChanged) Q_PROPERTY(int maxDrawn MEMBER maxDrawn NOTIFY dirty) @@ -58,13 +58,13 @@ protected: int numDrawn{ 0 }; }; -class DrawOverlay3D { +class DrawLayered3D { public: using Inputs = render::VaryingSet3; - using Config = DrawOverlay3DConfig; - using JobModel = render::Job::ModelI; + using Config = DrawLayered3DConfig; + using JobModel = render::Job::ModelI; - DrawOverlay3D(bool opaque); + DrawLayered3D(bool opaque); void configure(const Config& config) { _maxDrawn = config.maxDrawn; } void run(const render::RenderContextPointer& renderContext, const Inputs& inputs); diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index a685f3998e..673a165105 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -116,13 +116,13 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren const auto& items = fetchedItems.get0(); - // Extract opaques / transparents / lights / metas / overlays / background + // Extract opaques / transparents / lights / metas / layered / background const auto& opaques = items[RenderFetchCullSortTask::OPAQUE_SHAPE]; const auto& transparents = items[RenderFetchCullSortTask::TRANSPARENT_SHAPE]; - const auto& overlaysInFrontOpaque = items[RenderFetchCullSortTask::LAYER_FRONT_OPAQUE_SHAPE]; - const auto& overlaysInFrontTransparent = items[RenderFetchCullSortTask::LAYER_FRONT_TRANSPARENT_SHAPE]; - const auto& overlaysHUDOpaque = items[RenderFetchCullSortTask::LAYER_HUD_OPAQUE_SHAPE]; - const auto& overlaysHUDTransparent = items[RenderFetchCullSortTask::LAYER_HUD_TRANSPARENT_SHAPE]; + const auto& inFrontOpaque = items[RenderFetchCullSortTask::LAYER_FRONT_OPAQUE_SHAPE]; + const auto& inFrontTransparent = items[RenderFetchCullSortTask::LAYER_FRONT_TRANSPARENT_SHAPE]; + const auto& hudOpaque = items[RenderFetchCullSortTask::LAYER_HUD_OPAQUE_SHAPE]; + const auto& hudTransparent = items[RenderFetchCullSortTask::LAYER_HUD_TRANSPARENT_SHAPE]; // Lighting model comes next, the big configuration of the view const auto& lightingModel = inputs[1]; @@ -227,12 +227,12 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren task.addJob("HighlightRangeTimer", outlineRangeTimer); // Layered Over (in front) - const auto overlayInFrontOpaquesInputs = DrawOverlay3D::Inputs(overlaysInFrontOpaque, lightingModel, jitter).asVarying(); - const auto overlayInFrontTransparentsInputs = DrawOverlay3D::Inputs(overlaysInFrontTransparent, lightingModel, jitter).asVarying(); - task.addJob("DrawOverlayInFrontOpaque", overlayInFrontOpaquesInputs, true); - task.addJob("DrawOverlayInFrontTransparent", overlayInFrontTransparentsInputs, false); + const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, jitter).asVarying(); + const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, jitter).asVarying(); + task.addJob("DrawInFrontOpaque", inFrontOpaquesInputs, true); + task.addJob("DrawInFrontTransparent", inFrontTransparentsInputs, false); - const auto toneAndPostRangeTimer = task.addJob("BeginToneAndPostRangeTimer", "PostToneOverlaysAntialiasing"); + const auto toneAndPostRangeTimer = task.addJob("BeginToneAndPostRangeTimer", "PostToneLayeredAntialiasing"); // AA job before bloom to limit flickering const auto antialiasingInputs = Antialiasing::Inputs(deferredFrameTransform, lightingFramebuffer, linearDepthTarget, velocityBuffer).asVarying(); @@ -257,14 +257,14 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren // Upscale to finale resolution const auto primaryFramebuffer = task.addJob("PrimaryBufferUpscale", scaledPrimaryFramebuffer); - // Composite the HUD and HUD overlays + // Composite the HUD and HUD layered objects task.addJob("HUD"); const auto nullJitter = Varying(glm::vec2(0.0f, 0.0f)); - const auto overlayHUDOpaquesInputs = DrawOverlay3D::Inputs(overlaysHUDOpaque, lightingModel, nullJitter).asVarying(); - const auto overlayHUDTransparentsInputs = DrawOverlay3D::Inputs(overlaysHUDTransparent, lightingModel, nullJitter).asVarying(); - task.addJob("DrawOverlayHUDOpaque", overlayHUDOpaquesInputs, true); - task.addJob("DrawOverlayHUDTransparent", overlayHUDTransparentsInputs, false); + const auto hudOpaquesInputs = DrawLayered3D::Inputs(hudOpaque, lightingModel, nullJitter).asVarying(); + const auto hudTransparentsInputs = DrawLayered3D::Inputs(hudTransparent, lightingModel, nullJitter).asVarying(); + task.addJob("DrawHUDOpaque", hudOpaquesInputs, true); + task.addJob("DrawHUDTransparent", hudTransparentsInputs, false); task.addJob("ToneAndPostRangeTimer", toneAndPostRangeTimer); @@ -283,15 +283,15 @@ void RenderDeferredTaskDebug::build(JobModel& task, const render::Varying& input const auto& fetchCullSortTaskOut = inputs.get0(); const auto& items = fetchCullSortTaskOut.get0(); - // Extract opaques / transparents / lights / metas / overlays InFront and HUD / background + // Extract opaques / transparents / lights / metas / layered / background const auto& opaques = items[RenderFetchCullSortTask::OPAQUE_SHAPE]; const auto& transparents = items[RenderFetchCullSortTask::TRANSPARENT_SHAPE]; const auto& lights = items[RenderFetchCullSortTask::LIGHT]; const auto& metas = items[RenderFetchCullSortTask::META]; - const auto& overlaysInFrontOpaque = items[RenderFetchCullSortTask::LAYER_FRONT_OPAQUE_SHAPE]; - const auto& overlaysInFrontTransparent = items[RenderFetchCullSortTask::LAYER_FRONT_TRANSPARENT_SHAPE]; - const auto& overlaysHUDOpaque = items[RenderFetchCullSortTask::LAYER_HUD_OPAQUE_SHAPE]; - const auto& overlaysHUDTransparent = items[RenderFetchCullSortTask::LAYER_HUD_TRANSPARENT_SHAPE]; + const auto& inFrontOpaque = items[RenderFetchCullSortTask::LAYER_FRONT_OPAQUE_SHAPE]; + const auto& inFrontTransparent = items[RenderFetchCullSortTask::LAYER_FRONT_TRANSPARENT_SHAPE]; + const auto& hudOpaque = items[RenderFetchCullSortTask::LAYER_HUD_OPAQUE_SHAPE]; + const auto& hudTransparent = items[RenderFetchCullSortTask::LAYER_HUD_TRANSPARENT_SHAPE]; const auto& spatialSelection = fetchCullSortTaskOut[1]; @@ -388,14 +388,14 @@ void RenderDeferredTaskDebug::build(JobModel& task, const render::Varying& input task.addJob("DrawSelectionBounds", selectedItems); } - { // Debug the bounds of the rendered Overlay items that are marked drawInFront, still look at the zbuffer - task.addJob("DrawOverlayInFrontOpaqueBounds", overlaysInFrontOpaque); - task.addJob("DrawOverlayInFrontTransparentBounds", overlaysInFrontTransparent); + { // Debug the bounds of the layered objects, still look at the zbuffer + task.addJob("DrawInFrontOpaqueBounds", inFrontOpaque); + task.addJob("DrawInFrontTransparentBounds", inFrontTransparent); } - { // Debug the bounds of the rendered Overlay items that are marked drawHUDLayer, still look at the zbuffer - task.addJob("DrawOverlayHUDOpaqueBounds", overlaysHUDOpaque); - task.addJob("DrawOverlayHUDTransparentBounds", overlaysHUDTransparent); + { // Debug the bounds of the layered objects, still look at the zbuffer + task.addJob("DrawHUDOpaqueBounds", hudOpaque); + task.addJob("DrawHUDTransparentBounds", hudTransparent); } // Debugging stages diff --git a/libraries/render-utils/src/RenderForwardTask.cpp b/libraries/render-utils/src/RenderForwardTask.cpp index ffdbc1c4b1..92db4ec1e0 100755 --- a/libraries/render-utils/src/RenderForwardTask.cpp +++ b/libraries/render-utils/src/RenderForwardTask.cpp @@ -65,11 +65,10 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend const auto& opaques = items[RenderFetchCullSortTask::OPAQUE_SHAPE]; const auto& transparents = items[RenderFetchCullSortTask::TRANSPARENT_SHAPE]; const auto& metas = items[RenderFetchCullSortTask::META]; - const auto& overlaysInFrontOpaque = items[RenderFetchCullSortTask::LAYER_FRONT_OPAQUE_SHAPE]; - const auto& overlaysInFrontTransparent = items[RenderFetchCullSortTask::LAYER_FRONT_TRANSPARENT_SHAPE]; - // TODO: Re enable the rendering of the HUD overlayes - // const auto& overlaysHUDOpaque = items[RenderFetchCullSortTask::LAYER_HUD_OPAQUE_SHAPE]; - // const auto& overlaysHUDTransparent = items[RenderFetchCullSortTask::LAYER_HUD_TRANSPARENT_SHAPE]; + const auto& inFrontOpaque = items[RenderFetchCullSortTask::LAYER_FRONT_OPAQUE_SHAPE]; + const auto& inFrontTransparent = items[RenderFetchCullSortTask::LAYER_FRONT_TRANSPARENT_SHAPE]; + const auto& hudOpaque = items[RenderFetchCullSortTask::LAYER_HUD_OPAQUE_SHAPE]; + const auto& hudTransparent = items[RenderFetchCullSortTask::LAYER_HUD_TRANSPARENT_SHAPE]; // Lighting model comes next, the big configuration of the view const auto& lightingModel = inputs[1]; @@ -97,14 +96,12 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend // draw a stencil mask in hidden regions of the framebuffer. task.addJob("PrepareStencil", framebuffer); - // Layered Overlays + // Layered const auto nullJitter = Varying(glm::vec2(0.0f, 0.0f)); - - // Layered Over (in front) - const auto overlayInFrontOpaquesInputs = DrawOverlay3D::Inputs(overlaysInFrontOpaque, lightingModel, nullJitter).asVarying(); - const auto overlayInFrontTransparentsInputs = DrawOverlay3D::Inputs(overlaysInFrontTransparent, lightingModel, nullJitter).asVarying(); - task.addJob("DrawOverlayInFrontOpaque", overlayInFrontOpaquesInputs, true); - task.addJob("DrawOverlayInFrontTransparent", overlayInFrontTransparentsInputs, false); + const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, nullJitter).asVarying(); + const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, nullJitter).asVarying(); + task.addJob("DrawInFrontOpaque", inFrontOpaquesInputs, true); + task.addJob("DrawInFrontTransparent", inFrontTransparentsInputs, false); // Draw opaques forward const auto opaqueInputs = DrawForward::Inputs(opaques, lightingModel).asVarying(); @@ -135,10 +132,14 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend const auto toneMappingInputs = ToneMappingDeferred::Inputs(framebuffer, static_cast(nullptr) ).asVarying(); task.addJob("ToneMapping", toneMappingInputs); - // Layered Overlays - // Composite the HUD and HUD overlays + // Composite the HUD and HUD layered objects task.addJob("HUD"); + const auto hudOpaquesInputs = DrawLayered3D::Inputs(hudOpaque, lightingModel, nullJitter).asVarying(); + const auto hudTransparentsInputs = DrawLayered3D::Inputs(hudTransparent, lightingModel, nullJitter).asVarying(); + task.addJob("DrawHUDOpaque", hudOpaquesInputs, true); + task.addJob("DrawHUDTransparent", hudTransparentsInputs, false); + // Disable blit because we do tonemapping and compositing directly to the blit FBO // Blit! // task.addJob("Blit", framebuffer); diff --git a/libraries/render/src/render/HighlightStage.h b/libraries/render/src/render/HighlightStage.h index 5e6574840f..91d8cc3f81 100644 --- a/libraries/render/src/render/HighlightStage.h +++ b/libraries/render/src/render/HighlightStage.h @@ -107,7 +107,7 @@ namespace render { float getOccludedFillOpacity() const { return getStyle()._fillOccluded.alpha; } void setOccludedFillOpacity(float value); - std::string _selectionName{ "contextOverlayHighlightList" }; + std::string _selectionName { "contextOverlayHighlightList" }; mutable SelectionStyles _styles; const HighlightStyle& getStyle() const; diff --git a/libraries/render/src/render/RenderFetchCullSortTask.cpp b/libraries/render/src/render/RenderFetchCullSortTask.cpp index 324f1d879f..d82fdef258 100644 --- a/libraries/render/src/render/RenderFetchCullSortTask.cpp +++ b/libraries/render/src/render/RenderFetchCullSortTask.cpp @@ -29,10 +29,10 @@ void RenderFetchCullSortTask::build(JobModel& task, const Varying& input, Varyin const auto cullInputs = CullSpatialSelection::Inputs(spatialSelection, spatialFilter).asVarying(); const auto culledSpatialSelection = task.addJob("CullSceneSelection", cullInputs, cullFunctor, RenderDetails::ITEM); - // Overlays are not culled - const ItemFilter overlayfilter = ItemFilter::Builder().withVisible().withoutSubMetaCulled().withTagBits(tagBits, tagMask); - const auto nonspatialFilter = render::Varying(overlayfilter); - const auto nonspatialSelection = task.addJob("FetchOverlaySelection", nonspatialFilter); + // Layered objects are not culled + const ItemFilter layeredFilter = ItemFilter::Builder().withVisible().withoutSubMetaCulled().withTagBits(tagBits, tagMask); + const auto nonspatialFilter = render::Varying(layeredFilter); + const auto nonspatialSelection = task.addJob("FetchLayeredSelection", nonspatialFilter); // Multi filter visible items into different buckets const int NUM_SPATIAL_FILTERS = 4; @@ -57,26 +57,26 @@ void RenderFetchCullSortTask::build(JobModel& task, const Varying& input, Varyin task.addJob>("FilterSceneSelection", culledSpatialSelection, spatialFilters) .get::ItemBoundsArray>(); const auto filteredNonspatialBuckets = - task.addJob>("FilterOverlaySelection", nonspatialSelection, nonspatialFilters) + task.addJob>("FilterLayeredSelection", nonspatialSelection, nonspatialFilters) .get::ItemBoundsArray>(); - // Extract opaques / transparents / lights / overlays + // Extract opaques / transparents / lights / layered const auto opaques = task.addJob("DepthSortOpaque", filteredSpatialBuckets[OPAQUE_SHAPE_BUCKET]); const auto transparents = task.addJob("DepthSortTransparent", filteredSpatialBuckets[TRANSPARENT_SHAPE_BUCKET], DepthSortItems(false)); const auto lights = filteredSpatialBuckets[LIGHT_BUCKET]; const auto metas = filteredSpatialBuckets[META_BUCKET]; - const auto overlayOpaques = task.addJob("DepthSortOverlayOpaque", filteredNonspatialBuckets[OPAQUE_SHAPE_BUCKET]); - const auto overlayTransparents = task.addJob("DepthSortOverlayTransparent", filteredNonspatialBuckets[TRANSPARENT_SHAPE_BUCKET], DepthSortItems(false)); const auto background = filteredNonspatialBuckets[BACKGROUND_BUCKET]; - // split up the overlays into 3D front, hud - const auto filteredOverlaysOpaque = task.addJob("FilterOverlaysLayeredOpaque", overlayOpaques, ItemKey::Layer::LAYER_1); - const auto filteredOverlaysTransparent = task.addJob("FilterOverlaysLayeredTransparent", overlayTransparents, ItemKey::Layer::LAYER_1); + // split up the layered objects into 3D front, hud + const auto layeredOpaques = task.addJob("DepthSortLayaredOpaque", filteredNonspatialBuckets[OPAQUE_SHAPE_BUCKET]); + const auto layeredTransparents = task.addJob("DepthSortLayeredTransparent", filteredNonspatialBuckets[TRANSPARENT_SHAPE_BUCKET], DepthSortItems(false)); + const auto filteredLayeredOpaque = task.addJob("FilterLayeredOpaque", layeredOpaques, ItemKey::Layer::LAYER_1); + const auto filteredLayeredTransparent = task.addJob("FilterLayeredTransparent", layeredTransparents, ItemKey::Layer::LAYER_1); - output = Output(BucketList{ opaques, transparents, lights, metas, overlayOpaques, overlayTransparents, - filteredOverlaysOpaque.getN(0), filteredOverlaysTransparent.getN(0), - filteredOverlaysOpaque.getN(1), filteredOverlaysTransparent.getN(1), + output = Output(BucketList{ opaques, transparents, lights, metas, + filteredLayeredOpaque.getN(0), filteredLayeredTransparent.getN(0), + filteredLayeredOpaque.getN(1), filteredLayeredTransparent.getN(1), background }, spatialSelection); } diff --git a/libraries/render/src/render/RenderFetchCullSortTask.h b/libraries/render/src/render/RenderFetchCullSortTask.h index a75c814d91..1b1e4a5d8f 100644 --- a/libraries/render/src/render/RenderFetchCullSortTask.h +++ b/libraries/render/src/render/RenderFetchCullSortTask.h @@ -23,8 +23,6 @@ public: TRANSPARENT_SHAPE, LIGHT, META, - OVERLAY_OPAQUE_SHAPE, - OVERLAY_TRANSPARENT_SHAPE, LAYER_FRONT_OPAQUE_SHAPE, LAYER_FRONT_TRANSPARENT_SHAPE, LAYER_HUD_OPAQUE_SHAPE, diff --git a/libraries/render/src/render/Scene.h b/libraries/render/src/render/Scene.h index e05cb04532..f00c74775d 100644 --- a/libraries/render/src/render/Scene.h +++ b/libraries/render/src/render/Scene.h @@ -167,11 +167,9 @@ public: // Access the spatialized items const ItemSpatialTree& getSpatialTree() const { return _masterSpatialTree; } - // Access non-spatialized items (overlays, backgrounds) + // Access non-spatialized items (layered objects, backgrounds) const ItemIDSet& getNonspatialSet() const { return _masterNonspatialSet; } - - // Access a particular Stage (empty if doesn't exist) // Thread safe StagePointer getStage(const Stage::Name& name) const; diff --git a/libraries/script-engine/src/ScriptUUID.h b/libraries/script-engine/src/ScriptUUID.h index 45e6ec0ad1..48514968e8 100644 --- a/libraries/script-engine/src/ScriptUUID.h +++ b/libraries/script-engine/src/ScriptUUID.h @@ -19,7 +19,7 @@ #include /**jsdoc - * A UUID (Universally Unique IDentifier) is used to uniquely identify entities, overlays, avatars, and the like. It is + * A UUID (Universally Unique IDentifier) is used to uniquely identify entities, avatars, and the like. It is * represented in JavaScript as a string in the format, {nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn}, where the "n"s are * hexadecimal digits. * diff --git a/libraries/shared/src/PickFilter.h b/libraries/shared/src/PickFilter.h index 2efd408e4f..33f6e7278a 100644 --- a/libraries/shared/src/PickFilter.h +++ b/libraries/shared/src/PickFilter.h @@ -68,7 +68,7 @@ public: // Helpers for RayPickManager Flags getEntityFlags() const { unsigned int toReturn = 0; - for (int i = DOMAIN_ENTITIES; i < LOCAL_ENTITIES; i++) { + for (int i = DOMAIN_ENTITIES; i <= LOCAL_ENTITIES; i++) { if (_flags[i]) { toReturn |= getBitMask(FlagBit(i)); } @@ -80,15 +80,6 @@ public: } return Flags(toReturn); } - Flags getOverlayFlags() const { - unsigned int toReturn = getBitMask(LOCAL_ENTITIES); - for (int i = HUD + 1; i < NUM_FLAGS; i++) { - if (_flags[i]) { - toReturn |= getBitMask(FlagBit(i)); - } - } - return Flags(toReturn); - } Flags getAvatarFlags() const { return Flags(getBitMask(AVATARS)); } Flags getHUDFlags() const { return Flags(getBitMask(HUD)); } diff --git a/libraries/shared/src/PointerEvent.cpp b/libraries/shared/src/PointerEvent.cpp index 422f2dfb20..69d3f28d80 100644 --- a/libraries/shared/src/PointerEvent.cpp +++ b/libraries/shared/src/PointerEvent.cpp @@ -72,8 +72,8 @@ void PointerEvent::setButton(Button button) { * "Move". * @property {number} id - Integer number used to identify the pointer: 0 = hardware mouse, 1 = left * controller, 2 = right controller. - * @property {Vec2} pos2D - The 2D position of the event on the intersected overlay or entity XY plane, where applicable. - * @property {Vec3} pos3D - The 3D position of the event on the intersected overlay or entity, where applicable. + * @property {Vec2} pos2D - The 2D position of the event on the intersected object XY plane, where applicable. + * @property {Vec3} pos3D - The 3D position of the event on the intersected object, where applicable. * @property {Vec3} normal - The surface normal at the intersection point. * @property {Vec3} direction - The direction of the intersection ray. * @property {string} button - The name of the button pressed: None, Primary, Secondary, diff --git a/libraries/shared/src/RegisteredMetaTypes.h b/libraries/shared/src/RegisteredMetaTypes.h index 9d5bca6b9f..134eae41e9 100644 --- a/libraries/shared/src/RegisteredMetaTypes.h +++ b/libraries/shared/src/RegisteredMetaTypes.h @@ -232,7 +232,7 @@ public: }; /**jsdoc - * A PickRay defines a vector with a starting point. It is used, for example, when finding entities or overlays that lie under a + * A PickRay defines a vector with a starting point. It is used, for example, when finding entities or avatars that lie under a * mouse click or intersect a laser beam. * * @typedef {object} PickRay @@ -351,7 +351,7 @@ public: * The depth is measured in world space, but will scale with the parent if defined. * @property {CollisionMask} [collisionGroup=8] - The type of object this collision pick collides as. Objects whose collision masks overlap with the pick's collision group * will be considered colliding with the pick. -* @property {Uuid} parentID - The ID of the parent, either an avatar, an entity, or an overlay. +* @property {Uuid} parentID - The ID of the parent, either an avatar or an entity. * @property {number} parentJointIndex - The joint of the parent to parent to, for example, the joints on the model of an avatar. (default = 0, no joint) * @property {string} joint - If "Mouse," parents the pick to the mouse. If "Avatar," parents the pick to MyAvatar's head. Otherwise, parents to the joint of the given name on MyAvatar. */