Showing the changes to interface/src/raypick/PointerScriptingInterface.cpp (1 of 35 files). Show all
Unified · Split
| @@ -13,6 +13,7 @@ · 12 unmodified lines | ||
| 13 | 13 | #include <shared/QtHelpers.h> |
| 14 | 14 | |
| 15 | 15 | #include "Application.h" |
| 16 | +#include "PickManager.h" | |
| 16 | 17 | #include "LaserPointer.h" |
| 17 | 18 | #include "StylusPointer.h" |
| 18 | 19 | #include "ParabolaPointer.h" |
| @@ -38,16 +39,46 @@ unsigned int PointerScriptingInterface::createPointer(const PickQuery::PickType& · 19 unmodified lines | ||
| 38 | 39 | return result; |
| 39 | 40 | } |
| 40 | 41 | |
| 42 | + QVariantMap propertyMap = properties.toMap(); | |
| 43 | + | |
| 44 | + std::shared_ptr<Pointer> pointer; | |
| 41 | 45 | switch (type) { |
| 42 | 46 | case PickQuery::PickType::Ray: |
| 43 | − return createLaserPointer(properties); | |
| 47 | + pointer = buildLaserPointer(propertyMap); | |
| 48 | + break; | |
| 44 | 49 | case PickQuery::PickType::Stylus: |
| 45 | − return createStylus(properties); | |
| 50 | + pointer = buildStylus(propertyMap); | |
| 51 | + break; | |
| 46 | 52 | case PickQuery::PickType::Parabola: |
| 47 | − return createParabolaPointer(properties); | |
| 53 | + pointer = buildParabolaPointer(propertyMap); | |
| 54 | + break; | |
| 48 | 55 | default: |
| 49 | − return PointerEvent::INVALID_POINTER_ID; | |
| 56 | + break; | |
| 50 | 57 | } |
| 58 | + | |
| 59 | + if (!pointer) { | |
| 60 | + return PointerEvent::INVALID_POINTER_ID; | |
| 61 | + } | |
| 62 | + | |
| 63 | + propertyMap["type"] = (int)type; | |
| 64 | + | |
| 65 | + return DependencyManager::get<PointerManager>()->addPointer(pointer); | |
| 66 | +} | |
| 67 | + | |
| 68 | +bool PointerScriptingInterface::isPointerEnabled(unsigned int uid) const { | |
| 69 | + return DependencyManager::get<PointerManager>()->isPointerEnabled(uid); | |
| 70 | +} | |
| 71 | + | |
| 72 | +QVector<unsigned int> PointerScriptingInterface::getCreatedPointers() const { | |
| 73 | + return DependencyManager::get<PointerManager>()->getCreatedPointers(); | |
| 74 | +} | |
| 75 | + | |
| 76 | +QVariantMap PointerScriptingInterface::getPointerProperties(unsigned int uid) const { | |
| 77 | + return DependencyManager::get<PointerManager>()->getPointerProperties(uid); | |
| 78 | +} | |
| 79 | + | |
| 80 | +QVariantMap PointerScriptingInterface::getPointerScriptParameters(unsigned int uid) const { | |
| 81 | + return DependencyManager::get<PointerManager>()->getPointerScriptParameters(uid); | |
| 51 | 82 | } |
| 52 | 83 | |
| 53 | 84 | /**jsdoc |
| @@ -56,6 +87,7 @@ unsigned int PointerScriptingInterface::createPointer(const PickQuery::PickType& · 2 unmodified lines | ||
| 56 | 87 | * @property {Pointers.StylusPointerModel} [model] - Override some or all of the default stylus model properties. |
| 57 | 88 | * @property {boolean} [hover=false] - <code>true</code> if the pointer generates {@link Entities} hover events, |
| 58 | 89 | * <code>false</code> if it doesn't. |
| 90 | + * @property {number} [pickID] - Returned from {@link Pointers.getPointerProperties}. The ID of the pick created alongside this pointer. | |
| 59 | 91 | * @see {@link Picks.StylusPickProperties} for additional properties from the underlying stylus pick. |
| 60 | 92 | */ |
| 61 | 93 | /**jsdoc |
| @@ -67,7 +99,7 @@ unsigned int PointerScriptingInterface::createPointer(const PickQuery::PickType& · 5 unmodified lines | ||
| 67 | 99 | * offset. |
| 68 | 100 | * @property {Quat} [rotationOffset] - The rotation offset of the model from the hand, to override the default rotation offset. |
| 69 | 101 | */ |
| 70 | −unsigned int PointerScriptingInterface::createStylus(const QVariant& properties) const { | |
| 102 | +std::shared_ptr<Pointer> PointerScriptingInterface::buildStylus(const QVariant& properties) { | |
| 71 | 103 | QVariantMap propertyMap = properties.toMap(); |
| 72 | 104 | |
| 73 | 105 | bool hover = false; |
| @@ -100,8 +132,7 @@ unsigned int PointerScriptingInterface::createStylus(const QVariant& properties) · 26 unmodified lines | ||
| 100 | 132 | } |
| 101 | 133 | } |
| 102 | 134 | |
| 103 | − return DependencyManager::get<PointerManager>()->addPointer(std::make_shared<StylusPointer>(properties, StylusPointer::buildStylus(propertyMap), hover, enabled, modelPositionOffset, | |
| 104 | − modelRotationOffset, modelDimensions)); | |
| 135 | + return std::make_shared<StylusPointer>(properties, StylusPointer::buildStylus(propertyMap), hover, enabled, modelPositionOffset, modelRotationOffset, modelDimensions); | |
| 105 | 136 | } |
| 106 | 137 | |
| 107 | 138 | /**jsdoc |
| @@ -174,9 +205,10 @@ unsigned int PointerScriptingInterface::createStylus(const QVariant& properties) · 66 unmodified lines | ||
| 174 | 205 | * <code>false</code> if it doesn't. |
| 175 | 206 | * @property {Pointers.Trigger[]} [triggers=[]] - A list of ways that a {@link Controller} action or function should trigger |
| 176 | 207 | * events on the entity or overlay currently intersected. |
| 208 | + * @property {number} [pickID] - Returned from {@link Pointers.getPointerProperties}. The ID of the pick created alongside this pointer. | |
| 177 | 209 | * @see {@link Picks.RayPickProperties} for additional properties from the underlying ray pick. |
| 178 | 210 | */ |
| 179 | −unsigned int PointerScriptingInterface::createLaserPointer(const QVariant& properties) const { | |
| 211 | +std::shared_ptr<Pointer> PointerScriptingInterface::buildLaserPointer(const QVariant& properties) { | |
| 180 | 212 | QVariantMap propertyMap = properties.toMap(); |
| 181 | 213 | |
| 182 | 214 | #if defined (Q_OS_ANDROID) |
| @@ -185,7 +217,7 @@ unsigned int PointerScriptingInterface::createLaserPointer(const QVariant& prope · 2 unmodified lines | ||
| 185 | 217 | QString jointName = propertyMap["joint"].toString(); |
| 186 | 218 | const QString MOUSE_JOINT = "Mouse"; |
| 187 | 219 | if (jointName == MOUSE_JOINT) { |
| 188 | − return PointerEvent::INVALID_POINTER_ID; | |
| 220 | + return nullptr; | |
| 189 | 221 | } |
| 190 | 222 | } |
| 191 | 223 | #endif |
| @@ -283,9 +315,9 @@ unsigned int PointerScriptingInterface::createLaserPointer(const QVariant& prope · 91 unmodified lines | ||
| 283 | 315 | } |
| 284 | 316 | } |
| 285 | 317 | |
| 286 | − return DependencyManager::get<PointerManager>()->addPointer(std::make_shared<LaserPointer>(properties, renderStates, defaultRenderStates, hover, triggers, | |
| 287 | − faceAvatar, followNormal, followNormalStrength, centerEndY, lockEnd, | |
| 288 | − distanceScaleEnd, scaleWithParent, enabled)); | |
| 318 | + return std::make_shared<LaserPointer>(properties, renderStates, defaultRenderStates, hover, triggers, | |
| 319 | + faceAvatar, followNormal, followNormalStrength, centerEndY, lockEnd, | |
| 320 | + distanceScaleEnd, scaleWithParent, enabled); | |
| 289 | 321 | } |
| 290 | 322 | |
| 291 | 323 | /**jsdoc |
| @@ -365,9 +397,10 @@ unsigned int PointerScriptingInterface::createLaserPointer(const QVariant& prope · 73 unmodified lines | ||
| 365 | 397 | * <code>false</code> if it doesn't. |
| 366 | 398 | * @property {Pointers.Trigger[]} [triggers=[]] - A list of ways that a {@link Controller} action or function should trigger |
| 367 | 399 | * events on the entity or overlay currently intersected. |
| 400 | + * @property {number} [pickID] - Returned from {@link Pointers.getPointerProperties}. The ID of the pick created alongside this pointer. | |
| 368 | 401 | * @see {@link Picks.ParabolaPickProperties} for additional properties from the underlying parabola pick. |
| 369 | 402 | */ |
| 370 | −unsigned int PointerScriptingInterface::createParabolaPointer(const QVariant& properties) const { | |
| 403 | +std::shared_ptr<Pointer> PointerScriptingInterface::buildParabolaPointer(const QVariant& properties) { | |
| 371 | 404 | QVariantMap propertyMap = properties.toMap(); |
| 372 | 405 | |
| 373 | 406 | bool faceAvatar = false; |
| @@ -463,9 +496,9 @@ unsigned int PointerScriptingInterface::createParabolaPointer(const QVariant& pr · 89 unmodified lines | ||
| 463 | 496 | } |
| 464 | 497 | } |
| 465 | 498 | |
| 466 | − return DependencyManager::get<PointerManager>()->addPointer(std::make_shared<ParabolaPointer>(properties, renderStates, defaultRenderStates, hover, triggers, | |
| 467 | − faceAvatar, followNormal, followNormalStrength, centerEndY, lockEnd, distanceScaleEnd, | |
| 468 | − scaleWithParent, enabled)); | |
| 499 | + return std::make_shared<ParabolaPointer>(properties, renderStates, defaultRenderStates, hover, triggers, | |
| 500 | + faceAvatar, followNormal, followNormalStrength, centerEndY, lockEnd, distanceScaleEnd, | |
| 501 | + scaleWithParent, enabled); | |
| 469 | 502 | } |
| 470 | 503 | |
| 471 | 504 | void PointerScriptingInterface::editRenderState(unsigned int uid, const QString& renderState, const QVariant& properties) const { |
| @@ -497,7 +530,3 @@ QVariantMap PointerScriptingInterface::getPrevPickResult(unsigned int uid) const · 25 unmodified lines | ||
| 497 | 530 | } |
| 498 | 531 | return result; |
| 499 | 532 | } |
| 500 | − | |
| 501 | −QVariantMap PointerScriptingInterface::getPointerProperties(unsigned int uid) const { | |
| 502 | − return DependencyManager::get<PointerManager>()->getPointerProperties(uid); | |
| 503 | −} | |