Showing the changes to interface/src/ui/Keyboard.cpp (1 of 62 files). Show all
Unified · Split
| @@ -33,11 +33,6 @@ · 32 unmodified lines | ||
| 33 | 33 | #include <RegisteredMetaTypes.h> |
| 34 | 34 | #include <ui/TabletScriptingInterface.h> |
| 35 | 35 | |
| 36 | −#include "ui/overlays/Overlays.h" | |
| 37 | −#include "ui/overlays/Overlay.h" | |
| 38 | −#include "ui/overlays/ModelOverlay.h" | |
| 39 | −#include "ui/overlays/Cube3DOverlay.h" | |
| 40 | −#include "ui/overlays/Text3DOverlay.h" | |
| 41 | 36 | #include "avatar/AvatarManager.h" |
| 42 | 37 | #include "avatar/MyAvatar.h" |
| 43 | 38 | #include "avatar/AvatarManager.h" |
| @@ -120,21 +115,21 @@ std::pair<glm::vec3, glm::quat> calculateKeyboardPositionAndOrientation() { · 76 unmodified lines | ||
| 120 | 115 | float sensorToWorldScale = myAvatar->getSensorToWorldScale(); |
| 121 | 116 | QUuid tabletID = hmd->getCurrentTabletFrameID(); |
| 122 | 117 | if (!tabletID.isNull() && hmd->getShouldShowTablet()) { |
| 123 | − Overlays& overlays = qApp->getOverlays(); | |
| 124 | − auto tabletOverlay = std::dynamic_pointer_cast<Base3DOverlay>(overlays.getOverlay(tabletID)); | |
| 125 | − if (tabletOverlay) { | |
| 126 | − auto tablet = DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system"); | |
| 127 | − bool landscapeMode = tablet->getLandscape(); | |
| 128 | − glm::vec3 keyboardOffset = landscapeMode ? KEYBOARD_TABLET_LANDSCAPE_OFFSET : KEYBOARD_TABLET_OFFSET; | |
| 129 | − glm::vec3 keyboardDegreesOffset = landscapeMode ? KEYBOARD_TABLET_LANDSCAPE_DEGREES_OFFSET : KEYBOARD_TABLET_DEGREES_OFFSET; | |
| 130 | − glm::vec3 tabletWorldPosition = tabletOverlay->getWorldPosition(); | |
| 131 | − glm::quat tabletWorldOrientation = tabletOverlay->getWorldOrientation(); | |
| 132 | − glm::vec3 scaledKeyboardTabletOffset = keyboardOffset * sensorToWorldScale; | |
| 133 | − | |
| 134 | − keyboardLocation.first = tabletWorldPosition + (tabletWorldOrientation * scaledKeyboardTabletOffset); | |
| 135 | − keyboardLocation.second = tabletWorldOrientation * glm::quat(glm::radians(keyboardDegreesOffset)); | |
| 136 | − } | |
| 118 | + EntityPropertyFlags desiredProperties; | |
| 119 | + desiredProperties += PROP_POSITION; | |
| 120 | + desiredProperties += PROP_ROTATION; | |
| 121 | + auto properties = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(tabletID, desiredProperties); | |
| 137 | 122 | |
| 123 | + auto tablet = DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system"); | |
| 124 | + bool landscapeMode = tablet->getLandscape(); | |
| 125 | + glm::vec3 keyboardOffset = landscapeMode ? KEYBOARD_TABLET_LANDSCAPE_OFFSET : KEYBOARD_TABLET_OFFSET; | |
| 126 | + glm::vec3 keyboardDegreesOffset = landscapeMode ? KEYBOARD_TABLET_LANDSCAPE_DEGREES_OFFSET : KEYBOARD_TABLET_DEGREES_OFFSET; | |
| 127 | + glm::vec3 tabletWorldPosition = properties.getPosition(); | |
| 128 | + glm::quat tabletWorldOrientation = properties.getRotation(); | |
| 129 | + glm::vec3 scaledKeyboardTabletOffset = keyboardOffset * sensorToWorldScale; | |
| 130 | + | |
| 131 | + keyboardLocation.first = tabletWorldPosition + (tabletWorldOrientation * scaledKeyboardTabletOffset); | |
| 132 | + keyboardLocation.second = tabletWorldOrientation * glm::quat(glm::radians(keyboardDegreesOffset)); | |
| 138 | 133 | } else { |
| 139 | 134 | glm::vec3 avatarWorldPosition = myAvatar->getWorldPosition(); |
| 140 | 135 | glm::quat avatarWorldOrientation = myAvatar->getWorldOrientation(); |
| @@ -148,32 +143,25 @@ std::pair<glm::vec3, glm::quat> calculateKeyboardPositionAndOrientation() { · 7 unmodified lines | ||
| 148 | 143 | } |
| 149 | 144 | |
| 150 | 145 | void Key::saveDimensionsAndLocalPosition() { |
| 151 | − Overlays& overlays = qApp->getOverlays(); | |
| 152 | − auto model3DOverlay = std::dynamic_pointer_cast<ModelOverlay>(overlays.getOverlay(_keyID)); | |
| 146 | + EntityPropertyFlags desiredProperties; | |
| 147 | + desiredProperties += PROP_LOCAL_POSITION; | |
| 148 | + desiredProperties += PROP_DIMENSIONS; | |
| 149 | + auto properties = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(_keyID, desiredProperties); | |
| 153 | 150 | |
| 154 | − if (model3DOverlay) { | |
| 155 | − _originalLocalPosition = model3DOverlay->getLocalPosition(); | |
| 156 | − _originalDimensions = model3DOverlay->getDimensions(); | |
| 157 | − _currentLocalPosition = _originalLocalPosition; | |
| 158 | − } | |
| 151 | + _originalLocalPosition = properties.getLocalPosition(); | |
| 152 | + _originalDimensions = properties.getDimensions(); | |
| 153 | + _currentLocalPosition = _originalLocalPosition; | |
| 159 | 154 | } |
| 160 | 155 | |
| 161 | 156 | void Key::scaleKey(float sensorToWorldScale) { |
| 162 | − Overlays& overlays = qApp->getOverlays(); | |
| 163 | − auto model3DOverlay = std::dynamic_pointer_cast<ModelOverlay>(overlays.getOverlay(_keyID)); | |
| 164 | − | |
| 165 | − if (model3DOverlay) { | |
| 166 | − glm::vec3 scaledLocalPosition = _originalLocalPosition * sensorToWorldScale; | |
| 167 | − glm::vec3 scaledDimensions = _originalDimensions * sensorToWorldScale; | |
| 168 | − _currentLocalPosition = scaledLocalPosition; | |
| 157 | + glm::vec3 scaledLocalPosition = _originalLocalPosition * sensorToWorldScale; | |
| 158 | + glm::vec3 scaledDimensions = _originalDimensions * sensorToWorldScale; | |
| 159 | + _currentLocalPosition = scaledLocalPosition; | |
| 169 | 160 | |
| 170 | − QVariantMap properties { | |
| 171 | − { "dimensions", vec3toVariant(scaledDimensions) }, | |
| 172 | − { "localPosition", vec3toVariant(scaledLocalPosition) } | |
| 173 | − }; | |
| 174 | − | |
| 175 | − overlays.editOverlay(_keyID, properties); | |
| 176 | − } | |
| 161 | + EntityItemProperties properties; | |
| 162 | + properties.setDimensions(scaledDimensions); | |
| 163 | + properties.setLocalPosition(scaledLocalPosition); | |
| 164 | + DependencyManager::get<EntityScriptingInterface>()->editEntity(_keyID, properties); | |
| 177 | 165 | } |
| 178 | 166 | |
| 179 | 167 | void Key::startTimer(int time) { |
| @@ -262,21 +250,21 @@ void Keyboard::createKeyboard() { · 82 unmodified lines | ||
| 262 | 250 | |
| 263 | 251 | QVariantMap leftStylusProperties { |
| 264 | 252 | { "hand", LEFT_HAND_CONTROLLER_INDEX }, |
| 265 | − { "filter", PickScriptingInterface::PICK_OVERLAYS() }, | |
| 253 | + { "filter", PickScriptingInterface::PICK_LOCAL_ENTITIES() }, | |
| 266 | 254 | { "model", modelProperties }, |
| 267 | 255 | { "tipOffset", vec3toVariant(MALLET_TIP_OFFSET) } |
| 268 | 256 | }; |
| 269 | 257 | |
| 270 | 258 | QVariantMap rightStylusProperties { |
| 271 | 259 | { "hand", RIGHT_HAND_CONTROLLER_INDEX }, |
| 272 | − { "filter", PickScriptingInterface::PICK_OVERLAYS() }, | |
| 260 | + { "filter", PickScriptingInterface::PICK_LOCAL_ENTITIES() }, | |
| 273 | 261 | { "model", modelProperties }, |
| 274 | 262 | { "tipOffset", vec3toVariant(MALLET_TIP_OFFSET) } |
| 275 | 263 | }; |
| 276 | 264 | |
| 277 | − _leftHandStylus = pointerManager->addPointer(std::make_shared<StylusPointer>(leftStylusProperties, StylusPointer::buildStylusOverlay(leftStylusProperties), true, true, | |
| 265 | + _leftHandStylus = pointerManager->addPointer(std::make_shared<StylusPointer>(leftStylusProperties, StylusPointer::buildStylus(leftStylusProperties), true, true, | |
| 278 | 266 | MALLET_POSITION_OFFSET, MALLET_ROTATION_OFFSET, MALLET_MODEL_DIMENSIONS)); |
| 279 | − _rightHandStylus = pointerManager->addPointer(std::make_shared<StylusPointer>(rightStylusProperties, StylusPointer::buildStylusOverlay(rightStylusProperties), true, true, | |
| 267 | + _rightHandStylus = pointerManager->addPointer(std::make_shared<StylusPointer>(rightStylusProperties, StylusPointer::buildStylus(rightStylusProperties), true, true, | |
| 280 | 268 | MALLET_POSITION_OFFSET, MALLET_ROTATION_OFFSET, MALLET_MODEL_DIMENSIONS)); |
| 281 | 269 | |
| 282 | 270 | pointerManager->disablePointer(_rightHandStylus); |
| @@ -312,93 +300,70 @@ void Keyboard::setRaised(bool raised) { · 29 unmodified lines | ||
| 312 | 300 | } |
| 313 | 301 | |
| 314 | 302 | void Keyboard::updateTextDisplay() { |
| 315 | − Overlays& overlays = qApp->getOverlays(); | |
| 316 | − | |
| 317 | 303 | auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); |
| 304 | + auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 318 | 305 | float sensorToWorldScale = myAvatar->getSensorToWorldScale(); |
| 319 | − float textWidth = (float) overlays.textSize(_textDisplay.overlayID, _typedCharacters).width(); | |
| 306 | + float textWidth = (float)entityScriptingInterface->textSize(_textDisplay.entityID, _typedCharacters).width(); | |
| 320 | 307 | |
| 321 | 308 | glm::vec3 scaledDimensions = _textDisplay.dimensions; |
| 322 | 309 | scaledDimensions *= sensorToWorldScale; |
| 323 | 310 | float leftMargin = (scaledDimensions.x / 2); |
| 324 | 311 | scaledDimensions.x += textWidth; |
| 325 | 312 | |
| 326 | − | |
| 327 | − QVariantMap textDisplayProperties { | |
| 328 | − { "dimensions", vec3toVariant(scaledDimensions) }, | |
| 329 | − { "leftMargin", leftMargin }, | |
| 330 | − { "text", _typedCharacters }, | |
| 331 | − { "lineHeight", (_textDisplay.lineHeight * sensorToWorldScale) } | |
| 332 | − }; | |
| 333 | − | |
| 334 | − overlays.editOverlay(_textDisplay.overlayID, textDisplayProperties); | |
| 313 | + EntityItemProperties properties; | |
| 314 | + properties.setDimensions(scaledDimensions); | |
| 315 | + properties.setLeftMargin(leftMargin); | |
| 316 | + properties.setText(_typedCharacters); | |
| 317 | + properties.setLineHeight(_textDisplay.lineHeight * sensorToWorldScale); | |
| 318 | + entityScriptingInterface->editEntity(_textDisplay.entityID, properties); | |
| 335 | 319 | } |
| 336 | 320 | |
| 337 | 321 | void Keyboard::raiseKeyboardAnchor(bool raise) const { |
| 338 | − Overlays& overlays = qApp->getOverlays(); | |
| 339 | − OverlayID anchorOverlayID = _anchor.overlayID; | |
| 340 | − auto anchorOverlay = std::dynamic_pointer_cast<Cube3DOverlay>(overlays.getOverlay(anchorOverlayID)); | |
| 341 | − if (anchorOverlay) { | |
| 342 | − std::pair<glm::vec3, glm::quat> keyboardLocation = calculateKeyboardPositionAndOrientation(); | |
| 343 | − if (_resetKeyboardPositionOnRaise) { | |
| 344 | − anchorOverlay->setWorldPosition(keyboardLocation.first); | |
| 345 | − anchorOverlay->setWorldOrientation(keyboardLocation.second); | |
| 346 | − } | |
| 347 | − anchorOverlay->setVisible(raise); | |
| 348 | − | |
| 349 | − QVariantMap textDisplayProperties { | |
| 350 | − { "visible", raise } | |
| 351 | − }; | |
| 322 | + auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 352 | 323 | |
| 353 | − overlays.editOverlay(_textDisplay.overlayID, textDisplayProperties); | |
| 324 | + EntityItemProperties properties; | |
| 325 | + properties.setVisible(raise); | |
| 354 | 326 | |
| 355 | − auto backPlateOverlay = std::dynamic_pointer_cast<Cube3DOverlay>(overlays.getOverlay(_backPlate.overlayID)); | |
| 327 | + entityScriptingInterface->editEntity(_textDisplay.entityID, properties); | |
| 328 | + entityScriptingInterface->editEntity(_backPlate.entityID, properties); | |
| 356 | 329 | |
| 357 | − if (backPlateOverlay) { | |
| 358 | − backPlateOverlay->setVisible(raise); | |
| 359 | − } | |
| 330 | + if (_resetKeyboardPositionOnRaise) { | |
| 331 | + std::pair<glm::vec3, glm::quat> keyboardLocation = calculateKeyboardPositionAndOrientation(); | |
| 332 | + properties.setPosition(keyboardLocation.first); | |
| 333 | + properties.setRotation(keyboardLocation.second); | |
| 360 | 334 | } |
| 335 | + entityScriptingInterface->editEntity(_anchor.entityID, properties); | |
| 361 | 336 | } |
| 362 | 337 | |
| 363 | 338 | void Keyboard::scaleKeyboard(float sensorToWorldScale) { |
| 364 | − Overlays& overlays = qApp->getOverlays(); | |
| 365 | − | |
| 366 | − glm::vec3 scaledDimensions = _anchor.originalDimensions * sensorToWorldScale; | |
| 367 | − auto volume3DOverlay = std::dynamic_pointer_cast<Volume3DOverlay>(overlays.getOverlay(_anchor.overlayID)); | |
| 339 | + auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 368 | 340 | |
| 369 | − if (volume3DOverlay) { | |
| 370 | − volume3DOverlay->setDimensions(scaledDimensions); | |
| 341 | + { | |
| 342 | + EntityItemProperties properties; | |
| 343 | + properties.setDimensions(_anchor.originalDimensions * sensorToWorldScale); | |
| 344 | + entityScriptingInterface->editEntity(_anchor.entityID, properties); | |
| 371 | 345 | } |
| 372 | 346 | |
| 373 | − for (auto& keyboardLayer: _keyboardLayers) { | |
| 347 | + for (auto& keyboardLayer : _keyboardLayers) { | |
| 374 | 348 | for (auto iter = keyboardLayer.begin(); iter != keyboardLayer.end(); iter++) { |
| 375 | 349 | iter.value().scaleKey(sensorToWorldScale); |
| 376 | 350 | } |
| 377 | 351 | } |
| 378 | 352 | |
| 353 | + { | |
| 354 | + EntityItemProperties properties; | |
| 355 | + properties.setLocalPosition(_textDisplay.localPosition * sensorToWorldScale); | |
| 356 | + properties.setDimensions(_textDisplay.dimensions * sensorToWorldScale); | |
| 357 | + properties.setLineHeight(_textDisplay.lineHeight * sensorToWorldScale); | |
| 358 | + entityScriptingInterface->editEntity(_textDisplay.entityID, properties); | |
| 359 | + } | |
| 379 | 360 | |
| 380 | − | |
| 381 | − glm::vec3 scaledLocalPosition = _textDisplay.localPosition * sensorToWorldScale; | |
| 382 | − glm::vec3 textDisplayScaledDimensions = _textDisplay.dimensions * sensorToWorldScale; | |
| 383 | − | |
| 384 | − QVariantMap textDisplayProperties { | |
| 385 | − { "localPosition", vec3toVariant(scaledLocalPosition) }, | |
| 386 | − { "dimensions", vec3toVariant(textDisplayScaledDimensions) }, | |
| 387 | − { "lineHeight", (_textDisplay.lineHeight * sensorToWorldScale) } | |
| 388 | − }; | |
| 389 | − | |
| 390 | − overlays.editOverlay(_textDisplay.overlayID, textDisplayProperties); | |
| 391 | − | |
| 392 | − | |
| 393 | − glm::vec3 backPlateScaledDimensions = _backPlate.dimensions * sensorToWorldScale; | |
| 394 | − glm::vec3 backPlateScaledLocalPosition = _backPlate.localPosition * sensorToWorldScale; | |
| 395 | − | |
| 396 | − QVariantMap backPlateProperties { | |
| 397 | − { "localPosition", vec3toVariant(backPlateScaledLocalPosition) }, | |
| 398 | − { "dimensions", vec3toVariant(backPlateScaledDimensions) } | |
| 399 | − }; | |
| 400 | − | |
| 401 | − overlays.editOverlay(_backPlate.overlayID, backPlateProperties); | |
| 361 | + { | |
| 362 | + EntityItemProperties properties; | |
| 363 | + properties.setLocalPosition(_backPlate.localPosition * sensorToWorldScale); | |
| 364 | + properties.setDimensions(_backPlate.dimensions * sensorToWorldScale); | |
| 365 | + entityScriptingInterface->editEntity(_backPlate.entityID, properties); | |
| 366 | + } | |
| 402 | 367 | } |
| 403 | 368 | |
| 404 | 369 | void Keyboard::startLayerSwitchTimer() { |
| @@ -419,13 +384,12 @@ void Keyboard::raiseKeyboard(bool raise) const { · 14 unmodified lines | ||
| 419 | 384 | if (_keyboardLayers.empty()) { |
| 420 | 385 | return; |
| 421 | 386 | } |
| 422 | − Overlays& overlays = qApp->getOverlays(); | |
| 387 | + | |
| 423 | 388 | const auto& keyboardLayer = _keyboardLayers[_layerIndex]; |
| 389 | + EntityItemProperties properties; | |
| 390 | + properties.setVisible(raise); | |
| 424 | 391 | for (auto iter = keyboardLayer.begin(); iter != keyboardLayer.end(); iter++) { |
| 425 | − auto base3DOverlay = std::dynamic_pointer_cast<Base3DOverlay>(overlays.getOverlay(iter.key())); | |
| 426 | − if (base3DOverlay) { | |
| 427 | − base3DOverlay->setVisible(raise); | |
| 428 | − } | |
| 392 | + DependencyManager::get<EntityScriptingInterface>()->editEntity(iter.key(), properties); | |
| 429 | 393 | } |
| 430 | 394 | } |
| 431 | 395 | |
| @@ -465,19 +429,15 @@ bool Keyboard::getPreferMalletsOverLasers() const { · 33 unmodified lines | ||
| 465 | 429 | } |
| 466 | 430 | |
| 467 | 431 | void Keyboard::switchToLayer(int layerIndex) { |
| 432 | + auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 468 | 433 | if (layerIndex >= 0 && layerIndex < (int)_keyboardLayers.size()) { |
| 469 | − Overlays& overlays = qApp->getOverlays(); | |
| 470 | − | |
| 471 | − OverlayID currentAnchorOverlayID = _anchor.overlayID; | |
| 472 | − | |
| 473 | − glm::vec3 currentOverlayPosition; | |
| 474 | − glm::quat currentOverlayOrientation; | |
| 434 | + EntityPropertyFlags desiredProperties; | |
| 435 | + desiredProperties += PROP_POSITION; | |
| 436 | + desiredProperties += PROP_ROTATION; | |
| 437 | + auto oldProperties = entityScriptingInterface->getEntityProperties(_anchor.entityID, desiredProperties); | |
| 475 | 438 | |
| 476 | − auto currentAnchorOverlay = std::dynamic_pointer_cast<Cube3DOverlay>(overlays.getOverlay(currentAnchorOverlayID)); | |
| 477 | − if (currentAnchorOverlay) { | |
| 478 | − currentOverlayPosition = currentAnchorOverlay->getWorldPosition(); | |
| 479 | − currentOverlayOrientation = currentAnchorOverlay->getWorldOrientation(); | |
| 480 | − } | |
| 439 | + glm::vec3 currentPosition = oldProperties.getPosition(); | |
| 440 | + glm::quat currentOrientation = oldProperties.getRotation(); | |
| 481 | 441 | |
| 482 | 442 | raiseKeyboardAnchor(false); |
| 483 | 443 | raiseKeyboard(false); |
| @@ -487,19 +447,17 @@ void Keyboard::switchToLayer(int layerIndex) { · 3 unmodified lines | ||
| 487 | 447 | raiseKeyboardAnchor(true); |
| 488 | 448 | raiseKeyboard(true); |
| 489 | 449 | |
| 490 | − OverlayID newAnchorOverlayID = _anchor.overlayID; | |
| 491 | − auto newAnchorOverlay = std::dynamic_pointer_cast<Cube3DOverlay>(overlays.getOverlay(newAnchorOverlayID)); | |
| 492 | − if (newAnchorOverlay) { | |
| 493 | − newAnchorOverlay->setWorldPosition(currentOverlayPosition); | |
| 494 | − newAnchorOverlay->setWorldOrientation(currentOverlayOrientation); | |
| 495 | − } | |
| 450 | + EntityItemProperties properties; | |
| 451 | + properties.setPosition(currentPosition); | |
| 452 | + properties.setRotation(currentOrientation); | |
| 453 | + entityScriptingInterface->editEntity(_anchor.entityID, properties); | |
| 496 | 454 | |
| 497 | 455 | startLayerSwitchTimer(); |
| 498 | 456 | } |
| 499 | 457 | } |
| 500 | 458 | |
| 501 | −bool Keyboard::shouldProcessOverlayAndPointerEvent(const PointerEvent& event, const OverlayID& overlayID) const { | |
| 502 | − return (shouldProcessPointerEvent(event) && shouldProcessOverlay(overlayID)); | |
| 459 | +bool Keyboard::shouldProcessEntityAndPointerEvent(const PointerEvent& event, const QUuid& id) const { | |
| 460 | + return (shouldProcessPointerEvent(event) && shouldProcessEntity(id)); | |
| 503 | 461 | } |
| 504 | 462 | |
| 505 | 463 | bool Keyboard::shouldProcessPointerEvent(const PointerEvent& event) const { |
| @@ -510,14 +468,14 @@ bool Keyboard::shouldProcessPointerEvent(const PointerEvent& event) const { · 4 unmodified lines | ||
| 510 | 468 | return ((isStylusEvent && preferMalletsOverLasers) || (isLaserEvent && !preferMalletsOverLasers)); |
| 511 | 469 | } |
| 512 | 470 | |
| 513 | −void Keyboard::handleTriggerBegin(const OverlayID& overlayID, const PointerEvent& event) { | |
| 471 | +void Keyboard::handleTriggerBegin(const QUuid& id, const PointerEvent& event) { | |
| 514 | 472 | auto buttonType = event.getButton(); |
| 515 | − if (!shouldProcessOverlayAndPointerEvent(event, overlayID) || buttonType != PointerEvent::PrimaryButton) { | |
| 473 | + if (!shouldProcessEntityAndPointerEvent(event, id) || buttonType != PointerEvent::PrimaryButton) { | |
| 516 | 474 | return; |
| 517 | 475 | } |
| 518 | 476 | |
| 519 | 477 | auto& keyboardLayer = _keyboardLayers[_layerIndex]; |
| 520 | − auto search = keyboardLayer.find(overlayID); | |
| 478 | + auto search = keyboardLayer.find(id); | |
| 521 | 479 | |
| 522 | 480 | if (search == keyboardLayer.end()) { |
| 523 | 481 | return; |
| @@ -533,13 +491,9 @@ void Keyboard::handleTriggerBegin(const OverlayID& overlayID, const PointerEvent · 9 unmodified lines | ||
| 533 | 491 | auto userInputMapper = DependencyManager::get<UserInputMapper>(); |
| 534 | 492 | userInputMapper->triggerHapticPulse(PULSE_STRENGTH, PULSE_DURATION, handIndex); |
| 535 | 493 | |
| 536 | − Overlays& overlays = qApp->getOverlays(); | |
| 537 | − auto base3DOverlay = std::dynamic_pointer_cast<Base3DOverlay>(overlays.getOverlay(overlayID)); | |
| 538 | − | |
| 539 | − glm::vec3 keyWorldPosition; | |
| 540 | − if (base3DOverlay) { | |
| 541 | − keyWorldPosition = base3DOverlay->getWorldPosition(); | |
| 542 | − } | |
| 494 | + EntityPropertyFlags desiredProperties; | |
| 495 | + desiredProperties += PROP_POSITION; | |
| 496 | + glm::vec3 keyWorldPosition = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(id, desiredProperties).getPosition(); | |
| 543 | 497 | |
| 544 | 498 | AudioInjectorOptions audioOptions; |
| 545 | 499 | audioOptions.localOnly = true; |
| @@ -601,7 +555,7 @@ void Keyboard::handleTriggerBegin(const OverlayID& overlayID, const PointerEvent · 55 unmodified lines | ||
| 601 | 555 | key.startTimer(KEY_PRESS_TIMEOUT_MS); |
| 602 | 556 | } |
| 603 | 557 | auto selection = DependencyManager::get<SelectionScriptingInterface>(); |
| 604 | − selection->addToSelectedItemsList(KEY_PRESSED_HIGHLIGHT, "overlay", overlayID); | |
| 558 | + selection->addToSelectedItemsList(KEY_PRESSED_HIGHLIGHT, "entity", id); | |
| 605 | 559 | } |
| 606 | 560 | } |
| 607 | 561 | |
| @@ -617,25 +571,23 @@ void Keyboard::setRightHandLaser(unsigned int rightHandLaser) { · 9 unmodified lines | ||
| 617 | 571 | }); |
| 618 | 572 | } |
| 619 | 573 | |
| 620 | −void Keyboard::handleTriggerEnd(const OverlayID& overlayID, const PointerEvent& event) { | |
| 621 | − if (!shouldProcessOverlayAndPointerEvent(event, overlayID)) { | |
| 574 | +void Keyboard::handleTriggerEnd(const QUuid& id, const PointerEvent& event) { | |
| 575 | + if (!shouldProcessEntityAndPointerEvent(event, id)) { | |
| 622 | 576 | return; |
| 623 | 577 | } |
| 624 | 578 | |
| 625 | 579 | auto& keyboardLayer = _keyboardLayers[_layerIndex]; |
| 626 | − auto search = keyboardLayer.find(overlayID); | |
| 580 | + auto search = keyboardLayer.find(id); | |
| 627 | 581 | |
| 628 | 582 | if (search == keyboardLayer.end()) { |
| 629 | 583 | return; |
| 630 | 584 | } |
| 631 | 585 | |
| 632 | − Key& key = search.value();; | |
| 633 | − Overlays& overlays = qApp->getOverlays(); | |
| 634 | − auto base3DOverlay = std::dynamic_pointer_cast<Base3DOverlay>(overlays.getOverlay(overlayID)); | |
| 586 | + Key& key = search.value(); | |
| 635 | 587 | |
| 636 | − if (base3DOverlay) { | |
| 637 | − base3DOverlay->setLocalPosition(key.getCurrentLocalPosition()); | |
| 638 | − } | |
| 588 | + EntityItemProperties properties; | |
| 589 | + properties.setLocalPosition(key.getCurrentLocalPosition()); | |
| 590 | + DependencyManager::get<EntityScriptingInterface>()->editEntity(id, properties); | |
| 639 | 591 | |
| 640 | 592 | key.setIsPressed(false); |
| 641 | 593 | if (key.timerFinished() && getPreferMalletsOverLasers()) { |
| @@ -643,78 +595,79 @@ void Keyboard::handleTriggerEnd(const OverlayID& overlayID, const PointerEvent& · 1 unmodified line | ||
| 643 | 595 | } |
| 644 | 596 | |
| 645 | 597 | auto selection = DependencyManager::get<SelectionScriptingInterface>(); |
| 646 | − selection->removeFromSelectedItemsList(KEY_PRESSED_HIGHLIGHT, "overlay", overlayID); | |
| 598 | + selection->removeFromSelectedItemsList(KEY_PRESSED_HIGHLIGHT, "entity", id); | |
| 647 | 599 | } |
| 648 | 600 | |
| 649 | −void Keyboard::handleTriggerContinue(const OverlayID& overlayID, const PointerEvent& event) { | |
| 650 | − if (!shouldProcessOverlayAndPointerEvent(event, overlayID)) { | |
| 601 | +void Keyboard::handleTriggerContinue(const QUuid& id, const PointerEvent& event) { | |
| 602 | + if (!shouldProcessEntityAndPointerEvent(event, id)) { | |
| 651 | 603 | return; |
| 652 | 604 | } |
| 653 | 605 | |
| 654 | 606 | auto& keyboardLayer = _keyboardLayers[_layerIndex]; |
| 655 | − auto search = keyboardLayer.find(overlayID); | |
| 607 | + auto search = keyboardLayer.find(id); | |
| 656 | 608 | |
| 657 | 609 | if (search == keyboardLayer.end()) { |
| 658 | 610 | return; |
| 659 | 611 | } |
| 660 | 612 | |
| 661 | 613 | Key& key = search.value(); |
| 662 | − Overlays& overlays = qApp->getOverlays(); | |
| 663 | − | |
| 664 | 614 | if (!key.isPressed() && getPreferMalletsOverLasers()) { |
| 665 | − auto base3DOverlay = std::dynamic_pointer_cast<Base3DOverlay>(overlays.getOverlay(overlayID)); | |
| 666 | − | |
| 667 | − if (base3DOverlay) { | |
| 668 | − unsigned int pointerID = event.getID(); | |
| 669 | − auto pointerManager = DependencyManager::get<PointerManager>(); | |
| 670 | − auto pickResult = pointerManager->getPrevPickResult(pointerID); | |
| 671 | − auto stylusPickResult = std::dynamic_pointer_cast<StylusPickResult>(pickResult); | |
| 672 | − float distance = stylusPickResult->distance; | |
| 673 | − | |
| 674 | − static const float PENATRATION_THRESHOLD = 0.025f; | |
| 675 | − if (distance < PENATRATION_THRESHOLD) { | |
| 676 | − static const float Z_OFFSET = 0.002f; | |
| 677 | − glm::quat overlayOrientation = base3DOverlay->getWorldOrientation(); | |
| 678 | − glm::vec3 overlayYAxis = overlayOrientation * Z_AXIS; | |
| 679 | − glm::vec3 overlayYOffset = overlayYAxis * Z_OFFSET; | |
| 680 | − glm::vec3 localPosition = key.getCurrentLocalPosition() - overlayYOffset; | |
| 681 | − base3DOverlay->setLocalPosition(localPosition); | |
| 682 | − key.setIsPressed(true); | |
| 683 | − } | |
| 615 | + unsigned int pointerID = event.getID(); | |
| 616 | + auto pointerManager = DependencyManager::get<PointerManager>(); | |
| 617 | + auto pickResult = pointerManager->getPrevPickResult(pointerID); | |
| 618 | + auto stylusPickResult = std::dynamic_pointer_cast<StylusPickResult>(pickResult); | |
| 619 | + float distance = stylusPickResult->distance; | |
| 620 | + | |
| 621 | + static const float PENATRATION_THRESHOLD = 0.025f; | |
| 622 | + if (distance < PENATRATION_THRESHOLD) { | |
| 623 | + static const float Z_OFFSET = 0.002f; | |
| 624 | + | |
| 625 | + auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 626 | + EntityPropertyFlags desiredProperties; | |
| 627 | + desiredProperties += PROP_ROTATION; | |
| 628 | + glm::quat orientation = entityScriptingInterface->getEntityProperties(id, desiredProperties).getRotation(); | |
| 629 | + glm::vec3 yAxis = orientation * Z_AXIS; | |
| 630 | + glm::vec3 yOffset = yAxis * Z_OFFSET; | |
| 631 | + glm::vec3 localPosition = key.getCurrentLocalPosition() - yOffset; | |
| 632 | + | |
| 633 | + EntityItemProperties properties; | |
| 634 | + properties.setLocalPosition(localPosition); | |
| 635 | + entityScriptingInterface->editEntity(id, properties); | |
| 636 | + key.setIsPressed(true); | |
| 684 | 637 | } |
| 685 | 638 | } |
| 686 | 639 | } |
| 687 | 640 | |
| 688 | −void Keyboard::handleHoverBegin(const OverlayID& overlayID, const PointerEvent& event) { | |
| 689 | − if (!shouldProcessOverlayAndPointerEvent(event, overlayID)) { | |
| 641 | +void Keyboard::handleHoverBegin(const QUuid& id, const PointerEvent& event) { | |
| 642 | + if (!shouldProcessEntityAndPointerEvent(event, id)) { | |
| 690 | 643 | return; |
| 691 | 644 | } |
| 692 | 645 | |
| 693 | 646 | auto& keyboardLayer = _keyboardLayers[_layerIndex]; |
| 694 | − auto search = keyboardLayer.find(overlayID); | |
| 647 | + auto search = keyboardLayer.find(id); | |
| 695 | 648 | |
| 696 | 649 | if (search == keyboardLayer.end()) { |
| 697 | 650 | return; |
| 698 | 651 | } |
| 699 | 652 | |
| 700 | 653 | auto selection = DependencyManager::get<SelectionScriptingInterface>(); |
| 701 | − selection->addToSelectedItemsList(KEY_HOVER_HIGHLIGHT, "overlay", overlayID); | |
| 654 | + selection->addToSelectedItemsList(KEY_HOVER_HIGHLIGHT, "entity", id); | |
| 702 | 655 | } |
| 703 | 656 | |
| 704 | −void Keyboard::handleHoverEnd(const OverlayID& overlayID, const PointerEvent& event) { | |
| 705 | − if (!shouldProcessOverlayAndPointerEvent(event, overlayID)) { | |
| 657 | +void Keyboard::handleHoverEnd(const QUuid& id, const PointerEvent& event) { | |
| 658 | + if (!shouldProcessEntityAndPointerEvent(event, id)) { | |
| 706 | 659 | return; |
| 707 | 660 | } |
| 708 | 661 | |
| 709 | 662 | auto& keyboardLayer = _keyboardLayers[_layerIndex]; |
| 710 | − auto search = keyboardLayer.find(overlayID); | |
| 663 | + auto search = keyboardLayer.find(id); | |
| 711 | 664 | |
| 712 | 665 | if (search == keyboardLayer.end()) { |
| 713 | 666 | return; |
| 714 | 667 | } |
| 715 | 668 | |
| 716 | 669 | auto selection = DependencyManager::get<SelectionScriptingInterface>(); |
| 717 | − selection->removeFromSelectedItemsList(KEY_HOVER_HIGHLIGHT, "overlay", overlayID); | |
| 670 | + selection->removeFromSelectedItemsList(KEY_HOVER_HIGHLIGHT, "entity", id); | |
| 718 | 671 | } |
| 719 | 672 | |
| 720 | 673 | void Keyboard::disableStylus() { |
| @@ -752,7 +705,6 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) { · 31 unmodified lines | ||
| 752 | 705 | } |
| 753 | 706 | |
| 754 | 707 | clearKeyboardKeys(); |
| 755 | − Overlays& overlays = qApp->getOverlays(); | |
| 756 | 708 | auto requestData = request->getData(); |
| 757 | 709 | |
| 758 | 710 | QVector<QUuid> includeItems; |
| @@ -776,54 +728,58 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) { · 17 unmodified lines | ||
| 776 | 728 | return; |
| 777 | 729 | } |
| 778 | 730 | |
| 779 | − QVariantMap anchorProperties { | |
| 780 | − { "name", "KeyboardAnchor"}, | |
| 781 | − { "isSolid", true }, | |
| 782 | − { "visible", false }, | |
| 783 | − { "grabbable", true }, | |
| 784 | − { "ignorePickIntersection", false }, | |
| 785 | − { "dimensions", anchorObject["dimensions"].toVariant() }, | |
| 786 | − { "position", anchorObject["position"].toVariant() }, | |
| 787 | − { "orientation", anchorObject["rotation"].toVariant() } | |
| 788 | − }; | |
| 789 | − | |
| 790 | − glm::vec3 dimensions = vec3FromVariant(anchorObject["dimensions"].toVariant()); | |
| 791 | − | |
| 792 | − Anchor anchor; | |
| 793 | − anchor.overlayID = overlays.addOverlay("cube", anchorProperties); | |
| 794 | − anchor.originalDimensions = dimensions; | |
| 795 | − _anchor = anchor; | |
| 796 | − | |
| 797 | − QJsonObject backPlateObject = jsonObject["backPlate"].toObject(); | |
| 798 | − | |
| 799 | − QVariantMap backPlateProperties { | |
| 800 | − { "name", "backPlate"}, | |
| 801 | − { "isSolid", true }, | |
| 802 | − { "visible", true }, | |
| 803 | − { "grabbable", false }, | |
| 804 | − { "alpha", 0.0 }, | |
| 805 | − { "ignoreRayIntersection", false}, | |
| 806 | − { "dimensions", backPlateObject["dimensions"].toVariant() }, | |
| 807 | − { "position", backPlateObject["position"].toVariant() }, | |
| 808 | − { "orientation", backPlateObject["rotation"].toVariant() }, | |
| 809 | − { "parentID", _anchor.overlayID } | |
| 810 | − }; | |
| 811 | − | |
| 812 | − BackPlate backPlate; | |
| 813 | − backPlate.overlayID = overlays.addOverlay("cube", backPlateProperties); | |
| 814 | − backPlate.dimensions = vec3FromVariant(backPlateObject["dimensions"].toVariant()); | |
| 815 | − backPlate.localPosition = vec3FromVariant(overlays.getProperty(backPlate.overlayID, "localPosition").value); | |
| 816 | − _backPlate = backPlate; | |
| 731 | + auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 732 | + { | |
| 733 | + glm::vec3 dimensions = vec3FromVariant(anchorObject["dimensions"].toVariant()); | |
| 734 | + | |
| 735 | + EntityItemProperties properties; | |
| 736 | + properties.setType(EntityTypes::Box); | |
| 737 | + properties.setName("KeyboardAnchor"); | |
| 738 | + properties.setVisible(false); | |
| 739 | + properties.getGrab().setGrabbable(true); | |
| 740 | + properties.setIgnorePickIntersection(false); | |
| 741 | + properties.setDimensions(dimensions); | |
| 742 | + properties.setPosition(vec3FromVariant(anchorObject["position"].toVariant())); | |
| 743 | + properties.setRotation(quatFromVariant(anchorObject["rotation"].toVariant())); | |
| 744 | + | |
| 745 | + Anchor anchor; | |
| 746 | + anchor.entityID = entityScriptingInterface->addEntity(properties, "local"); | |
| 747 | + anchor.originalDimensions = dimensions; | |
| 748 | + _anchor = anchor; | |
| 749 | + } | |
| 750 | + | |
| 751 | + { | |
| 752 | + QJsonObject backPlateObject = jsonObject["backPlate"].toObject(); | |
| 753 | + glm::vec3 dimensions = vec3FromVariant(backPlateObject["dimensions"].toVariant()); | |
| 754 | + | |
| 755 | + EntityItemProperties properties; | |
| 756 | + properties.setType(EntityTypes::Box); | |
| 757 | + properties.setName("BackPlate"); | |
| 758 | + properties.setVisible(true); | |
| 759 | + properties.getGrab().setGrabbable(false); | |
| 760 | + properties.setAlpha(0.0f); | |
| 761 | + properties.setIgnorePickIntersection(false); | |
| 762 | + properties.setDimensions(dimensions); | |
| 763 | + properties.setPosition(vec3FromVariant(backPlateObject["position"].toVariant())); | |
| 764 | + properties.setRotation(quatFromVariant(backPlateObject["rotation"].toVariant())); | |
| 765 | + properties.setParentID(_anchor.entityID); | |
| 766 | + | |
| 767 | + BackPlate backPlate; | |
| 768 | + backPlate.entityID = entityScriptingInterface->addEntity(properties, "local"); | |
| 769 | + backPlate.dimensions = dimensions; | |
| 770 | + EntityPropertyFlags desiredProperties; | |
| 771 | + desiredProperties += PROP_LOCAL_POSITION; | |
| 772 | + backPlate.localPosition = entityScriptingInterface->getEntityProperties(backPlate.entityID, desiredProperties).getLocalPosition(); | |
| 773 | + _backPlate = backPlate; | |
| 774 | + } | |
| 817 | 775 | |
| 818 | 776 | const QJsonArray& keyboardLayers = jsonObject["layers"].toArray(); |
| 819 | 777 | int keyboardLayerCount = keyboardLayers.size(); |
| 820 | 778 | _keyboardLayers.reserve(keyboardLayerCount); |
| 821 | − | |
| 822 | − | |
| 823 | 779 | for (int keyboardLayerIndex = 0; keyboardLayerIndex < keyboardLayerCount; keyboardLayerIndex++) { |
| 824 | 780 | const QJsonValue& keyboardLayer = keyboardLayers[keyboardLayerIndex].toArray(); |
| 825 | 781 | |
| 826 | − QHash<OverlayID, Key> keyboardLayerKeys; | |
| 782 | + QHash<QUuid, Key> keyboardLayerKeys; | |
| 827 | 783 | foreach (const QJsonValue& keyboardKeyValue, keyboardLayer.toArray()) { |
| 828 | 784 | |
| 829 | 785 | QVariantMap textureMap; |
| @@ -841,21 +797,6 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) { · 11 unmodified lines | ||
| 841 | 797 | QString modelUrl = keyboardKeyValue["modelURL"].toString(); |
| 842 | 798 | QString url = (useResourcePath ? (resourcePath + modelUrl) : modelUrl); |
| 843 | 799 | |
| 844 | − QVariantMap properties { | |
| 845 | − { "dimensions", keyboardKeyValue["dimensions"].toVariant() }, | |
| 846 | − { "position", keyboardKeyValue["position"].toVariant() }, | |
| 847 | − { "visible", false }, | |
| 848 | − { "isSolid", true }, | |
| 849 | − { "emissive", true }, | |
| 850 | − { "parentID", _anchor.overlayID }, | |
| 851 | − { "url", url }, | |
| 852 | − { "textures", textureMap }, | |
| 853 | − { "grabbable", false }, | |
| 854 | − { "localOrientation", keyboardKeyValue["localOrientation"].toVariant() } | |
| 855 | − }; | |
| 856 | − | |
| 857 | − OverlayID overlayID = overlays.addOverlay("model", properties); | |
| 858 | − | |
| 859 | 800 | QString keyType = keyboardKeyValue["type"].toString(); |
| 860 | 801 | QString keyString = keyboardKeyValue["key"].toString(); |
| 861 | 802 | |
| @@ -869,48 +810,65 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) { · 7 unmodified lines | ||
| 869 | 810 | key.setSwitchToLayerIndex(switchToLayer); |
| 870 | 811 | } |
| 871 | 812 | } |
| 872 | − key.setID(overlayID); | |
| 813 | + | |
| 814 | + EntityItemProperties properties; | |
| 815 | + properties.setType(EntityTypes::Model); | |
| 816 | + properties.setDimensions(vec3FromVariant(keyboardKeyValue["dimensions"].toVariant())); | |
| 817 | + properties.setPosition(vec3FromVariant(keyboardKeyValue["position"].toVariant())); | |
| 818 | + properties.setVisible(false); | |
| 819 | + properties.setEmissive(true); | |
| 820 | + properties.setParentID(_anchor.entityID); | |
| 821 | + properties.setModelURL(url); | |
| 822 | + properties.setTextures(QVariant(textureMap).toString()); | |
| 823 | + properties.getGrab().setGrabbable(false); | |
| 824 | + properties.setLocalRotation(quatFromVariant(keyboardKeyValue["localOrientation"].toVariant())); | |
| 825 | + QUuid id = entityScriptingInterface->addEntity(properties, "local"); | |
| 826 | + key.setID(id); | |
| 873 | 827 | key.setKeyString(keyString); |
| 874 | 828 | key.saveDimensionsAndLocalPosition(); |
| 875 | 829 | |
| 876 | 830 | includeItems.append(key.getID()); |
| 877 | 831 | _itemsToIgnore.append(key.getID()); |
| 878 | − keyboardLayerKeys.insert(overlayID, key); | |
| 832 | + keyboardLayerKeys.insert(id, key); | |
| 879 | 833 | } |
| 880 | 834 | |
| 881 | 835 | _keyboardLayers.push_back(keyboardLayerKeys); |
| 882 | 836 | |
| 883 | 837 | } |
| 884 | 838 | |
| 885 | − TextDisplay textDisplay; | |
| 886 | − QJsonObject displayTextObject = jsonObject["textDisplay"].toObject(); | |
| 887 | − | |
| 888 | − QVariantMap displayTextProperties { | |
| 889 | − { "dimensions", displayTextObject["dimensions"].toVariant() }, | |
| 890 | − { "localPosition", displayTextObject["localPosition"].toVariant() }, | |
| 891 | − { "localOrientation", displayTextObject["localOrientation"].toVariant() }, | |
| 892 | − { "leftMargin", displayTextObject["leftMargin"].toVariant() }, | |
| 893 | − { "rightMargin", displayTextObject["rightMargin"].toVariant() }, | |
| 894 | − { "topMargin", displayTextObject["topMargin"].toVariant() }, | |
| 895 | − { "bottomMargin", displayTextObject["bottomMargin"].toVariant() }, | |
| 896 | − { "lineHeight", displayTextObject["lineHeight"].toVariant() }, | |
| 897 | − { "visible", false }, | |
| 898 | − { "emissive", true }, | |
| 899 | − { "grabbable", false }, | |
| 900 | − { "text", ""}, | |
| 901 | − { "parentID", _anchor.overlayID } | |
| 902 | − }; | |
| 903 | − | |
| 904 | − textDisplay.overlayID = overlays.addOverlay("text3d", displayTextProperties); | |
| 905 | − textDisplay.localPosition = vec3FromVariant(displayTextObject["localPosition"].toVariant()); | |
| 906 | − textDisplay.dimensions = vec3FromVariant(displayTextObject["dimensions"].toVariant()); | |
| 907 | − textDisplay.lineHeight = (float) displayTextObject["lineHeight"].toDouble(); | |
| 908 | − | |
| 909 | − _textDisplay = textDisplay; | |
| 839 | + { | |
| 840 | + QJsonObject displayTextObject = jsonObject["textDisplay"].toObject(); | |
| 841 | + glm::vec3 dimensions = vec3FromVariant(displayTextObject["dimensions"].toVariant()); | |
| 842 | + glm::vec3 localPosition = vec3FromVariant(displayTextObject["localPosition"].toVariant()); | |
| 843 | + float lineHeight = (float)displayTextObject["lineHeight"].toDouble(); | |
| 844 | + | |
| 845 | + EntityItemProperties properties; | |
| 846 | + properties.setType(EntityTypes::Text); | |
| 847 | + properties.setDimensions(dimensions); | |
| 848 | + properties.setLocalPosition(localPosition); | |
| 849 | + properties.setLocalRotation(quatFromVariant(displayTextObject["localOrientation"].toVariant())); | |
| 850 | + properties.setLeftMargin((float)displayTextObject["leftMargin"].toDouble()); | |
| 851 | + properties.setRightMargin((float)displayTextObject["rightMargin"].toDouble()); | |
| 852 | + properties.setTopMargin((float)displayTextObject["topMargin"].toDouble()); | |
| 853 | + properties.setBottomMargin((float)displayTextObject["bottomMargin"].toDouble()); | |
| 854 | + properties.setLineHeight((float)displayTextObject["lineHeight"].toDouble()); | |
| 855 | + properties.setVisible(false); | |
| 856 | + properties.setEmissive(true); | |
| 857 | + properties.getGrab().setGrabbable(false); | |
| 858 | + properties.setText(""); | |
| 859 | + properties.setParentID(_anchor.entityID); | |
| 860 | + | |
| 861 | + TextDisplay textDisplay; | |
| 862 | + textDisplay.entityID = entityScriptingInterface->addEntity(properties, "local"); | |
| 863 | + textDisplay.localPosition = localPosition; | |
| 864 | + textDisplay.dimensions = dimensions; | |
| 865 | + textDisplay.lineHeight = lineHeight; | |
| 866 | + _textDisplay = textDisplay; | |
| 867 | + } | |
| 910 | 868 | |
| 911 | 869 | _ignoreItemsLock.withWriteLock([&] { |
| 912 | − _itemsToIgnore.append(_textDisplay.overlayID); | |
| 913 | − _itemsToIgnore.append(_anchor.overlayID); | |
| 870 | + _itemsToIgnore.append(_textDisplay.entityID); | |
| 871 | + _itemsToIgnore.append(_anchor.entityID); | |
| 914 | 872 | }); |
| 915 | 873 | _layerIndex = 0; |
| 916 | 874 | auto pointerManager = DependencyManager::get<PointerManager>(); |
| @@ -922,34 +880,33 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) { · 5 unmodified lines | ||
| 922 | 880 | } |
| 923 | 881 | |
| 924 | 882 | |
| 925 | −OverlayID Keyboard::getAnchorID() { | |
| 926 | − return _ignoreItemsLock.resultWithReadLock<OverlayID>([&] { | |
| 927 | − return _anchor.overlayID; | |
| 883 | +QUuid Keyboard::getAnchorID() { | |
| 884 | + return _ignoreItemsLock.resultWithReadLock<QUuid>([&] { | |
| 885 | + return _anchor.entityID; | |
| 928 | 886 | }); |
| 929 | 887 | } |
| 930 | 888 | |
| 931 | −bool Keyboard::shouldProcessOverlay(const OverlayID& overlayID) const { | |
| 932 | − return (!_keyboardLayers.empty() && isLayerSwitchTimerFinished() && overlayID != _backPlate.overlayID); | |
| 889 | +bool Keyboard::shouldProcessEntity(const QUuid& id) const { | |
| 890 | + return (!_keyboardLayers.empty() && isLayerSwitchTimerFinished() && id != _backPlate.entityID); | |
| 933 | 891 | } |
| 934 | 892 | |
| 935 | −QVector<OverlayID> Keyboard::getKeysID() { | |
| 936 | − return _ignoreItemsLock.resultWithReadLock<QVector<OverlayID>>([&] { | |
| 893 | +QVector<QUuid> Keyboard::getKeysID() { | |
| 894 | + return _ignoreItemsLock.resultWithReadLock<QVector<QUuid>>([&] { | |
| 937 | 895 | return _itemsToIgnore; |
| 938 | 896 | }); |
| 939 | 897 | } |
| 940 | 898 | |
| 941 | 899 | void Keyboard::clearKeyboardKeys() { |
| 942 | − Overlays& overlays = qApp->getOverlays(); | |
| 943 | − | |
| 900 | + auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 944 | 901 | for (const auto& keyboardLayer: _keyboardLayers) { |
| 945 | 902 | for (auto iter = keyboardLayer.begin(); iter != keyboardLayer.end(); iter++) { |
| 946 | − overlays.deleteOverlay(iter.key()); | |
| 903 | + entityScriptingInterface->deleteEntity(iter.key()); | |
| 947 | 904 | } |
| 948 | 905 | } |
| 949 | 906 | |
| 950 | − overlays.deleteOverlay(_anchor.overlayID); | |
| 951 | − overlays.deleteOverlay(_textDisplay.overlayID); | |
| 952 | − overlays.deleteOverlay(_backPlate.overlayID); | |
| 907 | + entityScriptingInterface->deleteEntity(_anchor.entityID); | |
| 908 | + entityScriptingInterface->deleteEntity(_textDisplay.entityID); | |
| 909 | + entityScriptingInterface->deleteEntity(_backPlate.entityID); | |
| 953 | 910 | |
| 954 | 911 | _keyboardLayers.clear(); |
| 955 | 912 | |
| @@ -989,8 +946,8 @@ void Keyboard::disableRightMallet() { · 33 unmodified lines | ||
| 989 | 946 | pointerManager->disablePointer(_rightHandStylus); |
| 990 | 947 | } |
| 991 | 948 | |
| 992 | −bool Keyboard::containsID(OverlayID overlayID) const { | |
| 949 | +bool Keyboard::containsID(const QUuid& id) const { | |
| 993 | 950 | return resultWithReadLock<bool>([&] { |
| 994 | − return _itemsToIgnore.contains(overlayID) || _backPlate.overlayID == overlayID; | |
| 951 | + return _itemsToIgnore.contains(id) || _backPlate.entityID == id; | |
| 995 | 952 | }); |
| 996 | 953 | } |