From 237022d3042438ec462452039a187bf72fcbeb51 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Wed, 12 Sep 2018 10:56:19 -0700 Subject: [PATCH 01/39] Refactor new pick parenting system for use with RayPick, ParabolaPick --- interface/src/Application.cpp | 12 +- interface/src/raypick/CollisionPick.cpp | 2 +- interface/src/raypick/CollisionPick.h | 1 - interface/src/raypick/JointParabolaPick.cpp | 43 ----- interface/src/raypick/JointParabolaPick.h | 32 ---- interface/src/raypick/JointRayPick.cpp | 45 ----- interface/src/raypick/JointRayPick.h | 33 ---- interface/src/raypick/MouseParabolaPick.cpp | 28 --- interface/src/raypick/MouseParabolaPick.h | 24 --- interface/src/raypick/MouseRayPick.cpp | 29 --- interface/src/raypick/MouseRayPick.h | 26 --- interface/src/raypick/ParabolaPick.cpp | 49 +++-- interface/src/raypick/ParabolaPick.h | 14 +- .../src/raypick/PickScriptingInterface.cpp | 177 ++++++++++-------- .../src/raypick/PickScriptingInterface.h | 1 + interface/src/raypick/RayPick.cpp | 11 ++ interface/src/raypick/RayPick.h | 7 +- .../src/raypick/RayPickScriptingInterface.cpp | 4 - interface/src/raypick/StaticParabolaPick.cpp | 19 -- interface/src/raypick/StaticParabolaPick.h | 26 --- interface/src/raypick/StaticRayPick.cpp | 18 -- interface/src/raypick/StaticRayPick.h | 25 --- interface/src/raypick/StylusPick.h | 1 + libraries/pointers/src/Pick.h | 20 +- libraries/shared/src/RegisteredMetaTypes.h | 2 + 25 files changed, 185 insertions(+), 464 deletions(-) delete mode 100644 interface/src/raypick/JointParabolaPick.cpp delete mode 100644 interface/src/raypick/JointParabolaPick.h delete mode 100644 interface/src/raypick/JointRayPick.cpp delete mode 100644 interface/src/raypick/JointRayPick.h delete mode 100644 interface/src/raypick/MouseParabolaPick.cpp delete mode 100644 interface/src/raypick/MouseParabolaPick.h delete mode 100644 interface/src/raypick/MouseRayPick.cpp delete mode 100644 interface/src/raypick/MouseRayPick.h delete mode 100644 interface/src/raypick/StaticParabolaPick.cpp delete mode 100644 interface/src/raypick/StaticParabolaPick.h delete mode 100644 interface/src/raypick/StaticRayPick.cpp delete mode 100644 interface/src/raypick/StaticRayPick.h diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e290531471..7f43c3d773 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -214,7 +214,8 @@ #include #include #include -#include +#include +#include #include @@ -2235,8 +2236,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo }); // Setup the mouse ray pick and related operators - DependencyManager::get()->setMouseRayPickID(DependencyManager::get()->addPick(PickQuery::Ray, std::make_shared( - PickFilter(PickScriptingInterface::PICK_ENTITIES() | PickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()), 0.0f, true))); + { + auto mouseRayPick = std::make_shared(glm::vec3(), Vectors::UP, + PickFilter(PickScriptingInterface::PICK_ENTITIES() | PickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()), 0.0f, true); + mouseRayPick->parentTransform = std::make_shared(); + auto mouseRayPickID = DependencyManager::get()->addPick(PickQuery::Ray, mouseRayPick); + DependencyManager::get()->setMouseRayPickID(mouseRayPickID); + } DependencyManager::get()->setMouseRayPickResultOperator([](unsigned int rayPickID) { RayToEntityIntersectionResult entityResult; entityResult.intersects = false; diff --git a/interface/src/raypick/CollisionPick.cpp b/interface/src/raypick/CollisionPick.cpp index 9aee76a3da..f79879bf93 100644 --- a/interface/src/raypick/CollisionPick.cpp +++ b/interface/src/raypick/CollisionPick.cpp @@ -347,8 +347,8 @@ void CollisionPick::computeShapeInfo(const CollisionRegion& pick, ShapeInfo& sha CollisionPick::CollisionPick(const PickFilter& filter, float maxDistance, bool enabled, CollisionRegion collisionRegion, PhysicsEnginePointer physicsEngine) : Pick(filter, maxDistance, enabled), - _mathPick(collisionRegion), _physicsEngine(physicsEngine) { + _mathPick = collisionRegion; if (collisionRegion.shouldComputeShapeInfo()) { _cachedResource = DependencyManager::get()->getCollisionGeometryResource(collisionRegion.modelURL); } diff --git a/interface/src/raypick/CollisionPick.h b/interface/src/raypick/CollisionPick.h index 0662ab6c19..79238b37fc 100644 --- a/interface/src/raypick/CollisionPick.h +++ b/interface/src/raypick/CollisionPick.h @@ -67,7 +67,6 @@ protected: void computeShapeInfoDimensionsOnly(const CollisionRegion& pick, ShapeInfo& shapeInfo, QSharedPointer resource); void filterIntersections(std::vector& intersections) const; - CollisionRegion _mathPick; PhysicsEnginePointer _physicsEngine; QSharedPointer _cachedResource; diff --git a/interface/src/raypick/JointParabolaPick.cpp b/interface/src/raypick/JointParabolaPick.cpp deleted file mode 100644 index 11a2e90819..0000000000 --- a/interface/src/raypick/JointParabolaPick.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -// Created by Sam Gondelman 7/2/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 "JointParabolaPick.h" - -#include "avatar/AvatarManager.h" - -JointParabolaPick::JointParabolaPick(const std::string& jointName, const glm::vec3& posOffset, const glm::vec3& dirOffset, - float speed, const glm::vec3& accelerationAxis, bool rotateAccelerationWithAvatar, bool scaleWithAvatar, PickFilter& filter, float maxDistance, bool enabled) : - ParabolaPick(speed, accelerationAxis, rotateAccelerationWithAvatar, scaleWithAvatar, filter, maxDistance, enabled), - _jointName(jointName), - _posOffset(posOffset), - _dirOffset(dirOffset) -{ -} - -PickParabola JointParabolaPick::getMathematicalPick() const { - auto myAvatar = DependencyManager::get()->getMyAvatar(); - int jointIndex = myAvatar->getJointIndex(QString::fromStdString(_jointName)); - bool useAvatarHead = _jointName == "Avatar"; - const int INVALID_JOINT = -1; - if (jointIndex != INVALID_JOINT || useAvatarHead) { - glm::vec3 jointPos = useAvatarHead ? myAvatar->getHeadPosition() : myAvatar->getAbsoluteJointTranslationInObjectFrame(jointIndex); - glm::quat jointRot = useAvatarHead ? myAvatar->getHeadOrientation() : myAvatar->getAbsoluteJointRotationInObjectFrame(jointIndex); - glm::vec3 avatarPos = myAvatar->getWorldPosition(); - glm::quat avatarRot = myAvatar->getWorldOrientation(); - - glm::vec3 pos = useAvatarHead ? jointPos : avatarPos + (avatarRot * jointPos); - glm::quat rot = useAvatarHead ? jointRot * glm::angleAxis(-PI / 2.0f, Vectors::RIGHT) : avatarRot * jointRot; - - // Apply offset - pos = pos + (rot * (myAvatar->getSensorToWorldScale() * _posOffset)); - glm::vec3 dir = glm::normalize(rot * glm::normalize(_dirOffset)); - - return PickParabola(pos, getSpeed() * dir, getAcceleration()); - } - - return PickParabola(); -} diff --git a/interface/src/raypick/JointParabolaPick.h b/interface/src/raypick/JointParabolaPick.h deleted file mode 100644 index aff6bd34d8..0000000000 --- a/interface/src/raypick/JointParabolaPick.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// Created by Sam Gondelman 7/2/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_JointParabolaPick_h -#define hifi_JointParabolaPick_h - -#include "ParabolaPick.h" - -class JointParabolaPick : public ParabolaPick { - -public: - JointParabolaPick(const std::string& jointName, const glm::vec3& posOffset, const glm::vec3& dirOffset, - float speed, const glm::vec3& accelerationAxis, bool rotateAccelerationWithAvatar, bool scaleWithAvatar, - PickFilter& filter, float maxDistance = 0.0f, bool enabled = false); - - PickParabola getMathematicalPick() const override; - - bool isLeftHand() const override { return (_jointName == "_CONTROLLER_LEFTHAND") || (_jointName == "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND"); } - bool isRightHand() const override { return (_jointName == "_CONTROLLER_RIGHTHAND") || (_jointName == "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND"); } - -private: - std::string _jointName; - glm::vec3 _posOffset; - glm::vec3 _dirOffset; - -}; - -#endif // hifi_JointParabolaPick_h diff --git a/interface/src/raypick/JointRayPick.cpp b/interface/src/raypick/JointRayPick.cpp deleted file mode 100644 index 340014e7d2..0000000000 --- a/interface/src/raypick/JointRayPick.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// -// JointRayPick.cpp -// interface/src/raypick -// -// Created by Sam Gondelman 7/11/2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -#include "JointRayPick.h" - -#include "avatar/AvatarManager.h" - -JointRayPick::JointRayPick(const std::string& jointName, const glm::vec3& posOffset, const glm::vec3& dirOffset, const PickFilter& filter, float maxDistance, bool enabled) : - RayPick(filter, maxDistance, enabled), - _jointName(jointName), - _posOffset(posOffset), - _dirOffset(dirOffset) -{ -} - -PickRay JointRayPick::getMathematicalPick() const { - auto myAvatar = DependencyManager::get()->getMyAvatar(); - int jointIndex = myAvatar->getJointIndex(QString::fromStdString(_jointName)); - bool useAvatarHead = _jointName == "Avatar"; - const int INVALID_JOINT = -1; - if (jointIndex != INVALID_JOINT || useAvatarHead) { - glm::vec3 jointPos = useAvatarHead ? myAvatar->getHeadPosition() : myAvatar->getAbsoluteJointTranslationInObjectFrame(jointIndex); - glm::quat jointRot = useAvatarHead ? myAvatar->getHeadOrientation() : myAvatar->getAbsoluteJointRotationInObjectFrame(jointIndex); - glm::vec3 avatarPos = myAvatar->getWorldPosition(); - glm::quat avatarRot = myAvatar->getWorldOrientation(); - - glm::vec3 pos = useAvatarHead ? jointPos : avatarPos + (avatarRot * jointPos); - glm::quat rot = useAvatarHead ? jointRot * glm::angleAxis(-PI / 2.0f, Vectors::RIGHT) : avatarRot * jointRot; - - // Apply offset - pos = pos + (rot * (myAvatar->getSensorToWorldScale() * _posOffset)); - glm::vec3 dir = glm::normalize(rot * glm::normalize(_dirOffset)); - - return PickRay(pos, dir); - } - - return PickRay(); -} diff --git a/interface/src/raypick/JointRayPick.h b/interface/src/raypick/JointRayPick.h deleted file mode 100644 index c0031d87ff..0000000000 --- a/interface/src/raypick/JointRayPick.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// JointRayPick.h -// interface/src/raypick -// -// Created by Sam Gondelman 7/11/2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -#ifndef hifi_JointRayPick_h -#define hifi_JointRayPick_h - -#include "RayPick.h" - -class JointRayPick : public RayPick { - -public: - JointRayPick(const std::string& jointName, const glm::vec3& posOffset, const glm::vec3& dirOffset, const PickFilter& filter, float maxDistance = 0.0f, bool enabled = false); - - PickRay getMathematicalPick() const override; - - bool isLeftHand() const override { return (_jointName == "_CONTROLLER_LEFTHAND") || (_jointName == "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND"); } - bool isRightHand() const override { return (_jointName == "_CONTROLLER_RIGHTHAND") || (_jointName == "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND"); } - -private: - std::string _jointName; - glm::vec3 _posOffset; - glm::vec3 _dirOffset; - -}; - -#endif // hifi_JointRayPick_h diff --git a/interface/src/raypick/MouseParabolaPick.cpp b/interface/src/raypick/MouseParabolaPick.cpp deleted file mode 100644 index 66351f4520..0000000000 --- a/interface/src/raypick/MouseParabolaPick.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// -// Created by Sam Gondelman 7/2/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 "MouseParabolaPick.h" - -#include "Application.h" -#include "display-plugins/CompositorHelper.h" - -MouseParabolaPick::MouseParabolaPick(float speed, const glm::vec3& accelerationAxis, bool rotateAccelerationWithAvatar, - bool scaleWithAvatar, const PickFilter& filter, float maxDistance, bool enabled) : - ParabolaPick(speed, accelerationAxis, rotateAccelerationWithAvatar, scaleWithAvatar, filter, maxDistance, enabled) -{ -} - -PickParabola MouseParabolaPick::getMathematicalPick() const { - QVariant position = qApp->getApplicationCompositor().getReticleInterface()->getPosition(); - if (position.isValid()) { - QVariantMap posMap = position.toMap(); - PickRay pickRay = qApp->getCamera().computePickRay(posMap["x"].toFloat(), posMap["y"].toFloat()); - return PickParabola(pickRay.origin, getSpeed() * pickRay.direction, getAcceleration()); - } - - return PickParabola(); -} diff --git a/interface/src/raypick/MouseParabolaPick.h b/interface/src/raypick/MouseParabolaPick.h deleted file mode 100644 index cb67c3b361..0000000000 --- a/interface/src/raypick/MouseParabolaPick.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// Created by Sam Gondelman 7/2/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_MouseParabolaPick_h -#define hifi_MouseParabolaPick_h - -#include "ParabolaPick.h" - -class MouseParabolaPick : public ParabolaPick { - -public: - MouseParabolaPick(float speed, const glm::vec3& accelerationAxis, bool rotateAccelerationWithAvatar, bool scaleWithAvatar, - const PickFilter& filter, float maxDistance = 0.0f, bool enabled = false); - - PickParabola getMathematicalPick() const override; - - bool isMouse() const override { return true; } -}; - -#endif // hifi_MouseParabolaPick_h diff --git a/interface/src/raypick/MouseRayPick.cpp b/interface/src/raypick/MouseRayPick.cpp deleted file mode 100644 index 2b55c44460..0000000000 --- a/interface/src/raypick/MouseRayPick.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// -// MouseRayPick.cpp -// interface/src/raypick -// -// Created by Sam Gondelman 7/19/2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -#include "MouseRayPick.h" - -#include "Application.h" -#include "display-plugins/CompositorHelper.h" - -MouseRayPick::MouseRayPick(const PickFilter& filter, float maxDistance, bool enabled) : - RayPick(filter, maxDistance, enabled) -{ -} - -PickRay MouseRayPick::getMathematicalPick() const { - QVariant position = qApp->getApplicationCompositor().getReticleInterface()->getPosition(); - if (position.isValid()) { - QVariantMap posMap = position.toMap(); - return qApp->getCamera().computePickRay(posMap["x"].toFloat(), posMap["y"].toFloat()); - } - - return PickRay(); -} diff --git a/interface/src/raypick/MouseRayPick.h b/interface/src/raypick/MouseRayPick.h deleted file mode 100644 index a9070e8b92..0000000000 --- a/interface/src/raypick/MouseRayPick.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// MouseRayPick.h -// interface/src/raypick -// -// Created by Sam Gondelman 7/19/2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -#ifndef hifi_MouseRayPick_h -#define hifi_MouseRayPick_h - -#include "RayPick.h" - -class MouseRayPick : public RayPick { - -public: - MouseRayPick(const PickFilter& filter, float maxDistance = 0.0f, bool enabled = false); - - PickRay getMathematicalPick() const override; - - bool isMouse() const override { return true; } -}; - -#endif // hifi_MouseRayPick_h diff --git a/interface/src/raypick/ParabolaPick.cpp b/interface/src/raypick/ParabolaPick.cpp index 1b37eee096..a2a9211b88 100644 --- a/interface/src/raypick/ParabolaPick.cpp +++ b/interface/src/raypick/ParabolaPick.cpp @@ -14,6 +14,43 @@ #include "scripting/HMDScriptingInterface.h" #include "DependencyManager.h" +ParabolaPick::ParabolaPick(const glm::vec3& position, const glm::vec3& direction, float speed, const glm::vec3& accelerationAxis, bool rotateAccelerationWithAvatar, bool rotateAccelerationWithParent, bool scaleWithParent, const PickFilter& filter, float maxDistance, bool enabled) : + Pick(filter, maxDistance, enabled), + _rotateAccelerationWithAvatar(rotateAccelerationWithAvatar), + _rotateAccelerationWithParent(rotateAccelerationWithParent), + _scaleWithParent(scaleWithParent) { + _mathPick = PickParabola(position, speed*direction, accelerationAxis); +} + +PickParabola ParabolaPick::getMathematicalPick() const { + if (!parentTransform) { + PickParabola mathPick = _mathPick; + if (_rotateAccelerationWithAvatar) { + mathPick.acceleration = DependencyManager::get()->getMyAvatar()->getWorldOrientation() * mathPick.acceleration; + } + return mathPick; + } + + Transform currentParentTransform = parentTransform->getTransform(); + + glm::vec3 position = currentParentTransform.transform(_mathPick.origin); + glm::vec3 velocity = _mathPick.velocity; + if (_scaleWithParent) { + velocity = currentParentTransform.transformDirection(velocity); + } + glm::vec3 acceleration = _mathPick.acceleration; + if (_rotateAccelerationWithAvatar) { + acceleration = DependencyManager::get()->getMyAvatar()->getWorldOrientation() * acceleration; + } else if (_rotateAccelerationWithParent) { + acceleration = currentParentTransform.getRotation() * acceleration; + } + if (_scaleWithParent) { + acceleration *= currentParentTransform.getScale(); + } + + return PickParabola(position, velocity, acceleration); +} + PickResultPointer ParabolaPick::getEntityIntersection(const PickParabola& pick) { if (glm::length2(pick.acceleration) > EPSILON && glm::length2(pick.velocity) > EPSILON) { ParabolaToEntityIntersectionResult entityRes = @@ -57,18 +94,6 @@ PickResultPointer ParabolaPick::getHUDIntersection(const PickParabola& pick) { return std::make_shared(pick.toVariantMap()); } -float ParabolaPick::getSpeed() const { - return (_scaleWithAvatar ? DependencyManager::get()->getMyAvatar()->getSensorToWorldScale() * _speed : _speed); -} - -glm::vec3 ParabolaPick::getAcceleration() const { - float scale = (_scaleWithAvatar ? DependencyManager::get()->getMyAvatar()->getSensorToWorldScale() : 1.0f); - if (_rotateAccelerationWithAvatar) { - return scale * (DependencyManager::get()->getMyAvatar()->getWorldOrientation() * _accelerationAxis); - } - return scale * _accelerationAxis; -} - Transform ParabolaPick::getResultTransform() const { PickResultPointer result = getPrevPickResult(); if (!result) { diff --git a/interface/src/raypick/ParabolaPick.h b/interface/src/raypick/ParabolaPick.h index 01454390f9..7089228d21 100644 --- a/interface/src/raypick/ParabolaPick.h +++ b/interface/src/raypick/ParabolaPick.h @@ -74,9 +74,9 @@ public: class ParabolaPick : public Pick { public: - ParabolaPick(float speed, const glm::vec3& accelerationAxis, bool rotateAccelerationWithAvatar, bool scaleWithAvatar, const PickFilter& filter, float maxDistance, bool enabled) : - Pick(filter, maxDistance, enabled), _speed(speed), _accelerationAxis(accelerationAxis), _rotateAccelerationWithAvatar(rotateAccelerationWithAvatar), - _scaleWithAvatar(scaleWithAvatar) {} + ParabolaPick(const glm::vec3& position, const glm::vec3& direction, float speed, const glm::vec3& acceleration, bool rotateAccelerationWithAvatar, bool rotateAccelerationWithParent, bool scaleWithParent, const PickFilter& filter, float maxDistance, bool enabled); + + PickParabola getMathematicalPick() const override; PickResultPointer getDefaultResult(const QVariantMap& pickVariant) const override { return std::make_shared(pickVariant); } PickResultPointer getEntityIntersection(const PickParabola& pick) override; @@ -86,13 +86,9 @@ public: Transform getResultTransform() const override; protected: - float _speed; - glm::vec3 _accelerationAxis; bool _rotateAccelerationWithAvatar; - bool _scaleWithAvatar; - - float getSpeed() const; - glm::vec3 getAcceleration() const; + bool _rotateAccelerationWithParent; + bool _scaleWithParent; }; #endif // hifi_ParabolaPick_h diff --git a/interface/src/raypick/PickScriptingInterface.cpp b/interface/src/raypick/PickScriptingInterface.cpp index b9693f6782..600be743fe 100644 --- a/interface/src/raypick/PickScriptingInterface.cpp +++ b/interface/src/raypick/PickScriptingInterface.cpp @@ -14,13 +14,9 @@ #include "Application.h" #include -#include "StaticRayPick.h" -#include "JointRayPick.h" -#include "MouseRayPick.h" +#include "RayPick.h" #include "StylusPick.h" -#include "StaticParabolaPick.h" -#include "JointParabolaPick.h" -#include "MouseParabolaPick.h" +#include "ParabolaPick.h" #include "CollisionPick.h" #include "SpatialParentFinder.h" @@ -56,9 +52,9 @@ unsigned int PickScriptingInterface::createPick(const PickQuery::PickType type, * @property {boolean} [enabled=false] If this Pick should start enabled or not. Disabled Picks do not updated their pick results. * @property {number} [filter=Picks.PICK_NOTHING] 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 {string} [joint] Only for Joint or Mouse Ray Picks. If "Mouse", it will create a Ray Pick that follows the system mouse, in desktop or HMD. - * If "Avatar", it will create a Joint Ray Pick that follows your avatar's head. Otherwise, it will create a Joint Ray Pick that follows the given joint, if it - * exists on your current avatar. + * @property {Uuid} parentID - The ID of the parent, either an avatar, an entity, or an overlay. + * @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. * @property {Vec3} [posOffset=Vec3.ZERO] Only for Joint Ray Picks. A local joint position offset, in meters. x = upward, y = forward, z = lateral * @property {Vec3} [dirOffset=Vec3.UP] Only for Joint Ray Picks. A local joint direction offset. x = upward, y = forward, z = lateral * @property {Vec3} [position] Only for Static Ray Picks. The world-space origin of the ray. @@ -82,38 +78,30 @@ unsigned int PickScriptingInterface::createRayPick(const QVariant& properties) { maxDistance = propMap["maxDistance"].toFloat(); } - if (propMap["joint"].isValid()) { - std::string jointName = propMap["joint"].toString().toStdString(); - - if (jointName != "Mouse") { - // x = upward, y = forward, z = lateral - glm::vec3 posOffset = Vectors::ZERO; - if (propMap["posOffset"].isValid()) { - posOffset = vec3FromVariant(propMap["posOffset"]); - } - - glm::vec3 dirOffset = Vectors::UP; - if (propMap["dirOffset"].isValid()) { - dirOffset = vec3FromVariant(propMap["dirOffset"]); - } - - return DependencyManager::get()->addPick(PickQuery::Ray, std::make_shared(jointName, posOffset, dirOffset, filter, maxDistance, enabled)); - - } else { - return DependencyManager::get()->addPick(PickQuery::Ray, std::make_shared(filter, maxDistance, enabled)); - } - } else if (propMap["position"].isValid()) { - glm::vec3 position = vec3FromVariant(propMap["position"]); - - glm::vec3 direction = -Vectors::UP; - if (propMap["direction"].isValid()) { - direction = vec3FromVariant(propMap["direction"]); - } - - return DependencyManager::get()->addPick(PickQuery::Ray, std::make_shared(position, direction, filter, maxDistance, enabled)); + glm::vec3 position = Vectors::ZERO; + if (propMap["position"].isValid()) { + position = vec3FromVariant(propMap["position"]); + } else if (propMap["posOffset"].isValid()) { + position = vec3FromVariant(propMap["posOffset"]); } - return PickManager::INVALID_PICK_ID; + // direction has two defaults to ensure compatibility with older scripts + // Joint ray picks had default direction = Vec3.UP + // Static ray picks had default direction = -Vec3.UP + glm::vec3 direction = propMap["joint"].isValid() ? Vectors::UP : -Vectors::UP; + if (propMap["orientation"].isValid()) { + direction = quatFromVariant(propMap["orientation"]) * Vectors::UP; + } else if (propMap["direction"].isValid()) { + direction = vec3FromVariant(propMap["direction"]); + } else if (propMap["dirOffset"].isValid()) { + direction = vec3FromVariant(propMap["dirOffset"]); + } + + auto rayPick = std::make_shared(position, direction, filter, maxDistance, enabled); + rayPick->parentTransform = createTransformNode(propMap); + rayPick->setJointState(getPickJointState(propMap)); + + return DependencyManager::get()->addPick(PickQuery::Ray, rayPick); } /**jsdoc @@ -153,23 +141,26 @@ unsigned int PickScriptingInterface::createStylusPick(const QVariant& properties return DependencyManager::get()->addPick(PickQuery::Stylus, std::make_shared(side, filter, maxDistance, enabled)); } +// NOTE: Laser pointer still uses scaleWithAvatar. Until scaleWithAvatar is also deprecated for pointers, scaleWithAvatar should not be removed from the pick API. /**jsdoc * A set of properties that can be passed to {@link Picks.createPick} to create a new Parabola Pick. * @typedef {object} Picks.ParabolaPickProperties * @property {boolean} [enabled=false] If this Pick should start enabled or not. Disabled Picks do not updated their pick results. * @property {number} [filter=Picks.PICK_NOTHING] 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 {string} [joint] Only for Joint or Mouse Parabola Picks. If "Mouse", it will create a Parabola Pick that follows the system mouse, in desktop or HMD. - * If "Avatar", it will create a Joint Parabola Pick that follows your avatar's head. Otherwise, it will create a Joint Parabola Pick that follows the given joint, if it - * exists on your current avatar. + * @property {Uuid} parentID - The ID of the parent, either an avatar, an entity, or an overlay. + * @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. * @property {Vec3} [posOffset=Vec3.ZERO] Only for Joint Parabola Picks. A local joint position offset, in meters. x = upward, y = forward, z = lateral * @property {Vec3} [dirOffset=Vec3.UP] Only for Joint Parabola Picks. A local joint direction offset. x = upward, y = forward, z = lateral * @property {Vec3} [position] Only for Static Parabola Picks. The world-space origin of the parabola segment. * @property {Vec3} [direction=-Vec3.FRONT] Only for Static Parabola Picks. The world-space direction of the parabola segment. * @property {number} [speed=1] The initial speed of the parabola, i.e. the initial speed of the projectile whose trajectory defines the parabola. * @property {Vec3} [accelerationAxis=-Vec3.UP] The acceleration of the parabola, i.e. the acceleration of the projectile whose trajectory defines the parabola, both magnitude and direction. - * @property {boolean} [rotateAccelerationWithAvatar=true] Whether or not the acceleration axis should rotate with your avatar's local Y axis. - * @property {boolean} [scaleWithAvatar=false] If true, the velocity and acceleration of the Pick will scale linearly with your avatar. + * @property {boolean} [rotateAccelerationWithAvatar=true] Whether or not the acceleration axis should rotate with the avatar's local Y axis. + * @property {boolean} [rotateAccelerationWithParent=false] Whether or not the acceleration axis should rotate with the parent's local Y axis, if available. + * @property {boolean} [scaleWithParent=false] If true, the velocity and acceleration of the Pick will scale linearly with the parent, if available. + * @property {boolean} [scaleWithAvatar] Alias for scaleWithParent. Deprecated. */ unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properties) { QVariantMap propMap = properties.toMap(); @@ -204,48 +195,38 @@ unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properti rotateAccelerationWithAvatar = propMap["rotateAccelerationWithAvatar"].toBool(); } - bool scaleWithAvatar = false; - if (propMap["scaleWithAvatar"].isValid()) { - scaleWithAvatar = propMap["scaleWithAvatar"].toBool(); + bool rotateAccelerationWithParent = false; + if (propMap["rotateAccelerationWithParent"].isValid()) { + rotateAccelerationWithParent = propMap["rotateAccelerationWithParent"].toBool(); } - if (propMap["joint"].isValid()) { - std::string jointName = propMap["joint"].toString().toStdString(); - - if (jointName != "Mouse") { - // x = upward, y = forward, z = lateral - glm::vec3 posOffset = Vectors::ZERO; - if (propMap["posOffset"].isValid()) { - posOffset = vec3FromVariant(propMap["posOffset"]); - } - - glm::vec3 dirOffset = Vectors::UP; - if (propMap["dirOffset"].isValid()) { - dirOffset = vec3FromVariant(propMap["dirOffset"]); - } - - return DependencyManager::get()->addPick(PickQuery::Parabola, std::make_shared(jointName, posOffset, dirOffset, - speed, accelerationAxis, rotateAccelerationWithAvatar, - scaleWithAvatar, filter, maxDistance, enabled)); - - } else { - return DependencyManager::get()->addPick(PickQuery::Parabola, std::make_shared(speed, accelerationAxis, rotateAccelerationWithAvatar, - scaleWithAvatar, filter, maxDistance, enabled)); - } - } else if (propMap["position"].isValid()) { - glm::vec3 position = vec3FromVariant(propMap["position"]); - - glm::vec3 direction = -Vectors::FRONT; - if (propMap["direction"].isValid()) { - direction = vec3FromVariant(propMap["direction"]); - } - - return DependencyManager::get()->addPick(PickQuery::Parabola, std::make_shared(position, direction, speed, accelerationAxis, - rotateAccelerationWithAvatar, scaleWithAvatar, - filter, maxDistance, enabled)); + bool scaleWithParent = false; + if (propMap["scaleWithParent"].isValid()) { + scaleWithParent = propMap["scaleWithParent"].toBool(); + } else if (propMap["scaleWithAvatar"].isValid()) { + scaleWithParent = propMap["scaleWithAvatar"].toBool(); } - return PickManager::INVALID_PICK_ID; + glm::vec3 position = glm::vec3(); + glm::vec3 direction = -Vectors::FRONT; + if (propMap["position"].isValid()) { + position = vec3FromVariant(propMap["position"]); + } else if (propMap["posOffset"].isValid()) { + position = vec3FromVariant(propMap["posOffset"]); + } + if (propMap["orientation"].isValid()) { + direction = quatFromVariant(propMap["orientation"]) * Vectors::UP; + } else if (propMap["direction"].isValid()) { + direction = vec3FromVariant(propMap["direction"]); + } else if (propMap["dirOffset"].isValid()) { + direction = vec3FromVariant(propMap["dirOffset"]); + } + + auto parabolaPick = std::make_shared(position, direction, speed, accelerationAxis, + rotateAccelerationWithAvatar, rotateAccelerationWithParent, scaleWithParent, filter, maxDistance, enabled); + parabolaPick->parentTransform = createTransformNode(propMap); + parabolaPick->setJointState(getPickJointState(propMap)); + return DependencyManager::get()->addPick(PickQuery::Parabola, parabolaPick); } /**jsdoc @@ -297,6 +278,7 @@ unsigned int PickScriptingInterface::createCollisionPick(const QVariant& propert CollisionRegion collisionRegion(propMap); auto collisionPick = std::make_shared(filter, maxDistance, enabled, collisionRegion, qApp->getPhysicsEngine()); collisionPick->parentTransform = createTransformNode(propMap); + collisionPick->setJointState(getPickJointState(propMap)); return DependencyManager::get()->addPick(PickQuery::Collision, collisionPick); } @@ -373,6 +355,37 @@ void PickScriptingInterface::setPerFrameTimeBudget(unsigned int numUsecs) { DependencyManager::get()->setPerFrameTimeBudget(numUsecs); } +PickQuery::JointState PickScriptingInterface::getPickJointState(const QVariantMap& propMap) { + if (propMap["parentID"].isValid()) { + QUuid parentUuid = propMap["parentID"].toUuid(); + if (propMap["parentJointIndex"].isValid() && parentUuid == DependencyManager::get()->getMyAvatar()->getSessionUUID()) { + int jointIndex = propMap["parentJointIndes"].toInt(); + if (jointIndex == CONTROLLER_LEFTHAND_INDEX || jointIndex == CAMERA_RELATIVE_CONTROLLER_LEFTHAND_INDEX) { + return PickQuery::JOINT_STATE_LEFT_HAND; + } else if (jointIndex == CONTROLLER_RIGHTHAND_INDEX || jointIndex == CAMERA_RELATIVE_CONTROLLER_RIGHTHAND_INDEX) { + return PickQuery::JOINT_STATE_RIGHT_HAND; + } else { + return PickQuery::JOINT_STATE_NONE; + } + } else { + return PickQuery::JOINT_STATE_NONE; + } + } else if (propMap["joint"].isValid()) { + QString joint = propMap["joint"].toString(); + if (joint == "Mouse") { + return PickQuery::JOINT_STATE_MOUSE; + } else if (joint == "_CONTROLLER_LEFTHAND" || joint == "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND") { + return PickQuery::JOINT_STATE_LEFT_HAND; + } else if (joint== "_CONTROLLER_RIGHTHAND" || joint == "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND") { + return PickQuery::JOINT_STATE_RIGHT_HAND; + } else { + return PickQuery::JOINT_STATE_NONE; + } + } else { + return PickQuery::JOINT_STATE_NONE; + } +} + std::shared_ptr PickScriptingInterface::createTransformNode(const QVariantMap& propMap) { if (propMap["parentID"].isValid()) { QUuid parentUuid = propMap["parentID"].toUuid(); diff --git a/interface/src/raypick/PickScriptingInterface.h b/interface/src/raypick/PickScriptingInterface.h index 36079cec2b..224f7a547e 100644 --- a/interface/src/raypick/PickScriptingInterface.h +++ b/interface/src/raypick/PickScriptingInterface.h @@ -320,6 +320,7 @@ public slots: static constexpr unsigned int INTERSECTED_HUD() { return IntersectionType::HUD; } protected: + static PickQuery::JointState getPickJointState(const QVariantMap& propMap); static std::shared_ptr createTransformNode(const QVariantMap& propMap); }; diff --git a/interface/src/raypick/RayPick.cpp b/interface/src/raypick/RayPick.cpp index 736d3c1760..d16e10a3f4 100644 --- a/interface/src/raypick/RayPick.cpp +++ b/interface/src/raypick/RayPick.cpp @@ -14,6 +14,17 @@ #include "scripting/HMDScriptingInterface.h" #include "DependencyManager.h" +PickRay RayPick::getMathematicalPick() const { + if (!parentTransform) { + return _mathPick; + } + + Transform currentParentTransform = parentTransform->getTransform(); + Transform relativeTransform(rotationBetween(Vectors::UP, _mathPick.direction), glm::vec3(1.0f), _mathPick.origin); + Transform pickTransform = currentParentTransform.worldTransform(relativeTransform); + return PickRay(pickTransform.getTranslation(), pickTransform.getRotation() * Vectors::UP); +} + PickResultPointer RayPick::getEntityIntersection(const PickRay& pick) { RayToEntityIntersectionResult entityRes = DependencyManager::get()->findRayIntersectionVector(pick, !getFilter().doesPickCoarse(), diff --git a/interface/src/raypick/RayPick.h b/interface/src/raypick/RayPick.h index 11f985cec2..7c7ea5758a 100644 --- a/interface/src/raypick/RayPick.h +++ b/interface/src/raypick/RayPick.h @@ -70,7 +70,12 @@ public: class RayPick : public Pick { public: - RayPick(const PickFilter& filter, float maxDistance, bool enabled) : Pick(filter, maxDistance, enabled) {} + RayPick(glm::vec3 position, glm::vec3 direction, const PickFilter& filter, float maxDistance, bool enabled) : + Pick(filter, maxDistance, enabled) { + _mathPick = PickRay(position, direction); + } + + PickRay getMathematicalPick() const override; PickResultPointer getDefaultResult(const QVariantMap& pickVariant) const override { return std::make_shared(pickVariant); } PickResultPointer getEntityIntersection(const PickRay& pick) override; diff --git a/interface/src/raypick/RayPickScriptingInterface.cpp b/interface/src/raypick/RayPickScriptingInterface.cpp index c90f5d6c6c..247368df51 100644 --- a/interface/src/raypick/RayPickScriptingInterface.cpp +++ b/interface/src/raypick/RayPickScriptingInterface.cpp @@ -16,10 +16,6 @@ #include -#include "StaticRayPick.h" -#include "JointRayPick.h" -#include "MouseRayPick.h" - unsigned int RayPickScriptingInterface::createRayPick(const QVariant& properties) { return DependencyManager::get()->createRayPick(properties); } diff --git a/interface/src/raypick/StaticParabolaPick.cpp b/interface/src/raypick/StaticParabolaPick.cpp deleted file mode 100644 index a4e3ccb97f..0000000000 --- a/interface/src/raypick/StaticParabolaPick.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// -// Created by Sam Gondelman 7/2/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 "StaticParabolaPick.h" - -StaticParabolaPick::StaticParabolaPick(const glm::vec3& position, const glm::vec3& direction, float speed, const glm::vec3& accelerationAxis, - bool scaleWithAvatar, bool rotateAccelerationWithAvatar, const PickFilter& filter, float maxDistance, bool enabled) : - ParabolaPick(speed, accelerationAxis, rotateAccelerationWithAvatar, scaleWithAvatar, filter, maxDistance, enabled), - _position(position), _velocity(direction) -{ -} - -PickParabola StaticParabolaPick::getMathematicalPick() const { - return PickParabola(_position, getSpeed() * _velocity, getAcceleration()); -} \ No newline at end of file diff --git a/interface/src/raypick/StaticParabolaPick.h b/interface/src/raypick/StaticParabolaPick.h deleted file mode 100644 index df2057a6f0..0000000000 --- a/interface/src/raypick/StaticParabolaPick.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// Created by Sam Gondelman 7/2/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_StaticParabolaPick_h -#define hifi_StaticParabolaPick_h - -#include "ParabolaPick.h" - -class StaticParabolaPick : public ParabolaPick { - -public: - StaticParabolaPick(const glm::vec3& position, const glm::vec3& direction, float speed, const glm::vec3& accelerationAxis, bool rotateAccelerationWithAvatar, - bool scaleWithAvatar, const PickFilter& filter, float maxDistance = 0.0f, bool enabled = false); - - PickParabola getMathematicalPick() const override; - -private: - glm::vec3 _position; - glm::vec3 _velocity; -}; - -#endif // hifi_StaticParabolaPick_h diff --git a/interface/src/raypick/StaticRayPick.cpp b/interface/src/raypick/StaticRayPick.cpp deleted file mode 100644 index b74afd6b5d..0000000000 --- a/interface/src/raypick/StaticRayPick.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// -// Created by Sam Gondelman 7/11/2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -#include "StaticRayPick.h" - -StaticRayPick::StaticRayPick(const glm::vec3& position, const glm::vec3& direction, const PickFilter& filter, float maxDistance, bool enabled) : - RayPick(filter, maxDistance, enabled), - _pickRay(position, direction) -{ -} - -PickRay StaticRayPick::getMathematicalPick() const { - return _pickRay; -} \ No newline at end of file diff --git a/interface/src/raypick/StaticRayPick.h b/interface/src/raypick/StaticRayPick.h deleted file mode 100644 index e4da2dbd55..0000000000 --- a/interface/src/raypick/StaticRayPick.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// Created by Sam Gondelman 7/11/2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -#ifndef hifi_StaticRayPick_h -#define hifi_StaticRayPick_h - -#include "RayPick.h" - -class StaticRayPick : public RayPick { - -public: - StaticRayPick(const glm::vec3& position, const glm::vec3& direction, const PickFilter& filter, float maxDistance = 0.0f, bool enabled = false); - - PickRay getMathematicalPick() const override; - -private: - PickRay _pickRay; - -}; - -#endif // hifi_StaticRayPick_h diff --git a/interface/src/raypick/StylusPick.h b/interface/src/raypick/StylusPick.h index ca80e9fbea..e6b1da9914 100644 --- a/interface/src/raypick/StylusPick.h +++ b/interface/src/raypick/StylusPick.h @@ -70,6 +70,7 @@ public: bool isLeftHand() const override { return _side == Side::Left; } bool isRightHand() const override { return _side == Side::Right; } + bool isMouse() const override { return false; } private: const Side _side; diff --git a/libraries/pointers/src/Pick.h b/libraries/pointers/src/Pick.h index 099a791407..42a9354122 100644 --- a/libraries/pointers/src/Pick.h +++ b/libraries/pointers/src/Pick.h @@ -170,6 +170,13 @@ public: }; Q_ENUM(PickType) + enum JointState { + JOINT_STATE_NONE = 0, + JOINT_STATE_LEFT_HAND, + JOINT_STATE_RIGHT_HAND, + JOINT_STATE_MOUSE + }; + void enable(bool enabled = true); void disable() { enable(false); } @@ -210,9 +217,11 @@ public: void setIgnoreItems(const QVector& items); void setIncludeItems(const QVector& items); - virtual bool isLeftHand() const { return false; } - virtual bool isRightHand() const { return false; } - virtual bool isMouse() const { return false; } + virtual bool isLeftHand() const { return _jointState == JOINT_STATE_LEFT_HAND; } + virtual bool isRightHand() const { return _jointState == JOINT_STATE_RIGHT_HAND; } + virtual bool isMouse() const { return _jointState == JOINT_STATE_MOUSE; } + + void setJointState(JointState jointState) { _jointState = jointState; } virtual Transform getResultTransform() const = 0; @@ -226,6 +235,8 @@ private: QVector _ignoreItems; QVector _includeItems; + + JointState _jointState = JOINT_STATE_NONE; }; Q_DECLARE_METATYPE(PickQuery::PickType) @@ -240,6 +251,9 @@ public: virtual PickResultPointer getOverlayIntersection(const T& pick) = 0; virtual PickResultPointer getAvatarIntersection(const T& pick) = 0; virtual PickResultPointer getHUDIntersection(const T& pick) = 0; + +protected: + T _mathPick; }; namespace std { diff --git a/libraries/shared/src/RegisteredMetaTypes.h b/libraries/shared/src/RegisteredMetaTypes.h index 6ecf9faca7..46f112f5c6 100644 --- a/libraries/shared/src/RegisteredMetaTypes.h +++ b/libraries/shared/src/RegisteredMetaTypes.h @@ -178,7 +178,9 @@ public: QVariantMap toVariantMap() const override { QVariantMap pickRay; pickRay["origin"] = vec3toVariant(origin); + pickRay["position"] = vec3toVariant(origin); pickRay["direction"] = vec3toVariant(direction); + pickRay["orientation"] = quatToVariant(rotationBetween(Vectors::UP, direction)); return pickRay; } }; From a5950156cc42a78b077bee3f0d82db4373018b9b Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Mon, 24 Sep 2018 11:13:13 -0700 Subject: [PATCH 02/39] Add markdeep for docs --- docs/LICENSE_highlight.js.txt | 24 +++++ docs/LICENSE_markdeep.txt | 23 +++++ docs/markdeep.min.js | 7 ++ docs/markdeep_apidoc.css | 170 ++++++++++++++++++++++++++++++++++ 4 files changed, 224 insertions(+) create mode 100644 docs/LICENSE_highlight.js.txt create mode 100644 docs/LICENSE_markdeep.txt create mode 100644 docs/markdeep.min.js create mode 100644 docs/markdeep_apidoc.css diff --git a/docs/LICENSE_highlight.js.txt b/docs/LICENSE_highlight.js.txt new file mode 100644 index 0000000000..20975b7d41 --- /dev/null +++ b/docs/LICENSE_highlight.js.txt @@ -0,0 +1,24 @@ +Copyright (c) 2006, Ivan Sagalaev +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are +permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list +of conditions and the following disclaimer in the documentation and/or other materials +provided with the distribution. +* Neither the name of highlight.js nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/docs/LICENSE_markdeep.txt b/docs/LICENSE_markdeep.txt new file mode 100644 index 0000000000..9394bd5193 --- /dev/null +++ b/docs/LICENSE_markdeep.txt @@ -0,0 +1,23 @@ +Copyright 2015-2017, Morgan McGuire +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or other +materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/docs/markdeep.min.js b/docs/markdeep.min.js new file mode 100644 index 0000000000..d24225c984 --- /dev/null +++ b/docs/markdeep.min.js @@ -0,0 +1,7 @@ +/**See http://casual-effects.com/markdeep for @license and documentation. +markdeep.min.js 1.03 (C) 2018 Morgan McGuire +highlight.min.js 9.12.0 (C) 2017 Ivan Sagalaev https://highlightjs.org/*/ +!function(){"use strict";function e(e,t,r){return"<"+e+(r?" "+r:"")+">"+t+""}function t(e){try{var t=document.createElement("canvas"),r=t.getContext("2d");return r.font="10pt "+e,r.measureText("M").width}catch(e){return 10}}function r(e,t){if(window.markdeepOptions&&void 0!==window.markdeepOptions[e]){var r=window.markdeepOptions[e];return t?(r=r[t],void 0!==r?r:ne[e][t]):window.markdeepOptions[e]}return void 0!==ne[e]?t?ne[e][t]:ne[e]:void console.warn('Illegal option: "'+e+'"')}function n(t,n){if(r("showLabels")){var a=" {\xa0"+t+"\xa0}";return n?e(n,a):a}return""}function a(e){return r("lang").keyword[e.toLowerCase()]||e}function i(e){return(e+"").rp(/&/g,"&").rp(//g,">").rp(/"/g,""")}function s(e){return e.rp(/</g,"<").rp(/>/g,">").rp(/"/g,'"').rp(/'/g,"'").rp(/–/g,"\u2013").rp(/—/g,"---").rp(/&/g,"&")}function o(e){return e.rp(/<.*?>/g,"")}function c(e){return encodeURI(e.rp(/\s/g,"").toLowerCase())}function l(){for(var t="",r=1;r<=6;++r){t+=".md h"+r+"::before {\ncontent:";for(var n=1;n<=r;++n)t+="counter(h"+n+') "'+(n|<\/ftp:.*>|<\/[^ "\t\n>]+@[^ "\t\n>]+>/gi,""),r=r.rp(/<(https?|ftp): (.*?)>/gi,function(e,t,r){var n="<"+t+"://"+r.rp(/=""\s/g,"/");return'=""'===n.ss(n.length-3)&&(n=n.ss(0,n.length-3)),n=n.rp(/"/g,""),n+">"}),r=r.rp(/",rE:!0,sL:["css","xml"]}},{cN:"tag",b:"|$)",e:">",k:{name:"script"},c:[r],starts:{e:"",rE:!0,sL:["actionscript","javascript","handlebars","xml"]}},{cN:"meta",v:[{b:/<\?xml/,e:/\?>/,r:10},{b:/<\?\w+/,e:/\?>/}]},{cN:"tag",b:"",c:[{cN:"name",b:/[^\/><\s]+/,r:0},r]}]}}),hljs.g("markdown",function(e){return{aliases:["md","mkdown","mkd"],c:[{cN:"section",v:[{b:"^#{1,6}",e:"$"},{b:"^.+?\\n[=-]{2,}$"}]},{b:"<",e:">",sL:"xml",r:0},{cN:"bullet",b:"^([*+-]|(\\d+\\.))\\s+"},{cN:"strong",b:"[*_]{2}.+?[*_]{2}"},{cN:"emphasis",v:[{b:"\\*.+?\\*"},{b:"_.+?_",r:0}]},{cN:"quote",b:"^>\\s+",e:"$"},{cN:"code",v:[{b:"^```w*s*$",e:"^```s*$"},{b:"`.+?`"},{b:"^( {4}|\t)",e:"$",r:0}]},{b:"^[-\\*]{3,}",e:"$"},{b:"\\[.+?\\][\\(\\[].*?[\\)\\]]",rB:!0,c:[{cN:"string",b:"\\[",e:"\\]",eB:!0,rE:!0,r:0},{cN:"link",b:"\\]\\(",e:"\\)",eB:!0,eE:!0},{cN:"symbol",b:"\\]\\[",e:"\\]",eB:!0,eE:!0}],r:10},{b:/^\[[^\n]+\]:/,rB:!0,c:[{cN:"symbol",b:/\[/,e:/\]/,eB:!0,eE:!0},{cN:"link",b:/:\s*/,e:/$/,eB:!0}]}]}}),hljs.g("javascript",function(e){var t="[A-Za-z$_][0-9A-Za-z$_]*",r={keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await static import from as",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},n={cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},a={cN:"subst",b:"\\$\\{",e:"\\}",k:r,c:[]},i={cN:"string",b:"`",e:"`",c:[e.BE,a]};a.c=[e.ASM,e.QSM,i,n,e.RM];var s=a.c.concat([e.CBCM,e.CLCM]);return{aliases:["js","jsx"],k:r,c:[{cN:"meta",r:10,b:/^\s*['"]use (strict|asm)['"]/},{cN:"meta",b:/^#!/,e:/$/},e.ASM,e.QSM,i,e.CLCM,e.CBCM,n,{b:/[{,]\s*/,r:0,c:[{b:t+"\\s*:",rB:!0,r:0,c:[{cN:"attr",b:t,r:0}]}]},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+t+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:t},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:r,c:s}]}]},{b://,sL:"xml",c:[{b:/<\w+\s*\/>/,skip:!0},{b:/<\w+/,e:/(\/\w+|\w+\/)>/,skip:!0,c:[{b:/<\w+\s*\/>/,skip:!0},"self"]}]}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[e.inherit(e.TM,{b:t}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,c:s}],i:/\[|%/},{b:/\$[(.]/},e.METHOD_GUARD,{cN:"class",bK:"class",e:/[{;=]/,eE:!0,i:/[:"\[\]]/,c:[{bK:"extends"},e.UTM]},{bK:"constructor",e:/\{/,eE:!0}],i:/#(?!!)/}}),hljs.g("lisp",function(e){var t="[a-zA-Z_\\-\\+\\*\\/\\<\\=\\>\\&\\#][a-zA-Z0-9_\\-\\+\\*\\/\\<\\=\\>\\&\\#!]*",r="\\|[^]*?\\|",n="(\\-|\\+)?\\d+(\\.\\d+|\\/\\d+)?((d|e|f|l|s|D|E|F|L|S)(\\+|\\-)?\\d+)?",a={cN:"meta",b:"^#!",e:"$"},i={cN:"literal",b:"\\b(t{1}|nil)\\b"},s={cN:"number",v:[{b:n,r:0},{b:"#(b|B)[0-1]+(/[0-1]+)?"},{b:"#(o|O)[0-7]+(/[0-7]+)?"},{b:"#(x|X)[0-9a-fA-F]+(/[0-9a-fA-F]+)?"},{b:"#(c|C)\\("+n+" +"+n,e:"\\)"}]},o=e.inherit(e.QSM,{i:null}),c=e.C(";","$",{r:0}),l={b:"\\*",e:"\\*"},u={cN:"symbol",b:"[:&]"+t},d={b:t,r:0},p={b:r},m={b:"\\(",e:"\\)",c:["self",i,o,s,d]},g={c:[s,o,l,u,m,d],v:[{b:"['`]\\(",e:"\\)"},{b:"\\(quote ",e:"\\)",k:{name:"quote"}},{b:"'"+r}]},b={v:[{b:"'"+t},{b:"#'"+t+"(::"+t+")*"}]},f={b:"\\(\\s*",e:"\\)"},h={eW:!0,r:0};return f.c=[{cN:"name",v:[{b:t},{b:r}]},h],h.c=[g,b,f,i,s,o,c,l,u,p,d],{i:/\S/,c:[s,a,i,o,c,g,b,f,d]}}),hljs.g("r",function(e){var t="([a-zA-Z]|\\.[a-zA-Z.])[a-zA-Z0-9._]*";return{c:[e.HCM,{b:t,l:t,k:{keyword:"function if in break next repeat else for return switch while try tryCatch stop warning require library attach detach source setMethod setGeneric setGroupGeneric setClass ...",literal:"NULL NA TRUE FALSE T F Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10"},r:0},{cN:"number",b:"0[xX][0-9a-fA-F]+[Li]?\\b",r:0},{cN:"number",b:"\\d+(?:[eE][+\\-]?\\d*)?L\\b",r:0},{cN:"number",b:"\\d+\\.(?!\\d)(?:i\\b)?",r:0},{cN:"number",b:"\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d*)?i?\\b",r:0},{cN:"number",b:"\\.\\d+(?:[eE][+\\-]?\\d*)?i?\\b",r:0},{b:"`",e:"`",r:0},{cN:"string",c:[e.BE],v:[{b:'"',e:'"'},{b:"'",e:"'"}]}]}}),hljs.g("go",function(e){var t={keyword:"break default func interface select case map struct chan else goto package switch const fallthrough if range type continue for import return var go defer bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 uint16 uint32 uint64 int uint uintptr rune",literal:"true false iota nil",built_in:"append cap close complex copy imag len make new panic print println real recover delete"};return{aliases:["golang"],k:t,i:"|<-"}]}}),hljs.g("bash",function(e){var t={cN:"variable",v:[{b:/\$[\w\d#@][\w\d_]*/},{b:/\$\{(.*?)}/}]},r={cN:"string",b:/"/,e:/"/,c:[e.BE,t,{cN:"variable",b:/\$\(/,e:/\)/,c:[e.BE]}]},n={cN:"string",b:/'/,e:/'/};return{aliases:["sh","zsh"],l:/\b-?[a-z\._]+\b/,k:{keyword:"if then else elif fi for while in do done case esac function",literal:"true false",built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp",_:"-ne -eq -lt -gt -f -d -e -s -l -a"},c:[{cN:"meta",b:/^#![^\n]+sh\s*$/,r:10},{cN:"function",b:/\w[\w\d_]*\s*\(\s*\)\s*\{/,rB:!0,c:[e.inherit(e.TM,{b:/\w[\w\d_]*/})],r:0},e.HCM,r,n,t]}}),hljs.g("java",function(e){var t="[\xc0-\u02b8a-zA-Z_$][\xc0-\u02b8a-zA-Z_$0-9]*",r=t+"(<"+t+"(\\s*,\\s*"+t+")*>)?",n="false synchronized int abstract float private char boolean static null if const for true while long strictfp finally protected import native final void enum else break transient catch instanceof byte super volatile case assert short package default double public try this switch continue throws protected public private module requires exports do",a="\\b(0[bB]([01]+[01_]+[01]+|[01]+)|0[xX]([a-fA-F0-9]+[a-fA-F0-9_]+[a-fA-F0-9]+|[a-fA-F0-9]+)|(([\\d]+[\\d_]+[\\d]+|[\\d]+)(\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))?|\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))([eE][-+]?\\d+)?)[lLfF]?",i={cN:"number",b:a,r:0};return{aliases:["jsp"],k:n,i:/<\/|#/,c:[e.C("/\\*\\*","\\*/",{r:0,c:[{b:/\w+@/,r:0},{cN:"doctag",b:"@[A-Za-z]+"}]}),e.CLCM,e.CBCM,e.ASM,e.QSM,{cN:"class",bK:"class interface",e:/[{;=]/,eE:!0,k:"class interface",i:/[:"\[\]]/,c:[{bK:"extends implements"},e.UTM]},{bK:"new throw return else",r:0},{cN:"function",b:"("+r+"\\s+)+"+e.UIR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:n,c:[{b:e.UIR+"\\s*\\(",rB:!0,r:0,c:[e.UTM]},{cN:"params",b:/\(/,e:/\)/,k:n,r:0,c:[e.ASM,e.QSM,e.CNM,e.CBCM]},e.CLCM,e.CBCM]},i,{cN:"meta",b:"@[A-Za-z]+"}]}}),hljs.g("perl",function(e){var t="getpwent getservent quotemeta msgrcv scalar kill dbmclose undef lc ma syswrite tr send umask sysopen shmwrite vec qx utime local oct semctl localtime readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qqfileno qw endprotoent wait sethostent bless s|0 opendir continue each sleep endgrent shutdown dump chomp connect getsockname die socketpair close flock exists index shmgetsub for endpwent redo lstat msgctl setpgrp abs exit select print ref gethostbyaddr unshift fcntl syscall goto getnetbyaddr join gmtime symlink semget splice x|0 getpeername recv log setsockopt cos last reverse gethostbyname getgrnam study formline endhostent times chop length gethostent getnetent pack getprotoent getservbyname rand mkdir pos chmod y|0 substr endnetent printf next open msgsnd readdir use unlink getsockopt getpriority rindex wantarray hex system getservbyport endservent int chr untie rmdir prototype tell listen fork shmread ucfirst setprotoent else sysseek link getgrgid shmctl waitpid unpack getnetbyname reset chdir grep split require caller lcfirst until warn while values shift telldir getpwuid my getprotobynumber delete and sort uc defined srand accept package seekdir getprotobyname semop our rename seek if q|0 chroot sysread setpwent no crypt getc chown sqrt write setnetent setpriority foreach tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedirioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when",r={cN:"subst",b:"[$@]\\{",e:"\\}",k:t},n={b:"->{",e:"}"},a={v:[{b:/\$\d/},{b:/[\$%@](\^\w\b|#\w+(::\w+)*|{\w+}|\w+(::\w*)*)/},{b:/[\$%@][^\s\w{]/,r:0}]},i=[e.BE,r,a],s=[a,e.HCM,e.C("^\\=\\w","\\=cut",{eW:!0}),n,{cN:"string",c:i,v:[{b:"q[qwxr]?\\s*\\(",e:"\\)",r:5},{b:"q[qwxr]?\\s*\\[",e:"\\]",r:5},{b:"q[qwxr]?\\s*\\{",e:"\\}",r:5},{b:"q[qwxr]?\\s*\\|",e:"\\|",r:5},{b:"q[qwxr]?\\s*\\<",e:"\\>",r:5},{b:"qw\\s+q",e:"q",r:5},{b:"'",e:"'",c:[e.BE]},{b:'"',e:'"'},{b:"`",e:"`",c:[e.BE]},{b:"{\\w+}",c:[],r:0},{b:"-?\\w+\\s*\\=\\>",c:[],r:0}]},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{b:"(\\/\\/|"+e.RSR+"|\\b(split|return|print|reverse|grep)\\b)\\s*",k:"split return print reverse grep",r:0,c:[e.HCM,{cN:"regexp",b:"(s|tr|y)/(\\\\.|[^/])*/(\\\\.|[^/])*/[a-z]*",r:10},{cN:"regexp",b:"(m|qr)?/",e:"/[a-z]*",c:[e.BE],r:0}]},{cN:"function",bK:"sub",e:"(\\s*\\(.*?\\))?[;{]",eE:!0,r:5,c:[e.TM]},{b:"-\\w\\b",r:0},{b:"^__DATA__$",e:"^__END__$",sL:"mojolicious",c:[{b:"^@@.*",e:"$",cN:"comment"}]}];return r.c=s,n.c=s,{aliases:["pl","pm"],l:/[\w\.]+/,k:t,c:s}}),hljs.g("coffeescript",function(e){var t={keyword:"in if for while finally new do return else break catch instanceof throw try this switch continue typeof delete debugger super yield import export from as default await then unless until loop of by when and or is isnt not",literal:"true false null undefined yes no on off",built_in:"npm require console print module global window document"},r="[A-Za-z$_][0-9A-Za-z$_]*",n={cN:"subst",b:/#\{/,e:/}/,k:t},a=[e.BNM,e.inherit(e.CNM,{starts:{e:"(\\s*/)?",r:0}}),{cN:"string",v:[{b:/'''/,e:/'''/,c:[e.BE]},{b:/'/,e:/'/,c:[e.BE]},{b:/"""/,e:/"""/,c:[e.BE,n]},{b:/"/,e:/"/,c:[e.BE,n]}]},{cN:"regexp",v:[{b:"///",e:"///",c:[n,e.HCM]},{b:"//[gim]*",r:0},{b:/\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/}]},{b:"@"+r},{sL:"javascript",eB:!0,eE:!0,v:[{b:"```",e:"```"},{b:"`",e:"`"}]}];n.c=a;var i=e.inherit(e.TM,{b:r}),s="(\\(.*\\))?\\s*\\B[-=]>",o={cN:"params",b:"\\([^\\(]",rB:!0,c:[{b:/\(/,e:/\)/,k:t,c:["self"].concat(a)}]};return{aliases:["coffee","cson","iced"],k:t,i:/\/\*/,c:a.concat([e.C("###","###"),e.HCM,{cN:"function",b:"^\\s*"+r+"\\s*=\\s*"+s,e:"[-=]>",rB:!0,c:[i,o]},{b:/[:\(,=]\s*/,r:0,c:[{cN:"function",b:s,e:"[-=]>",rB:!0,c:[o]}]},{cN:"class",bK:"class",e:"$",i:/[:="\[\]]/,c:[{bK:"extends",eW:!0,i:/[:="\[\]]/,c:[i]},i]},{b:r+":",e:":",rB:!0,rE:!0,r:0}])}}),hljs.g("kotlin",function(e){var t={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit initinterface annotation data sealed internal infix operator out by constructor super trait volatile transient native default",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},r={cN:"keyword",b:/\b(break|continue|return|this)\b/,starts:{c:[{cN:"symbol",b:/@\w+/}]}},n={cN:"symbol",b:e.UIR+"@"},a={cN:"subst",b:"\\${",e:"}",c:[e.ASM,e.CNM]},i={cN:"variable",b:"\\$"+e.UIR},s={cN:"string",v:[{b:'"""',e:'"""',c:[i,a]},{b:"'",e:"'",i:/\n/,c:[e.BE]},{b:'"',e:'"',i:/\n/,c:[e.BE,i,a]}]},o={cN:"meta",b:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UIR+")?"},c={cN:"meta",b:"@"+e.UIR,c:[{b:/\(/,e:/\)/,c:[e.inherit(s,{cN:"meta-string"})]}]};return{k:t,c:[e.C("/\\*\\*","\\*/",{r:0,c:[{cN:"doctag",b:"@[A-Za-z]+"}]}),e.CLCM,e.CBCM,r,n,o,c,{cN:"function",bK:"fun",e:"[(]|$",rB:!0,eE:!0,k:t,i:/fun\s+(<.*>)?[^\s\(]+(\s+[^\s\(]+)\s*=/,r:5,c:[{b:e.UIR+"\\s*\\(",rB:!0,r:0,c:[e.UTM]},{cN:"type",b://,k:"reified",r:0},{cN:"params",b:/\(/,e:/\)/,endsParent:!0,k:t,r:0,c:[{b:/:/,e:/[=,\/]/,eW:!0,c:[{cN:"type",b:e.UIR},e.CLCM,e.CBCM],r:0},e.CLCM,e.CBCM,o,c,s,e.CNM]},e.CBCM]},{cN:"class",bK:"class interface trait",e:/[:\{(]|$/,eE:!0,i:"extends implements",c:[{bK:"public protected internal private constructor"},e.UTM,{cN:"type",b://,eB:!0,eE:!0,r:0},{cN:"type",b:/[,:]\s*/,e:/[<\(,]|$/,eB:!0,rE:!0},o,c]},s,{cN:"meta",b:"^#!/usr/bin/env",e:"$",i:"\n"},e.CNM]}}),hljs.g("ruby",function(e){var t="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?",r={keyword:"and then defined module in return redo if BEGIN retry end for self when next until do begin unless END rescue else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor",literal:"true false nil"},n={cN:"doctag",b:"@[A-Za-z]+"},a={b:"#<",e:">"},i=[e.C("#","$",{c:[n]}),e.C("^\\=begin","^\\=end",{c:[n],r:10}),e.C("^__END__","\\n$")],s={cN:"subst",b:"#\\{",e:"}",k:r},o={cN:"string",c:[e.BE,s],v:[{b:/'/,e:/'/},{b:/"/,e:/"/},{b:/`/,e:/`/},{b:"%[qQwWx]?\\(",e:"\\)"},{b:"%[qQwWx]?\\[",e:"\\]"},{b:"%[qQwWx]?{",e:"}"},{b:"%[qQwWx]?<",e:">"},{b:"%[qQwWx]?/",e:"/"},{b:"%[qQwWx]?%",e:"%"},{b:"%[qQwWx]?-",e:"-"},{b:"%[qQwWx]?\\|",e:"\\|"},{b:/\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/},{b:/<<(-?)\w+$/,e:/^\s*\w+$/}]},c={cN:"params",b:"\\(",e:"\\)",endsParent:!0,k:r},l=[o,a,{cN:"class",bK:"class module",e:"$|;",i:/=/,c:[e.inherit(e.TM,{b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?"}),{b:"<\\s*",c:[{b:"("+e.IR+"::)?"+e.IR}]}].concat(i)},{cN:"function",bK:"def",e:"$|;",c:[e.inherit(e.TM,{b:t}),c].concat(i)},{b:e.IR+"::"},{cN:"symbol",b:e.UIR+"(\\!|\\?)?:",r:0},{cN:"symbol",b:":(?!\\s)",c:[o,{b:t}],r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},{cN:"params",b:/\|/,e:/\|/,k:r},{b:"("+e.RSR+"|unless)\\s*",k:"unless",c:[a,{cN:"regexp",c:[e.BE,s],i:/\n/,v:[{b:"/",e:"/[a-z]*"},{b:"%r{",e:"}[a-z]*"},{b:"%r\\(",e:"\\)[a-z]*"},{b:"%r!",e:"![a-z]*"},{b:"%r\\[",e:"\\][a-z]*"}]}].concat(i),r:0}].concat(i);s.c=l,c.c=l;var u="[>?]>",d="[\\w#]+\\(\\w+\\):\\d+:\\d+>",p="(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>",m=[{ +b:/^\s*=>/,starts:{e:"$",c:l}},{cN:"meta",b:"^("+u+"|"+d+"|"+p+")",starts:{e:"$",c:l}}];return{aliases:["rb","gemspec","podspec","thor","irb"],k:r,i:/\/\*/,c:i.concat(m).concat(l)}}),hljs.g("css",function(e){var t="[a-zA-Z-][a-zA-Z0-9_-]*",r={b:/[A-Z\_\.\-]+\s*:/,rB:!0,e:";",eW:!0,c:[{cN:"attribute",b:/\S/,e:":",eE:!0,starts:{eW:!0,eE:!0,c:[{b:/[\w-]+\(/,rB:!0,c:[{cN:"built_in",b:/[\w-]+/},{b:/\(/,e:/\)/,c:[e.ASM,e.QSM]}]},e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"number",b:"#[0-9A-Fa-f]+"},{cN:"meta",b:"!important"}]}}]};return{cI:!0,i:/[=\/|'\$]/,c:[e.CBCM,{cN:"selector-id",b:/#[A-Za-z0-9_-]+/},{cN:"selector-class",b:/\.[A-Za-z0-9_-]+/},{cN:"selector-attr",b:/\[/,e:/\]/,i:"$"},{cN:"selector-pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{b:"@",e:"[{;]",i:/:/,c:[{cN:"keyword",b:/\w+/},{b:/\s/,eW:!0,eE:!0,r:0,c:[e.ASM,e.QSM,e.CSSNM]}]},{cN:"selector-tag",b:t,r:0},{b:"{",e:"}",i:/\S/,c:[e.CBCM,r]}]}}),hljs.g("cpp",function(e){var t={cN:"keyword",b:"\\b[a-z\\d_]*_t\\b"},r={cN:"string",v:[{b:'(u8?|U)?L?"',e:'"',i:"\\n",c:[e.BE]},{b:'(u8?|U)?R"',e:'"',c:[e.BE]},{b:"'\\\\?.",e:"'",i:"."}]},n={cN:"number",v:[{b:"\\b(0b[01']+)"},{b:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{b:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],r:0},a={cN:"meta",b:/#\s*[a-z]+\b/,e:/$/,k:{"meta-keyword":"if else elif endif define undef warning error line pragma ifdef ifndef include"},c:[{b:/\\\n/,r:0},e.inherit(r,{cN:"meta-string"}),{cN:"meta-string",b:/<[^\n>]*>/,e:/$/,i:"\\n"},e.CLCM,e.CBCM]},i=e.IR+"\\s*\\(",s={keyword:"int float while private char catch import module export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using asm case typeid short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignof constexpr decltype noexcept static_assert thread_local restrict _Bool complex _Complex _Imaginary atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong new throw return and or not",built_in:"std string cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap array shared_ptr abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr",literal:"true false nullptr NULL"},o=[t,e.CLCM,e.CBCM,n,r];return{aliases:["c","cc","h","c++","h++","hpp"],k:s,i:"",k:s,c:["self",t]},{b:e.IR+"::",k:s},{v:[{b:/=/,e:/;/},{b:/\(/,e:/\)/},{bK:"new throw return else",e:/;/}],k:s,c:o.concat([{b:/\(/,e:/\)/,k:s,c:o.concat(["self"]),r:0}]),r:0},{cN:"function",b:"("+e.IR+"[\\*&\\s]+)+"+i,rB:!0,e:/[{;=]/,eE:!0,k:s,i:/[^\w\s\*&]/,c:[{b:i,rB:!0,c:[e.TM],r:0},{cN:"params",b:/\(/,e:/\)/,k:s,r:0,c:[e.CLCM,e.CBCM,r,n,t]},e.CLCM,e.CBCM,a]},{cN:"class",bK:"class struct",e:/[{;:]/,c:[{b://,c:["self"]},e.TM]}]),exports:{preprocessor:a,strings:r,k:s}}}),hljs.g("typescript",function(e){var t={keyword:"in if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const class public private protected get set super static implements enum export import declare type namespace abstract as from extends async await",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document any number boolean string void Promise"};return{aliases:["ts"],k:t,c:[{cN:"meta",b:/^\s*['"]use strict['"]/},e.ASM,e.QSM,{cN:"string",b:"`",e:"`",c:[e.BE,{cN:"subst",b:"\\$\\{",e:"\\}"}]},e.CLCM,e.CBCM,{cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+e.IR+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:e.IR},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:t,c:["self",e.CLCM,e.CBCM]}]}]}],r:0},{cN:"function",b:"function",e:/[\{;]/,eE:!0,k:t,c:["self",e.inherit(e.TM,{b:/[A-Za-z$_][0-9A-Za-z$_]*/}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:t,c:[e.CLCM,e.CBCM],i:/["'\(]/}],i:/%/,r:0},{bK:"constructor",e:/\{/,eE:!0,c:["self",{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:t,c:[e.CLCM,e.CBCM],i:/["'\(]/}]},{b:/module\./,k:{built_in:"module"},r:0},{bK:"module",e:/\{/,eE:!0},{bK:"interface",e:/\{/,eE:!0,k:"interface extends"},{b:/\$[(.]/},{b:"\\."+e.IR,r:0},{cN:"meta",b:"@[A-Za-z]+"}]}}),hljs.g("shell",function(e){return{aliases:["console"],c:[{cN:"meta",b:"^\\s{0,3}[\\w\\d\\[\\]()@-]*[>%$#]",starts:{e:"$",sL:"bash"}}]}}),hljs.g("rust",function(e){var t="([ui](8|16|32|64|128|size)|f(32|64))?",r="alignof as be box break const continue crate do else enum extern false fn for if impl in let loop match mod mut offsetof once priv proc pub pure ref return self Self sizeof static struct super trait true type typeof unsafe unsized use virtual while where yield move default",n="drop i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize f32 f64 str char bool Box Option Result String Vec Copy Send Sized Sync Drop Fn FnMut FnOnce ToOwned Clone Debug PartialEq PartialOrd Eq Ord AsRef AsMut Into From Default Iterator Extend IntoIterator DoubleEndedIterator ExactSizeIterator SliceConcatExt ToString assert! assert_eq! bitflags! bytes! cfg! col! concat! concat_idents! debug_assert! debug_assert_eq! env! panic! file! format! format_args! include_bin! include_str! line! local_data_key! module_path! option_env! print! println! select! stringify! try! unimplemented! unreachable! vec! write! writeln! macro_rules! assert_ne! debug_assert_ne!";return{aliases:["rs"],k:{keyword:r,literal:"true false Some None Ok Err",built_in:n},l:e.IR+"!?",i:""}]}}),hljs.g("objectivec",function(e){var t={cN:"built_in",b:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},r={keyword:"int float while char export sizeof typedef const struct for union unsigned long volatile static bool mutable if do return goto void enum else break extern asm case short default double register explicit signed typename this switch continue wchar_t inline readonly assign readwrite self @synchronized id typeof nonatomic super unichar IBOutlet IBAction strong weak copy in out inout bycopy byref oneway __strong __weak __block __autoreleasing @private @protected @public @try @property @end @throw @catch @finally @autoreleasepool @synthesize @dynamic @selector @optional @required @encode @package @import @defs @compatibility_alias __bridge __bridge_transfer __bridge_retained __bridge_retain __covariant __contravariant __kindof _Nonnull _Nullable _Null_unspecified __FUNCTION__ __PRETTY_FUNCTION__ __attribute__ getter setter retain unsafe_unretained nonnull nullable null_unspecified null_resettable class instancetype NS_DESIGNATED_INITIALIZER NS_UNAVAILABLE NS_REQUIRES_SUPER NS_RETURNS_INNER_POINTER NS_INLINE NS_AVAILABLE NS_DEPRECATED NS_ENUM NS_OPTIONS NS_SWIFT_UNAVAILABLE NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END NS_REFINED_FOR_SWIFT NS_SWIFT_NAME NS_SWIFT_NOTHROW NS_DURING NS_HANDLER NS_ENDHANDLER NS_VALUERETURN NS_VOIDRETURN",literal:"false true FALSE TRUE nil YES NO NULL",built_in:"BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,a="@interface @class @protocol @implementation";return{aliases:["mm","objc","obj-c"],k:r,l:n,i:""}]}]},{cN:"class",b:"("+a.split(" ").join("|")+")\\b",e:"({|$)",eE:!0,k:a,l:n,c:[e.UTM]},{b:"\\."+e.UIR,r:0}]}}),hljs.g("tex",function(e){var t={cN:"tag",b:/\\/,r:0,c:[{cN:"name",v:[{b:/[a-zA-Z\u0430-\u044f\u0410-\u044f]+[*]?/},{b:/[^a-zA-Z\u0430-\u044f\u0410-\u044f0-9]/}],starts:{eW:!0,r:0,c:[{cN:"string",v:[{b:/\[/,e:/\]/},{b:/\{/,e:/\}/}]},{b:/\s*=\s*/,eW:!0,r:0,c:[{cN:"number",b:/-?\d*\.?\d+(pt|pc|mm|cm|in|dd|cc|ex|em)?/}]}]}}]};return{c:[t,{cN:"formula",c:[t],r:0,v:[{b:/\$\$/,e:/\$\$/},{b:/\$/,e:/\$/}]},e.C("%","$",{r:0})]}}),hljs.g("makefile",function(e){var t={cN:"variable",v:[{b:"\\$\\("+e.UIR+"\\)",c:[e.BE]},{b:/\$[@%>>|\.\.\.) /},n={cN:"subst",b:/\{/,e:/\}/,k:t,i:/#/},a={cN:"string",c:[e.BE],v:[{b:/(u|b)?r?'''/,e:/'''/,c:[r],r:10},{b:/(u|b)?r?"""/,e:/"""/,c:[r],r:10},{b:/(fr|rf|f)'''/,e:/'''/,c:[r,n]},{b:/(fr|rf|f)"""/,e:/"""/,c:[r,n]},{b:/(u|r|ur)'/,e:/'/,r:10},{b:/(u|r|ur)"/,e:/"/,r:10},{b:/(b|br)'/,e:/'/},{b:/(b|br)"/,e:/"/},{b:/(fr|rf|f)'/,e:/'/,c:[n]},{b:/(fr|rf|f)"/,e:/"/,c:[n]},e.ASM,e.QSM]},i={cN:"number",r:0,v:[{b:e.BNR+"[lLjJ]?"},{b:"\\b(0o[0-7]+)[lLjJ]?"},{b:e.CNR+"[lLjJ]?"}]},s={cN:"params",b:/\(/,e:/\)/,c:["self",r,i,a]};return n.c=[a,i,r],{aliases:["py","gyp"],k:t,i:/(<\/|->|\?)|=>/,c:[r,i,a,e.HCM,{v:[{cN:"function",bK:"def"},{cN:"class",bK:"class"}],e:/:/,i:/[${=;\n,]/,c:[e.UTM,s,{b:/->/,eW:!0,k:"None"}]},{cN:"meta",b:/^[\t ]*@/,e:/$/},{b:/\b(print|exec)\(/}]}}),hljs.g("json",function(e){var t={literal:"true false null"},r=[e.QSM,e.CNM],n={e:",",eW:!0,eE:!0,c:r,k:t},a={b:"{",e:"}",c:[{cN:"attr",b:/"/,e:/"/,c:[e.BE],i:"\\n"},e.inherit(n,{b:/:/})],i:"\\S"},i={b:"\\[",e:"\\]",c:[e.inherit(n)],i:"\\S"};return r.splice(r.length,0,a,i),{c:r,k:t,i:"\\S"}}),hljs.g("armasm",function(e){return{cI:!0,aliases:["arm"],l:"\\.?"+e.IR,k:{meta:".2byte .4byte .align .ascii .asciz .balign .byte .code .data .else .end .endif .endm .endr .equ .err .exitm .extern .global .hword .if .ifdef .ifndef .include .irp .long .macro .rept .req .section .set .skip .space .text .word .arm .thumb .code16 .code32 .force_thumb .thumb_func .ltorg ALIAS ALIGN ARM AREA ASSERT ATTR CN CODE CODE16 CODE32 COMMON CP DATA DCB DCD DCDU DCDO DCFD DCFDU DCI DCQ DCQU DCW DCWU DN ELIF ELSE END ENDFUNC ENDIF ENDP ENTRY EQU EXPORT EXPORTAS EXTERN FIELD FILL FUNCTION GBLA GBLL GBLS GET GLOBAL IF IMPORT INCBIN INCLUDE INFO KEEP LCLA LCLL LCLS LTORG MACRO MAP MEND MEXIT NOFP OPT PRESERVE8 PROC QN READONLY RELOC REQUIRE REQUIRE8 RLIST FN ROUT SETA SETL SETS SN SPACE SUBT THUMB THUMBX TTL WHILE WEND ",built_in:"r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 pc lr sp ip sl sb fp a1 a2 a3 a4 v1 v2 v3 v4 v5 v6 v7 v8 f0 f1 f2 f3 f4 f5 f6 f7 p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 q0 q1 q2 q3 q4 q5 q6 q7 q8 q9 q10 q11 q12 q13 q14 q15 cpsr_c cpsr_x cpsr_s cpsr_f cpsr_cx cpsr_cxs cpsr_xs cpsr_xsf cpsr_sf cpsr_cxsf spsr_c spsr_x spsr_s spsr_f spsr_cx spsr_cxs spsr_xs spsr_xsf spsr_sf spsr_cxsf s0 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 s17 s18 s19 s20 s21 s22 s23 s24 s25 s26 s27 s28 s29 s30 s31 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d12 d13 d14 d15 d16 d17 d18 d19 d20 d21 d22 d23 d24 d25 d26 d27 d28 d29 d30 d31 {PC} {VAR} {TRUE} {FALSE} {OPT} {CONFIG} {ENDIAN} {CODESIZE} {CPU} {FPU} {ARCHITECTURE} {PCSTOREOFFSET} {ARMASM_VERSION} {INTER} {ROPI} {RWPI} {SWST} {NOSWST} . @"},c:[{cN:"keyword",b:"\\b(adc|(qd?|sh?|u[qh]?)?add(8|16)?|usada?8|(q|sh?|u[qh]?)?(as|sa)x|and|adrl?|sbc|rs[bc]|asr|b[lx]?|blx|bxj|cbn?z|tb[bh]|bic|bfc|bfi|[su]bfx|bkpt|cdp2?|clz|clrex|cmp|cmn|cpsi[ed]|cps|setend|dbg|dmb|dsb|eor|isb|it[te]{0,3}|lsl|lsr|ror|rrx|ldm(([id][ab])|f[ds])?|ldr((s|ex)?[bhd])?|movt?|mvn|mra|mar|mul|[us]mull|smul[bwt][bt]|smu[as]d|smmul|smmla|mla|umlaal|smlal?([wbt][bt]|d)|mls|smlsl?[ds]|smc|svc|sev|mia([bt]{2}|ph)?|mrr?c2?|mcrr2?|mrs|msr|orr|orn|pkh(tb|bt)|rbit|rev(16|sh)?|sel|[su]sat(16)?|nop|pop|push|rfe([id][ab])?|stm([id][ab])?|str(ex)?[bhd]?|(qd?)?sub|(sh?|q|u[qh]?)?sub(8|16)|[su]xt(a?h|a?b(16)?)|srs([id][ab])?|swpb?|swi|smi|tst|teq|wfe|wfi|yield)(eq|ne|cs|cc|mi|pl|vs|vc|hi|ls|ge|lt|gt|le|al|hs|lo)?[sptrx]?",e:"\\s"},e.C("[;@]","$",{r:0}),e.CBCM,e.QSM,{cN:"string",b:"'",e:"[^\\\\]'",r:0},{cN:"title",b:"\\|",e:"\\|",i:"\\n",r:0},{cN:"number",v:[{b:"[#$=]?0x[0-9a-f]+"},{b:"[#$=]?0b[01]+"},{b:"[#$=]\\d+"},{b:"\\b\\d+"}],r:0},{cN:"symbol",v:[{b:"^[a-z_\\.\\$][a-z0-9_\\.\\$]+"},{b:"^\\s*[a-z_\\.\\$][a-z0-9_\\.\\$]+:"},{b:"[=#]\\w+"}],r:0}]}}),hljs.g("cs",function(e){var t={keyword:"abstract as base bool break byte case catch char checked const continue decimal default delegate do double enum event explicit extern finally fixed float for foreach goto if implicit in int interface internal is lock long nameof object operator out override params private protected public readonly ref sbyte sealed short sizeof stackalloc static string struct switch this try typeof uint ulong unchecked unsafe ushort using virtual void volatile while add alias ascending async await by descending dynamic equals from get global group into join let on orderby partial remove select set value var where yield",literal:"null false true"},r={cN:"string",b:'@"',e:'"',c:[{b:'""'}]},n=e.inherit(r,{i:/\n/}),a={cN:"subst",b:"{",e:"}",k:t},i=e.inherit(a,{i:/\n/}),s={cN:"string",b:/\$"/,e:'"',i:/\n/,c:[{b:"{{"},{b:"}}"},e.BE,i]},o={cN:"string",b:/\$@"/,e:'"',c:[{b:"{{"},{b:"}}"},{b:'""'},a]},c=e.inherit(o,{i:/\n/,c:[{b:"{{"},{b:"}}"},{b:'""'},i]});a.c=[o,s,r,e.ASM,e.QSM,e.CNM,e.CBCM],i.c=[c,s,n,e.ASM,e.QSM,e.CNM,e.inherit(e.CBCM,{i:/\n/})];var l={v:[o,s,r,e.ASM,e.QSM]},u=e.IR+"(<"+e.IR+"(\\s*,\\s*"+e.IR+")*>)?(\\[\\])?";return{aliases:["csharp"],k:t,i:/::/,c:[e.C("///","$",{rB:!0,c:[{cN:"doctag",v:[{b:"///",r:0},{b:""},{b:""}]}]}),e.CLCM,e.CBCM,{cN:"meta",b:"#",e:"$",k:{"meta-keyword":"if else elif endif define undef warning error line region endregion pragma checksum"}},l,e.CNM,{bK:"class interface",e:/[{;=]/,i:/[^\s:]/,c:[e.TM,e.CLCM,e.CBCM]},{bK:"namespace",e:/[{;=]/,i:/[^\s:]/,c:[e.inherit(e.TM,{b:"[a-zA-Z](\\.?\\w)*"}),e.CLCM,e.CBCM]},{cN:"meta",b:"^\\s*\\[",eB:!0,e:"\\]",eE:!0,c:[{cN:"meta-string",b:/"/,e:/"/}]},{bK:"new return throw await else",r:0},{cN:"function",b:"("+u+"\\s+)+"+e.IR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:t,c:[{b:e.IR+"\\s*\\(",rB:!0,c:[e.TM],r:0},{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:t,r:0,c:[l,e.CNM,e.CBCM]},e.CLCM,e.CBCM]}]}}),hljs.g("matlab",function(e){var t=[e.CNM,{cN:"string",b:"'",e:"'",c:[e.BE,{b:"''"}]}],r={r:0,c:[{b:/'['\.]*/}]};return{k:{keyword:"break case catch classdef continue else elseif end enumerated events for function global if methods otherwise parfor persistent properties return spmd switch try while",built_in:"sin sind sinh asin asind asinh cos cosd cosh acos acosd acosh tan tand tanh atan atand atan2 atanh sec secd sech asec asecd asech csc cscd csch acsc acscd acsch cot cotd coth acot acotd acoth hypot exp expm1 log log1p log10 log2 pow2 realpow reallog realsqrt sqrt nthroot nextpow2 abs angle complex conj imag real unwrap isreal cplxpair fix floor ceil round mod rem sign airy besselj bessely besselh besseli besselk beta betainc betaln ellipj ellipke erf erfc erfcx erfinv expint gamma gammainc gammaln psi legendre cross dot factor isprime primes gcd lcm rat rats perms nchoosek factorial cart2sph cart2pol pol2cart sph2cart hsv2rgb rgb2hsv zeros ones eye repmat rand randn linspace logspace freqspace meshgrid accumarray size length ndims numel disp isempty isequal isequalwithequalnans cat reshape diag blkdiag tril triu fliplr flipud flipdim rot90 find sub2ind ind2sub bsxfun ndgrid permute ipermute shiftdim circshift squeeze isscalar isvector ans eps realmax realmin pi i inf nan isnan isinf isfinite j why compan gallery hadamard hankel hilb invhilb magic pascal rosser toeplitz vander wilkinson"},i:'(//|"|#|/\\*|\\s+/\\w+)',c:[{cN:"function",bK:"function",e:"$",c:[e.UTM,{cN:"params",v:[{b:"\\(",e:"\\)"},{b:"\\[",e:"\\]"}]}]},{b:/[a-zA-Z_][a-zA-Z_0-9]*'['\.]*/,rB:!0,r:0,c:[{b:/[a-zA-Z_][a-zA-Z_0-9]*/,r:0},r.c[0]]},{b:"\\[",e:"\\]",c:t,r:0,starts:r},{b:"\\{",e:/}/,c:t,r:0,starts:r},{b:/\)/,r:0,starts:r},e.C("^\\s*\\%\\{\\s*$","^\\s*\\%\\}\\s*$"),e.C("\\%","$")].concat(t)}}),hljs.g("swift",function(e){var t={keyword:"__COLUMN__ __FILE__ __FUNCTION__ __LINE__ as as! as? associativity break case catch class continue convenience default defer deinit didSet do dynamic dynamicType else enum extension fallthrough false fileprivate final for func get guard if import in indirect infix init inout internal is lazy left let mutating nil none nonmutating open operator optional override postfix precedence prefix private protocol Protocol public repeat required rethrows return right self Self set static struct subscript super switch throw throws true try try! try? Type typealias unowned var weak where while willSet",literal:"true false nil",built_in:"abs advance alignof alignofValue anyGenerator assert assertionFailure bridgeFromObjectiveC bridgeFromObjectiveCUnconditional bridgeToObjectiveC bridgeToObjectiveCUnconditional c contains count countElements countLeadingZeros debugPrint debugPrintln distance dropFirst dropLast dump encodeBitsAsWords enumerate equal fatalError filter find getBridgedObjectiveCType getVaList indices insertionSort isBridgedToObjectiveC isBridgedVerbatimToObjectiveC isUniquelyReferenced isUniquelyReferencedNonObjC join lazy lexicographicalCompare map max maxElement min minElement numericCast overlaps partition posix precondition preconditionFailure print println quickSort readLine reduce reflect reinterpretCast reverse roundUpToAlignment sizeof sizeofValue sort split startsWith stride strideof strideofValue swap toString transcode underestimateCount unsafeAddressOf unsafeBitCast unsafeDowncast unsafeUnwrap unsafeReflect withExtendedLifetime withObjectAtPlusZero withUnsafePointer withUnsafePointerToObject withUnsafeMutablePointer withUnsafeMutablePointers withUnsafePointer withUnsafePointers withVaList zip"},r={cN:"type",b:"\\b[A-Z][\\w\xc0-\u02b8']*",r:0},n=e.C("/\\*","\\*/",{c:["self"]}),a={cN:"subst",b:/\\\(/,e:"\\)",k:t,c:[]},i={cN:"number",b:"\\b([\\d_]+(\\.[\\deE_]+)?|0x[a-fA-F0-9_]+(\\.[a-fA-F0-9p_]+)?|0b[01_]+|0o[0-7_]+)\\b",r:0},s=e.inherit(e.QSM,{c:[a,e.BE]});return a.c=[i],{k:t,c:[s,e.CLCM,n,r,i,{cN:"function",bK:"func",e:"{",eE:!0,c:[e.inherit(e.TM,{b:/[A-Za-z$_][0-9A-Za-z$_]*/}),{b://},{cN:"params",b:/\(/,e:/\)/,endsParent:!0,k:t,c:["self",i,s,e.CBCM,{b:":"}],i:/["']/}],i:/\[|%/},{cN:"class",bK:"struct protocol class extension enum",k:t,e:"\\{",eE:!0,c:[e.inherit(e.TM,{b:/[A-Za-z$_][\u00C0-\u02B80-9A-Za-z$_]*/})]},{cN:"meta",b:"(@warn_unused_result|@exported|@lazy|@noescape|@NSCopying|@NSManaged|@objc|@convention|@required|@noreturn|@IBAction|@IBDesignable|@IBInspectable|@IBOutlet|@infix|@prefix|@postfix|@autoclosure|@testable|@available|@nonobjc|@NSApplicationMain|@UIApplicationMain)"},{bK:"import",e:/$/,c:[e.CLCM,n]}]}}),hljs.g("scheme",function(e){var t="[^\\(\\)\\[\\]\\{\\}\",'`;#|\\\\\\s]+",r="(\\-|\\+)?\\d+([./]\\d+)?",n=r+"[+\\-]"+r+"i",a={"builtin-name":"case-lambda call/cc class define-class exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules ' * + , ,@ - ... / ; < <= = => > >= ` abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string=? string>? string? substring symbol->string symbol? tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?" +},i={cN:"meta",b:"^#!",e:"$"},s={cN:"literal",b:"(#t|#f|#\\\\"+t+"|#\\\\.)"},o={cN:"number",v:[{b:r,r:0},{b:n,r:0},{b:"#b[0-1]+(/[0-1]+)?"},{b:"#o[0-7]+(/[0-7]+)?"},{b:"#x[0-9a-f]+(/[0-9a-f]+)?"}]},c=e.QSM,l=[e.C(";","$",{r:0}),e.C("#\\|","\\|#")],u={b:t,r:0},d={cN:"symbol",b:"'"+t},p={eW:!0,r:0},m={v:[{b:/'/},{b:"`"}],c:[{b:"\\(",e:"\\)",c:["self",s,c,o,u,d]}]},g={cN:"name",b:t,l:t,k:a},b={b:/lambda/,eW:!0,rB:!0,c:[g,{b:/\(/,e:/\)/,endsParent:!0,c:[u]}]},f={v:[{b:"\\(",e:"\\)"},{b:"\\[",e:"\\]"}],c:[b,g,p]};return p.c=[s,o,c,u,d,m,f].concat(l),{i:/\S/,c:[i,o,c,d,m,f].concat(l)}}),hljs.g("php",function(e){var t={b:"\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*"},r={cN:"meta",b:/<\?(php)?|\?>/},n={cN:"string",c:[e.BE,r],v:[{b:'b"',e:'"'},{b:"b'",e:"'"},e.inherit(e.ASM,{i:null}),e.inherit(e.QSM,{i:null})]},a={v:[e.BNM,e.CNM]};return{aliases:["php3","php4","php5","php6"],cI:!0,k:"and include_once list abstract global private echo interface as static endswitch array null if endwhile or const for endforeach self var while isset public protected exit foreach throw elseif include __FILE__ empty require_once do xor return parent clone use __CLASS__ __LINE__ else break print eval new catch __METHOD__ case exception default die require __FUNCTION__ enddeclare final try switch continue endfor endif declare unset true false trait goto instanceof insteadof __DIR__ __NAMESPACE__ yield finally",c:[e.HCM,e.C("//","$",{c:[r]}),e.C("/\\*","\\*/",{c:[{cN:"doctag",b:"@[A-Za-z]+"}]}),e.C("__halt_compiler.+?;",!1,{eW:!0,k:"__halt_compiler",l:e.UIR}),{cN:"string",b:/<<<['"]?\w+['"]?$/,e:/^\w+;?$/,c:[e.BE,{cN:"subst",v:[{b:/\$\w+/},{b:/\{\$/,e:/\}/}]}]},r,{cN:"keyword",b:/\$this\b/},t,{b:/(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/},{cN:"function",bK:"function",e:/[;{]/,eE:!0,i:"\\$|\\[|%",c:[e.UTM,{cN:"params",b:"\\(",e:"\\)",c:["self",t,e.CBCM,n,a]}]},{cN:"class",bK:"class interface",e:"{",eE:!0,i:/[:\(\$"]/,c:[{bK:"extends implements"},e.UTM]},{bK:"namespace",e:";",i:/[\.']/,c:[e.UTM]},{bK:"use",e:";",c:[e.UTM]},{b:"=>"},n,a]}}),hljs.g("http",function(e){var t="HTTP/[0-9\\.]+";return{aliases:["https"],i:"\\S",c:[{b:"^"+t,e:"$",c:[{cN:"number",b:"\\b\\d{3}\\b"}]},{b:"^[A-Z]+ (.*?) "+t+"$",rB:!0,e:"$",c:[{cN:"string",b:" ",e:" ",eB:!0,eE:!0},{b:t},{cN:"keyword",b:"[A-Z]+"}]},{cN:"attribute",b:"^\\w",e:": ",eE:!0,i:"\\n|\\s|=",starts:{e:"$",r:0}},{b:"\\n\\n",starts:{sL:[],eW:!0}}]}});var U="Menlo,Consolas,monospace",O=105.1316178/t(U)+"px",F=e("style",'body{max-width:680px;margin:auto;padding:20px;text-align:justify;line-height:140%; -webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-smoothing:antialiased;color:#222;font-family:Palatino,Georgia,"Times New Roman",serif}'),P=e("style","body{counter-reset: h1 h2 h3 h4 h5 h6 paragraph}@page{margin:0;size:auto}.md code,pre{font-family:"+U+";font-size:"+O+';line-height:140%}.md div.title{font-size:26px;font-weight:800;line-height:120%;text-align:center}.md div.afterTitles{height:10px}.md div.subtitle{text-align:center}.md .image{display:inline-block}.md div.imagecaption,.md div.tablecaption,.md div.listingcaption{margin:5px 5px 5px 5px;text-align: justify;font-style:italic}.md div.imagecaption{margin-bottom:0}.md img{max-width:100%;page-break-inside:avoid}.md li{text-align:left;text-indent:0}.md pre.listing {tab-size:4;-moz-tab-size:4;-o-tab-size:4;counter-reset:line}.md pre.listing .linenumbers span.line:before{width:30px;margin-left:-52px;font-size:80%;text-align:right;counter-increment:line;content:counter(line);display:inline-block;padding-right:13px;margin-right:8px;color:#ccc}.md div.tilde{margin:20px 0 -10px;text-align:center}.md blockquote.fancyquote{margin:25px 0 25px;text-align:left;line-height:160%}.md blockquote.fancyquote::before{content:"\u201c";color:#DDD;font-family:Times New Roman;font-size:45px;line-height:0;margin-right:6px;vertical-align:-0.3em}.md span.fancyquote{font-size:118%;color:#777;font-style:italic}.md span.fancyquote::after{content:"\u201d";font-style:normal;color:#DDD;font-family:Times New Roman;font-size:45px;line-height:0;margin-left:6px;vertical-align:-0.3em}.md blockquote.fancyquote .author{width:100%;margin-top:10px;display:inline-block;text-align:right}.md small{font-size:60%}.md div.title,contents,.md .tocHeader,h1,h2,h3,h4,h5,h6,.md .shortTOC,.md .mediumTOC,.nonumberh1,.nonumberh2,.nonumberh3,.nonumberh4,.nonumberh5,.nonumberh6{font-family:Verdana,Helvetica,Arial,sans-serif;margin:13.4px 0 13.4px;padding:15px 0 3px;border-top:none;clear:both}.md h1,.md h2,.md h3,.md h4,.md h5,.md h6,.md .nonumberh1,.md .nonumberh2,.md .nonumberh3,.md .nonumberh4,.md .nonumberh5,.md .nonumberh6{page-break-after:avoid;break-after:avoid}.md svg.diagram{display:block;font-family:'+U+";font-size:"+O+";text-align:center;stroke-linecap:round;stroke-width:"+z+'px;page-break-inside:avoid;stroke:#000;fill:#000}.md svg.diagram .opendot{fill:#FFF}.md svg.diagram text{stroke:none}@media print{.md .pagebreak{page-break-after:always;visibility:hidden}}.md a{font-family:Georgia,Palatino,\'Times New Roman\'}.md h1,.md .tocHeader,.md .nonumberh1{border-bottom:3px solid;font-size:20px;font-weight:bold;}.md h1,.md .nonumberh1{counter-reset: h2 h3 h4 h5 h6}.md h2,.md .nonumberh2{counter-reset: h3 h4 h5 h6;border-bottom:2px solid #999;color:#555;font-weight:bold;font-size:18px;}.md h3,.md h4,.md h5,.md h6,.md .nonumberh3,.md .nonumberh4,.md .nonumberh5,.md .nonumberh6{font-family:Helvetica,Arial,sans-serif;color:#555;font-size:16px;}.md h3{counter-reset:h4 h5 h6}.md h4{counter-reset:h5 h6}.md h5{counter-reset:h6}.md div.table{margin:16px 0 16px 0}.md table{border-collapse:collapse;line-height:140%;page-break-inside:avoid}.md table.table{margin:auto}.md table.calendar{width:100%;margin:auto;font-size:11px;font-family:Helvetica,Arial,sans-serif}.md table.calendar th{font-size:16px}.md .today{background:#ECF8FA}.md .calendar .parenthesized{color:#999;font-style:italic}.md div.tablecaption{text-align:center}.md table.table th{color:#FFF;background-color:#AAA;border:1px solid #888;padding:8px 15px 8px 15px}.md table.table td{padding:5px 15px 5px 15px;border:1px solid #888}.md table.table tr:nth-child(even){background:#EEE}.md pre.tilde{border-top: 1px solid #CCC;border-bottom: 1px solid #CCC;padding: 5px 0 5px 20px;margin:0 0 0 0;background:#FCFCFC;page-break-inside:avoid}.md a.target{width:0px;height:0px;visibility:hidden;font-size:0px;display:inline-block}.md a:link, .md a:visited{color:#38A;text-decoration:none}.md a:link:hover{text-decoration:underline}.md dt{font-weight:700}.md dl>dd{margin-top:-8px; margin-bottom:8px}.md dl>table{margin:35px 0 30px}.md code{white-space:pre-wrap;overflow-wrap:break-word;text-align:left;page-break-inside:avoid}.md .endnote{font-size:13px;line-height:15px;padding-left:10px;text-indent:-10px}.md .bib{padding-left:80px;text-indent:-80px;text-align:left}.markdeepFooter{font-size:9px;text-align:right;padding-top:80px;color:#999}.md .mediumTOC{float:right;font-size:12px;line-height:15px;border-left:1px solid #CCC;padding-left:15px;margin:15px 0px 15px 25px}.md .mediumTOC .level1{font-weight:600}.md .longTOC .level1{font-weight:600;display:block;padding-top:12px;margin:0 0 -20px}.md .shortTOC{text-align:center;font-weight:bold;margin-top:15px;font-size:14px}.md .admonition{position:relative;margin:1em 0;padding:.4rem 1rem;border-radius:.2rem;border-left:2.5rem solid rgba(68,138,255,.4);background-color:rgba(68,138,255,.15);}.md .admonition-title{font-weight:bold;border-bottom:solid 1px rgba(68,138,255,.4);padding-bottom:4px;margin-bottom:4px;margin-left: -1rem;padding-left:1rem;margin-right:-1rem;border-color:rgba(68,138,255,.4)}.md .admonition.tip{border-left:2.5rem solid rgba(50,255,90,.4);background-color:rgba(50,255,90,.15)}.md .admonition.tip::before{content:"\\24d8";font-weight:bold;font-size:150%;position:relative;top:3px;color:rgba(26,128,46,.8);left:-2.95rem;display:block;width:0;height:0}.md .admonition.tip>.admonition-title{border-color:rgba(50,255,90,.4)}.md .admonition.warn,.md .admonition.warning{border-left:2.5rem solid rgba(255,145,0,.4);background-color:rgba(255,145,0,.15)}.md .admonition.warn::before,.md .admonition.warning::before{content:"\\26A0";font-weight:bold;font-size:150%;position:relative;top:2px;color:rgba(128,73,0,.8);left:-2.95rem;display:block;width:0;height:0}.md .admonition.warn>.admonition-title,.md .admonition.warning>.admonition-title{border-color:rgba(255,145,0,.4)}.md .admonition.error{border-left: 2.5rem solid rgba(255,23,68,.4);background-color:rgba(255,23,68,.15)}.md .admonition.error>.admonition-title{border-color:rgba(255,23,68,.4)}.md .admonition.error::before{content: "\\2612";font-family:"Arial";font-size:200%;position:relative;color:rgba(128,12,34,.8);top:-2px;left:-3rem;display:block;width:0;height:0}.md .admonition p:last-child{margin-bottom:0}.md li.checked,.md li.unchecked{list-style:none;overflow:visible;text-indent:-1.2em}.md li.checked:before,.md li.unchecked:before{content:"\\2611";display:block;float:left;width:1em;font-size:120%}.md li.unchecked:before{content:"\\2610"}'),H='',W={keyword:{table:"tableau",figure:"figure",m:"liste",diagram:"diagramme",contents:"Table des mati\xe8res",sec:"sec",section:"section",subsection:"paragraphe",Monday:"lundi",Tuesday:"mardi",Wednesday:"mercredi",Thursday:"jeudi",Friday:"vendredi",Saturday:"samedi",Sunday:"dimanche",January:"Janvier",February:"F\xe9vrier",March:"Mars",April:"Avril",May:"Mai",June:"Juin",July:"Julliet",August:"Ao\xfbt",September:"Septembre",October:"Octobre",November:"Novembre",December:"D\xe9cembre",jan:"janv",feb:"f\xe9vr",mar:"mars",apr:"avril",may:"mai",jun:"juin",jul:"juil",aug:"ao\xfbt",sep:"sept",oct:"oct",nov:"nov",dec:"d\xe9c","“":"« ","&rtquo;":" »"}},V={keyword:{table:"lentel\u0117",figure:"paveiksl\u0117lis",m:"s\u0105ra\u0161as",diagram:"diagrama",contents:"Turinys",sec:"sk",section:"skyrius",subsection:"poskyris",Monday:"pirmadienis",Tuesday:"antradienis",Wednesday:"tre\u010diadienis",Thursday:"ketvirtadienis",Friday:"penktadienis",Saturday:"\u0161e\u0161tadienis",Sunday:"sekmadienis",January:"Sausis",February:"Vasaris",March:"Kovas",April:"Balandis",May:"Gegu\u017e\u0117",June:"Bir\u017eelis",July:"Liepa",August:"Rugpj\u016btis",September:"Rugs\u0117jis",October:"Spalis",November:"Lapkritis",December:"Gruodis",jan:"saus",feb:"vas",mar:"kov",apr:"bal",may:"geg",jun:"bir\u017e",jul:"liep",aug:"rugpj",sep:"rugs",oct:"spal",nov:"lapkr",dec:"gruod","“":"„","&rtquo;":"“"}},Z={keyword:{table:"\u0442\u0430\u0431\u043b\u0438\u0446\u0430",figure:"\u0444\u0438\u0433\u0443\u0440\u0430",m:"\u0441\u043f\u0438\u0441\u044a\u043a",diagram:"\u0434\u0438\u0430\u0433\u0440\u0430\u043c\u0430",contents:"c\u044a\u0434\u044a\u0440\u0436\u0430\u043d\u0438\u0435",sec:"\u0441\u0435\u043a",section:"\u0440\u0430\u0437\u0434\u0435\u043b",subsection:"\u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b",Monday:"\u043f\u043e\u043d\u0435\u0434\u0435\u043b\u043d\u0438\u043a",Tuesday:"\u0432\u0442\u043e\u0440\u043d\u0438\u043a",Wednesday:"\u0441\u0440\u044f\u0434\u0430",Thursday:"\u0447\u0435\u0442\u0432\u044a\u0440\u0442\u044a\u043a",Friday:"\u043f\u0435\u0442\u044a\u043a",Saturday:"\u0441\u044a\u0431\u043e\u0442\u0430",Sunday:"\u043d\u0435\u0434\u0435\u043b\u044f",January:"\u044f\u043d\u0443\u0430\u0440\u0438",February:"\u0444\u0435\u0432\u0440\u0443\u0430\u0440\u0438",March:"\u043c\u0430\u0440\u0442",April:"\u0430\u043f\u0440\u0438\u043b",May:"\u043c\u0430\u0439",June:"\u044e\u043d\u0438",July:"\u044e\u043b\u0438",August:"\u0430\u0432\u0433\u0443\u0441\u0442",September:"\u0441\u0435\u043f\u0442\u0435\u043c\u0432\u0440\u0438",October:"\u043e\u043a\u0442\u043e\u043c\u0432\u0440\u0438",November:"\u043d\u043e\u0435\u043c\u0432\u0440\u0438",December:"\u0434\u0435\u043a\u0435\u043c\u0432\u0440\u0438",jan:"\u044f\u043d",feb:"\u0444\u0435\u0432\u0440",mar:"\u043c\u0430\u0440\u0442",apr:"\u0430\u043f\u0440",may:"\u043c\u0430\u0439",jun:"\u044e\u043d\u0438",jul:"\u044e\u043b\u0438",aug:"\u0430\u0432\u0433",sep:"\u0441\u0435\u043f\u0442",oct:"\u043e\u043a\u0442",nov:"\u043d\u043e\u0435\u043c",dec:"\u0434\u0435\u043a","“":"„","”":"”"}},G={keyword:{table:"tabela",figure:"figura",m:"lista",diagram:"diagrama",contents:"conte\xfado",sec:"sec",section:"sec\xe7\xe3o",subsection:"subsec\xe7\xe3o",Monday:"Segunda-feira",Tuesday:"Ter\xe7a-feira",Wednesday:"Quarta-feira",Thursday:"Quinta-feira",Friday:"Sexta-feira",Saturday:"S\xe1bado",Sunday:"Domingo",January:"Janeiro",February:"Fevereiro",March:"Mar\xe7o",April:"Abril",May:"Maio",June:"Junho",July:"Julho",August:"Agosto",September:"Setembro",October:"Outubro",November:"Novembro",December:"Dezembro",jan:"jan",feb:"fev",mar:"mar",apr:"abr",may:"mai",jun:"jun",jul:"jul",aug:"ago",sep:"set",oct:"oct",nov:"nov",dec:"dez","“":"«","&rtquo;":"»"}},J={keyword:{table:"Tabulka",figure:"Obr\xe1zek",m:"Seznam",diagram:"Diagram",contents:"Obsah",sec:"kap.",section:"kapitola",subsection:"podkapitola",Monday:"pond\u011bl\xed",Tuesday:"\xfater\xfd",Wednesday:"st\u0159eda",Thursday:"\u010dtvrtek",Friday:"p\xe1tek",Saturday:"sobota",Sunday:"ned\u011ble",January:"leden",February:"\xfanor",March:"b\u0159ezen",April:"duben",May:"kv\u011bten",June:"\u010derven",July:"\u010dervenec",August:"srpen",September:"z\xe1\u0159\xed",October:"\u0159\xedjen",November:"listopad",December:"prosinec",jan:"led",feb:"\xfano",mar:"b\u0159e",apr:"dub",may:"kv\u011b",jun:"\u010dvn",jul:"\u010dvc",aug:"srp",sep:"z\xe1\u0159",oct:"\u0159\xedj",nov:"lis",dec:"pro","“":"„","”":"“"}},K={keyword:{table:"tabella",figure:"figura",m:"lista",diagram:"diagramma",contents:"indice",sec:"sez",section:"sezione",subsection:"paragrafo",Monday:"luned\xec",Tuesday:"marted\xec",Wednesday:"mercoled\xec",Thursday:"gioved\xec",Friday:"venerd\xec",Saturday:"sabato",Sunday:"domenica",January:"Gennaio",February:"Febbraio",March:"Marzo",April:"Aprile",May:"Maggio",June:"Giugno",July:"Luglio",August:"Agosto",September:"Settembre",October:"Ottobre",November:"Novembre",December:"Dicembre",jan:"gen",feb:"feb",mar:"mar",apr:"apr",may:"mag",jun:"giu",jul:"lug",aug:"ago",sep:"set",oct:"ott",nov:"nov",dec:"dic","“":"“","&rtquo;":"”"}},Q={keyword:{table:"\u0442\u0430\u0431\u043b\u0438\u0446\u0430",figure:"\u0440\u0438\u0441\u0443\u043d\u043e\u043a",m:"\u043b\u0438\u0441\u0442\u0438\u043d\u0433",diagram:"\u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430",contents:"\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435",sec:"\u0441\u0435\u043a",section:"\u0440\u0430\u0437\u0434\u0435\u043b",subsection:"\u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b",Monday:"\u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a",Tuesday:"\u0432\u0442\u043e\u0440\u043d\u0438\u043a",Wednesday:"\u0441\u0440\u0435\u0434\u0430",Thursday:"\u0447\u0435\u0442\u0432\u0435\u0440\u0433",Friday:"\u043f\u044f\u0442\u043d\u0438\u0446\u0430",Saturday:"\u0441\u0443\u0431\u0431\u043e\u0442\u0430",Sunday:"\u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435",January:"\u044f\u043d\u0432\u0430\u0440\u044cr",February:"\u0444\u0435\u0432\u0440\u0430\u043b\u044c",March:"\u043c\u0430\u0440\u0442",April:"\u0430\u043f\u0440\u0435\u043b\u044c",May:"\u043c\u0430\u0439",June:"\u0438\u044e\u043d\u044c",July:"\u0438\u044e\u043b\u044c",August:"\u0430\u0432\u0433\u0443\u0441\u0442",September:"\u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044c",October:"\u043e\u043a\u0442\u044f\u0431\u0440\u044c",November:"\u043d\u043e\u044f\u0431\u0440\u044c",December:"\u0434\u0435\u043a\u0430\u0431\u0440\u044c",jan:"\u044f\u043d\u0432",feb:"\u0444\u0435\u0432\u0440",mar:"\u043c\u0430\u0440\u0442",apr:"\u0430\u043f\u0440",may:"\u043c\u0430\u0439",jun:"\u0438\u044e\u043d\u044c",jul:"\u0438\u044e\u043b\u044c",aug:"\u0430\u0432\u0433",sep:"\u0441\u0435\u043d\u0442",oct:"\u043e\u043a\u0442",nov:"\u043d\u043e\u044f\u0431\u0440\u044c",dec:"\u0434\u0435\u043a","“":"\xab","”":"\xbb"}},X={keyword:{table:"tabela",figure:"ilustracja",m:"wykaz",diagram:"diagram",contents:"Spis tre\u015bci",sec:"rozdz.",section:"rozdzia\u0142",subsection:"podrozdzia\u0142",Monday:"Poniedzia\u0142ek",Tuesday:"Wtorek",Wednesday:"\u015aroda",Thursday:"Czwartek",Friday:"Pi\u0105tek",Saturday:"Sobota",Sunday:"Niedziela",January:"Stycze\u0144",February:"Luty",March:"Marzec",April:"Kwiecie\u0144",May:"Maj",June:"Czerwiec",July:"Lipiec",August:"Sierpie\u0144",September:"Wrzesie\u0144",October:"Pa\u017adziernik",November:"Listopad",December:"Grudzie\u0144",jan:"sty",feb:"lut",mar:"mar",apr:"kwi",may:"maj",jun:"cze",jul:"lip",aug:"sie",sep:"wrz",oct:"pa\u017a",nov:"lis",dec:"gru","“":"„","”":"”"}},Y={keyword:{table:"t\xe1bl\xe1zat",figure:"\xe1bra",m:"lista",diagram:"diagramm",contents:"Tartalomjegyz\xe9k",sec:"fej",section:"fejezet",subsection:"alfejezet",Monday:"h\xe9tf\u0151",Tuesday:"kedd",Wednesday:"szerda",Thursday:"cs\xfct\xf6rt\xf6k",Friday:"p\xe9ntek",Saturday:"szombat",Sunday:"vas\xe1rnap",January:"janu\xe1r",February:"febru\xe1r",March:"m\xe1rcius",April:"\xe1prilis",May:"m\xe1jus",June:"j\xfanius",July:"j\xfalius",August:"augusztus",September:"szeptember",October:"okt\xf3ber",November:"november",December:"december",jan:"jan",feb:"febr",mar:"m\xe1rc",apr:"\xe1pr",may:"m\xe1j",jun:"j\xfan",jul:"j\xfal",aug:"aug",sep:"szept",oct:"okt",nov:"nov",dec:"dec","“":"„","”":"”"}},ee={keyword:{table:"\u8868",figure:"\u56f3",m:"\u4e00\u89a7",diagram:"\u56f3",contents:"\u76ee\u6b21",sec:"\u7ae0",section:"\u7bc0",subsection:"\u9805",Monday:"\u6708",Tuesday:"\u706b",Wednesday:"\u6c34",Thursday:"\u6728",Friday:"\u91d1",Saturday:"\u571f",Sunday:"\u65e5",January:"1\u6708",February:"2\u6708",March:"3\u6708",April:"4\u6708",May:"5\u6708",June:"6\u6708",July:"7\u6708",August:"8\u6708",September:"9\u6708",October:"10\u6708",November:"11\u6708",December:"12\u6708",jan:"1\u6708",feb:"2\u6708",mar:"3\u6708",apr:"4\u6708",may:"5\u6708",jun:"6\u6708",jul:"7\u6708",aug:"8\u6708",sep:"9\u6708",oct:"10\u6708",nov:"11\u6708",dec:"12\u6708","“":"\u300c","”":"\u300d"}},te={keyword:{table:"Tabelle",figure:"Abbildung",m:"Auflistung",diagram:"Diagramm",contents:"Inhaltsverzeichnis",sec:"Kap",section:"Kapitel",subsection:"Unterabschnitt",Monday:"Montag",Tuesday:"Dienstag",Wednesday:"Mittwoch",Thursday:"Donnerstag",Friday:"Freitag",Saturday:"Samstag",Sunday:"Sonntag",January:"Januar",February:"Februar",March:"M\xe4rz",April:"April",May:"Mai",June:"Juni",July:"Juli",August:"August",September:"September",October:"Oktober",November:"November",December:"Dezember",jan:"Jan",feb:"Feb",mar:"M\xe4r",apr:"Apr",may:"Mai",jun:"Jun",jul:"Jul",aug:"Aug",sep:"Sep",oct:"Okt",nov:"Nov",dec:"Dez","“":"„","”":"“"}},re={keyword:{table:"tabell",figure:"illustration",m:"lista",diagram:"diagram",contents:"inneh\xe5llsf\xf6rteckning",sec:"kap",section:"kapitel",subsection:"avsnitt",Monday:"m\xe5ndag",Tuesday:"tisdag",Wednesday:"onsdag",Thursday:"torsdag",Friday:"fredag",Saturday:"l\xf6rdag",Sunday:"s\xf6ndag",January:"januari",February:"februari",March:"mars",April:"april",May:"maj",June:"juni",July:"juli",August:"augusti",September:"september",October:"oktober",November:"november",December:"december",jan:"jan",feb:"feb",mar:"mar",apr:"apr",may:"maj",jun:"jun",jul:"jul",aug:"aug",sep:"sep",oct:"okt",nov:"nov",dec:"dec","“":"”","”":"”"}},ne={mode:"markdeep",detectMath:!0,lang:{keyword:{}},tocStyle:"auto",hideEmptyWeekends:!0,showLabels:!1,o:!0,captionAbove:{diagram:!1,image:!1,table:!1,m:!1}},ae={en:{keyword:{}},ru:Q,fr:W,pl:X,bg:Z,de:te,hu:Y,sv:re,pt:G,ja:ee,it:K,lt:V,cz:J};[].slice.call(document.getElementsByTagName("meta")).forEach(function(e){var t=e.getAttribute("lang");if(t){var r=ae[t];r&&(ne.lang=r)}});var ie=Math.max,se=Math.min,oe=Math.abs,ce=Math.sign||function(e){return+e===e?0===e?e:e>0?1:-1:NaN},le="";if(!window.alreadyProcessedMarkdeep){window.alreadyProcessedMarkdeep=!0;var ue=window.location.href.search(/\?.*noformat.*/i)!==-1;window.markdeep=Object.freeze({format:v,formatDiagram:M,stylesheet:function(){return P+l()+le}});var de=''+"$$NC{\\n}{\\hat{n}}NC{\\w}{\\hat{\\omega}}NC{\\wi}{\\w_\\mathrm{i}}NC{\\wo}{\\w_\\mathrm{o}}NC{\\wh}{\\w_\\mathrm{h}}NC{\\Li}{L_\\mathrm{i}}NC{\\Lo}{L_\\mathrm{o}}NC{\\Le}{L_\\mathrm{e}}NC{\\Lr}{L_\\mathrm{r}}NC{\\Lt}{L_\\mathrm{t}}NC{\\O}{\\mathrm{O}}NC{\\degrees}{{^{\\large\\circ}}}NC{\\T}{\\mathsf{T}}NC{\\mathset}[1]{\\mathbb{#1}}NC{\\Real}{\\mathset{R}}NC{\\Integer}{\\mathset{Z}}NC{\\Boolean}{\\mathset{B}}NC{\\Complex}{\\mathset{C}}NC{\\un}[1]{\\,\\mathrm{#1}}$$\n".rp(/NC/g,"\\newcommand")+"\n",pe="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML",me=r("mode");switch(me){case"script":return;case"html":case"doxygen":A(document.getElementsByClassName("diagram")).concat(A(document.getElementsByTagName("diagram"))).forEach(function(e){var t=s(e.innerHTML);t=t.rp(/(:?^[ \t]*\n)|(:?\n[ \t]*)$/g,""),"doxygen"===me&&(t=t.rp(RegExp("\u2013","g"),"--"),t=t.rp(RegExp("\u2014","g"),"---"),t=t.rp(/(.*)<\/a>/g,"$1")),e.outerHTML='
'+M(C(t),"")+"
"});var ge=!1;return A(document.getElementsByClassName("markdeep")).concat(A(document.getElementsByTagName("markdeep"))).forEach(function(e){var t=document.createElement("div"),r=v(C(s(e.innerHTML)),!0);ge=ge||S(r),t.innerHTML=r,e.parentNode.replaceChild(t,e)}),document.head.innerHTML=window.markdeep.stylesheet()+document.head.innerHTML+(ge?de:""),void E()}ue||(A(document.getElementsByTagName("script")).forEach(function(e){k(e.src)&&e.parentNode.removeChild(e)}),document.body.style.visibility="hidden");var be=u(document.body);if(ue){be=be.rp(/ */ <----+ * +* | | | / offset child * +* | | |/ ^ transform* +* v +---------+ / <---+ * +* . +-> dimensions * +* . . . . . . . . . . . . . . | relative * +* . . . v to parent * +************************************************************************ + +!!! WARNING + Skew is not supported for collision picks. Scaling a parent entity or + overlay non-uniformly can lead to inaccurate shapes for the child + collision pick. + +## Avatar parent + +A pick parented to an avatar behaves like a wearable. It will maintain +its position relative to some point on the avatar's body. If the pick +has scale (currently only collision picks), then the pick will rescale +when the avatar rescales. + +**************************************************************** +* Avatar .---. hand ^ -. * +* | | | joint / | * +* '-----> | | \ /orientation | * +* '-+-' +-> o | * +* | / ^ position |relative * +* +---------' +----- |avatar * +* | |scale * +* | if not a joint, |factor * +* | parent to the |(default: 1) * +* | avatar's origin | * +* |\ | |uniform scale * +* | \ | | ^ * +* | \ | | +-> * +* | o \ <-+ -' v * +**************************************************************** + +*************************************************************** +* orientation offset * +* <-----+ * +* ^ \ * +* \ * +* \ child * +* Avatar .---. hand .......... * <-- transform * +* | | | joint . ^ | * +* '-----> | | \ . / v * +* '-+-' +-> o ---------+ ^ * +* | / position +-> scale * +* +---------' offset v relative * +* | to avatar * +*************************************************************** + +## Pick parent + +Picks can also be parented to other picks. +When this is done, the child pick is actually parented to +the parent pick's result, not the pick itself. + +A pick parented to another pick will have its position changed, +but not its orientation or scale. + +### Ray pick parent + +********************************** +* position * +* o * +* \ \ orientation * +* \ \ * +* \ v . . . . * +* \ . * +* \ . result transform * +* * <-- no scale * +* . no orientation * +* . * +********************************** + +### Parabola pick parent + +************************************************************** +* .------. acceleration * +* + + | ^ * +* speed x ^ / \ . | | * +* orientation / / \ . v | * +* / / * y axis to rotate * +* | . ^ acceleration with * +* o . | * +* position result transform * +* no scale * +* no orientation * +************************************************************** + +### Stylus pick parent + +******************************************** +* * +* * +* . * +* . * +* . * +* .---. avatar * * +* | | hand / ^. * +* | | \ / \ . * +* '-+-' +-> o \ * +* | / result transform * +* +---------' no scale * +* | no orientation * +******************************************** + +### Collision pick parent + +******************************************** +* * +* .---. * +* | | <-- collision pick * +* | | * +* | *<-+--- result transform at * +* | | collision pick position * +* | | no scale * +* . . . '---' . . no orientation * +* * +******************************************** + +# Effect of scale on picks + +Scale affects the position and shape of picks, which in turn affects the pick result. +Scale currently does not affect the max distance of a pick. + +## Ray and stylus pick scaling + +Rescaling the parent of a ray pick or stylus pick can result in a translation of the pick. + +*************************************** +* before after * +* * +* pick * +* pick +--------------+ ^ * +* ^ | |/ * +* +-----+/ | o * +* | o | | * +* | | | | * +* +-----+ | | * +* parent | | * +* +--------------+ * +* parent * +* * +*************************************** + +## Parabola pick scaling + +*************************************************************************** +* before after after * +* (scaleWithParent (scaleWithParent * +* is false) is true) * +* * +* .----. * +* + + * +* .--. / \ * +* + + / \ * +* .--. / \ / \ * +* + + /pick \ /pick \ * +* / \ +-------o +-------o * +* /pick \ | | | | * +* +---o | | | | * +* | | | | | | * +* +---+ +-------+ +-------+ * +* parent parent parent * +*************************************************************************** + +## Collision pick scaling + +Collision picks use the full transform of their parent (position, orientation, and scale/dimensions). +When first created, a collision pick's transform is defined in world space. +As the parent rescales, the collision pick rescales proportionally. + +The collision pick's threshold also rescales. The change is proportional to the largest +dimension of the parent. So, if the largest dimension of the parent was 3.0 and is now 6.0, +the threshold doubles. + +************************************************************ +* * +* before after * +* * +* pick * +* +------------+ * +* | | * +* | ........ | * +* | . . | * +* | . . | * +* | . . | * +* pick | . . | * +* +-----+ | ........ +___ * +* |.....| | | theshold * +* |. .| theshold +------------+--- * +* |.....|___ | * +* +-----+--- <-+ * +* +----------+ * +* +---+ / \ * +* +-----+ +--------------+ * +* parent parent * +* * +************************************************************ + + + + + + \ No newline at end of file From a9164f96b9f9edd7a2219988bda570785a596fdd Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 09:53:42 -0700 Subject: [PATCH 04/39] Fix some inaccuracies in the pick parenting doc --- docs/interface/raypick/pick-parenting.md.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/interface/raypick/pick-parenting.md.html b/docs/interface/raypick/pick-parenting.md.html index cb3e935317..d495e21419 100644 --- a/docs/interface/raypick/pick-parenting.md.html +++ b/docs/interface/raypick/pick-parenting.md.html @@ -8,7 +8,7 @@ Picks are immutable to allow efficient use by scripts. There are currently four - Ray pick - Finds the first intersected object along a straight path - Parabola pick - Finds the first intersected object along a parabolic path -- Stylus pick - Finds the distance between a point and a list of whitelisted objects +- Stylus pick - Finds the distance between a point and the XZ planes of a list of whitelisted objects - Collision pick - Uses a volume to check for collisions in the physics engine With the exception of collision picks, all picks use the visible appearance of the object to check for collisions. @@ -21,17 +21,17 @@ Pick parenting allows the pick's transform to be calculated relative to another # What can be parented to what? -Child type: | Entity | My Avatar | Other Avatar | 3D Overlay | Pick^1 | Pointer^1 + | Entity | My Avatar | Other Avatar | 3D Overlay | Pick^1 | Pointer^1 ---------------|----------|-------------|----------------|--------------|----------|--------------- -Entity | yes | no | no | yes | yes | yes +Entity | yes | yes | no | yes | yes | yes My Avatar | yes | no | no | yes | yes | yes -Other Avatar | yes | no | no | yes | yes | yes -3D Overlay | yes | no | no | yes | yes | yes +Other Avatar | yes | yes | no | yes | yes | yes +3D Overlay | yes | yes | no | yes | yes | yes Pick | no | no | no | no | yes | yes Pointer | no | no | no | no | no | no The Mouse | no | no | no | no | yes | yes -- ^1 Excluding stylus, which can only be parented to My Avatar's hands +- ^1 Excluding stylus, which can only be parented to My Avatar's hands for now # How pick parenting works From 14b30935069b4e7a913b284547692bc0b50b2452 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 10:33:21 -0700 Subject: [PATCH 05/39] Clarify 'what can be parented to what' table in pick parenting doc --- docs/interface/raypick/pick-parenting.md.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/interface/raypick/pick-parenting.md.html b/docs/interface/raypick/pick-parenting.md.html index d495e21419..82f38a1494 100644 --- a/docs/interface/raypick/pick-parenting.md.html +++ b/docs/interface/raypick/pick-parenting.md.html @@ -21,15 +21,15 @@ Pick parenting allows the pick's transform to be calculated relative to another # What can be parented to what? - | Entity | My Avatar | Other Avatar | 3D Overlay | Pick^1 | Pointer^1 ----------------|----------|-------------|----------------|--------------|----------|--------------- -Entity | yes | yes | no | yes | yes | yes -My Avatar | yes | no | no | yes | yes | yes -Other Avatar | yes | yes | no | yes | yes | yes -3D Overlay | yes | yes | no | yes | yes | yes -Pick | no | no | no | no | yes | yes -Pointer | no | no | no | no | no | no -The Mouse | no | no | no | no | yes | yes +This object... | | Entity | My Avatar | 3D Overlay | Pick^1 | Pointer^1 +---------------------|----------------|--------|-----------|------------|--------|----------- +Can be parented to...| Entity | yes | yes | yes | yes | yes + | My Avatar | yes | no | yes | yes | yes + | Other Avatar | yes | yes | yes | yes | yes + | 3D Overlay | yes | yes | yes | yes | yes + | Pick | no | no | no | yes | yes + | Pointer | no | no | no | no | no + | The Mouse | no | no | no | yes | yes - ^1 Excluding stylus, which can only be parented to My Avatar's hands for now From b68031b9696436d9dafbb8891f51537675636a8b Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 10:53:10 -0700 Subject: [PATCH 06/39] Add simpler RayPick constructor with position/direction values set to default --- interface/src/Application.cpp | 3 +-- interface/src/raypick/RayPick.h | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index db89b0a9cd..8bb362b9cb 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2271,8 +2271,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // Setup the mouse ray pick and related operators { - auto mouseRayPick = std::make_shared(glm::vec3(), Vectors::UP, - PickFilter(PickScriptingInterface::PICK_ENTITIES() | PickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()), 0.0f, true); + auto mouseRayPick = std::make_shared(PickFilter(PickScriptingInterface::PICK_ENTITIES() | PickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()), 0.0f, true); mouseRayPick->parentTransform = std::make_shared(); auto mouseRayPickID = DependencyManager::get()->addPick(PickQuery::Ray, mouseRayPick); DependencyManager::get()->setMouseRayPickID(mouseRayPickID); diff --git a/interface/src/raypick/RayPick.h b/interface/src/raypick/RayPick.h index 7c7ea5758a..07e2136864 100644 --- a/interface/src/raypick/RayPick.h +++ b/interface/src/raypick/RayPick.h @@ -70,6 +70,11 @@ public: class RayPick : public Pick { public: + RayPick(const PickFilter& filter, float maxDistance, bool enabled) : + Pick(filter, maxDistance, enabled) { + _mathPick = PickRay(Vectors::ZERO, Vectors::UP); + } + RayPick(glm::vec3 position, glm::vec3 direction, const PickFilter& filter, float maxDistance, bool enabled) : Pick(filter, maxDistance, enabled) { _mathPick = PickRay(position, direction); From bb38efa061803d325baff4b41ab0b4b0999b47dc Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 10:58:21 -0700 Subject: [PATCH 07/39] Set joint state for the mouse RayPick of the EntityTreeRenderer --- interface/src/Application.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8bb362b9cb..35c071b512 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2273,6 +2273,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo { auto mouseRayPick = std::make_shared(PickFilter(PickScriptingInterface::PICK_ENTITIES() | PickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()), 0.0f, true); mouseRayPick->parentTransform = std::make_shared(); + mouseRayPick->setJointState(PickQuery::JOINT_STATE_MOUSE); auto mouseRayPickID = DependencyManager::get()->addPick(PickQuery::Ray, mouseRayPick); DependencyManager::get()->setMouseRayPickID(mouseRayPickID); } From 3ac9478101ccd4d02a1783fa5e5140a31c7fd97b Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 11:27:25 -0700 Subject: [PATCH 08/39] Assign _mathPick in the Pick constructor --- interface/src/raypick/CollisionPick.cpp | 3 +-- interface/src/raypick/ParabolaPick.cpp | 3 +-- interface/src/raypick/RayPick.h | 6 ++---- interface/src/raypick/StylusPick.cpp | 7 +++---- interface/src/raypick/StylusPick.h | 7 ++----- libraries/pointers/src/Pick.h | 2 +- libraries/shared/src/RegisteredMetaTypes.h | 2 ++ 7 files changed, 12 insertions(+), 18 deletions(-) diff --git a/interface/src/raypick/CollisionPick.cpp b/interface/src/raypick/CollisionPick.cpp index f79879bf93..5b5ecd09ff 100644 --- a/interface/src/raypick/CollisionPick.cpp +++ b/interface/src/raypick/CollisionPick.cpp @@ -346,9 +346,8 @@ void CollisionPick::computeShapeInfo(const CollisionRegion& pick, ShapeInfo& sha } CollisionPick::CollisionPick(const PickFilter& filter, float maxDistance, bool enabled, CollisionRegion collisionRegion, PhysicsEnginePointer physicsEngine) : - Pick(filter, maxDistance, enabled), + Pick(collisionRegion, filter, maxDistance, enabled), _physicsEngine(physicsEngine) { - _mathPick = collisionRegion; if (collisionRegion.shouldComputeShapeInfo()) { _cachedResource = DependencyManager::get()->getCollisionGeometryResource(collisionRegion.modelURL); } diff --git a/interface/src/raypick/ParabolaPick.cpp b/interface/src/raypick/ParabolaPick.cpp index e8aa42140b..eb95d03f13 100644 --- a/interface/src/raypick/ParabolaPick.cpp +++ b/interface/src/raypick/ParabolaPick.cpp @@ -16,11 +16,10 @@ #include "PickManager.h" ParabolaPick::ParabolaPick(const glm::vec3& position, const glm::vec3& direction, float speed, const glm::vec3& accelerationAxis, bool rotateAccelerationWithAvatar, bool rotateAccelerationWithParent, bool scaleWithParent, const PickFilter& filter, float maxDistance, bool enabled) : - Pick(filter, maxDistance, enabled), + Pick(PickParabola(position, speed * direction, accelerationAxis), filter, maxDistance, enabled), _rotateAccelerationWithAvatar(rotateAccelerationWithAvatar), _rotateAccelerationWithParent(rotateAccelerationWithParent), _scaleWithParent(scaleWithParent) { - _mathPick = PickParabola(position, speed*direction, accelerationAxis); } PickParabola ParabolaPick::getMathematicalPick() const { diff --git a/interface/src/raypick/RayPick.h b/interface/src/raypick/RayPick.h index 07e2136864..4af8490fdc 100644 --- a/interface/src/raypick/RayPick.h +++ b/interface/src/raypick/RayPick.h @@ -71,13 +71,11 @@ class RayPick : public Pick { public: RayPick(const PickFilter& filter, float maxDistance, bool enabled) : - Pick(filter, maxDistance, enabled) { - _mathPick = PickRay(Vectors::ZERO, Vectors::UP); + Pick(PickRay(Vectors::ZERO, Vectors::UP), filter, maxDistance, enabled) { } RayPick(glm::vec3 position, glm::vec3 direction, const PickFilter& filter, float maxDistance, bool enabled) : - Pick(filter, maxDistance, enabled) { - _mathPick = PickRay(position, direction); + Pick(PickRay(position, direction), filter, maxDistance, enabled) { } PickRay getMathematicalPick() const override; diff --git a/interface/src/raypick/StylusPick.cpp b/interface/src/raypick/StylusPick.cpp index 69f605e7f9..c495ddd194 100644 --- a/interface/src/raypick/StylusPick.cpp +++ b/interface/src/raypick/StylusPick.cpp @@ -65,8 +65,7 @@ bool StylusPickResult::checkOrFilterAgainstMaxDistance(float maxDistance) { } StylusPick::StylusPick(Side side, const PickFilter& filter, float maxDistance, bool enabled) : - Pick(filter, maxDistance, enabled), - _side(side) + Pick(StylusTip(side), filter, maxDistance, enabled) { } @@ -130,9 +129,9 @@ static StylusTip getControllerWorldLocation(Side side) { StylusTip StylusPick::getMathematicalPick() const { StylusTip result; if (qApp->getPreferAvatarFingerOverStylus()) { - result = getFingerWorldLocation(_side); + result = getFingerWorldLocation(_mathPick.side); } else { - result = getControllerWorldLocation(_side); + result = getControllerWorldLocation(_mathPick.side); } return result; } diff --git a/interface/src/raypick/StylusPick.h b/interface/src/raypick/StylusPick.h index e6b1da9914..cd01df20e9 100644 --- a/interface/src/raypick/StylusPick.h +++ b/interface/src/raypick/StylusPick.h @@ -68,12 +68,9 @@ public: PickResultPointer getHUDIntersection(const StylusTip& pick) override; Transform getResultTransform() const override; - bool isLeftHand() const override { return _side == Side::Left; } - bool isRightHand() const override { return _side == Side::Right; } + bool isLeftHand() const override { return _mathPick.side == Side::Left; } + bool isRightHand() const override { return _mathPick.side == Side::Right; } bool isMouse() const override { return false; } - -private: - const Side _side; }; #endif // hifi_StylusPick_h \ No newline at end of file diff --git a/libraries/pointers/src/Pick.h b/libraries/pointers/src/Pick.h index 42a9354122..2ae1048249 100644 --- a/libraries/pointers/src/Pick.h +++ b/libraries/pointers/src/Pick.h @@ -243,7 +243,7 @@ Q_DECLARE_METATYPE(PickQuery::PickType) template class Pick : public PickQuery { public: - Pick(const PickFilter& filter, const float maxDistance, const bool enabled) : PickQuery(filter, maxDistance, enabled) {} + Pick(const T& mathPick, const PickFilter& filter, const float maxDistance, const bool enabled) : PickQuery(filter, maxDistance, enabled), _mathPick(mathPick) {} virtual T getMathematicalPick() const = 0; virtual PickResultPointer getDefaultResult(const QVariantMap& pickVariant) const = 0; diff --git a/libraries/shared/src/RegisteredMetaTypes.h b/libraries/shared/src/RegisteredMetaTypes.h index 46f112f5c6..58b99bc0f7 100644 --- a/libraries/shared/src/RegisteredMetaTypes.h +++ b/libraries/shared/src/RegisteredMetaTypes.h @@ -200,6 +200,8 @@ void pickRayFromScriptValue(const QScriptValue& object, PickRay& pickRay); class StylusTip : public MathPick { public: StylusTip() : position(NAN), velocity(NAN) {} + StylusTip(bilateral::Side side, glm::vec3 position = Vectors::ZERO, glm::quat orientation = Quaternions::IDENTITY, glm::vec3 velocity = Vectors::ZERO) : + side(side), position(position), orientation(orientation), velocity(velocity) {} StylusTip(const QVariantMap& pickVariant) : side(bilateral::Side(pickVariant["side"].toInt())), position(vec3FromVariant(pickVariant["position"])), orientation(quatFromVariant(pickVariant["orientation"])), velocity(vec3FromVariant(pickVariant["velocity"])) {} From 12a755310f1037bda9c0a8676cd4a91dfec49daf Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 11:37:30 -0700 Subject: [PATCH 09/39] Fix wrong velocity in ParabolaPick::getMathematicalPick --- interface/src/raypick/ParabolaPick.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/src/raypick/ParabolaPick.cpp b/interface/src/raypick/ParabolaPick.cpp index eb95d03f13..b10f82c9bd 100644 --- a/interface/src/raypick/ParabolaPick.cpp +++ b/interface/src/raypick/ParabolaPick.cpp @@ -36,6 +36,8 @@ PickParabola ParabolaPick::getMathematicalPick() const { glm::vec3 position = currentParentTransform.transform(_mathPick.origin); glm::vec3 velocity = _mathPick.velocity; if (_scaleWithParent) { + velocity = currentParentTransform.transform(velocity); + } else { velocity = currentParentTransform.transformDirection(velocity); } glm::vec3 acceleration = _mathPick.acceleration; From ed987ffe9e2f848ad2a1608dafcd98e49c3c0a9b Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 11:42:19 -0700 Subject: [PATCH 10/39] Improve style/compatibility for default position/direction when creating parabola pick --- interface/src/raypick/PickScriptingInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/raypick/PickScriptingInterface.cpp b/interface/src/raypick/PickScriptingInterface.cpp index 600be743fe..7de69b537d 100644 --- a/interface/src/raypick/PickScriptingInterface.cpp +++ b/interface/src/raypick/PickScriptingInterface.cpp @@ -207,8 +207,8 @@ unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properti scaleWithParent = propMap["scaleWithAvatar"].toBool(); } - glm::vec3 position = glm::vec3(); - glm::vec3 direction = -Vectors::FRONT; + glm::vec3 position = Vectors::ZERO; + glm::vec3 direction = propMap["joint"].isValid() ? Vectors::UP : -Vectors::FRONT; if (propMap["position"].isValid()) { position = vec3FromVariant(propMap["position"]); } else if (propMap["posOffset"].isValid()) { From 9e0d35e40d4b02f1bb51b21e94874c39e94e3700 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 14:28:10 -0700 Subject: [PATCH 11/39] Combine PickScriptingInterface::getPickJointState and createTransformNode into one function --- .../src/raypick/PickScriptingInterface.cpp | 126 ++++++++---------- .../src/raypick/PickScriptingInterface.h | 3 +- 2 files changed, 53 insertions(+), 76 deletions(-) diff --git a/interface/src/raypick/PickScriptingInterface.cpp b/interface/src/raypick/PickScriptingInterface.cpp index 7de69b537d..2e8f790da5 100644 --- a/interface/src/raypick/PickScriptingInterface.cpp +++ b/interface/src/raypick/PickScriptingInterface.cpp @@ -98,8 +98,7 @@ unsigned int PickScriptingInterface::createRayPick(const QVariant& properties) { } auto rayPick = std::make_shared(position, direction, filter, maxDistance, enabled); - rayPick->parentTransform = createTransformNode(propMap); - rayPick->setJointState(getPickJointState(propMap)); + setParentTransform(rayPick, propMap); return DependencyManager::get()->addPick(PickQuery::Ray, rayPick); } @@ -224,8 +223,7 @@ unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properti auto parabolaPick = std::make_shared(position, direction, speed, accelerationAxis, rotateAccelerationWithAvatar, rotateAccelerationWithParent, scaleWithParent, filter, maxDistance, enabled); - parabolaPick->parentTransform = createTransformNode(propMap); - parabolaPick->setJointState(getPickJointState(propMap)); + setParentTransform(parabolaPick, propMap); return DependencyManager::get()->addPick(PickQuery::Parabola, parabolaPick); } @@ -277,8 +275,7 @@ unsigned int PickScriptingInterface::createCollisionPick(const QVariant& propert CollisionRegion collisionRegion(propMap); auto collisionPick = std::make_shared(filter, maxDistance, enabled, collisionRegion, qApp->getPhysicsEngine()); - collisionPick->parentTransform = createTransformNode(propMap); - collisionPick->setJointState(getPickJointState(propMap)); + setParentTransform(collisionPick, propMap); return DependencyManager::get()->addPick(PickQuery::Collision, collisionPick); } @@ -355,82 +352,63 @@ void PickScriptingInterface::setPerFrameTimeBudget(unsigned int numUsecs) { DependencyManager::get()->setPerFrameTimeBudget(numUsecs); } -PickQuery::JointState PickScriptingInterface::getPickJointState(const QVariantMap& propMap) { +void PickScriptingInterface::setParentTransform(std::shared_ptr pick, const QVariantMap& propMap) { + QUuid parentUuid; + int parentJointIndex = 0; + auto myAvatar = DependencyManager::get()->getMyAvatar(); + if (propMap["parentID"].isValid()) { - QUuid parentUuid = propMap["parentID"].toUuid(); - if (propMap["parentJointIndex"].isValid() && parentUuid == DependencyManager::get()->getMyAvatar()->getSessionUUID()) { - int jointIndex = propMap["parentJointIndes"].toInt(); - if (jointIndex == CONTROLLER_LEFTHAND_INDEX || jointIndex == CAMERA_RELATIVE_CONTROLLER_LEFTHAND_INDEX) { - return PickQuery::JOINT_STATE_LEFT_HAND; - } else if (jointIndex == CONTROLLER_RIGHTHAND_INDEX || jointIndex == CAMERA_RELATIVE_CONTROLLER_RIGHTHAND_INDEX) { - return PickQuery::JOINT_STATE_RIGHT_HAND; - } else { - return PickQuery::JOINT_STATE_NONE; - } - } else { - return PickQuery::JOINT_STATE_NONE; + parentUuid = propMap["parentID"].toUuid(); + if (propMap["parentJointIndex"].isValid()) { + parentJointIndex = propMap["parentJointIndex"].toInt(); } } else if (propMap["joint"].isValid()) { QString joint = propMap["joint"].toString(); if (joint == "Mouse") { - return PickQuery::JOINT_STATE_MOUSE; - } else if (joint == "_CONTROLLER_LEFTHAND" || joint == "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND") { - return PickQuery::JOINT_STATE_LEFT_HAND; - } else if (joint== "_CONTROLLER_RIGHTHAND" || joint == "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND") { - return PickQuery::JOINT_STATE_RIGHT_HAND; + pick->parentTransform = std::make_shared(); + pick->setJointState(PickQuery::JOINT_STATE_MOUSE); + return; + } else if (joint == "Avatar") { + pick->parentTransform = std::make_shared(); + return; } else { - return PickQuery::JOINT_STATE_NONE; + parentUuid = myAvatar->getSessionUUID(); + parentJointIndex = myAvatar->getJointIndex(joint); + } + } + + if (parentUuid == myAvatar->getSessionUUID()) { + if (parentJointIndex == CONTROLLER_LEFTHAND_INDEX || parentJointIndex == CAMERA_RELATIVE_CONTROLLER_LEFTHAND_INDEX) { + pick->setJointState(PickQuery::JOINT_STATE_LEFT_HAND); + } else if (parentJointIndex == CONTROLLER_RIGHTHAND_INDEX || parentJointIndex == CAMERA_RELATIVE_CONTROLLER_RIGHTHAND_INDEX) { + pick->setJointState(PickQuery::JOINT_STATE_RIGHT_HAND); + } + + pick->parentTransform = std::make_shared(myAvatar, parentJointIndex); + } else if (!parentUuid.isNull()) { + // Infer object type from parentID + // For now, assume a QUuid is a SpatiallyNestable. This should change when picks are converted over to QUuids. + bool success; + std::weak_ptr nestablePointer = DependencyManager::get()->find(parentUuid, success, nullptr); + auto sharedNestablePointer = nestablePointer.lock(); + + if (success && sharedNestablePointer) { + 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 { + pick->parentTransform = std::make_shared(nestablePointer, parentJointIndex); + } } } else { - return PickQuery::JOINT_STATE_NONE; - } -} - -std::shared_ptr PickScriptingInterface::createTransformNode(const QVariantMap& propMap) { - if (propMap["parentID"].isValid()) { - QUuid parentUuid = propMap["parentID"].toUuid(); - if (!parentUuid.isNull()) { - // Infer object type from parentID - // For now, assume a QUuuid is a SpatiallyNestable. This should change when picks are converted over to QUuids. - bool success; - std::weak_ptr nestablePointer = DependencyManager::get()->find(parentUuid, success, nullptr); - int parentJointIndex = 0; - if (propMap["parentJointIndex"].isValid()) { - parentJointIndex = propMap["parentJointIndex"].toInt(); - } - auto sharedNestablePointer = nestablePointer.lock(); - if (success && sharedNestablePointer) { - NestableType nestableType = sharedNestablePointer->getNestableType(); - if (nestableType == NestableType::Avatar) { - return std::make_shared(std::static_pointer_cast(sharedNestablePointer), parentJointIndex); - } else if (nestableType == NestableType::Overlay) { - return std::make_shared(std::static_pointer_cast(sharedNestablePointer), parentJointIndex); - } else if (nestableType == NestableType::Entity) { - return std::make_shared(std::static_pointer_cast(sharedNestablePointer), parentJointIndex); - } else { - return std::make_shared(nestablePointer, parentJointIndex); - } - } - } - unsigned int pickID = propMap["parentID"].toUInt(); - if (pickID != 0) { - return std::make_shared(pickID); - } - } - - if (propMap["joint"].isValid()) { - QString joint = propMap["joint"].toString(); - if (joint == "Mouse") { - return std::make_shared(); - } else if (joint == "Avatar") { - return std::make_shared(); - } else if (!joint.isNull()) { - auto myAvatar = DependencyManager::get()->getMyAvatar(); - int jointIndex = myAvatar->getJointIndex(joint); - return std::make_shared(myAvatar, jointIndex); - } - } - return std::shared_ptr(); + if (pickID != 0) { + pick->parentTransform = std::make_shared(pickID); + } + } } \ No newline at end of file diff --git a/interface/src/raypick/PickScriptingInterface.h b/interface/src/raypick/PickScriptingInterface.h index 224f7a547e..94112d5fae 100644 --- a/interface/src/raypick/PickScriptingInterface.h +++ b/interface/src/raypick/PickScriptingInterface.h @@ -320,8 +320,7 @@ public slots: static constexpr unsigned int INTERSECTED_HUD() { return IntersectionType::HUD; } protected: - static PickQuery::JointState getPickJointState(const QVariantMap& propMap); - static std::shared_ptr createTransformNode(const QVariantMap& propMap); + static void setParentTransform(std::shared_ptr pick, const QVariantMap& propMap); }; #endif // hifi_PickScriptingInterface_h From bfa270375a891ea0292138f8108106988a67824f Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 14:33:29 -0700 Subject: [PATCH 12/39] Simplify PickRay calculations in RayPick::getMathematicalPick --- interface/src/raypick/RayPick.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/raypick/RayPick.cpp b/interface/src/raypick/RayPick.cpp index 07e583ea1b..227b4e2f32 100644 --- a/interface/src/raypick/RayPick.cpp +++ b/interface/src/raypick/RayPick.cpp @@ -21,9 +21,9 @@ PickRay RayPick::getMathematicalPick() const { } Transform currentParentTransform = parentTransform->getTransform(); - Transform relativeTransform(rotationBetween(Vectors::UP, _mathPick.direction), glm::vec3(1.0f), _mathPick.origin); - Transform pickTransform = currentParentTransform.worldTransform(relativeTransform); - return PickRay(pickTransform.getTranslation(), pickTransform.getRotation() * Vectors::UP); + glm::vec3 origin = currentParentTransform.transform(_mathPick.origin); + glm::vec3 direction = currentParentTransform.transformDirection(_mathPick.direction); + return PickRay(origin, direction); } PickResultPointer RayPick::getEntityIntersection(const PickRay& pick) { From c3df7103962d671fac948ba85cb3a43e93001bef Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 14:34:36 -0700 Subject: [PATCH 13/39] Use bracket default initialization for PickQuery::_jointState --- libraries/pointers/src/Pick.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/pointers/src/Pick.h b/libraries/pointers/src/Pick.h index 2ae1048249..0354e81163 100644 --- a/libraries/pointers/src/Pick.h +++ b/libraries/pointers/src/Pick.h @@ -236,7 +236,7 @@ private: QVector _ignoreItems; QVector _includeItems; - JointState _jointState = JOINT_STATE_NONE; + JointState _jointState { JOINT_STATE_NONE }; }; Q_DECLARE_METATYPE(PickQuery::PickType) From 74937a1979a5d4700ccd1384cdfbe92b32e7171f Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 14:41:38 -0700 Subject: [PATCH 14/39] Serialize PickRay according to its variables --- libraries/shared/src/RegisteredMetaTypes.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/libraries/shared/src/RegisteredMetaTypes.h b/libraries/shared/src/RegisteredMetaTypes.h index 58b99bc0f7..f4624686ab 100644 --- a/libraries/shared/src/RegisteredMetaTypes.h +++ b/libraries/shared/src/RegisteredMetaTypes.h @@ -178,9 +178,7 @@ public: QVariantMap toVariantMap() const override { QVariantMap pickRay; pickRay["origin"] = vec3toVariant(origin); - pickRay["position"] = vec3toVariant(origin); pickRay["direction"] = vec3toVariant(direction); - pickRay["orientation"] = quatToVariant(rotationBetween(Vectors::UP, direction)); return pickRay; } }; From c1c853790b3b4e98f62d04f0885fc7c1c8fea046 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 27 Sep 2018 14:53:28 -0700 Subject: [PATCH 15/39] update soft entities and fix deadlock --- .../qml/hifi/avatarapp/AdjustWearables.qml | 20 +++++++++++++++++++ .../src/avatars-renderer/Avatar.cpp | 8 ++++++-- .../entities/src/EntityScriptingInterface.cpp | 10 ++++++---- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml index 5bf867a331..d4a574411e 100644 --- a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml +++ b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml @@ -100,6 +100,21 @@ Rectangle { wearablesModel.setProperty(wearableIndex, 'properties', wearableModelItemProperties); } + function entityHasAvatarJoints(entityID) { + console.log(entityID); + var hasAvatarJoint = false; + var entityJointNames = Entities.getJointNames(entityID); + for (var index = 0; index < entityJointNames.length; index++) { + var avatarJointIndex = MyAvatar.getJointIndex(entityJointNames[index]); + if (avatarJointIndex >= 0) { + hasAvatarJoint = true; + break; + } + } + + return hasAvatarJoint; + } + function getCurrentWearable() { return wearablesCombobox.currentIndex !== -1 ? wearablesCombobox.model.get(wearablesCombobox.currentIndex) : null; } @@ -109,6 +124,7 @@ Rectangle { var wearable = wearablesCombobox.model.get(i); if (wearable.id === entityID) { wearablesCombobox.currentIndex = i; + isSoft.enabled = entityHasAvatarJoints(entityID); break; } } @@ -248,12 +264,16 @@ Rectangle { var scale = currentWearable ? currentWearable.dimensions.x / currentWearable.naturalDimensions.x : 1.0; var joint = currentWearable ? currentWearable.parentJointIndex : -1; var soft = currentWearable ? currentWearable.relayParentJoints : false; + var softEnabled = currentWearable ? entityHasAvatarJoints(currentWearable.id) : false; + positionVector.set(position); rotationVector.set(rotation); scalespinner.set(scale); jointsCombobox.set(joint); isSoft.set(soft); + isSoft.enabled = softEnabled; + if (currentWearable) { wearableSelected(currentWearable.id); diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index 914a3b7c6e..57d44bd9bb 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -436,9 +436,13 @@ void Avatar::relayJointDataToChildren() { modelEntity->setLocalJointTranslation(jointIndex, jointTranslation); } } + + Transform finalTransform; Transform avatarTransform = _skeletonModel->getTransform(); - avatarTransform.setScale(_skeletonModel->getScale()); - modelEntity->setOverrideTransform(avatarTransform, _skeletonModel->getOffset()); + Transform entityTransform = modelEntity->getLocalTransform(); + Transform::mult(finalTransform, avatarTransform, entityTransform); + finalTransform.setScale(_skeletonModel->getScale()); + modelEntity->setOverrideTransform(finalTransform, _skeletonModel->getOffset()); modelEntity->simulateRelayedJoints(); } } diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 8f0fde5c9a..f05971e9d7 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -1626,8 +1626,9 @@ int EntityScriptingInterface::getJointIndex(const QUuid& entityID, const QString return -1; } int result; - BLOCKING_INVOKE_METHOD(_entityTree.get(), "getJointIndex", - Q_RETURN_ARG(int, result), Q_ARG(QUuid, entityID), Q_ARG(QString, name)); + _entityTree->withReadLock([&] { + result = _entityTree->getJointIndex(entityID, name); + }); return result; } @@ -1636,8 +1637,9 @@ QStringList EntityScriptingInterface::getJointNames(const QUuid& entityID) { return QStringList(); } QStringList result; - BLOCKING_INVOKE_METHOD(_entityTree.get(), "getJointNames", - Q_RETURN_ARG(QStringList, result), Q_ARG(QUuid, entityID)); + _entityTree->withReadLock([&] { + result = _entityTree->getJointNames(entityID); + }); return result; } From bc861c1368e736a76c64674e66809dff0b2cb6e6 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 16:20:19 -0700 Subject: [PATCH 16/39] Make path pointers use scaleWithParent behind the scenes instead of scaleWithAvatar --- interface/src/raypick/LaserPointer.cpp | 21 ++++++++++---------- interface/src/raypick/LaserPointer.h | 9 ++------- interface/src/raypick/ParabolaPointer.cpp | 6 +++--- interface/src/raypick/ParabolaPointer.h | 8 ++------ interface/src/raypick/PathPointer.cpp | 24 +++++++++++++---------- interface/src/raypick/PathPointer.h | 10 +++++++--- libraries/pointers/src/PickManager.cpp | 11 +++++++++++ libraries/pointers/src/PickManager.h | 1 + 8 files changed, 50 insertions(+), 40 deletions(-) diff --git a/interface/src/raypick/LaserPointer.cpp b/interface/src/raypick/LaserPointer.cpp index 5fbe3a90b5..e5d76483df 100644 --- a/interface/src/raypick/LaserPointer.cpp +++ b/interface/src/raypick/LaserPointer.cpp @@ -14,13 +14,14 @@ #include "avatar/AvatarManager.h" #include +#include "PickManager.h" #include "RayPick.h" LaserPointer::LaserPointer(const QVariant& rayProps, const RenderStateMap& renderStates, const DefaultRenderStateMap& defaultRenderStates, bool hover, const PointerTriggers& triggers, bool faceAvatar, bool followNormal, float followNormalTime, bool centerEndY, bool lockEnd, - bool distanceScaleEnd, bool scaleWithAvatar, bool enabled) : + bool distanceScaleEnd, bool scaleWithParent, bool enabled) : PathPointer(PickQuery::Ray, rayProps, renderStates, defaultRenderStates, hover, triggers, faceAvatar, followNormal, followNormalTime, - centerEndY, lockEnd, distanceScaleEnd, scaleWithAvatar, enabled) + centerEndY, lockEnd, distanceScaleEnd, scaleWithParent, enabled) { } @@ -28,9 +29,9 @@ void LaserPointer::editRenderStatePath(const std::string& state, const QVariant& auto renderState = std::static_pointer_cast(_renderStates[state]); if (renderState) { updateRenderStateOverlay(renderState->getPathID(), pathProps); - QVariant lineWidth = pathProps.toMap()["lineWidth"]; - if (lineWidth.isValid()) { - renderState->setLineWidth(lineWidth.toFloat()); + QVariant pathWidth = pathProps.toMap()["lineWidth"]; + if (pathWidth.isValid()) { + renderState->setPathWidth(pathWidth.toFloat()); } } } @@ -117,7 +118,7 @@ LaserPointer::RenderState::RenderState(const OverlayID& startID, const OverlayID { if (!_pathID.isNull()) { _pathIgnoreRays = qApp->getOverlays().getProperty(_pathID, "ignoreRayIntersection").value.toBool(); - _lineWidth = qApp->getOverlays().getProperty(_pathID, "lineWidth").value.toFloat(); + _pathWidth = qApp->getOverlays().getProperty(_pathID, "lineWidth").value.toFloat(); } } @@ -138,9 +139,9 @@ void LaserPointer::RenderState::disable() { } } -void LaserPointer::RenderState::update(const glm::vec3& origin, const glm::vec3& end, const glm::vec3& surfaceNormal, bool scaleWithAvatar, bool distanceScaleEnd, bool centerEndY, +void LaserPointer::RenderState::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) { - StartEndRenderState::update(origin, end, surfaceNormal, scaleWithAvatar, distanceScaleEnd, centerEndY, faceAvatar, followNormal, followNormalStrength, distance, pickResult); + StartEndRenderState::update(origin, end, surfaceNormal, parentScale, distanceScaleEnd, centerEndY, faceAvatar, followNormal, followNormalStrength, distance, pickResult); QVariant endVariant = vec3toVariant(end); if (!getPathID().isNull()) { QVariantMap pathProps; @@ -148,9 +149,7 @@ void LaserPointer::RenderState::update(const glm::vec3& origin, const glm::vec3& pathProps.insert("end", endVariant); pathProps.insert("visible", true); pathProps.insert("ignoreRayIntersection", doesPathIgnoreRays()); - if (scaleWithAvatar) { - pathProps.insert("lineWidth", getLineWidth() * DependencyManager::get()->getMyAvatar()->getSensorToWorldScale()); - } + pathProps.insert("lineWidth", getPathWidth() * parentScale); qApp->getOverlays().editOverlay(getPathID(), pathProps); } } diff --git a/interface/src/raypick/LaserPointer.h b/interface/src/raypick/LaserPointer.h index c0ac3259d9..e5c195f9d4 100644 --- a/interface/src/raypick/LaserPointer.h +++ b/interface/src/raypick/LaserPointer.h @@ -24,23 +24,18 @@ public: const OverlayID& getPathID() const { return _pathID; } const bool& doesPathIgnoreRays() const { return _pathIgnoreRays; } - void setLineWidth(const float& lineWidth) { _lineWidth = lineWidth; } - const float& getLineWidth() const { return _lineWidth; } - void cleanup() override; void disable() override; - void update(const glm::vec3& origin, const glm::vec3& end, const glm::vec3& surfaceNormal, bool scaleWithAvatar, bool distanceScaleEnd, bool centerEndY, + void 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) override; private: OverlayID _pathID; bool _pathIgnoreRays; - - float _lineWidth; }; LaserPointer(const QVariant& rayProps, const RenderStateMap& renderStates, const DefaultRenderStateMap& defaultRenderStates, bool hover, const PointerTriggers& triggers, - bool faceAvatar, bool followNormal, float followNormalStrength, bool centerEndY, bool lockEnd, bool distanceScaleEnd, bool scaleWithAvatar, bool enabled); + bool faceAvatar, bool followNormal, float followNormalStrength, bool centerEndY, bool lockEnd, bool distanceScaleEnd, bool scaleWithParent, bool enabled); QVariantMap toVariantMap() const override; diff --git a/interface/src/raypick/ParabolaPointer.cpp b/interface/src/raypick/ParabolaPointer.cpp index ad698c409b..71e4caeb76 100644 --- a/interface/src/raypick/ParabolaPointer.cpp +++ b/interface/src/raypick/ParabolaPointer.cpp @@ -190,9 +190,9 @@ void ParabolaPointer::RenderState::editParabola(const glm::vec3& color, float al } } -void ParabolaPointer::RenderState::update(const glm::vec3& origin, const glm::vec3& end, const glm::vec3& surfaceNormal, bool scaleWithAvatar, bool distanceScaleEnd, bool centerEndY, +void ParabolaPointer::RenderState::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) { - StartEndRenderState::update(origin, end, surfaceNormal, scaleWithAvatar, distanceScaleEnd, centerEndY, faceAvatar, followNormal, followNormalStrength, distance, pickResult); + StartEndRenderState::update(origin, end, surfaceNormal, parentScale, distanceScaleEnd, centerEndY, faceAvatar, followNormal, followNormalStrength, distance, pickResult); auto parabolaPickResult = std::static_pointer_cast(pickResult); if (parabolaPickResult && render::Item::isValidID(_pathID)) { render::Transaction transaction; @@ -202,7 +202,7 @@ void ParabolaPointer::RenderState::update(const glm::vec3& origin, const glm::ve glm::vec3 velocity = parabola.velocity; glm::vec3 acceleration = parabola.acceleration; float parabolicDistance = distance > 0.0f ? distance : parabolaPickResult->parabolicDistance; - float width = scaleWithAvatar ? getPathWidth() * DependencyManager::get()->getMyAvatar()->getSensorToWorldScale() : getPathWidth(); + float width = getPathWidth() * parentScale; transaction.updateItem(_pathID, [origin, velocity, acceleration, parabolicDistance, width](ParabolaRenderItem& item) { item.setVisible(true); item.setOrigin(origin); diff --git a/interface/src/raypick/ParabolaPointer.h b/interface/src/raypick/ParabolaPointer.h index 526abe3b0d..e4394bc509 100644 --- a/interface/src/raypick/ParabolaPointer.h +++ b/interface/src/raypick/ParabolaPointer.h @@ -76,22 +76,18 @@ public: }; RenderState() {} - RenderState(const OverlayID& startID, const OverlayID& endID, const glm::vec3& pathColor, float pathAlpha, float pathWidth, + RenderState(const OverlayID& startID, const OverlayID& endID, const glm::vec3& pathColor, float pathAlpha, float parentScale, bool isVisibleInSecondaryCamera, bool pathEnabled); - void setPathWidth(float width) { _pathWidth = width; } - float getPathWidth() const { return _pathWidth; } - void cleanup() override; void disable() override; - void update(const glm::vec3& origin, const glm::vec3& end, const glm::vec3& surfaceNormal, bool scaleWithAvatar, bool distanceScaleEnd, bool centerEndY, + void 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) override; void editParabola(const glm::vec3& color, float alpha, float width, bool isVisibleInSecondaryCamera, bool enabled); private: int _pathID; - float _pathWidth; }; ParabolaPointer(const QVariant& rayProps, const RenderStateMap& renderStates, const DefaultRenderStateMap& defaultRenderStates, bool hover, const PointerTriggers& triggers, diff --git a/interface/src/raypick/PathPointer.cpp b/interface/src/raypick/PathPointer.cpp index 0301136bfa..6cc3dfba56 100644 --- a/interface/src/raypick/PathPointer.cpp +++ b/interface/src/raypick/PathPointer.cpp @@ -17,7 +17,7 @@ PathPointer::PathPointer(PickQuery::PickType type, const QVariant& rayProps, const RenderStateMap& renderStates, const DefaultRenderStateMap& defaultRenderStates, bool hover, const PointerTriggers& triggers, bool faceAvatar, bool followNormal, float followNormalStrength, bool centerEndY, bool lockEnd, - bool distanceScaleEnd, bool scaleWithAvatar, bool enabled) : + bool distanceScaleEnd, bool scaleWithParent, bool enabled) : Pointer(DependencyManager::get()->createPick(type, rayProps), enabled, hover), _renderStates(renderStates), _defaultRenderStates(defaultRenderStates), @@ -28,7 +28,7 @@ PathPointer::PathPointer(PickQuery::PickType type, const QVariant& rayProps, con _centerEndY(centerEndY), _lockEnd(lockEnd), _distanceScaleEnd(distanceScaleEnd), - _scaleWithAvatar(scaleWithAvatar) + _scaleWithParent(scaleWithParent) { for (auto& state : _renderStates) { if (!enabled || state.first != _currentRenderState) { @@ -146,12 +146,18 @@ void PathPointer::updateVisuals(const PickResultPointer& pickResult) { IntersectionType type = getPickedObjectType(pickResult); auto renderState = _renderStates.find(_currentRenderState); auto defaultRenderState = _defaultRenderStates.find(_currentRenderState); + float parentScale = 1; + if (_enabled && _scaleWithParent) { + glm::vec3 dimensions = DependencyManager::get()->getParentTransform(_pickUID).getScale(); + parentScale = glm::max(glm::max(dimensions.x, dimensions.y), dimensions.z); + } + if (_enabled && !_currentRenderState.empty() && renderState != _renderStates.end() && (type != IntersectionType::NONE || _pathLength > 0.0f)) { glm::vec3 origin = getPickOrigin(pickResult); glm::vec3 end = getPickEnd(pickResult, _pathLength); glm::vec3 surfaceNormal = getPickedObjectNormal(pickResult); - renderState->second->update(origin, end, surfaceNormal, _scaleWithAvatar, _distanceScaleEnd, _centerEndY, _faceAvatar, + renderState->second->update(origin, end, surfaceNormal, parentScale, _distanceScaleEnd, _centerEndY, _faceAvatar, _followNormal, _followNormalStrength, _pathLength, pickResult); if (defaultRenderState != _defaultRenderStates.end() && defaultRenderState->second.second->isEnabled()) { defaultRenderState->second.second->disable(); @@ -162,7 +168,7 @@ void PathPointer::updateVisuals(const PickResultPointer& pickResult) { } glm::vec3 origin = getPickOrigin(pickResult); glm::vec3 end = getPickEnd(pickResult, defaultRenderState->second.first); - defaultRenderState->second.second->update(origin, end, Vectors::UP, _scaleWithAvatar, _distanceScaleEnd, _centerEndY, + defaultRenderState->second.second->update(origin, end, Vectors::UP, parentScale, _distanceScaleEnd, _centerEndY, _faceAvatar, _followNormal, _followNormalStrength, defaultRenderState->second.first, pickResult); } else if (!_currentRenderState.empty()) { if (renderState != _renderStates.end() && renderState->second->isEnabled()) { @@ -281,15 +287,13 @@ void StartEndRenderState::disable() { _enabled = false; } -void StartEndRenderState::update(const glm::vec3& origin, const glm::vec3& end, const glm::vec3& surfaceNormal, bool scaleWithAvatar, bool distanceScaleEnd, bool centerEndY, +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) { if (!getStartID().isNull()) { QVariantMap startProps; startProps.insert("position", vec3toVariant(origin)); startProps.insert("visible", true); - if (scaleWithAvatar) { - startProps.insert("dimensions", vec3toVariant(getStartDim() * DependencyManager::get()->getMyAvatar()->getSensorToWorldScale())); - } + startProps.insert("dimensions", vec3toVariant(getStartDim() * parentScale)); startProps.insert("ignoreRayIntersection", doesStartIgnoreRays()); qApp->getOverlays().editOverlay(getStartID(), startProps); } @@ -300,8 +304,8 @@ void StartEndRenderState::update(const glm::vec3& origin, const glm::vec3& end, if (distanceScaleEnd) { dim = getEndDim() * glm::distance(origin, end); endProps.insert("dimensions", vec3toVariant(dim)); - } else if (scaleWithAvatar) { - dim = getEndDim() * DependencyManager::get()->getMyAvatar()->getSensorToWorldScale(); + } else { + dim = getEndDim() * parentScale; endProps.insert("dimensions", vec3toVariant(dim)); } diff --git a/interface/src/raypick/PathPointer.h b/interface/src/raypick/PathPointer.h index b3638d1f7d..5001d3d1bd 100644 --- a/interface/src/raypick/PathPointer.h +++ b/interface/src/raypick/PathPointer.h @@ -42,9 +42,12 @@ public: void setEndRot(const glm::quat& endRot) { _endRot = endRot; } const glm::quat& getEndRot() const { return _endRot; } + void setPathWidth(float width) { _pathWidth = width; } + float getPathWidth() const { return _pathWidth; } + virtual void cleanup(); virtual void disable(); - virtual void update(const glm::vec3& origin, const glm::vec3& end, const glm::vec3& surfaceNormal, bool scaleWithAvatar, bool distanceScaleEnd, bool centerEndY, + virtual void 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); bool isEnabled() const { return _enabled; } @@ -58,6 +61,7 @@ protected: glm::vec3 _startDim; glm::vec3 _endDim; glm::quat _endRot; + float _pathWidth; glm::quat _avgEndRot; bool _avgEndRotInitialized { false }; @@ -73,7 +77,7 @@ class PathPointer : public Pointer { public: PathPointer(PickQuery::PickType type, const QVariant& rayProps, const RenderStateMap& renderStates, const DefaultRenderStateMap& defaultRenderStates, bool hover, const PointerTriggers& triggers, bool faceAvatar, bool followNormal, float followNormalStrength, bool centerEndY, bool lockEnd, - bool distanceScaleEnd, bool scaleWithAvatar, bool enabled); + bool distanceScaleEnd, bool scaleWithParent, bool enabled); virtual ~PathPointer(); void setRenderState(const std::string& state) override; @@ -97,7 +101,7 @@ protected: bool _centerEndY; bool _lockEnd; bool _distanceScaleEnd; - bool _scaleWithAvatar; + bool _scaleWithParent; LockEndObject _lockEndObject; struct TriggerState { diff --git a/libraries/pointers/src/PickManager.cpp b/libraries/pointers/src/PickManager.cpp index f7553cb66e..caa62f3397 100644 --- a/libraries/pointers/src/PickManager.cpp +++ b/libraries/pointers/src/PickManager.cpp @@ -90,6 +90,17 @@ void PickManager::setIncludeItems(unsigned int uid, const QVector& includ } } +Transform PickManager::getParentTransform(unsigned int uid) const { + auto pick = findPick(uid); + if (pick) { + auto parentTransform = pick->parentTransform; + if (parentTransform) { + return parentTransform->getTransform(); + } + } + return Transform(); +} + Transform PickManager::getResultTransform(unsigned int uid) const { auto pick = findPick(uid); if (pick) { diff --git a/libraries/pointers/src/PickManager.h b/libraries/pointers/src/PickManager.h index cf911236a1..9d5971078d 100644 --- a/libraries/pointers/src/PickManager.h +++ b/libraries/pointers/src/PickManager.h @@ -43,6 +43,7 @@ public: void setIgnoreItems(unsigned int uid, const QVector& ignore) const; void setIncludeItems(unsigned int uid, const QVector& include) const; + Transform getParentTransform(unsigned int uid) const; Transform getResultTransform(unsigned int uid) const; bool isLeftHand(unsigned int uid); From 2dd8140158435dde4efe6e02e870d974f71438a9 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 16:37:40 -0700 Subject: [PATCH 17/39] Make scaleWithAvatar an alias for scaleWithParent in PointerScriptingInterface and make true the default for parabola pointers --- .../src/raypick/PointerScriptingInterface.cpp | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/interface/src/raypick/PointerScriptingInterface.cpp b/interface/src/raypick/PointerScriptingInterface.cpp index 7209e402a1..1f1bf76d21 100644 --- a/interface/src/raypick/PointerScriptingInterface.cpp +++ b/interface/src/raypick/PointerScriptingInterface.cpp @@ -97,7 +97,8 @@ unsigned int PointerScriptingInterface::createStylus(const QVariant& properties) * @property {boolean} [centerEndY=true] If false, the end of the Pointer will be moved up by half of its height. * @property {boolean} [lockEnd=false] If true, the end of the Pointer will lock on to the center of the object at which the pointer is pointing. * @property {boolean} [distanceScaleEnd=false] If true, the dimensions of the end of the Pointer will scale linearly with distance. - * @property {boolean} [scaleWithAvatar=false] If true, the width of the Pointer's path will scale linearly with your avatar's scale. + * @property {boolean} [scaleWithParent=false] If true, the width of the Pointer's path will scale linearly with the pick parent's scale. + * @property {boolean} [scaleWithAvatar] Alias for scaleWithParent * @property {boolean} [followNormal=false] If true, the end of the Pointer will rotate to follow the normal of the intersected surface. * @property {number} [followNormalStrength=0.0] The strength of the interpolation between the real normal and the visual normal if followNormal is true. 0-1. If 0 or 1, * the normal will follow exactly. @@ -134,9 +135,11 @@ unsigned int PointerScriptingInterface::createLaserPointer(const QVariant& prope distanceScaleEnd = propertyMap["distanceScaleEnd"].toBool(); } - bool scaleWithAvatar = false; - if (propertyMap["scaleWithAvatar"].isValid()) { - scaleWithAvatar = propertyMap["scaleWithAvatar"].toBool(); + bool scaleWithParent = false; + if (propertyMap["scaleWithParent"].isValid()) { + scaleWithParent = propertyMap["scaleWithParent"].toBool(); + } else if (propertyMap["scaleWithAvatar"].isValid()) { + scaleWithParent = propertyMap["scaleWithAvatar"].toBool(); } bool followNormal = false; @@ -207,7 +210,7 @@ unsigned int PointerScriptingInterface::createLaserPointer(const QVariant& prope return DependencyManager::get()->addPointer(std::make_shared(properties, renderStates, defaultRenderStates, hover, triggers, faceAvatar, followNormal, followNormalStrength, centerEndY, lockEnd, - distanceScaleEnd, scaleWithAvatar, enabled)); + distanceScaleEnd, scaleWithParent, enabled)); } /**jsdoc @@ -248,7 +251,8 @@ unsigned int PointerScriptingInterface::createLaserPointer(const QVariant& prope * @property {boolean} [centerEndY=true] If false, the end of the Pointer will be moved up by half of its height. * @property {boolean} [lockEnd=false] If true, the end of the Pointer will lock on to the center of the object at which the pointer is pointing. * @property {boolean} [distanceScaleEnd=false] If true, the dimensions of the end of the Pointer will scale linearly with distance. -* @property {boolean} [scaleWithAvatar=false] If true, the width of the Pointer's path will scale linearly with your avatar's scale. +* @property {boolean} [scaleWithParent=true] If true, the width of the Pointer's path will scale linearly with the pick parent's scale. +* @property {boolean} [scaleWithAvatar] Alias for scaleWithParent * @property {boolean} [followNormal=false] If true, the end of the Pointer will rotate to follow the normal of the intersected surface. * @property {number} [followNormalStrength=0.0] The strength of the interpolation between the real normal and the visual normal if followNormal is true. 0-1. If 0 or 1, * the normal will follow exactly. @@ -285,9 +289,11 @@ unsigned int PointerScriptingInterface::createParabolaPointer(const QVariant& pr distanceScaleEnd = propertyMap["distanceScaleEnd"].toBool(); } - bool scaleWithAvatar = false; - if (propertyMap["scaleWithAvatar"].isValid()) { - scaleWithAvatar = propertyMap["scaleWithAvatar"].toBool(); + bool scaleWithParent = true; + if (propertyMap["scaleWithParent"].isValid()) { + scaleWithParent = propertyMap["scaleWithParent"].toBool(); + } else if (propertyMap["scaleWithAvatar"].isValid()) { + scaleWithParent = propertyMap["scaleWithAvatar"].toBool(); } bool followNormal = false; @@ -358,7 +364,7 @@ unsigned int PointerScriptingInterface::createParabolaPointer(const QVariant& pr return DependencyManager::get()->addPointer(std::make_shared(properties, renderStates, defaultRenderStates, hover, triggers, faceAvatar, followNormal, followNormalStrength, centerEndY, lockEnd, distanceScaleEnd, - scaleWithAvatar, enabled)); + scaleWithParent, enabled)); } void PointerScriptingInterface::editRenderState(unsigned int uid, const QString& renderState, const QVariant& properties) const { From e1761430258023faa0547a6af50c2933c09e8aac Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 16:39:37 -0700 Subject: [PATCH 18/39] Make scaleWithParent true by default for parabola picks --- interface/src/raypick/PickScriptingInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/raypick/PickScriptingInterface.cpp b/interface/src/raypick/PickScriptingInterface.cpp index 2e8f790da5..18677fa6e7 100644 --- a/interface/src/raypick/PickScriptingInterface.cpp +++ b/interface/src/raypick/PickScriptingInterface.cpp @@ -158,7 +158,7 @@ unsigned int PickScriptingInterface::createStylusPick(const QVariant& properties * @property {Vec3} [accelerationAxis=-Vec3.UP] The acceleration of the parabola, i.e. the acceleration of the projectile whose trajectory defines the parabola, both magnitude and direction. * @property {boolean} [rotateAccelerationWithAvatar=true] Whether or not the acceleration axis should rotate with the avatar's local Y axis. * @property {boolean} [rotateAccelerationWithParent=false] Whether or not the acceleration axis should rotate with the parent's local Y axis, if available. - * @property {boolean} [scaleWithParent=false] If true, the velocity and acceleration of the Pick will scale linearly with the parent, if available. + * @property {boolean} [scaleWithParent=true] If true, the velocity and acceleration of the Pick will scale linearly with the parent, if available. * @property {boolean} [scaleWithAvatar] Alias for scaleWithParent. Deprecated. */ unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properties) { @@ -199,7 +199,7 @@ unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properti rotateAccelerationWithParent = propMap["rotateAccelerationWithParent"].toBool(); } - bool scaleWithParent = false; + bool scaleWithParent = true; if (propMap["scaleWithParent"].isValid()) { scaleWithParent = propMap["scaleWithParent"].toBool(); } else if (propMap["scaleWithAvatar"].isValid()) { From 44efe648e083f7fd80393775424e1897e9f83ca7 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 17:05:31 -0700 Subject: [PATCH 19/39] Add scaleWithParent option to collision pick creation --- interface/src/raypick/CollisionPick.cpp | 15 +++++++++++---- interface/src/raypick/CollisionPick.h | 4 +++- interface/src/raypick/PickScriptingInterface.cpp | 8 +++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/interface/src/raypick/CollisionPick.cpp b/interface/src/raypick/CollisionPick.cpp index 5b5ecd09ff..7ea739be06 100644 --- a/interface/src/raypick/CollisionPick.cpp +++ b/interface/src/raypick/CollisionPick.cpp @@ -345,8 +345,9 @@ void CollisionPick::computeShapeInfo(const CollisionRegion& pick, ShapeInfo& sha } } -CollisionPick::CollisionPick(const PickFilter& filter, float maxDistance, bool enabled, CollisionRegion collisionRegion, PhysicsEnginePointer physicsEngine) : +CollisionPick::CollisionPick(const PickFilter& filter, float maxDistance, bool enabled, bool scaleWithParent, CollisionRegion collisionRegion, PhysicsEnginePointer physicsEngine) : Pick(collisionRegion, filter, maxDistance, enabled), + _scaleWithParent(scaleWithParent), _physicsEngine(physicsEngine) { if (collisionRegion.shouldComputeShapeInfo()) { _cachedResource = DependencyManager::get()->getCollisionGeometryResource(collisionRegion.modelURL); @@ -360,9 +361,15 @@ CollisionRegion CollisionPick::getMathematicalPick() const { if (parentTransform) { Transform parentTransformValue = parentTransform->getTransform(); mathPick.transform = parentTransformValue.worldTransform(mathPick.transform); - glm::vec3 scale = parentTransformValue.getScale(); - float largestDimension = glm::max(glm::max(scale.x, scale.y), scale.z); - mathPick.threshold *= largestDimension; + + if (_scaleWithParent) { + glm::vec3 scale = parentTransformValue.getScale(); + float largestDimension = glm::max(glm::max(scale.x, scale.y), scale.z); + mathPick.threshold *= largestDimension; + } else { + // We need to undo parent scaling after-the-fact because the parent's scale was needed to calculate this mathPick's position + mathPick.transform.setScale(_mathPick.transform.getScale()); + } } return mathPick; } diff --git a/interface/src/raypick/CollisionPick.h b/interface/src/raypick/CollisionPick.h index 79238b37fc..67e39e4d72 100644 --- a/interface/src/raypick/CollisionPick.h +++ b/interface/src/raypick/CollisionPick.h @@ -47,7 +47,7 @@ public: class CollisionPick : public Pick { public: - CollisionPick(const PickFilter& filter, float maxDistance, bool enabled, CollisionRegion collisionRegion, PhysicsEnginePointer physicsEngine); + CollisionPick(const PickFilter& filter, float maxDistance, bool enabled, bool scaleWithParent, CollisionRegion collisionRegion, PhysicsEnginePointer physicsEngine); CollisionRegion getMathematicalPick() const override; PickResultPointer getDefaultResult(const QVariantMap& pickVariant) const override { @@ -67,6 +67,8 @@ protected: void computeShapeInfoDimensionsOnly(const CollisionRegion& pick, ShapeInfo& shapeInfo, QSharedPointer resource); void filterIntersections(std::vector& intersections) const; + bool _scaleWithParent; + PhysicsEnginePointer _physicsEngine; QSharedPointer _cachedResource; diff --git a/interface/src/raypick/PickScriptingInterface.cpp b/interface/src/raypick/PickScriptingInterface.cpp index 18677fa6e7..4218d593aa 100644 --- a/interface/src/raypick/PickScriptingInterface.cpp +++ b/interface/src/raypick/PickScriptingInterface.cpp @@ -254,6 +254,7 @@ unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properti * @property {Uuid} parentID - The ID of the parent, either an avatar, an entity, or an overlay. * @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. +* @property {boolean} [scaleWithParent=true] If true, the collision pick's dimensions and threshold will adjust according to the scale of the parent. */ unsigned int PickScriptingInterface::createCollisionPick(const QVariant& properties) { QVariantMap propMap = properties.toMap(); @@ -273,8 +274,13 @@ unsigned int PickScriptingInterface::createCollisionPick(const QVariant& propert maxDistance = propMap["maxDistance"].toFloat(); } + bool scaleWithParent = true; + if (propMap["scaleWithParent"].isValid()) { + scaleWithParent = propMap["scaleWithParent"].toBool(); + } + CollisionRegion collisionRegion(propMap); - auto collisionPick = std::make_shared(filter, maxDistance, enabled, collisionRegion, qApp->getPhysicsEngine()); + auto collisionPick = std::make_shared(filter, maxDistance, enabled, scaleWithParent, collisionRegion, qApp->getPhysicsEngine()); setParentTransform(collisionPick, propMap); return DependencyManager::get()->addPick(PickQuery::Collision, collisionPick); From e7c70705b27ab0e9d0a05c7c6a9e3ba63e4106ab Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 17:07:03 -0700 Subject: [PATCH 20/39] Actually make the result transform of a collision pick just a position, as documented --- interface/src/raypick/CollisionPick.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/src/raypick/CollisionPick.cpp b/interface/src/raypick/CollisionPick.cpp index 7ea739be06..25927c5b68 100644 --- a/interface/src/raypick/CollisionPick.cpp +++ b/interface/src/raypick/CollisionPick.cpp @@ -430,5 +430,7 @@ PickResultPointer CollisionPick::getHUDIntersection(const CollisionRegion& pick) } Transform CollisionPick::getResultTransform() const { - return Transform(getMathematicalPick().transform); + Transform transform; + transform.setTranslation(_mathPick.transform.getTranslation()); + return transform; } \ No newline at end of file From 411dbbbad3f424aef1b735c6ec82f6ab00c3b0c0 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Thu, 27 Sep 2018 17:14:30 -0700 Subject: [PATCH 21/39] Make scripts use the default scaleWithParent when creating ray/parabola picks --- scripts/system/controllers/controllerDispatcher.js | 8 ++++---- scripts/system/controllers/controllerModules/teleport.js | 8 ++++---- scripts/system/controllers/grab.js | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index 7a916392b9..f23b61a5b1 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -408,7 +408,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); triggers: [{action: Controller.Standard.LTClick, button: "Focus"}, {action: Controller.Standard.LTClick, button: "Primary"}], posOffset: getGrabPointSphereOffset(Controller.Standard.LeftHand, true), hover: true, - scaleWithAvatar: true, + scaleWithParent: true, distanceScaleEnd: true, hand: LEFT_HAND }); @@ -418,7 +418,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); triggers: [{action: Controller.Standard.RTClick, button: "Focus"}, {action: Controller.Standard.RTClick, button: "Primary"}], posOffset: getGrabPointSphereOffset(Controller.Standard.RightHand, true), hover: true, - scaleWithAvatar: true, + scaleWithParent: true, distanceScaleEnd: true, hand: RIGHT_HAND }); @@ -429,7 +429,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); posOffset: getGrabPointSphereOffset(Controller.Standard.LeftHand, true), triggers: [{action: Controller.Standard.LTClick, button: "Focus"}, {action: Controller.Standard.LTClick, button: "Primary"}], hover: true, - scaleWithAvatar: true, + scaleWithParent: true, distanceScaleEnd: true, hand: LEFT_HAND }); @@ -440,7 +440,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); posOffset: getGrabPointSphereOffset(Controller.Standard.RightHand, true), triggers: [{action: Controller.Standard.RTClick, button: "Focus"}, {action: Controller.Standard.RTClick, button: "Primary"}], hover: true, - scaleWithAvatar: true, + scaleWithParent: true, distanceScaleEnd: true, hand: RIGHT_HAND }); diff --git a/scripts/system/controllers/controllerModules/teleport.js b/scripts/system/controllers/controllerModules/teleport.js index deaa934f99..077d529262 100644 --- a/scripts/system/controllers/controllerModules/teleport.js +++ b/scripts/system/controllers/controllerModules/teleport.js @@ -169,7 +169,7 @@ Script.include("/~/system/libraries/controllers.js"); posOffset: { x: (_this.hand === RIGHT_HAND) ? 0.03 : -0.03, y: 0.2, z: 0.02 }, filter: Picks.PICK_ENTITIES | Picks.PICK_INCLUDE_INVISIBLE, faceAvatar: true, - scaleWithAvatar: true, + scaleWithParent: true, centerEndY: false, speed: speed, accelerationAxis: accelerationAxis, @@ -185,7 +185,7 @@ Script.include("/~/system/libraries/controllers.js"); posOffset: { x: (_this.hand === RIGHT_HAND) ? 0.03 : -0.03, y: 0.2, z: 0.02 }, filter: Picks.PICK_ENTITIES | Picks.PICK_INCLUDE_INVISIBLE, faceAvatar: true, - scaleWithAvatar: true, + scaleWithParent: true, centerEndY: false, speed: speed, accelerationAxis: accelerationAxis, @@ -198,7 +198,7 @@ Script.include("/~/system/libraries/controllers.js"); joint: "Avatar", filter: Picks.PICK_ENTITIES | Picks.PICK_INCLUDE_INVISIBLE, faceAvatar: true, - scaleWithAvatar: true, + scaleWithParent: true, centerEndY: false, speed: speed, accelerationAxis: accelerationAxis, @@ -212,7 +212,7 @@ Script.include("/~/system/libraries/controllers.js"); joint: "Avatar", filter: Picks.PICK_ENTITIES | Picks.PICK_INCLUDE_INVISIBLE, faceAvatar: true, - scaleWithAvatar: true, + scaleWithParent: true, centerEndY: false, speed: speed, accelerationAxis: accelerationAxis, diff --git a/scripts/system/controllers/grab.js b/scripts/system/controllers/grab.js index 066ef18c97..48229ac9d9 100644 --- a/scripts/system/controllers/grab.js +++ b/scripts/system/controllers/grab.js @@ -272,7 +272,7 @@ function Grabber() { joint: "Mouse", filter: Picks.PICK_ENTITIES | Picks.PICK_INCLUDE_NONCOLLIDABLE, faceAvatar: true, - scaleWithAvatar: true, + scaleWithParent: true, enabled: true, renderStates: renderStates }); From 8f2d3b17d3d8e5e3dcec715c4e741785aad7894a Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Fri, 28 Sep 2018 09:27:38 -0700 Subject: [PATCH 22/39] Fix parabola scaling issues and raypick velocity denormalization due to transform affecting direction scale --- interface/src/raypick/ParabolaPick.cpp | 5 +++-- interface/src/raypick/RayPick.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/interface/src/raypick/ParabolaPick.cpp b/interface/src/raypick/ParabolaPick.cpp index b10f82c9bd..e8986f7ce9 100644 --- a/interface/src/raypick/ParabolaPick.cpp +++ b/interface/src/raypick/ParabolaPick.cpp @@ -36,9 +36,10 @@ PickParabola ParabolaPick::getMathematicalPick() const { glm::vec3 position = currentParentTransform.transform(_mathPick.origin); glm::vec3 velocity = _mathPick.velocity; if (_scaleWithParent) { - velocity = currentParentTransform.transform(velocity); - } else { velocity = currentParentTransform.transformDirection(velocity); + } else { + glm::vec3 transformedVelocity = currentParentTransform.transformDirection(velocity); + velocity = glm::normalize(transformedVelocity) * glm::distance(velocity, Vectors::ZERO); } glm::vec3 acceleration = _mathPick.acceleration; if (_rotateAccelerationWithAvatar) { diff --git a/interface/src/raypick/RayPick.cpp b/interface/src/raypick/RayPick.cpp index 227b4e2f32..ad12db4df2 100644 --- a/interface/src/raypick/RayPick.cpp +++ b/interface/src/raypick/RayPick.cpp @@ -22,7 +22,7 @@ PickRay RayPick::getMathematicalPick() const { Transform currentParentTransform = parentTransform->getTransform(); glm::vec3 origin = currentParentTransform.transform(_mathPick.origin); - glm::vec3 direction = currentParentTransform.transformDirection(_mathPick.direction); + glm::vec3 direction = glm::normalize(currentParentTransform.transformDirection(_mathPick.direction)); return PickRay(origin, direction); } From e51f48d7ef6a8091802c8991dfd2d40e8c3fea53 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Fri, 28 Sep 2018 09:55:02 -0700 Subject: [PATCH 23/39] Add collision pick documentation on scaleWithParent option --- docs/interface/raypick/pick-parenting.md.html | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/docs/interface/raypick/pick-parenting.md.html b/docs/interface/raypick/pick-parenting.md.html index 82f38a1494..5c2ceb37ac 100644 --- a/docs/interface/raypick/pick-parenting.md.html +++ b/docs/interface/raypick/pick-parenting.md.html @@ -247,29 +247,31 @@ The collision pick's threshold also rescales. The change is proportional to the dimension of the parent. So, if the largest dimension of the parent was 3.0 and is now 6.0, the threshold doubles. -************************************************************ -* * -* before after * -* * -* pick * -* +------------+ * -* | | * -* | ........ | * -* | . . | * -* | . . | * -* | . . | * -* pick | . . | * -* +-----+ | ........ +___ * -* |.....| | | theshold * -* |. .| theshold +------------+--- * -* |.....|___ | * -* +-----+--- <-+ * -* +----------+ * -* +---+ / \ * -* +-----+ +--------------+ * -* parent parent * -* * -************************************************************ +************************************************************************************** +* * +* before after after * +* (scaleWithParent (scaleWithParent * +* is false) is true) * +* * +* pick * +* +------------+ * +* | | * +* pick | ........ | * +* +-----+ | . . | * +* |.....| | . . | * +* |. .| theshold | . . | * +* pick |.....|___ | | . . | * +* +-----+ +-----+--- <-+ | ........ +___ * +* |.....| | | theshold * +* |. .| theshold +------------+--- * +* |.....|___ | * +* +-----+--- <-+ * +* +----------+ +----------+ * +* +---+ / \ / \ * +* +-----+ +--------------+ +--------------+ * +* parent parent parent * +* * +************************************************************************************** From 0c3f55d6eff89c84b8cc2eabd42800b4635b9882 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Fri, 28 Sep 2018 15:39:37 -0700 Subject: [PATCH 24/39] Code style for floating point literal --- interface/src/raypick/PathPointer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/raypick/PathPointer.cpp b/interface/src/raypick/PathPointer.cpp index 6cc3dfba56..00ab32bde4 100644 --- a/interface/src/raypick/PathPointer.cpp +++ b/interface/src/raypick/PathPointer.cpp @@ -146,7 +146,7 @@ void PathPointer::updateVisuals(const PickResultPointer& pickResult) { IntersectionType type = getPickedObjectType(pickResult); auto renderState = _renderStates.find(_currentRenderState); auto defaultRenderState = _defaultRenderStates.find(_currentRenderState); - float parentScale = 1; + float parentScale = 1.0f; if (_enabled && _scaleWithParent) { glm::vec3 dimensions = DependencyManager::get()->getParentTransform(_pickUID).getScale(); parentScale = glm::max(glm::max(dimensions.x, dimensions.y), dimensions.z); From b60a62da8f87e7ba05f73074696766a69db36c58 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Fri, 28 Sep 2018 16:04:34 -0700 Subject: [PATCH 25/39] Move pathWidth variable in PathPointer back down to specialized classes --- interface/src/raypick/LaserPointer.cpp | 10 +++++----- interface/src/raypick/LaserPointer.h | 5 +++++ interface/src/raypick/ParabolaPointer.h | 4 ++++ interface/src/raypick/PathPointer.h | 4 ---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/interface/src/raypick/LaserPointer.cpp b/interface/src/raypick/LaserPointer.cpp index e5d76483df..8c34f1ab0b 100644 --- a/interface/src/raypick/LaserPointer.cpp +++ b/interface/src/raypick/LaserPointer.cpp @@ -29,9 +29,9 @@ void LaserPointer::editRenderStatePath(const std::string& state, const QVariant& auto renderState = std::static_pointer_cast(_renderStates[state]); if (renderState) { updateRenderStateOverlay(renderState->getPathID(), pathProps); - QVariant pathWidth = pathProps.toMap()["lineWidth"]; - if (pathWidth.isValid()) { - renderState->setPathWidth(pathWidth.toFloat()); + QVariant lineWidth = pathProps.toMap()["lineWidth"]; + if (lineWidth.isValid()) { + renderState->setLineWidth(lineWidth.toFloat()); } } } @@ -118,7 +118,7 @@ LaserPointer::RenderState::RenderState(const OverlayID& startID, const OverlayID { if (!_pathID.isNull()) { _pathIgnoreRays = qApp->getOverlays().getProperty(_pathID, "ignoreRayIntersection").value.toBool(); - _pathWidth = qApp->getOverlays().getProperty(_pathID, "lineWidth").value.toFloat(); + _lineWidth = qApp->getOverlays().getProperty(_pathID, "lineWidth").value.toFloat(); } } @@ -149,7 +149,7 @@ void LaserPointer::RenderState::update(const glm::vec3& origin, const glm::vec3& pathProps.insert("end", endVariant); pathProps.insert("visible", true); pathProps.insert("ignoreRayIntersection", doesPathIgnoreRays()); - pathProps.insert("lineWidth", getPathWidth() * parentScale); + pathProps.insert("lineWidth", getLineWidth() * parentScale); qApp->getOverlays().editOverlay(getPathID(), pathProps); } } diff --git a/interface/src/raypick/LaserPointer.h b/interface/src/raypick/LaserPointer.h index e5c195f9d4..9b53d8da4b 100644 --- a/interface/src/raypick/LaserPointer.h +++ b/interface/src/raypick/LaserPointer.h @@ -24,6 +24,9 @@ public: const OverlayID& getPathID() const { return _pathID; } const bool& doesPathIgnoreRays() const { return _pathIgnoreRays; } + void setLineWidth(float width) { _lineWidth = width; } + float getLineWidth() const { return _lineWidth; } + void cleanup() override; void disable() override; void update(const glm::vec3& origin, const glm::vec3& end, const glm::vec3& surfaceNormal, float parentScale, bool distanceScaleEnd, bool centerEndY, @@ -32,6 +35,8 @@ public: private: OverlayID _pathID; bool _pathIgnoreRays; + + float _lineWidth; }; LaserPointer(const QVariant& rayProps, const RenderStateMap& renderStates, const DefaultRenderStateMap& defaultRenderStates, bool hover, const PointerTriggers& triggers, diff --git a/interface/src/raypick/ParabolaPointer.h b/interface/src/raypick/ParabolaPointer.h index e4394bc509..aaae66fadf 100644 --- a/interface/src/raypick/ParabolaPointer.h +++ b/interface/src/raypick/ParabolaPointer.h @@ -79,6 +79,9 @@ public: RenderState(const OverlayID& startID, const OverlayID& endID, const glm::vec3& pathColor, float pathAlpha, float parentScale, bool isVisibleInSecondaryCamera, bool pathEnabled); + void setPathWidth(float width) { _pathWidth = width; } + float getPathWidth() const { return _pathWidth; } + void cleanup() override; void disable() override; void update(const glm::vec3& origin, const glm::vec3& end, const glm::vec3& surfaceNormal, float parentScale, bool distanceScaleEnd, bool centerEndY, @@ -88,6 +91,7 @@ public: private: int _pathID; + float _pathWidth; }; ParabolaPointer(const QVariant& rayProps, const RenderStateMap& renderStates, const DefaultRenderStateMap& defaultRenderStates, bool hover, const PointerTriggers& triggers, diff --git a/interface/src/raypick/PathPointer.h b/interface/src/raypick/PathPointer.h index 5001d3d1bd..aed6ed4f71 100644 --- a/interface/src/raypick/PathPointer.h +++ b/interface/src/raypick/PathPointer.h @@ -42,9 +42,6 @@ public: void setEndRot(const glm::quat& endRot) { _endRot = endRot; } const glm::quat& getEndRot() const { return _endRot; } - void setPathWidth(float width) { _pathWidth = width; } - float getPathWidth() const { return _pathWidth; } - virtual void cleanup(); virtual void disable(); virtual void update(const glm::vec3& origin, const glm::vec3& end, const glm::vec3& surfaceNormal, float parentScale, bool distanceScaleEnd, bool centerEndY, @@ -61,7 +58,6 @@ protected: glm::vec3 _startDim; glm::vec3 _endDim; glm::quat _endRot; - float _pathWidth; glm::quat _avgEndRot; bool _avgEndRotInitialized { false }; From f3f9976cfb89ea12134eb39b1db4c84c742a8274 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Fri, 28 Sep 2018 16:10:17 -0700 Subject: [PATCH 26/39] Cache ParabolaPick speed --- interface/src/raypick/ParabolaPick.cpp | 5 +++-- interface/src/raypick/ParabolaPick.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/interface/src/raypick/ParabolaPick.cpp b/interface/src/raypick/ParabolaPick.cpp index e8986f7ce9..2b55bb9c94 100644 --- a/interface/src/raypick/ParabolaPick.cpp +++ b/interface/src/raypick/ParabolaPick.cpp @@ -19,7 +19,8 @@ ParabolaPick::ParabolaPick(const glm::vec3& position, const glm::vec3& direction Pick(PickParabola(position, speed * direction, accelerationAxis), filter, maxDistance, enabled), _rotateAccelerationWithAvatar(rotateAccelerationWithAvatar), _rotateAccelerationWithParent(rotateAccelerationWithParent), - _scaleWithParent(scaleWithParent) { + _scaleWithParent(scaleWithParent), + _speed(speed) { } PickParabola ParabolaPick::getMathematicalPick() const { @@ -39,7 +40,7 @@ PickParabola ParabolaPick::getMathematicalPick() const { velocity = currentParentTransform.transformDirection(velocity); } else { glm::vec3 transformedVelocity = currentParentTransform.transformDirection(velocity); - velocity = glm::normalize(transformedVelocity) * glm::distance(velocity, Vectors::ZERO); + velocity = glm::normalize(transformedVelocity) * _speed; } glm::vec3 acceleration = _mathPick.acceleration; if (_rotateAccelerationWithAvatar) { diff --git a/interface/src/raypick/ParabolaPick.h b/interface/src/raypick/ParabolaPick.h index 7089228d21..8cbbc79bf5 100644 --- a/interface/src/raypick/ParabolaPick.h +++ b/interface/src/raypick/ParabolaPick.h @@ -89,6 +89,8 @@ protected: bool _rotateAccelerationWithAvatar; bool _rotateAccelerationWithParent; bool _scaleWithParent; + // Cached magnitude of _mathPick.velocity + float _speed; }; #endif // hifi_ParabolaPick_h From 728f8aeecdf6e3f8086596f4e6c6649d67f8b24e Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Mon, 1 Oct 2018 09:02:41 -0700 Subject: [PATCH 27/39] Scale Parabola Pick acceleration before rotating it --- interface/src/raypick/ParabolaPick.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/raypick/ParabolaPick.cpp b/interface/src/raypick/ParabolaPick.cpp index 2b55bb9c94..571f4a6ea6 100644 --- a/interface/src/raypick/ParabolaPick.cpp +++ b/interface/src/raypick/ParabolaPick.cpp @@ -43,14 +43,14 @@ PickParabola ParabolaPick::getMathematicalPick() const { velocity = glm::normalize(transformedVelocity) * _speed; } glm::vec3 acceleration = _mathPick.acceleration; + if (_scaleWithParent) { + acceleration *= currentParentTransform.getScale(); + } if (_rotateAccelerationWithAvatar) { acceleration = DependencyManager::get()->getMyAvatar()->getWorldOrientation() * acceleration; } else if (_rotateAccelerationWithParent) { acceleration = currentParentTransform.getRotation() * acceleration; } - if (_scaleWithParent) { - acceleration *= currentParentTransform.getScale(); - } return PickParabola(position, velocity, acceleration); } From f0de3ef31c0ac1d83000d01d2f4effea592b782f Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Mon, 1 Oct 2018 09:18:39 -0700 Subject: [PATCH 28/39] jsdocs: Do not list scaleWithAvatar as separate property, and document 0 as default for parentJointIndex --- interface/src/raypick/PickScriptingInterface.cpp | 11 +++++------ interface/src/raypick/PointerScriptingInterface.cpp | 6 ++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/interface/src/raypick/PickScriptingInterface.cpp b/interface/src/raypick/PickScriptingInterface.cpp index 4218d593aa..3d1a198d66 100644 --- a/interface/src/raypick/PickScriptingInterface.cpp +++ b/interface/src/raypick/PickScriptingInterface.cpp @@ -52,8 +52,8 @@ unsigned int PickScriptingInterface::createPick(const PickQuery::PickType type, * @property {boolean} [enabled=false] If this Pick should start enabled or not. Disabled Picks do not updated their pick results. * @property {number} [filter=Picks.PICK_NOTHING] 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, or an overlay. - * @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 {Uuid} parentID - The ID of the parent, either an avatar, an entity, an overlay, 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 * @property {Vec3} [dirOffset=Vec3.UP] Only for Joint Ray Picks. A local joint direction offset. x = upward, y = forward, z = lateral @@ -148,7 +148,7 @@ unsigned int PickScriptingInterface::createStylusPick(const QVariant& properties * @property {number} [filter=Picks.PICK_NOTHING] 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, or an overlay. - * @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 {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 * @property {Vec3} [dirOffset=Vec3.UP] Only for Joint Parabola Picks. A local joint direction offset. x = upward, y = forward, z = lateral @@ -158,8 +158,7 @@ unsigned int PickScriptingInterface::createStylusPick(const QVariant& properties * @property {Vec3} [accelerationAxis=-Vec3.UP] The acceleration of the parabola, i.e. the acceleration of the projectile whose trajectory defines the parabola, both magnitude and direction. * @property {boolean} [rotateAccelerationWithAvatar=true] Whether or not the acceleration axis should rotate with the avatar's local Y axis. * @property {boolean} [rotateAccelerationWithParent=false] Whether or not the acceleration axis should rotate with the parent's local Y axis, if available. - * @property {boolean} [scaleWithParent=true] If true, the velocity and acceleration of the Pick will scale linearly with the parent, if available. - * @property {boolean} [scaleWithAvatar] Alias for scaleWithParent. Deprecated. + * @property {boolean} [scaleWithParent=true] If true, the velocity and acceleration of the Pick will scale linearly with the parent, if available. scaleWithAvatar is an alias but is deprecated. */ unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properties) { QVariantMap propMap = properties.toMap(); @@ -252,7 +251,7 @@ unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properti * @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 {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 {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. */ diff --git a/interface/src/raypick/PointerScriptingInterface.cpp b/interface/src/raypick/PointerScriptingInterface.cpp index 1f1bf76d21..ac9319b2f8 100644 --- a/interface/src/raypick/PointerScriptingInterface.cpp +++ b/interface/src/raypick/PointerScriptingInterface.cpp @@ -97,8 +97,7 @@ unsigned int PointerScriptingInterface::createStylus(const QVariant& properties) * @property {boolean} [centerEndY=true] If false, the end of the Pointer will be moved up by half of its height. * @property {boolean} [lockEnd=false] If true, the end of the Pointer will lock on to the center of the object at which the pointer is pointing. * @property {boolean} [distanceScaleEnd=false] If true, the dimensions of the end of the Pointer will scale linearly with distance. - * @property {boolean} [scaleWithParent=false] If true, the width of the Pointer's path will scale linearly with the pick parent's scale. - * @property {boolean} [scaleWithAvatar] Alias for scaleWithParent + * @property {boolean} [scaleWithParent=false] If true, the width of the Pointer's path will scale linearly with the pick parent's scale. scaleWithAvatar is an alias but is deprecated. * @property {boolean} [followNormal=false] If true, the end of the Pointer will rotate to follow the normal of the intersected surface. * @property {number} [followNormalStrength=0.0] The strength of the interpolation between the real normal and the visual normal if followNormal is true. 0-1. If 0 or 1, * the normal will follow exactly. @@ -251,8 +250,7 @@ unsigned int PointerScriptingInterface::createLaserPointer(const QVariant& prope * @property {boolean} [centerEndY=true] If false, the end of the Pointer will be moved up by half of its height. * @property {boolean} [lockEnd=false] If true, the end of the Pointer will lock on to the center of the object at which the pointer is pointing. * @property {boolean} [distanceScaleEnd=false] If true, the dimensions of the end of the Pointer will scale linearly with distance. -* @property {boolean} [scaleWithParent=true] If true, the width of the Pointer's path will scale linearly with the pick parent's scale. -* @property {boolean} [scaleWithAvatar] Alias for scaleWithParent +* @property {boolean} [scaleWithParent=true] If true, the width of the Pointer's path will scale linearly with the pick parent's scale. scaleWithAvatar is an alias but is deprecated. * @property {boolean} [followNormal=false] If true, the end of the Pointer will rotate to follow the normal of the intersected surface. * @property {number} [followNormalStrength=0.0] The strength of the interpolation between the real normal and the visual normal if followNormal is true. 0-1. If 0 or 1, * the normal will follow exactly. From 0cf7e954ccea73288da7bc11df23256a3d9b032d Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Mon, 1 Oct 2018 09:19:56 -0700 Subject: [PATCH 29/39] Simplify a RayPick and StylusTip constructor --- interface/src/raypick/RayPick.h | 2 +- libraries/shared/src/RegisteredMetaTypes.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/raypick/RayPick.h b/interface/src/raypick/RayPick.h index 4af8490fdc..adacd78487 100644 --- a/interface/src/raypick/RayPick.h +++ b/interface/src/raypick/RayPick.h @@ -71,7 +71,7 @@ class RayPick : public Pick { public: RayPick(const PickFilter& filter, float maxDistance, bool enabled) : - Pick(PickRay(Vectors::ZERO, Vectors::UP), filter, maxDistance, enabled) { + Pick(PickRay(), filter, maxDistance, enabled) { } RayPick(glm::vec3 position, glm::vec3 direction, const PickFilter& filter, float maxDistance, bool enabled) : diff --git a/libraries/shared/src/RegisteredMetaTypes.h b/libraries/shared/src/RegisteredMetaTypes.h index f4624686ab..3d7231aed7 100644 --- a/libraries/shared/src/RegisteredMetaTypes.h +++ b/libraries/shared/src/RegisteredMetaTypes.h @@ -198,7 +198,7 @@ void pickRayFromScriptValue(const QScriptValue& object, PickRay& pickRay); class StylusTip : public MathPick { public: StylusTip() : position(NAN), velocity(NAN) {} - StylusTip(bilateral::Side side, glm::vec3 position = Vectors::ZERO, glm::quat orientation = Quaternions::IDENTITY, glm::vec3 velocity = Vectors::ZERO) : + StylusTip(const bilateral::Side& side, const glm::vec3& position = Vectors::ZERO, const glm::quat& orientation = Quaternions::IDENTITY, const glm::vec3& velocity = Vectors::ZERO) : side(side), position(position), orientation(orientation), velocity(velocity) {} StylusTip(const QVariantMap& pickVariant) : side(bilateral::Side(pickVariant["side"].toInt())), position(vec3FromVariant(pickVariant["position"])), orientation(quatFromVariant(pickVariant["orientation"])), velocity(vec3FromVariant(pickVariant["velocity"])) {} From 7a89f959d1176f092525edaa294a6be7fa8c2fc5 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Mon, 1 Oct 2018 09:34:07 -0700 Subject: [PATCH 30/39] Fix not mentioning pick parenting in all pick parenting jsdocs for parentID --- interface/src/raypick/PickScriptingInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/raypick/PickScriptingInterface.cpp b/interface/src/raypick/PickScriptingInterface.cpp index 3d1a198d66..26b5aacac5 100644 --- a/interface/src/raypick/PickScriptingInterface.cpp +++ b/interface/src/raypick/PickScriptingInterface.cpp @@ -147,7 +147,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=Picks.PICK_NOTHING] 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, or an overlay. + * @property {Uuid} parentID - The ID of the parent, either an avatar, an entity, an overlay, 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 @@ -250,7 +250,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, or an overlay. +* @property {Uuid} parentID - The ID of the parent, either an avatar, an entity, an overlay, 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. From ad92b172cb6f50af229bedd914e9218c78722f68 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Mon, 1 Oct 2018 09:47:07 -0700 Subject: [PATCH 31/39] removing comment --- interface/resources/qml/hifi/avatarapp/AdjustWearables.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml index d4a574411e..08c74794fc 100644 --- a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml +++ b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml @@ -101,7 +101,6 @@ Rectangle { } function entityHasAvatarJoints(entityID) { - console.log(entityID); var hasAvatarJoint = false; var entityJointNames = Entities.getJointNames(entityID); for (var index = 0; index < entityJointNames.length; index++) { From b9883829183b9ecddf110d34e4ca7aa9f7338959 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Mon, 1 Oct 2018 11:07:02 -0700 Subject: [PATCH 32/39] Remove smaller RayPick constructor --- interface/src/Application.cpp | 2 +- interface/src/raypick/RayPick.h | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 35c071b512..5fa9c94f05 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2271,7 +2271,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // Setup the mouse ray pick and related operators { - auto mouseRayPick = std::make_shared(PickFilter(PickScriptingInterface::PICK_ENTITIES() | PickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()), 0.0f, true); + auto mouseRayPick = std::make_shared(Vectors::ZERO, Vectors::UP, PickFilter(PickScriptingInterface::PICK_ENTITIES() | PickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()), 0.0f, true); mouseRayPick->parentTransform = std::make_shared(); mouseRayPick->setJointState(PickQuery::JOINT_STATE_MOUSE); auto mouseRayPickID = DependencyManager::get()->addPick(PickQuery::Ray, mouseRayPick); diff --git a/interface/src/raypick/RayPick.h b/interface/src/raypick/RayPick.h index adacd78487..ba67ceebb1 100644 --- a/interface/src/raypick/RayPick.h +++ b/interface/src/raypick/RayPick.h @@ -70,10 +70,6 @@ public: class RayPick : public Pick { public: - RayPick(const PickFilter& filter, float maxDistance, bool enabled) : - Pick(PickRay(), filter, maxDistance, enabled) { - } - RayPick(glm::vec3 position, glm::vec3 direction, const PickFilter& filter, float maxDistance, bool enabled) : Pick(PickRay(position, direction), filter, maxDistance, enabled) { } From 182c92b95116fbb1a62942a710fdab49b0a72d2e Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 2 Oct 2018 11:23:13 -0700 Subject: [PATCH 33/39] fix mac issue --- .../qml/hifi/avatarapp/AdjustWearables.qml | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml index 08c74794fc..361ac838fe 100644 --- a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml +++ b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml @@ -123,7 +123,7 @@ Rectangle { var wearable = wearablesCombobox.model.get(i); if (wearable.id === entityID) { wearablesCombobox.currentIndex = i; - isSoft.enabled = entityHasAvatarJoints(entityID); + softWearableTimer.restart(); break; } } @@ -145,6 +145,20 @@ Rectangle { hoverEnabled: true; } + Timer { + id: softWearableTimer + interval: 500 + running: false + repeat: false + onTriggered: { + var currentWearable = getCurrentWearable(); + var soft = currentWearable ? currentWearable.relayParentJoints : false; + var softEnabled = currentWearable ? entityHasAvatarJoints(currentWearable.id) : false; + isSoft.set(soft); + isSoft.enabled = softEnabled; + } + } + Column { anchors.top: parent.top anchors.topMargin: 12 @@ -262,16 +276,12 @@ Rectangle { var rotation = currentWearable ? currentWearable.localRotationAngles : { x : 0, y : 0, z : 0 }; var scale = currentWearable ? currentWearable.dimensions.x / currentWearable.naturalDimensions.x : 1.0; var joint = currentWearable ? currentWearable.parentJointIndex : -1; - var soft = currentWearable ? currentWearable.relayParentJoints : false; - var softEnabled = currentWearable ? entityHasAvatarJoints(currentWearable.id) : false; - + softWearableTimer.restart(); positionVector.set(position); rotationVector.set(rotation); scalespinner.set(scale); jointsCombobox.set(joint); - isSoft.set(soft); - isSoft.enabled = softEnabled; if (currentWearable) { From c0ae95f853deba8dc723888ba3b1e12b2e390f1b Mon Sep 17 00:00:00 2001 From: Anthony Thibault Date: Wed, 3 Oct 2018 12:54:49 -0700 Subject: [PATCH 34/39] Bug fix for rotation culling in AvatarData::toByteArray() The commit 5a0de0f103c inadvertently introduced a regression in how the AvatarMixer and clients encode AvatarData packets. When encoding packets that with the cullSmallChanges flag set to true, we only include rotations that have changed significantly from the previous packet. A bug was introduced that incorrectly preformed the comparison to detect changed rotations, this needs to handle the case when two quaternions are almost equal but have negative signs. Previously, this was preformed with an absolute value after the 4-component dot product. In commit 5a0de0f103c, this absolute value was removed, causing the culling to happen much more frequently. This PR re-introduces that absolute value. --- libraries/avatars/src/AvatarData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 2168dff1f6..5fb4ef3156 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -594,7 +594,7 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent // The dot product for larger rotations is a lower number. // So if the dot() is less than the value, then the rotation is a larger angle of rotation if (sendAll || last.rotationIsDefaultPose || (!cullSmallChanges && last.rotation != data.rotation) - || (cullSmallChanges && glm::dot(last.rotation, data.rotation) < minRotationDOT) ) { + || (cullSmallChanges && fabsf(glm::dot(last.rotation, data.rotation)) < minRotationDOT) ) { validity |= (1 << validityBit); #ifdef WANT_DEBUG rotationSentCount++; From 5734c24af49dde576013b96645e706a4556911a1 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 3 Oct 2018 13:51:02 -0700 Subject: [PATCH 35/39] another PR fix --- .../qml/hifi/avatarapp/AdjustWearables.qml | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml index 361ac838fe..c4b1443731 100644 --- a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml +++ b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml @@ -23,6 +23,9 @@ Rectangle { property bool modified: false; Component.onCompleted: { modified = false; + MyAavatar.animGraphLoaded.connect(function() { + softWearableTimer.restart(); + }); } property var jointNames: [] @@ -102,13 +105,20 @@ Rectangle { function entityHasAvatarJoints(entityID) { var hasAvatarJoint = false; - var entityJointNames = Entities.getJointNames(entityID); - for (var index = 0; index < entityJointNames.length; index++) { - var avatarJointIndex = MyAvatar.getJointIndex(entityJointNames[index]); - if (avatarJointIndex >= 0) { - hasAvatarJoint = true; - break; + + var props = Entities.getEntityProperties(entityID); + var avatarJointsCount = MyAvatar.getJointNames().length; + if (props && avatarJointsCount >= 0 ) { + var entityJointNames = Entities.getJointNames(entityID); + for (var index = 0; index < entityJointNames.length; index++) { + var avatarJointIndex = MyAvatar.getJointIndex(entityJointNames[index]); + if (avatarJointIndex >= 0) { + hasAvatarJoint = true; + break; + } } + } else { + softWearableTimer.restart(); } return hasAvatarJoint; @@ -133,6 +143,7 @@ Rectangle { visible = false; adjustWearablesClosed(status, avatarName); } + HifiConstants { id: hifi } From 676293c880ba6738b2d1321365efc3a79ad31b4a Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 3 Oct 2018 16:19:47 -0700 Subject: [PATCH 36/39] trying another fix --- interface/resources/qml/hifi/avatarapp/AdjustWearables.qml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml index c4b1443731..6ed13835f9 100644 --- a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml +++ b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml @@ -117,8 +117,6 @@ Rectangle { break; } } - } else { - softWearableTimer.restart(); } return hasAvatarJoint; @@ -158,9 +156,9 @@ Rectangle { Timer { id: softWearableTimer - interval: 500 + interval: 1000 running: false - repeat: false + repeat: true onTriggered: { var currentWearable = getCurrentWearable(); var soft = currentWearable ? currentWearable.relayParentJoints : false; From bb98457d09525b7ff04fb7505601f15455c74180 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Wed, 3 Oct 2018 16:23:09 -0700 Subject: [PATCH 37/39] Fix avatars transit on domain enter --- interface/src/avatar/AvatarManager.cpp | 6 +++++- libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp | 5 +++++ libraries/avatars-renderer/src/avatars-renderer/Avatar.h | 1 + libraries/avatars/src/AvatarData.h | 4 ++++ libraries/avatars/src/AvatarHashMap.cpp | 6 ++++-- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 7d91681c0e..661b13d6d1 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -275,7 +275,11 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { if (inView && avatar->hasNewJointData()) { numAvatarsUpdated++; } - avatar->_transit.update(deltaTime, avatar->_globalPosition, _transitConfig); + auto transitStatus = avatar->_transit.update(deltaTime, avatar->_globalPosition, _transitConfig); + if (avatar->getIsNewAvatar() && transitStatus == AvatarTransit::Status::START_TRANSIT) { + avatar->_transit.reset(); + avatar->setIsNewAvatar(false); + } avatar->simulate(deltaTime, inView); avatar->updateRenderItem(renderTransaction); avatar->updateSpaceProxy(workloadTransaction); diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index b4b213dc87..fe3e1644c4 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -126,6 +126,11 @@ AvatarTransit::Status AvatarTransit::update(float deltaTime, const glm::vec3& av return _status; } +void AvatarTransit::reset() { + _lastPosition = _endPosition; + _currentPosition = _endPosition; + _isTransiting = false; +} void AvatarTransit::start(float deltaTime, const glm::vec3& startPosition, const glm::vec3& endPosition, const AvatarTransit::TransitConfig& config) { _startPosition = startPosition; _endPosition = endPosition; diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h index fe5d310812..7764d0ef54 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h @@ -84,6 +84,7 @@ public: glm::vec3 getEndPosition() { return _endPosition; } float getTransitTime() { return _totalTime; } void setScale(float scale) { _scale = scale; } + void reset(); private: Status updatePosition(float deltaTime); diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index a890482e9a..860772b7c9 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -1190,6 +1190,9 @@ public: void setReplicaIndex(int replicaIndex) { _replicaIndex = replicaIndex; } int getReplicaIndex() { return _replicaIndex; } + void setIsNewAvatar(bool isNewAvatar) { _isNewAvatar = isNewAvatar; } + bool getIsNewAvatar() { return _isNewAvatar; } + signals: /**jsdoc @@ -1452,6 +1455,7 @@ protected: bool _hasProcessedFirstIdentity { false }; float _density; int _replicaIndex { 0 }; + bool _isNewAvatar { true }; // null unless MyAvatar or ScriptableAvatar sending traits data to mixer std::unique_ptr _clientTraitsHandler; diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp index c8ea68dae4..af65a32ef5 100644 --- a/libraries/avatars/src/AvatarHashMap.cpp +++ b/libraries/avatars/src/AvatarHashMap.cpp @@ -259,18 +259,20 @@ AvatarSharedPointer AvatarHashMap::parseAvatarData(QSharedPointersetIsNewAvatar(true); auto replicaIDs = _replicas.getReplicaIDs(sessionUUID); for (auto replicaID : replicaIDs) { auto replicaAvatar = addAvatar(replicaID, sendingNode); + replicaAvatar->setIsNewAvatar(true); _replicas.addReplica(sessionUUID, replicaAvatar); } } - - + // have the matching (or new) avatar parse the data from the packet int bytesRead = avatar->parseDataFromBuffer(byteArray); message->seek(positionBeforeRead + bytesRead); _replicas.parseDataFromBuffer(sessionUUID, byteArray); + return avatar; } else { From a05e493e0634dbb57b71fb75dfbddf11134609a0 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Wed, 3 Oct 2018 17:09:51 -0700 Subject: [PATCH 38/39] Long distance avatars should not be new --- interface/src/avatar/AvatarManager.cpp | 2 +- .../avatars-renderer/src/avatars-renderer/Avatar.cpp | 9 +++++++-- libraries/avatars-renderer/src/avatars-renderer/Avatar.h | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 661b13d6d1..c268561a8d 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -276,7 +276,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { numAvatarsUpdated++; } auto transitStatus = avatar->_transit.update(deltaTime, avatar->_globalPosition, _transitConfig); - if (avatar->getIsNewAvatar() && transitStatus == AvatarTransit::Status::START_TRANSIT) { + if (avatar->getIsNewAvatar() && (transitStatus == AvatarTransit::Status::START_TRANSIT || transitStatus == AvatarTransit::Status::ABORT_TRANSIT)) { avatar->_transit.reset(); avatar->setIsNewAvatar(false); } diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index fe3e1644c4..e3d6e707a2 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -118,8 +118,13 @@ AvatarTransit::Status AvatarTransit::update(float deltaTime, const glm::vec3& av float oneFrameDistance = glm::length(currentPosition - _lastPosition); const float MAX_TRANSIT_DISTANCE = 30.0f; float scaledMaxTransitDistance = MAX_TRANSIT_DISTANCE * _scale; - if (oneFrameDistance > config._triggerDistance && oneFrameDistance < scaledMaxTransitDistance && !_isTransiting) { - start(deltaTime, _lastPosition, currentPosition, config); + if (oneFrameDistance > config._triggerDistance && !_isTransiting) { + if (oneFrameDistance < scaledMaxTransitDistance) { + start(deltaTime, _lastPosition, currentPosition, config); + } else { + _lastPosition = currentPosition; + return Status::ABORT_TRANSIT; + } } _lastPosition = currentPosition; _status = updatePosition(deltaTime); diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h index 7764d0ef54..1087f74c07 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h @@ -56,7 +56,8 @@ public: IDLE = 0, START_TRANSIT, TRANSITING, - END_TRANSIT + END_TRANSIT, + ABORT_TRANSIT }; enum EaseType { From 613a6ab8cde7ec0992f601f7d97ac509fa964032 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 4 Oct 2018 12:18:18 -0700 Subject: [PATCH 39/39] removing unneeded code --- interface/resources/qml/hifi/avatarapp/AdjustWearables.qml | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml index 6ed13835f9..a78ebfa940 100644 --- a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml +++ b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml @@ -23,9 +23,6 @@ Rectangle { property bool modified: false; Component.onCompleted: { modified = false; - MyAavatar.animGraphLoaded.connect(function() { - softWearableTimer.restart(); - }); } property var jointNames: []