mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-07 23:12:36 +02:00
Merge pull request #16025 from sabrina-shanman/picks_debug
(BUGZ-1059) Improve debug API for picks/pointers
This commit is contained in:
commit
0728df8a8f
40 changed files with 434 additions and 89 deletions
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Created by Sabrina Shanman 2018/08/14
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
@ -21,4 +21,10 @@ Transform MyAvatarHeadTransformNode::getTransform() {
|
|||
glm::quat ori = headOri * glm::angleAxis(-PI / 2.0f, Vectors::RIGHT);
|
||||
|
||||
return Transform(ori, scale, pos);
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap MyAvatarHeadTransformNode::toVariantMap() const {
|
||||
QVariantMap map;
|
||||
map["joint"] = "Avatar";
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Created by Sabrina Shanman 2018/08/14
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
@ -14,6 +14,7 @@ class MyAvatarHeadTransformNode : public TransformNode {
|
|||
public:
|
||||
MyAvatarHeadTransformNode() { }
|
||||
Transform getTransform() override;
|
||||
QVariantMap toVariantMap() const override;
|
||||
};
|
||||
|
||||
#endif // hifi_MyAvatarHeadTransformNode_h
|
||||
#endif // hifi_MyAvatarHeadTransformNode_h
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 7/16/2018
|
||||
// Created by Sabrina Shanman 2018/07/16
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
@ -460,4 +460,4 @@ Transform CollisionPick::getResultTransform() const {
|
|||
Transform transform;
|
||||
transform.setTranslation(_mathPick.transform.getTranslation());
|
||||
return transform;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 7/11/2018
|
||||
// Created by Sabrina Shanman 2018/07/11
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
@ -49,6 +49,7 @@ class CollisionPick : public Pick<CollisionRegion> {
|
|||
public:
|
||||
CollisionPick(const PickFilter& filter, float maxDistance, bool enabled, bool scaleWithParent, CollisionRegion collisionRegion, PhysicsEnginePointer physicsEngine);
|
||||
|
||||
PickType getType() const override { return PickType::Collision; }
|
||||
CollisionRegion getMathematicalPick() const override;
|
||||
PickResultPointer getDefaultResult(const QVariantMap& pickVariant) const override {
|
||||
return std::make_shared<CollisionPickResult>(pickVariant, std::vector<ContactTestResult>(), std::vector<ContactTestResult>());
|
||||
|
|
|
@ -27,6 +27,10 @@ LaserPointer::LaserPointer(const QVariant& rayProps, const RenderStateMap& rende
|
|||
{
|
||||
}
|
||||
|
||||
PickQuery::PickType LaserPointer::getType() const {
|
||||
return PickQuery::PickType::Ray;
|
||||
}
|
||||
|
||||
void LaserPointer::editRenderStatePath(const std::string& state, const QVariant& pathProps) {
|
||||
auto renderState = std::static_pointer_cast<RenderState>(_renderStates[state]);
|
||||
if (renderState) {
|
||||
|
@ -47,7 +51,7 @@ PickResultPointer LaserPointer::getPickResultCopy(const PickResultPointer& pickR
|
|||
}
|
||||
|
||||
QVariantMap LaserPointer::toVariantMap() const {
|
||||
QVariantMap qVariantMap;
|
||||
QVariantMap qVariantMap = Parent::toVariantMap();
|
||||
|
||||
QVariantMap qRenderStates;
|
||||
for (auto iter = _renderStates.cbegin(); iter != _renderStates.cend(); iter++) {
|
||||
|
|
|
@ -42,6 +42,8 @@ public:
|
|||
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 scaleWithParent, bool enabled);
|
||||
|
||||
PickQuery::PickType getType() const override;
|
||||
|
||||
QVariantMap toVariantMap() const override;
|
||||
|
||||
static std::shared_ptr<StartEndRenderState> buildRenderState(const QVariantMap& propMap);
|
||||
|
|
|
@ -23,7 +23,7 @@ void LaserPointerScriptingInterface::setIncludeItems(unsigned int uid, const QSc
|
|||
}
|
||||
|
||||
unsigned int LaserPointerScriptingInterface::createLaserPointer(const QVariant& properties) const {
|
||||
return DependencyManager::get<PointerScriptingInterface>()->createLaserPointer(properties);
|
||||
return DependencyManager::get<PointerScriptingInterface>()->createPointer(PickQuery::PickType::Ray, properties);
|
||||
}
|
||||
|
||||
void LaserPointerScriptingInterface::editRenderState(unsigned int uid, const QString& renderState, const QVariant& properties) const {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Created by Sabrina Shanman 2018/08/14
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
@ -24,4 +24,10 @@ Transform MouseTransformNode::getTransform() {
|
|||
}
|
||||
|
||||
return Transform();
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap MouseTransformNode::toVariantMap() const {
|
||||
QVariantMap map;
|
||||
map["joint"] = "Mouse";
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Created by Sabrina Shanman 2018/08/14
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
@ -13,6 +13,7 @@
|
|||
class MouseTransformNode : public TransformNode {
|
||||
public:
|
||||
Transform getTransform() override;
|
||||
QVariantMap toVariantMap() const override;
|
||||
};
|
||||
|
||||
#endif // hifi_MouseTransformNode_h
|
||||
#endif // hifi_MouseTransformNode_h
|
||||
|
|
|
@ -92,6 +92,8 @@ class ParabolaPick : public Pick<PickParabola> {
|
|||
public:
|
||||
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);
|
||||
|
||||
PickType getType() const override { return PickType::Parabola; }
|
||||
|
||||
PickParabola getMathematicalPick() const override;
|
||||
|
||||
PickResultPointer getDefaultResult(const QVariantMap& pickVariant) const override { return std::make_shared<ParabolaPickResult>(pickVariant); }
|
||||
|
|
|
@ -30,6 +30,10 @@ ParabolaPointer::ParabolaPointer(const QVariant& rayProps, const RenderStateMap&
|
|||
{
|
||||
}
|
||||
|
||||
PickQuery::PickType ParabolaPointer::getType() const {
|
||||
return PickQuery::PickType::Parabola;
|
||||
}
|
||||
|
||||
PickResultPointer ParabolaPointer::getPickResultCopy(const PickResultPointer& pickResult) const {
|
||||
auto parabolaPickResult = std::dynamic_pointer_cast<ParabolaPickResult>(pickResult);
|
||||
if (!parabolaPickResult) {
|
||||
|
@ -72,7 +76,7 @@ void ParabolaPointer::editRenderStatePath(const std::string& state, const QVaria
|
|||
}
|
||||
|
||||
QVariantMap ParabolaPointer::toVariantMap() const {
|
||||
QVariantMap qVariantMap;
|
||||
QVariantMap qVariantMap = Parent::toVariantMap();
|
||||
|
||||
QVariantMap qRenderStates;
|
||||
for (auto iter = _renderStates.cbegin(); iter != _renderStates.cend(); iter++) {
|
||||
|
|
|
@ -101,6 +101,8 @@ public:
|
|||
ParabolaPointer(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);
|
||||
|
||||
PickQuery::PickType getType() const override;
|
||||
|
||||
QVariantMap toVariantMap() const override;
|
||||
|
||||
static std::shared_ptr<StartEndRenderState> buildRenderState(const QVariantMap& propMap);
|
||||
|
|
|
@ -34,18 +34,35 @@ static const float WEB_TOUCH_Y_OFFSET = 0.105f; // how far forward (or back wit
|
|||
static const glm::vec3 TIP_OFFSET = glm::vec3(0.0f, StylusPick::WEB_STYLUS_LENGTH - WEB_TOUCH_Y_OFFSET, 0.0f);
|
||||
|
||||
unsigned int PickScriptingInterface::createPick(const PickQuery::PickType type, const QVariant& properties) {
|
||||
std::shared_ptr<PickQuery> pick;
|
||||
QVariantMap propMap = properties.toMap();
|
||||
|
||||
switch (type) {
|
||||
case PickQuery::PickType::Ray:
|
||||
return createRayPick(properties);
|
||||
pick = buildRayPick(propMap);
|
||||
break;
|
||||
case PickQuery::PickType::Stylus:
|
||||
return createStylusPick(properties);
|
||||
pick = buildStylusPick(propMap);
|
||||
break;
|
||||
case PickQuery::PickType::Parabola:
|
||||
return createParabolaPick(properties);
|
||||
pick = buildParabolaPick(propMap);
|
||||
break;
|
||||
case PickQuery::PickType::Collision:
|
||||
return createCollisionPick(properties);
|
||||
pick = buildCollisionPick(propMap);
|
||||
break;
|
||||
default:
|
||||
return PickManager::INVALID_PICK_ID;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pick) {
|
||||
return PickManager::INVALID_PICK_ID;
|
||||
}
|
||||
|
||||
propMap["pickType"] = (int)type;
|
||||
|
||||
pick->setScriptParameters(propMap);
|
||||
|
||||
return DependencyManager::get<PickManager>()->addPick(type, pick);
|
||||
}
|
||||
|
||||
PickFilter getPickFilter(unsigned int filter) {
|
||||
|
@ -82,17 +99,18 @@ PickFilter getPickFilter(unsigned int filter) {
|
|||
* @property {Vec3} [dirOffset] - Synonym for <code>direction</code>.
|
||||
* @property {Quat} [orientation] - Alternative property for specifying <code>direction</code>. The value is applied to the
|
||||
* default <code>direction</code> value.
|
||||
* @property {PickType} pickType - The type of pick when getting these properties from {@link Picks.getPickProperties} or {@link Picks.getPickScriptParameters}. A ray pick's type is {@link PickType.Ray}.
|
||||
* @property {Vec3} baseScale - Returned from {@link Picks.getPickProperties} when the pick has a parent with varying scale (usually an avatar or an entity).
|
||||
* Its value is the original scale of the parent at the moment the pick was created, and is used to scale the pointer which owns this pick, if any.
|
||||
*/
|
||||
unsigned int PickScriptingInterface::createRayPick(const QVariant& properties) {
|
||||
QVariantMap propMap = properties.toMap();
|
||||
|
||||
std::shared_ptr<PickQuery> PickScriptingInterface::buildRayPick(const QVariantMap& propMap) {
|
||||
#if defined (Q_OS_ANDROID)
|
||||
QString jointName { "" };
|
||||
if (propMap["joint"].isValid()) {
|
||||
QString jointName = propMap["joint"].toString();
|
||||
const QString MOUSE_JOINT = "Mouse";
|
||||
if (jointName == MOUSE_JOINT) {
|
||||
return PointerEvent::INVALID_POINTER_ID;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -134,7 +152,7 @@ unsigned int PickScriptingInterface::createRayPick(const QVariant& properties) {
|
|||
auto rayPick = std::make_shared<RayPick>(position, direction, filter, maxDistance, enabled);
|
||||
setParentTransform(rayPick, propMap);
|
||||
|
||||
return DependencyManager::get<PickManager>()->addPick(PickQuery::Ray, rayPick);
|
||||
return rayPick;
|
||||
}
|
||||
|
||||
/**jsdoc
|
||||
|
@ -152,10 +170,9 @@ unsigned int PickScriptingInterface::createRayPick(const QVariant& properties) {
|
|||
* means no maximum.
|
||||
* @property {Vec3} [tipOffset=0,0.095,0] - The position of the stylus tip relative to the hand position at default avatar
|
||||
* scale.
|
||||
* @property {PickType} pickType - The type of pick when getting these properties from {@link Picks.getPickProperties} or {@link Picks.getPickScriptParameters}. A stylus pick's type is {@link PickType.Stylus}.
|
||||
*/
|
||||
unsigned int PickScriptingInterface::createStylusPick(const QVariant& properties) {
|
||||
QVariantMap propMap = properties.toMap();
|
||||
|
||||
std::shared_ptr<PickQuery> PickScriptingInterface::buildStylusPick(const QVariantMap& propMap) {
|
||||
bilateral::Side side = bilateral::Side::Invalid;
|
||||
{
|
||||
QVariant handVar = propMap["hand"];
|
||||
|
@ -184,7 +201,7 @@ unsigned int PickScriptingInterface::createStylusPick(const QVariant& properties
|
|||
tipOffset = vec3FromVariant(propMap["tipOffset"]);
|
||||
}
|
||||
|
||||
return DependencyManager::get<PickManager>()->addPick(PickQuery::Stylus, std::make_shared<StylusPick>(side, filter, maxDistance, enabled, tipOffset));
|
||||
return std::make_shared<StylusPick>(side, filter, maxDistance, enabled, tipOffset);
|
||||
}
|
||||
|
||||
// NOTE: Laser pointer still uses scaleWithAvatar. Until scaleWithAvatar is also deprecated for pointers, scaleWithAvatar should not be removed from the pick API.
|
||||
|
@ -228,10 +245,11 @@ unsigned int PickScriptingInterface::createStylusPick(const QVariant& properties
|
|||
* with the avatar or other parent.
|
||||
* @property {boolean} [scaleWithAvatar=true] - Synonym for <code>scalewithParent</code>.
|
||||
* <p class="important">Deprecated: This property is deprecated and will be removed.</p>
|
||||
* @property {PickType} pickType - The type of pick when getting these properties from {@link Picks.getPickProperties} or {@link Picks.getPickScriptParameters}. A parabola pick's type is {@link PickType.Parabola}.
|
||||
* @property {Vec3} baseScale - Returned from {@link Picks.getPickProperties} when the pick has a parent with varying scale (usually an avatar or an entity).
|
||||
* Its value is the original scale of the parent at the moment the pick was created, and is used to rescale the pick, and/or the pointer which owns this pick, if any.
|
||||
*/
|
||||
unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properties) {
|
||||
QVariantMap propMap = properties.toMap();
|
||||
|
||||
std::shared_ptr<PickQuery> PickScriptingInterface::buildParabolaPick(const QVariantMap& propMap) {
|
||||
bool enabled = false;
|
||||
if (propMap["enabled"].isValid()) {
|
||||
enabled = propMap["enabled"].toBool();
|
||||
|
@ -292,7 +310,7 @@ unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properti
|
|||
auto parabolaPick = std::make_shared<ParabolaPick>(position, direction, speed, accelerationAxis,
|
||||
rotateAccelerationWithAvatar, rotateAccelerationWithParent, scaleWithParent, filter, maxDistance, enabled);
|
||||
setParentTransform(parabolaPick, propMap);
|
||||
return DependencyManager::get<PickManager>()->addPick(PickQuery::Parabola, parabolaPick);
|
||||
return parabolaPick;
|
||||
}
|
||||
|
||||
|
||||
|
@ -326,10 +344,11 @@ unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properti
|
|||
* the collision region. The depth is in world coordinates but scales with the parent if defined.
|
||||
* @property {CollisionMask} [collisionGroup=8] - The type of objects the collision region collides as. Objects whose collision
|
||||
* masks overlap with the region's collision group are considered to be colliding with the region.
|
||||
* @property {PickType} pickType - The type of pick when getting these properties from {@link Picks.getPickProperties} or {@link Picks.getPickScriptParameters}. A collision pick's type is {@link PickType.Collision}.
|
||||
* @property {Vec3} baseScale - Returned from {@link Picks.getPickProperties} when the pick has a parent with varying scale (usually an avatar or an entity).
|
||||
* Its value is the original scale of the parent at the moment the pick was created, and is used to rescale the pick, and/or the pointer which owns this pick, if any.
|
||||
*/
|
||||
unsigned int PickScriptingInterface::createCollisionPick(const QVariant& properties) {
|
||||
QVariantMap propMap = properties.toMap();
|
||||
|
||||
std::shared_ptr<PickQuery> PickScriptingInterface::buildCollisionPick(const QVariantMap& propMap) {
|
||||
bool enabled = false;
|
||||
if (propMap["enabled"].isValid()) {
|
||||
enabled = propMap["enabled"].toBool();
|
||||
|
@ -354,7 +373,7 @@ unsigned int PickScriptingInterface::createCollisionPick(const QVariant& propert
|
|||
auto collisionPick = std::make_shared<CollisionPick>(filter, maxDistance, enabled, scaleWithParent, collisionRegion, qApp->getPhysicsEngine());
|
||||
setParentTransform(collisionPick, propMap);
|
||||
|
||||
return DependencyManager::get<PickManager>()->addPick(PickQuery::Collision, collisionPick);
|
||||
return collisionPick;
|
||||
}
|
||||
|
||||
void PickScriptingInterface::enablePick(unsigned int uid) {
|
||||
|
@ -365,10 +384,26 @@ void PickScriptingInterface::disablePick(unsigned int uid) {
|
|||
DependencyManager::get<PickManager>()->disablePick(uid);
|
||||
}
|
||||
|
||||
bool PickScriptingInterface::isPickEnabled(unsigned int uid) const {
|
||||
return DependencyManager::get<PickManager>()->isPickEnabled(uid);
|
||||
}
|
||||
|
||||
void PickScriptingInterface::removePick(unsigned int uid) {
|
||||
DependencyManager::get<PickManager>()->removePick(uid);
|
||||
}
|
||||
|
||||
QVariantMap PickScriptingInterface::getPickProperties(unsigned int uid) const {
|
||||
return DependencyManager::get<PickManager>()->getPickProperties(uid);
|
||||
}
|
||||
|
||||
QVariantMap PickScriptingInterface::getPickScriptParameters(unsigned int uid) const {
|
||||
return DependencyManager::get<PickManager>()->getPickScriptParameters(uid);
|
||||
}
|
||||
|
||||
QVector<unsigned int> PickScriptingInterface::getPicks() const {
|
||||
return DependencyManager::get<PickManager>()->getPicks();
|
||||
}
|
||||
|
||||
QVariantMap PickScriptingInterface::getPrevPickResult(unsigned int uid) {
|
||||
QVariantMap result;
|
||||
auto pickResult = DependencyManager::get<PickManager>()->getPrevPickResult(uid);
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include <RegisteredMetaTypes.h>
|
||||
#include <DependencyManager.h>
|
||||
#include <PhysicsEngine.h>
|
||||
#include <Pick.h>
|
||||
|
@ -98,11 +97,6 @@ class PickScriptingInterface : public QObject, public Dependency {
|
|||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
unsigned int createRayPick(const QVariant& properties);
|
||||
unsigned int createStylusPick(const QVariant& properties);
|
||||
unsigned int createCollisionPick(const QVariant& properties);
|
||||
unsigned int createParabolaPick(const QVariant& properties);
|
||||
|
||||
void registerMetaTypes(QScriptEngine* engine);
|
||||
|
||||
/**jsdoc
|
||||
|
@ -134,6 +128,14 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE void disablePick(unsigned int uid);
|
||||
|
||||
/**jsdoc
|
||||
* Get the enabled status of a pick. Enabled picks update their pick results.
|
||||
* @function Picks.isPickEnabled
|
||||
* @param {number} id - The ID of the pick.
|
||||
* @returns {boolean} enabled - Whether or not the pick is enabled.
|
||||
*/
|
||||
Q_INVOKABLE bool isPickEnabled(unsigned int uid) const;
|
||||
|
||||
/**jsdoc
|
||||
* Removes (deletes) a pick.
|
||||
* @function Picks.removePick
|
||||
|
@ -141,6 +143,32 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE void removePick(unsigned int uid);
|
||||
|
||||
/**jsdoc
|
||||
* Gets the current properties of the pick.
|
||||
* @function Picks.getPickProperties
|
||||
* @param {number} id - The ID of the pick.
|
||||
* @returns {Picks.RayPickProperties|Picks.ParabolaPickProperties|Picks.StylusPickProperties|Picks.CollisionPickProperties} Properties of the pick, per the pick <code>type</code>.
|
||||
*/
|
||||
Q_INVOKABLE QVariantMap getPickProperties(unsigned int uid) const;
|
||||
|
||||
/**jsdoc
|
||||
* Gets the parameters that were passed in to {@link Picks.createPick} to create the pick,
|
||||
* if the pick was created through a script.
|
||||
* Note that these properties do not reflect the current state of the pick.
|
||||
* See {@link Picks.getPickProperties}.
|
||||
* @function Picks.getPickScriptParameters
|
||||
* @param {number} id - The ID of the pick.
|
||||
* @returns {Picks.RayPickProperties|Picks.ParabolaPickProperties|Picks.StylusPickProperties|Picks.CollisionPickProperties} User-provided properties, per the pick <code>type</code>.
|
||||
*/
|
||||
Q_INVOKABLE QVariantMap getPickScriptParameters(unsigned int uid) const;
|
||||
|
||||
/**jsdoc
|
||||
* Gets all picks which currently exist, including disabled picks.
|
||||
* @function Picks.getPicks
|
||||
* @returns {number[]} picks - The IDs of the picks.
|
||||
*/
|
||||
Q_INVOKABLE QVector<unsigned int> getPicks() const;
|
||||
|
||||
/**jsdoc
|
||||
* Gets the most recent result from a pick. A pick continues to be updated ready to return a result, as long as it is
|
||||
* enabled.
|
||||
|
@ -419,6 +447,11 @@ public slots:
|
|||
static constexpr unsigned int INTERSECTED_HUD() { return IntersectionType::HUD; }
|
||||
|
||||
protected:
|
||||
static std::shared_ptr<PickQuery> buildRayPick(const QVariantMap& properties);
|
||||
static std::shared_ptr<PickQuery> buildStylusPick(const QVariantMap& properties);
|
||||
static std::shared_ptr<PickQuery> buildCollisionPick(const QVariantMap& properties);
|
||||
static std::shared_ptr<PickQuery> buildParabolaPick(const QVariantMap& properties);
|
||||
|
||||
static void setParentTransform(std::shared_ptr<PickQuery> pick, const QVariantMap& propMap);
|
||||
};
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <shared/QtHelpers.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "PickManager.h"
|
||||
#include "LaserPointer.h"
|
||||
#include "StylusPointer.h"
|
||||
#include "ParabolaPointer.h"
|
||||
|
@ -38,16 +39,48 @@ unsigned int PointerScriptingInterface::createPointer(const PickQuery::PickType&
|
|||
return result;
|
||||
}
|
||||
|
||||
QVariantMap propertyMap = properties.toMap();
|
||||
|
||||
std::shared_ptr<Pointer> pointer;
|
||||
switch (type) {
|
||||
case PickQuery::PickType::Ray:
|
||||
return createLaserPointer(properties);
|
||||
pointer = buildLaserPointer(propertyMap);
|
||||
break;
|
||||
case PickQuery::PickType::Stylus:
|
||||
return createStylus(properties);
|
||||
pointer = buildStylus(propertyMap);
|
||||
break;
|
||||
case PickQuery::PickType::Parabola:
|
||||
return createParabolaPointer(properties);
|
||||
pointer = buildParabolaPointer(propertyMap);
|
||||
break;
|
||||
default:
|
||||
return PointerEvent::INVALID_POINTER_ID;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pointer) {
|
||||
return PointerEvent::INVALID_POINTER_ID;
|
||||
}
|
||||
|
||||
propertyMap["pointerType"] = (int)type;
|
||||
|
||||
pointer->setScriptParameters(propertyMap);
|
||||
|
||||
return DependencyManager::get<PointerManager>()->addPointer(pointer);
|
||||
}
|
||||
|
||||
bool PointerScriptingInterface::isPointerEnabled(unsigned int uid) const {
|
||||
return DependencyManager::get<PointerManager>()->isPointerEnabled(uid);
|
||||
}
|
||||
|
||||
QVector<unsigned int> PointerScriptingInterface::getPointers() const {
|
||||
return DependencyManager::get<PointerManager>()->getPointers();
|
||||
}
|
||||
|
||||
QVariantMap PointerScriptingInterface::getPointerProperties(unsigned int uid) const {
|
||||
return DependencyManager::get<PointerManager>()->getPointerProperties(uid);
|
||||
}
|
||||
|
||||
QVariantMap PointerScriptingInterface::getPointerScriptParameters(unsigned int uid) const {
|
||||
return DependencyManager::get<PointerManager>()->getPointerScriptParameters(uid);
|
||||
}
|
||||
|
||||
/**jsdoc
|
||||
|
@ -56,6 +89,8 @@ unsigned int PointerScriptingInterface::createPointer(const PickQuery::PickType&
|
|||
* @property {Pointers.StylusPointerModel} [model] - Override some or all of the default stylus model properties.
|
||||
* @property {boolean} [hover=false] - <code>true</code> if the pointer generates {@link Entities} hover events,
|
||||
* <code>false</code> if it doesn't.
|
||||
* @property {PickType} pointerType - The type of pointer when getting these properties from {@link Pointers.getPointerProperties} or {@link Pointers.getPointerScriptParameters}. A stylus pointer's type is {@link PickType.Stylus}.
|
||||
* @property {number} [pickID] - Returned from {@link Pointers.getPointerProperties}. The ID of the pick created alongside this pointer.
|
||||
* @see {@link Picks.StylusPickProperties} for additional properties from the underlying stylus pick.
|
||||
*/
|
||||
/**jsdoc
|
||||
|
@ -67,7 +102,7 @@ unsigned int PointerScriptingInterface::createPointer(const PickQuery::PickType&
|
|||
* offset.
|
||||
* @property {Quat} [rotationOffset] - The rotation offset of the model from the hand, to override the default rotation offset.
|
||||
*/
|
||||
unsigned int PointerScriptingInterface::createStylus(const QVariant& properties) const {
|
||||
std::shared_ptr<Pointer> PointerScriptingInterface::buildStylus(const QVariant& properties) {
|
||||
QVariantMap propertyMap = properties.toMap();
|
||||
|
||||
bool hover = false;
|
||||
|
@ -100,8 +135,7 @@ unsigned int PointerScriptingInterface::createStylus(const QVariant& properties)
|
|||
}
|
||||
}
|
||||
|
||||
return DependencyManager::get<PointerManager>()->addPointer(std::make_shared<StylusPointer>(properties, StylusPointer::buildStylus(propertyMap), hover, enabled, modelPositionOffset,
|
||||
modelRotationOffset, modelDimensions));
|
||||
return std::make_shared<StylusPointer>(properties, StylusPointer::buildStylus(propertyMap), hover, enabled, modelPositionOffset, modelRotationOffset, modelDimensions);
|
||||
}
|
||||
|
||||
/**jsdoc
|
||||
|
@ -174,9 +208,11 @@ unsigned int PointerScriptingInterface::createStylus(const QVariant& properties)
|
|||
* <code>false</code> if it doesn't.
|
||||
* @property {Pointers.Trigger[]} [triggers=[]] - A list of ways that a {@link Controller} action or function should trigger
|
||||
* events on the entity or overlay currently intersected.
|
||||
* @property {PickType} pointerType - The type of pointer when getting these properties from {@link Pointers.getPointerProperties} or {@link Pointers.getPointerScriptParameters}. A laser pointer's type is {@link PickType.Ray}.
|
||||
* @property {number} [pickID] - Returned from {@link Pointers.getPointerProperties}. The ID of the pick created alongside this pointer.
|
||||
* @see {@link Picks.RayPickProperties} for additional properties from the underlying ray pick.
|
||||
*/
|
||||
unsigned int PointerScriptingInterface::createLaserPointer(const QVariant& properties) const {
|
||||
std::shared_ptr<Pointer> PointerScriptingInterface::buildLaserPointer(const QVariant& properties) {
|
||||
QVariantMap propertyMap = properties.toMap();
|
||||
|
||||
#if defined (Q_OS_ANDROID)
|
||||
|
@ -185,7 +221,7 @@ unsigned int PointerScriptingInterface::createLaserPointer(const QVariant& prope
|
|||
QString jointName = propertyMap["joint"].toString();
|
||||
const QString MOUSE_JOINT = "Mouse";
|
||||
if (jointName == MOUSE_JOINT) {
|
||||
return PointerEvent::INVALID_POINTER_ID;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -283,9 +319,9 @@ unsigned int PointerScriptingInterface::createLaserPointer(const QVariant& prope
|
|||
}
|
||||
}
|
||||
|
||||
return DependencyManager::get<PointerManager>()->addPointer(std::make_shared<LaserPointer>(properties, renderStates, defaultRenderStates, hover, triggers,
|
||||
faceAvatar, followNormal, followNormalStrength, centerEndY, lockEnd,
|
||||
distanceScaleEnd, scaleWithParent, enabled));
|
||||
return std::make_shared<LaserPointer>(properties, renderStates, defaultRenderStates, hover, triggers,
|
||||
faceAvatar, followNormal, followNormalStrength, centerEndY, lockEnd,
|
||||
distanceScaleEnd, scaleWithParent, enabled);
|
||||
}
|
||||
|
||||
/**jsdoc
|
||||
|
@ -365,9 +401,11 @@ unsigned int PointerScriptingInterface::createLaserPointer(const QVariant& prope
|
|||
* <code>false</code> if it doesn't.
|
||||
* @property {Pointers.Trigger[]} [triggers=[]] - A list of ways that a {@link Controller} action or function should trigger
|
||||
* events on the entity or overlay currently intersected.
|
||||
* @property {PickType} pointerType - The type of pointer when getting these properties from {@link Pointers.getPointerProperties} or {@link Pointers.getPointerScriptParameters}. A parabola pointer's type is {@link PickType.Parabola}.
|
||||
* @property {number} [pickID] - Returned from {@link Pointers.getPointerProperties}. The ID of the pick created alongside this pointer.
|
||||
* @see {@link Picks.ParabolaPickProperties} for additional properties from the underlying parabola pick.
|
||||
*/
|
||||
unsigned int PointerScriptingInterface::createParabolaPointer(const QVariant& properties) const {
|
||||
std::shared_ptr<Pointer> PointerScriptingInterface::buildParabolaPointer(const QVariant& properties) {
|
||||
QVariantMap propertyMap = properties.toMap();
|
||||
|
||||
bool faceAvatar = false;
|
||||
|
@ -463,9 +501,9 @@ unsigned int PointerScriptingInterface::createParabolaPointer(const QVariant& pr
|
|||
}
|
||||
}
|
||||
|
||||
return DependencyManager::get<PointerManager>()->addPointer(std::make_shared<ParabolaPointer>(properties, renderStates, defaultRenderStates, hover, triggers,
|
||||
faceAvatar, followNormal, followNormalStrength, centerEndY, lockEnd, distanceScaleEnd,
|
||||
scaleWithParent, enabled));
|
||||
return std::make_shared<ParabolaPointer>(properties, renderStates, defaultRenderStates, hover, triggers,
|
||||
faceAvatar, followNormal, followNormalStrength, centerEndY, lockEnd, distanceScaleEnd,
|
||||
scaleWithParent, enabled);
|
||||
}
|
||||
|
||||
void PointerScriptingInterface::editRenderState(unsigned int uid, const QString& renderState, const QVariant& properties) const {
|
||||
|
@ -497,7 +535,3 @@ QVariantMap PointerScriptingInterface::getPrevPickResult(unsigned int uid) const
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QVariantMap PointerScriptingInterface::getPointerProperties(unsigned int uid) const {
|
||||
return DependencyManager::get<PointerManager>()->getPointerProperties(uid);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <QtCore/QObject>
|
||||
|
||||
#include "DependencyManager.h"
|
||||
#include "RegisteredMetaTypes.h"
|
||||
#include <PointerManager.h>
|
||||
#include <Pick.h>
|
||||
|
||||
|
@ -31,9 +32,6 @@ class PointerScriptingInterface : public QObject, public Dependency {
|
|||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
unsigned int createLaserPointer(const QVariant& properties) const;
|
||||
unsigned int createStylus(const QVariant& properties) const;
|
||||
unsigned int createParabolaPointer(const QVariant& properties) const;
|
||||
|
||||
/**jsdoc
|
||||
* Specifies that a {@link Controller} action or function should trigger events on the entity or overlay currently
|
||||
|
@ -147,6 +145,14 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE void disablePointer(unsigned int uid) const { DependencyManager::get<PointerManager>()->disablePointer(uid); }
|
||||
|
||||
/**jsdoc
|
||||
* Gets the enabled status of a pointer. Enabled pointers update their pick results and generate events.
|
||||
* @function Pointers.isPointerEnabled
|
||||
* @param {number} id - The ID of the pointer.
|
||||
* @returns {boolean} enabled - Whether or not the pointer is enabled.
|
||||
*/
|
||||
Q_INVOKABLE bool isPointerEnabled(unsigned int uid) const;
|
||||
|
||||
/**jsdoc
|
||||
* Removes (deletes) a pointer.
|
||||
* @function Pointers.removePointer
|
||||
|
@ -154,6 +160,24 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE void removePointer(unsigned int uid) const { DependencyManager::get<PointerManager>()->removePointer(uid); }
|
||||
|
||||
/**jsdoc
|
||||
* Gets the parameters that were passed in to {@link Pointers.createPointer} to create the pointer,
|
||||
* if the pointer was created through a script.
|
||||
* Note that these properties do not reflect the current state of the pointer.
|
||||
* See {@link Pointers.getPointerProperties}.
|
||||
* @function Pointers.getPointerScriptParameters
|
||||
* @param {number} id - The ID of the pointer.
|
||||
* @returns {Pointers.RayPointerProperties|Picks.ParabolaPointerProperties|Picks.StylusPointerProperties} User-provided properties, per the pointer <code>type</code>.
|
||||
*/
|
||||
Q_INVOKABLE QVariantMap getPointerScriptParameters(unsigned int uid) const;
|
||||
|
||||
/**jsdoc
|
||||
* Gets all pointers which currently exist, including disabled pointers.
|
||||
* @function Pointers.getPointers
|
||||
* @returns {number[]} pointers - The IDs of the pointers.
|
||||
*/
|
||||
Q_INVOKABLE QVector<unsigned int> getPointers() const;
|
||||
|
||||
/**jsdoc
|
||||
* Edits a render state of a {@link Pointers.RayPointerProperties|ray} or
|
||||
* {@link Pointers.ParabolaPointerProperties|parabola} pointer, to change its visual appearance for the state when the
|
||||
|
@ -448,6 +472,11 @@ public:
|
|||
* });
|
||||
*/
|
||||
Q_INVOKABLE QVariantMap getPointerProperties(unsigned int uid) const;
|
||||
|
||||
protected:
|
||||
static std::shared_ptr<Pointer> buildLaserPointer(const QVariant& properties);
|
||||
static std::shared_ptr<Pointer> buildStylus(const QVariant& properties);
|
||||
static std::shared_ptr<Pointer> buildParabolaPointer(const QVariant& properties);
|
||||
};
|
||||
|
||||
#endif // hifi_PointerScriptingInterface_h
|
||||
|
|
|
@ -88,6 +88,8 @@ public:
|
|||
Pick(PickRay(position, direction), filter, maxDistance, enabled) {
|
||||
}
|
||||
|
||||
PickType getType() const override { return PickType::Ray; }
|
||||
|
||||
PickRay getMathematicalPick() const override;
|
||||
|
||||
PickResultPointer getDefaultResult(const QVariantMap& pickVariant) const override { return std::make_shared<RayPickResult>(pickVariant); }
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <PickManager.h>
|
||||
|
||||
unsigned int RayPickScriptingInterface::createRayPick(const QVariant& properties) {
|
||||
return DependencyManager::get<PickScriptingInterface>()->createRayPick(properties);
|
||||
return DependencyManager::get<PickScriptingInterface>()->createPick(PickQuery::PickType::Ray, properties);
|
||||
}
|
||||
|
||||
void RayPickScriptingInterface::enableRayPick(unsigned int uid) {
|
||||
|
|
|
@ -72,6 +72,7 @@ class StylusPick : public Pick<StylusTip> {
|
|||
public:
|
||||
StylusPick(Side side, const PickFilter& filter, float maxDistance, bool enabled, const glm::vec3& tipOffset);
|
||||
|
||||
PickType getType() const override { return PickType::Stylus; }
|
||||
StylusTip getMathematicalPick() const override;
|
||||
PickResultPointer getDefaultResult(const QVariantMap& pickVariant) const override;
|
||||
PickResultPointer getEntityIntersection(const StylusTip& pick) override;
|
||||
|
|
|
@ -29,7 +29,7 @@ static const QString DEFAULT_STYLUS_MODEL_URL = PathUtils::resourcesUrl() + "/me
|
|||
|
||||
StylusPointer::StylusPointer(const QVariant& props, const QUuid& stylus, bool hover, bool enabled,
|
||||
const glm::vec3& modelPositionOffset, const glm::quat& modelRotationOffset, const glm::vec3& modelDimensions) :
|
||||
Pointer(DependencyManager::get<PickScriptingInterface>()->createStylusPick(props), enabled, hover),
|
||||
Pointer(DependencyManager::get<PickScriptingInterface>()->createPick(PickQuery::PickType::Stylus, props), enabled, hover),
|
||||
_stylus(stylus),
|
||||
_modelPositionOffset(modelPositionOffset),
|
||||
_modelDimensions(modelDimensions),
|
||||
|
@ -43,6 +43,10 @@ StylusPointer::~StylusPointer() {
|
|||
}
|
||||
}
|
||||
|
||||
PickQuery::PickType StylusPointer::getType() const {
|
||||
return PickQuery::PickType::Stylus;
|
||||
}
|
||||
|
||||
QUuid StylusPointer::buildStylus(const QVariantMap& properties) {
|
||||
// FIXME: we have to keep using the Overlays interface here, because existing scripts use overlay properties to define pointers
|
||||
QVariantMap propertiesMap;
|
||||
|
@ -229,7 +233,7 @@ void StylusPointer::setRenderState(const std::string& state) {
|
|||
}
|
||||
|
||||
QVariantMap StylusPointer::toVariantMap() const {
|
||||
return QVariantMap();
|
||||
return Parent::toVariantMap();
|
||||
}
|
||||
|
||||
glm::vec3 StylusPointer::findIntersection(const PickedObject& pickedObject, const glm::vec3& origin, const glm::vec3& direction) {
|
||||
|
|
|
@ -23,6 +23,8 @@ public:
|
|||
const glm::vec3& modelPositionOffset, const glm::quat& modelRotationOffset, const glm::vec3& modelDimensions);
|
||||
~StylusPointer();
|
||||
|
||||
PickQuery::PickType getType() const override;
|
||||
|
||||
void updateVisuals(const PickResultPointer& pickResult) override;
|
||||
|
||||
// Styluses have three render states:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 9/5/2018
|
||||
// Created by Sabrina Shanman 2018/09/05
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
@ -10,4 +10,4 @@
|
|||
template<>
|
||||
glm::vec3 BaseNestableTransformNode<Avatar>::getActualScale(const std::shared_ptr<Avatar>& nestablePointer) const {
|
||||
return nestablePointer->scaleForChildren();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 9/5/2018
|
||||
// Created by Sabrina Shanman 2018/09/05
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
@ -17,4 +17,4 @@ public:
|
|||
AvatarTransformNode(std::weak_ptr<Avatar> spatiallyNestable, int jointIndex) : BaseNestableTransformNode(spatiallyNestable, jointIndex) {};
|
||||
};
|
||||
|
||||
#endif // hifi_AvatarTransformNode_h
|
||||
#endif // hifi_AvatarTransformNode_h
|
||||
|
|
|
@ -297,10 +297,6 @@ MeshPointer GraphicsScriptingInterface::getMeshPointer(scriptable::ScriptableMes
|
|||
|
||||
namespace {
|
||||
QVector<int> metaTypeIds{
|
||||
qRegisterMetaType<glm::uint32>("uint32"),
|
||||
qRegisterMetaType<glm::uint32>("glm::uint32"),
|
||||
qRegisterMetaType<QVector<glm::uint32>>(),
|
||||
qRegisterMetaType<QVector<glm::uint32>>("QVector<uint32>"),
|
||||
qRegisterMetaType<scriptable::ScriptableMeshes>(),
|
||||
qRegisterMetaType<scriptable::ScriptableMeshes>("ScriptableMeshes"),
|
||||
qRegisterMetaType<scriptable::ScriptableMeshes>("scriptable::ScriptableMeshes"),
|
||||
|
@ -532,7 +528,6 @@ namespace scriptable {
|
|||
}
|
||||
|
||||
void GraphicsScriptingInterface::registerMetaTypes(QScriptEngine* engine) {
|
||||
qScriptRegisterSequenceMetaType<QVector<glm::uint32>>(engine);
|
||||
qScriptRegisterSequenceMetaType<QVector<scriptable::ScriptableMaterialLayer>>(engine);
|
||||
|
||||
scriptable::registerQPointerMetaType<scriptable::ScriptableModel>(engine);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "ScriptableMesh.h"
|
||||
#include <DependencyManager.h>
|
||||
#include "RegisteredMetaTypes.h"
|
||||
|
||||
|
||||
/**jsdoc
|
||||
|
@ -107,8 +108,6 @@ namespace scriptable {
|
|||
QScriptValue scriptableMaterialToScriptValue(QScriptEngine* engine, const scriptable::ScriptableMaterial &material);
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(glm::uint32)
|
||||
Q_DECLARE_METATYPE(QVector<glm::uint32>)
|
||||
Q_DECLARE_METATYPE(NestableType)
|
||||
|
||||
#endif // hifi_GraphicsScriptingInterface_h
|
||||
|
|
|
@ -56,6 +56,14 @@ QVector<QUuid> PickQuery::getIgnoreItems() const {
|
|||
});
|
||||
}
|
||||
|
||||
void PickQuery::setScriptParameters(const QVariantMap& parameters) {
|
||||
_scriptParameters = parameters;
|
||||
}
|
||||
|
||||
QVariantMap PickQuery::getScriptParameters() const {
|
||||
return _scriptParameters;
|
||||
}
|
||||
|
||||
QVector<QUuid> PickQuery::getIncludeItems() const {
|
||||
return resultWithReadLock<QVector<QUuid>>([&] {
|
||||
return _includeItems;
|
||||
|
|
|
@ -117,7 +117,8 @@ public:
|
|||
Stylus,
|
||||
Parabola,
|
||||
Collision,
|
||||
NUM_PICK_TYPES
|
||||
NUM_PICK_TYPES,
|
||||
INVALID_PICK_TYPE = -1
|
||||
};
|
||||
Q_ENUM(PickType)
|
||||
|
||||
|
@ -134,6 +135,7 @@ public:
|
|||
PickFilter getFilter() const;
|
||||
float getMaxDistance() const;
|
||||
bool isEnabled() const;
|
||||
virtual PickType getType() const = 0;
|
||||
|
||||
void setPrecisionPicking(bool precisionPicking);
|
||||
|
||||
|
@ -168,6 +170,27 @@ public:
|
|||
void setIgnoreItems(const QVector<QUuid>& items);
|
||||
void setIncludeItems(const QVector<QUuid>& items);
|
||||
|
||||
virtual QVariantMap toVariantMap() const {
|
||||
QVariantMap properties;
|
||||
|
||||
properties["pickType"] = (int)getType();
|
||||
properties["enabled"] = isEnabled();
|
||||
properties["filter"] = (unsigned int)getFilter()._flags.to_ulong();
|
||||
properties["maxDistance"] = getMaxDistance();
|
||||
|
||||
if (parentTransform) {
|
||||
auto transformNodeProperties = parentTransform->toVariantMap();
|
||||
for (auto it = transformNodeProperties.cbegin(); it != transformNodeProperties.cend(); ++it) {
|
||||
properties[it.key()] = it.value();
|
||||
}
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
void setScriptParameters(const QVariantMap& parameters);
|
||||
QVariantMap getScriptParameters() const;
|
||||
|
||||
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; }
|
||||
|
@ -187,6 +210,9 @@ private:
|
|||
QVector<QUuid> _ignoreItems;
|
||||
QVector<QUuid> _includeItems;
|
||||
|
||||
// The parameters used to create this pick when created through a script
|
||||
QVariantMap _scriptParameters;
|
||||
|
||||
JointState _jointState { JOINT_STATE_NONE };
|
||||
};
|
||||
Q_DECLARE_METATYPE(PickQuery::PickType)
|
||||
|
@ -202,6 +228,17 @@ public:
|
|||
virtual PickResultPointer getAvatarIntersection(const T& pick) = 0;
|
||||
virtual PickResultPointer getHUDIntersection(const T& pick) = 0;
|
||||
|
||||
QVariantMap toVariantMap() const override {
|
||||
QVariantMap properties = PickQuery::toVariantMap();
|
||||
|
||||
const QVariantMap mathPickProperties = _mathPick.toVariantMap();
|
||||
for (auto it = mathPickProperties.cbegin(); it != mathPickProperties.cend(); ++it) {
|
||||
properties[it.key()] = it.value();
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
protected:
|
||||
T _mathPick;
|
||||
};
|
||||
|
|
|
@ -49,6 +49,35 @@ void PickManager::removePick(unsigned int uid) {
|
|||
});
|
||||
}
|
||||
|
||||
QVariantMap PickManager::getPickProperties(unsigned int uid) const {
|
||||
auto pick = findPick(uid);
|
||||
if (pick) {
|
||||
return pick->toVariantMap();
|
||||
}
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
QVariantMap PickManager::getPickScriptParameters(unsigned int uid) const {
|
||||
auto pick = findPick(uid);
|
||||
if (pick) {
|
||||
return pick->getScriptParameters();
|
||||
}
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
QVector<unsigned int> PickManager::getPicks() const {
|
||||
QVector<unsigned int> picks;
|
||||
withReadLock([&] {
|
||||
for (auto typeIt = _picks.cbegin(); typeIt != _picks.cend(); ++typeIt) {
|
||||
auto& picksForType = typeIt->second;
|
||||
for (auto pickIt = picksForType.cbegin(); pickIt != picksForType.cend(); ++pickIt) {
|
||||
picks.push_back(pickIt->first);
|
||||
}
|
||||
}
|
||||
});
|
||||
return picks;
|
||||
}
|
||||
|
||||
PickResultPointer PickManager::getPrevPickResult(unsigned int uid) const {
|
||||
auto pick = findPick(uid);
|
||||
if (pick) {
|
||||
|
@ -71,6 +100,14 @@ void PickManager::disablePick(unsigned int uid) const {
|
|||
}
|
||||
}
|
||||
|
||||
bool PickManager::isPickEnabled(unsigned int uid) const {
|
||||
auto pick = findPick(uid);
|
||||
if (pick) {
|
||||
return pick->isEnabled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PickManager::setPrecisionPicking(unsigned int uid, bool precisionPicking) const {
|
||||
auto pick = findPick(uid);
|
||||
if (pick) {
|
||||
|
|
|
@ -31,8 +31,14 @@ public:
|
|||
void removePick(unsigned int uid);
|
||||
void enablePick(unsigned int uid) const;
|
||||
void disablePick(unsigned int uid) const;
|
||||
bool isPickEnabled(unsigned int uid) const;
|
||||
QVector<unsigned int> getPicks() const;
|
||||
|
||||
PickResultPointer getPrevPickResult(unsigned int uid) const;
|
||||
// The actual current properties of the pick
|
||||
QVariantMap getPickProperties(unsigned int uid) const;
|
||||
// The properties that were passed in to create the pick (may be empty if the pick was created by invoking the constructor)
|
||||
QVariantMap getPickScriptParameters(unsigned int uid) const;
|
||||
|
||||
template <typename T>
|
||||
std::shared_ptr<T> getPrevPickResultTyped(unsigned int uid) const {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/22/2018
|
||||
// Created by Sabrina Shanman 2018/08/22
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
@ -23,4 +23,10 @@ Transform PickTransformNode::getTransform() {
|
|||
}
|
||||
|
||||
return pickManager->getResultTransform(_uid);
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap PickTransformNode::toVariantMap() const {
|
||||
QVariantMap map;
|
||||
map["parentID"] = _uid;
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/22/2018
|
||||
// Created by Sabrina Shanman 2018/08/22
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
@ -15,9 +15,10 @@ class PickTransformNode : public TransformNode {
|
|||
public:
|
||||
PickTransformNode(unsigned int uid);
|
||||
Transform getTransform() override;
|
||||
QVariantMap toVariantMap() const override;
|
||||
|
||||
protected:
|
||||
unsigned int _uid;
|
||||
};
|
||||
|
||||
#endif // hifi_PickTransformNode_h
|
||||
#endif // hifi_PickTransformNode_h
|
||||
|
|
|
@ -36,10 +36,32 @@ void Pointer::disable() {
|
|||
DependencyManager::get<PickManager>()->disablePick(_pickUID);
|
||||
}
|
||||
|
||||
bool Pointer::isEnabled() {
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
PickResultPointer Pointer::getPrevPickResult() {
|
||||
return DependencyManager::get<PickManager>()->getPrevPickResult(_pickUID);
|
||||
}
|
||||
|
||||
QVariantMap Pointer::toVariantMap() const {
|
||||
QVariantMap qVariantMap = DependencyManager::get<PickManager>()->getPickProperties(_pickUID);
|
||||
|
||||
qVariantMap["pointerType"] = getType();
|
||||
qVariantMap["pickID"] = _pickUID;
|
||||
qVariantMap["hover"] = _hover;
|
||||
|
||||
return qVariantMap;
|
||||
}
|
||||
|
||||
void Pointer::setScriptParameters(const QVariantMap& scriptParameters) {
|
||||
_scriptParameters = scriptParameters;
|
||||
}
|
||||
|
||||
QVariantMap Pointer::getScriptParameters() const {
|
||||
return _scriptParameters;
|
||||
}
|
||||
|
||||
void Pointer::setPrecisionPicking(bool precisionPicking) {
|
||||
DependencyManager::get<PickManager>()->setPrecisionPicking(_pickUID, precisionPicking);
|
||||
}
|
||||
|
|
|
@ -45,12 +45,16 @@ public:
|
|||
|
||||
virtual void enable();
|
||||
virtual void disable();
|
||||
virtual bool isEnabled();
|
||||
virtual PickQuery::PickType getType() const = 0;
|
||||
virtual PickResultPointer getPrevPickResult();
|
||||
|
||||
virtual void setRenderState(const std::string& state) = 0;
|
||||
virtual void editRenderState(const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps) = 0;
|
||||
|
||||
virtual QVariantMap toVariantMap() const = 0;
|
||||
virtual QVariantMap toVariantMap() const;
|
||||
virtual void setScriptParameters(const QVariantMap& scriptParameters);
|
||||
virtual QVariantMap getScriptParameters() const;
|
||||
|
||||
virtual void setPrecisionPicking(bool precisionPicking);
|
||||
virtual void setIgnoreItems(const QVector<QUuid>& ignoreItems) const;
|
||||
|
@ -84,6 +88,9 @@ protected:
|
|||
bool _enabled;
|
||||
bool _hover;
|
||||
|
||||
// The parameters used to create this pointer when created through a script
|
||||
QVariantMap _scriptParameters;
|
||||
|
||||
virtual PointerEvent buildPointerEvent(const PickedObject& target, const PickResultPointer& pickResult, const std::string& button = "", bool hover = true) = 0;
|
||||
|
||||
virtual PickedObject getHoveredObject(const PickResultPointer& pickResult) = 0;
|
||||
|
|
|
@ -54,6 +54,24 @@ void PointerManager::disablePointer(unsigned int uid) const {
|
|||
}
|
||||
}
|
||||
|
||||
bool PointerManager::isPointerEnabled(unsigned int uid) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
return pointer->isEnabled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QVector<unsigned int> PointerManager::getPointers() const {
|
||||
QVector<unsigned int> pointers;
|
||||
withReadLock([&] {
|
||||
for (auto it = _pointers.cbegin(); it != _pointers.cend(); ++it) {
|
||||
pointers.push_back(it->first);
|
||||
}
|
||||
});
|
||||
return pointers;
|
||||
}
|
||||
|
||||
void PointerManager::setRenderState(unsigned int uid, const std::string& renderState) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
|
@ -86,6 +104,14 @@ QVariantMap PointerManager::getPointerProperties(unsigned int uid) const {
|
|||
}
|
||||
}
|
||||
|
||||
QVariantMap PointerManager::getPointerScriptParameters(unsigned int uid) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
return pointer->getScriptParameters();
|
||||
}
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
void PointerManager::update() {
|
||||
auto cachedPointers = resultWithReadLock<std::unordered_map<unsigned int, std::shared_ptr<Pointer>>>([&] {
|
||||
return _pointers;
|
||||
|
|
|
@ -27,10 +27,17 @@ public:
|
|||
void removePointer(unsigned int uid);
|
||||
void enablePointer(unsigned int uid) const;
|
||||
void disablePointer(unsigned int uid) const;
|
||||
bool isPointerEnabled(unsigned int uid) const;
|
||||
QVector<unsigned int> getPointers() const;
|
||||
|
||||
void setRenderState(unsigned int uid, const std::string& renderState) const;
|
||||
void editRenderState(unsigned int uid, const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps) const;
|
||||
|
||||
PickResultPointer getPrevPickResult(unsigned int uid) const;
|
||||
// The actual current properties of the pointer
|
||||
QVariantMap getPointerProperties(unsigned int uid) const;
|
||||
// The properties that were passed in to create the pointer (may be empty if the pointer was created by invoking the constructor)
|
||||
QVariantMap getPointerScriptParameters(unsigned int uid) const;
|
||||
|
||||
void setPrecisionPicking(unsigned int uid, bool precisionPicking) const;
|
||||
void setIgnoreItems(unsigned int uid, const QVector<QUuid>& ignoreEntities) const;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Created by Sabrina Shanman 2018/08/14
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
@ -11,4 +11,4 @@
|
|||
template<>
|
||||
glm::vec3 BaseNestableTransformNode<SpatiallyNestable>::getActualScale(const std::shared_ptr<SpatiallyNestable>& nestablePointer) const {
|
||||
return nestablePointer->getAbsoluteJointScaleInObjectFrame(_jointIndex);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Created by Sabrina Shanman 2018/08/14
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
@ -12,6 +12,8 @@
|
|||
|
||||
#include "SpatiallyNestable.h"
|
||||
|
||||
#include "RegisteredMetaTypes.h"
|
||||
|
||||
template <typename T>
|
||||
class BaseNestableTransformNode : public TransformNode {
|
||||
public:
|
||||
|
@ -45,6 +47,19 @@ public:
|
|||
return jointWorldTransform;
|
||||
}
|
||||
|
||||
QVariantMap toVariantMap() const override {
|
||||
QVariantMap map;
|
||||
|
||||
auto nestable = _spatiallyNestable.lock();
|
||||
if (nestable) {
|
||||
map["parentID"] = nestable->getID();
|
||||
map["parentJointIndex"] = _jointIndex;
|
||||
map["baseParentScale"] = vec3toVariant(_baseScale);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
glm::vec3 getActualScale(const std::shared_ptr<T>& nestablePointer) const;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include <QtScript/QScriptValueIterator>
|
||||
#include <QJsonDocument>
|
||||
|
||||
int uint32MetaTypeId = qRegisterMetaType<glm::uint32>("uint32");
|
||||
int glmUint32MetaTypeId = qRegisterMetaType<glm::uint32>("glm::uint32");
|
||||
int vec2MetaTypeId = qRegisterMetaType<glm::vec2>();
|
||||
int u8vec3MetaTypeId = qRegisterMetaType<u8vec3>();
|
||||
int vec3MetaTypeId = qRegisterMetaType<glm::vec3>();
|
||||
|
@ -33,6 +35,7 @@ int vec4MetaTypeId = qRegisterMetaType<glm::vec4>();
|
|||
int qVectorVec3MetaTypeId = qRegisterMetaType<QVector<glm::vec3>>();
|
||||
int qVectorQuatMetaTypeId = qRegisterMetaType<QVector<glm::quat>>();
|
||||
int qVectorBoolMetaTypeId = qRegisterMetaType<QVector<bool>>();
|
||||
int qVectorGLMUint32MetaTypeId = qRegisterMetaType<QVector<unsigned int>>("QVector<glm::uint32>");
|
||||
int quatMetaTypeId = qRegisterMetaType<glm::quat>();
|
||||
int pickRayMetaTypeId = qRegisterMetaType<PickRay>();
|
||||
int collisionMetaTypeId = qRegisterMetaType<Collision>();
|
||||
|
@ -67,6 +70,8 @@ void registerMetaTypes(QScriptEngine* engine) {
|
|||
qScriptRegisterMetaType(engine, aaCubeToScriptValue, aaCubeFromScriptValue);
|
||||
|
||||
qScriptRegisterMetaType(engine, stencilMaskModeToScriptValue, stencilMaskModeFromScriptValue);
|
||||
|
||||
qScriptRegisterSequenceMetaType<QVector<unsigned int>>(engine);
|
||||
}
|
||||
|
||||
QScriptValue vec2ToScriptValue(QScriptEngine* engine, const glm::vec2& vec2) {
|
||||
|
|
|
@ -37,6 +37,8 @@ Q_DECLARE_METATYPE(glm::vec4)
|
|||
Q_DECLARE_METATYPE(glm::quat)
|
||||
Q_DECLARE_METATYPE(glm::mat4)
|
||||
Q_DECLARE_METATYPE(QVector<float>)
|
||||
Q_DECLARE_METATYPE(unsigned int)
|
||||
Q_DECLARE_METATYPE(QVector<unsigned int>)
|
||||
Q_DECLARE_METATYPE(AACube)
|
||||
Q_DECLARE_METATYPE(std::function<void()>);
|
||||
Q_DECLARE_METATYPE(std::function<QVariant()>);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Sabrina Shanman 8/14/2018
|
||||
// Created by Sabrina Shanman 2018/08/14
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
@ -8,6 +8,8 @@
|
|||
#ifndef hifi_TransformNode_h
|
||||
#define hifi_TransformNode_h
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "Transform.h"
|
||||
|
||||
class TransformNode {
|
||||
|
@ -15,6 +17,7 @@ public:
|
|||
virtual ~TransformNode() = default;
|
||||
|
||||
virtual Transform getTransform() = 0;
|
||||
virtual QVariantMap toVariantMap() const = 0;
|
||||
};
|
||||
|
||||
#endif // hifi_TransformNode_h
|
||||
|
|
Loading…
Reference in a new issue