Showing the changes to interface/src/raypick/PointerScriptingInterface.cpp (1 of 20 files). Show all
Unified · Split
| @@ -21,7 +21,7 @@ void PointerScriptingInterface::setIncludeItems(const QUuid& uid, const QScriptV · 20 unmodified lines | ||
| 21 | 21 | DependencyManager::get<PointerManager>()->setIncludeItems(uid, qVectorQUuidFromScriptValue(includeItems)); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | −QUuid PointerScriptingInterface::createPointer(const PickQuery::PickType type, const QVariant& properties) const { | |
| 24 | +QUuid PointerScriptingInterface::createPointer(const PickQuery::PickType& type, const QVariant& properties) const { | |
| 25 | 25 | switch (type) { |
| 26 | 26 | case PickQuery::PickType::Ray: |
| 27 | 27 | return createLaserPointer(properties); |
| @@ -61,7 +61,7 @@ QUuid PointerScriptingInterface::createLaserPointer(const QVariant& properties) · 33 unmodified lines | ||
| 61 | 61 | LaserPointer::RenderStateMap renderStates; |
| 62 | 62 | if (propertyMap["renderStates"].isValid()) { |
| 63 | 63 | QList<QVariant> renderStateVariants = propertyMap["renderStates"].toList(); |
| 64 | − for (QVariant& renderStateVariant : renderStateVariants) { | |
| 64 | + for (const QVariant& renderStateVariant : renderStateVariants) { | |
| 65 | 65 | if (renderStateVariant.isValid()) { |
| 66 | 66 | QVariantMap renderStateMap = renderStateVariant.toMap(); |
| 67 | 67 | if (renderStateMap["name"].isValid()) { |
| @@ -75,7 +75,7 @@ QUuid PointerScriptingInterface::createLaserPointer(const QVariant& properties) · 7 unmodified lines | ||
| 75 | 75 | LaserPointer::DefaultRenderStateMap defaultRenderStates; |
| 76 | 76 | if (propertyMap["defaultRenderStates"].isValid()) { |
| 77 | 77 | QList<QVariant> renderStateVariants = propertyMap["defaultRenderStates"].toList(); |
| 78 | − for (QVariant& renderStateVariant : renderStateVariants) { | |
| 78 | + for (const QVariant& renderStateVariant : renderStateVariants) { | |
| 79 | 79 | if (renderStateVariant.isValid()) { |
| 80 | 80 | QVariantMap renderStateMap = renderStateVariant.toMap(); |
| 81 | 81 | if (renderStateMap["name"].isValid() && renderStateMap["distance"].isValid()) { |
| @@ -87,7 +87,26 @@ QUuid PointerScriptingInterface::createLaserPointer(const QVariant& properties) · 5 unmodified lines | ||
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | − return DependencyManager::get<PointerManager>()->addPointer(std::make_shared<LaserPointer>(properties, renderStates, defaultRenderStates, faceAvatar, centerEndY, lockEnd, distanceScaleEnd, enabled)); | |
| 90 | + PointerTriggers triggers; | |
| 91 | + auto userInputMapper = DependencyManager::get<UserInputMapper>(); | |
| 92 | + if (propertyMap["triggers"].isValid()) { | |
| 93 | + QList<QVariant> triggerVariants = propertyMap["triggers"].toList(); | |
| 94 | + for (const QVariant& triggerVariant : triggerVariants) { | |
| 95 | + if (triggerVariant.isValid()) { | |
| 96 | + QVariantMap triggerMap = triggerVariant.toMap(); | |
| 97 | + if (triggerMap["action"].isValid() && triggerMap["button"].isValid()) { | |
| 98 | + controller::Endpoint::Pointer endpoint = userInputMapper->endpointFor(controller::Input(triggerMap["action"].toUInt())); | |
| 99 | + if (endpoint) { | |
| 100 | + std::string button = triggerMap["button"].toString().toStdString(); | |
| 101 | + triggers.emplace_back(endpoint, button); | |
| 102 | + } | |
| 103 | + } | |
| 104 | + } | |
| 105 | + } | |
| 106 | + } | |
| 107 | + | |
| 108 | + return DependencyManager::get<PointerManager>()->addPointer(std::make_shared<LaserPointer>(properties, renderStates, defaultRenderStates, triggers, | |
| 109 | + faceAvatar, centerEndY, lockEnd, distanceScaleEnd, enabled)); | |
| 91 | 110 | } |
| 92 | 111 | |
| 93 | 112 | void PointerScriptingInterface::editRenderState(const QUuid& uid, const QString& renderState, const QVariant& properties) const { |