mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:38:02 +02:00
dante's keyboard changes + getProperty + some fixes
This commit is contained in:
parent
e2bdac1bdd
commit
2db45b3ec9
5 changed files with 211 additions and 57 deletions
|
@ -2361,6 +2361,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
});
|
});
|
||||||
|
|
||||||
// Preload Tablet sounds
|
// Preload Tablet sounds
|
||||||
|
DependencyManager::get<EntityScriptingInterface>()->setEntityTree(qApp->getEntities()->getTree());
|
||||||
DependencyManager::get<TabletScriptingInterface>()->preloadSounds();
|
DependencyManager::get<TabletScriptingInterface>()->preloadSounds();
|
||||||
DependencyManager::get<Keyboard>()->createKeyboard();
|
DependencyManager::get<Keyboard>()->createKeyboard();
|
||||||
|
|
||||||
|
@ -8692,12 +8693,11 @@ void Application::createLoginDialog() {
|
||||||
|
|
||||||
auto keyboard = DependencyManager::get<Keyboard>().data();
|
auto keyboard = DependencyManager::get<Keyboard>().data();
|
||||||
if (!keyboard->getAnchorID().isNull() && !_loginDialogID.isNull()) {
|
if (!keyboard->getAnchorID().isNull() && !_loginDialogID.isNull()) {
|
||||||
const auto KEYBOARD_LOCAL_ORIENTATION = glm::quat(0.0f, 0.0, 1.0f, 0.25f);
|
|
||||||
auto keyboardLocalOffset = cameraOrientation * glm::vec3(-0.4f * getMyAvatar()->getSensorToWorldScale(), -0.3f, 0.2f);
|
auto keyboardLocalOffset = cameraOrientation * glm::vec3(-0.4f * getMyAvatar()->getSensorToWorldScale(), -0.3f, 0.2f);
|
||||||
|
|
||||||
EntityItemProperties properties;
|
EntityItemProperties properties;
|
||||||
properties.setPosition(position + keyboardLocalOffset);
|
properties.setPosition(position + keyboardLocalOffset);
|
||||||
properties.setRotation(cameraOrientation * KEYBOARD_LOCAL_ORIENTATION);
|
properties.setRotation(cameraOrientation * Quaternions::Y_180);
|
||||||
|
|
||||||
entityScriptingInterface->editEntity(keyboard->getAnchorID(), properties);
|
entityScriptingInterface->editEntity(keyboard->getAnchorID(), properties);
|
||||||
keyboard->setResetKeyboardPositionOnRaise(false);
|
keyboard->setResetKeyboardPositionOnRaise(false);
|
||||||
|
@ -8728,7 +8728,6 @@ void Application::updateLoginDialogPosition() {
|
||||||
auto upVec = getMyAvatar()->getWorldOrientation() * Vectors::UNIT_Y;
|
auto upVec = getMyAvatar()->getWorldOrientation() * Vectors::UNIT_Y;
|
||||||
auto offset = headLookVec * OFFSET.x;
|
auto offset = headLookVec * OFFSET.x;
|
||||||
auto newPositionVec = (cameraPositionVec + offset) + (upVec * OFFSET.y);
|
auto newPositionVec = (cameraPositionVec + offset) + (upVec * OFFSET.y);
|
||||||
auto newOrientation = glm::inverse(glm::quat_cast(glm::lookAt(newPositionVec, cameraPositionVec, upVec))) * Quaternions::Y_180;
|
|
||||||
|
|
||||||
bool outOfBounds = glm::distance(positionVec, cameraPositionVec) > 1.0f;
|
bool outOfBounds = glm::distance(positionVec, cameraPositionVec) > 1.0f;
|
||||||
|
|
||||||
|
@ -8736,17 +8735,17 @@ void Application::updateLoginDialogPosition() {
|
||||||
{
|
{
|
||||||
EntityItemProperties properties;
|
EntityItemProperties properties;
|
||||||
properties.setPosition(newPositionVec);
|
properties.setPosition(newPositionVec);
|
||||||
properties.setRotation(newOrientation);
|
properties.setRotation(cameraOrientation);
|
||||||
entityScriptingInterface->editEntity(_loginDialogID, properties);
|
entityScriptingInterface->editEntity(_loginDialogID, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto KEYBOARD_LOCAL_ORIENTATION = glm::quat(0.0f, 0.0, 1.0f, 0.25f);
|
glm::vec3 keyboardLocalOffset = cameraOrientation * glm::vec3(-0.4f * getMyAvatar()->getSensorToWorldScale(), -0.3f, 0.2f);
|
||||||
auto keyboardLocalOffset = newOrientation * glm::vec3(-0.4f * getMyAvatar()->getSensorToWorldScale(), -0.3f, 0.2f);
|
glm::quat keyboardOrientation = cameraOrientation * glm::quat(glm::radians(glm::vec3(-30.0f, 180.0f, 0.0f)));
|
||||||
|
|
||||||
EntityItemProperties properties;
|
EntityItemProperties properties;
|
||||||
properties.setPosition(newPositionVec + keyboardLocalOffset);
|
properties.setPosition(newPositionVec + keyboardLocalOffset);
|
||||||
properties.setRotation(newOrientation * KEYBOARD_LOCAL_ORIENTATION);
|
properties.setRotation(keyboardOrientation);
|
||||||
entityScriptingInterface->editEntity(DependencyManager::get<Keyboard>()->getAnchorID(), properties);
|
entityScriptingInterface->editEntity(DependencyManager::get<Keyboard>()->getAnchorID(), properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,17 +151,20 @@ void Key::saveDimensionsAndLocalPosition() {
|
||||||
_originalLocalPosition = properties.getLocalPosition();
|
_originalLocalPosition = properties.getLocalPosition();
|
||||||
_originalDimensions = properties.getDimensions();
|
_originalDimensions = properties.getDimensions();
|
||||||
_currentLocalPosition = _originalLocalPosition;
|
_currentLocalPosition = _originalLocalPosition;
|
||||||
|
_originalDimensionsAndLocalPositionSaved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Key::scaleKey(float sensorToWorldScale) {
|
void Key::scaleKey(float sensorToWorldScale) {
|
||||||
glm::vec3 scaledLocalPosition = _originalLocalPosition * sensorToWorldScale;
|
if (_originalDimensionsAndLocalPositionSaved) {
|
||||||
glm::vec3 scaledDimensions = _originalDimensions * sensorToWorldScale;
|
glm::vec3 scaledLocalPosition = _originalLocalPosition * sensorToWorldScale;
|
||||||
_currentLocalPosition = scaledLocalPosition;
|
glm::vec3 scaledDimensions = _originalDimensions * sensorToWorldScale;
|
||||||
|
_currentLocalPosition = scaledLocalPosition;
|
||||||
|
|
||||||
EntityItemProperties properties;
|
EntityItemProperties properties;
|
||||||
properties.setDimensions(scaledDimensions);
|
properties.setDimensions(scaledDimensions);
|
||||||
properties.setLocalPosition(scaledLocalPosition);
|
properties.setLocalPosition(scaledLocalPosition);
|
||||||
DependencyManager::get<EntityScriptingInterface>()->editEntity(_keyID, properties);
|
DependencyManager::get<EntityScriptingInterface>()->editEntity(_keyID, properties);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Key::startTimer(int time) {
|
void Key::startTimer(int time) {
|
||||||
|
@ -229,6 +232,18 @@ void Keyboard::registerKeyboardHighlighting() {
|
||||||
selection->enableListToScene(KEY_PRESSED_HIGHLIGHT);
|
selection->enableListToScene(KEY_PRESSED_HIGHLIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Keyboard::disableSelectionLists() {
|
||||||
|
auto selection = DependencyManager::get<SelectionScriptingInterface>();
|
||||||
|
selection->disableListHighlight(KEY_HOVER_HIGHLIGHT);
|
||||||
|
selection->disableListHighlight(KEY_PRESSED_HIGHLIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Keyboard::enableSelectionLists() {
|
||||||
|
auto selection = DependencyManager::get<SelectionScriptingInterface>();
|
||||||
|
selection->enableListHighlight(KEY_HOVER_HIGHLIGHT, KEY_HOVERING_STYLE);
|
||||||
|
selection->enableListHighlight(KEY_PRESSED_HIGHLIGHT, KEY_PRESSING_STYLE);
|
||||||
|
}
|
||||||
|
|
||||||
bool Keyboard::getUse3DKeyboard() const {
|
bool Keyboard::getUse3DKeyboard() const {
|
||||||
return _use3DKeyboardLock.resultWithReadLock<bool>([&] {
|
return _use3DKeyboardLock.resultWithReadLock<bool>([&] {
|
||||||
return _use3DKeyboard.get();
|
return _use3DKeyboard.get();
|
||||||
|
@ -288,6 +303,7 @@ void Keyboard::setRaised(bool raised) {
|
||||||
raiseKeyboardAnchor(raised);
|
raiseKeyboardAnchor(raised);
|
||||||
raiseKeyboard(raised);
|
raiseKeyboard(raised);
|
||||||
raised ? enableStylus() : disableStylus();
|
raised ? enableStylus() : disableStylus();
|
||||||
|
raised ? enableSelectionLists() : disableSelectionLists();
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
_raised = raised;
|
_raised = raised;
|
||||||
_layerIndex = 0;
|
_layerIndex = 0;
|
||||||
|
@ -340,8 +356,9 @@ void Keyboard::scaleKeyboard(float sensorToWorldScale) {
|
||||||
|
|
||||||
{
|
{
|
||||||
EntityItemProperties properties;
|
EntityItemProperties properties;
|
||||||
properties.setDimensions(_anchor.originalDimensions * sensorToWorldScale);
|
properties.setLocalPosition(_backPlate.localPosition * sensorToWorldScale);
|
||||||
entityScriptingInterface->editEntity(_anchor.entityID, properties);
|
properties.setDimensions(_backPlate.dimensions * sensorToWorldScale);
|
||||||
|
entityScriptingInterface->editEntity(_backPlate.entityID, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& keyboardLayer : _keyboardLayers) {
|
for (auto& keyboardLayer : _keyboardLayers) {
|
||||||
|
@ -357,13 +374,6 @@ void Keyboard::scaleKeyboard(float sensorToWorldScale) {
|
||||||
properties.setLineHeight(_textDisplay.lineHeight * sensorToWorldScale);
|
properties.setLineHeight(_textDisplay.lineHeight * sensorToWorldScale);
|
||||||
entityScriptingInterface->editEntity(_textDisplay.entityID, properties);
|
entityScriptingInterface->editEntity(_textDisplay.entityID, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
EntityItemProperties properties;
|
|
||||||
properties.setLocalPosition(_backPlate.localPosition * sensorToWorldScale);
|
|
||||||
properties.setDimensions(_backPlate.dimensions * sensorToWorldScale);
|
|
||||||
entityScriptingInterface->editEntity(_backPlate.entityID, properties);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Keyboard::startLayerSwitchTimer() {
|
void Keyboard::startLayerSwitchTimer() {
|
||||||
|
@ -456,8 +466,8 @@ void Keyboard::switchToLayer(int layerIndex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Keyboard::shouldProcessEntityAndPointerEvent(const PointerEvent& event, const QUuid& id) const {
|
bool Keyboard::shouldProcessEntityAndPointerEvent(const PointerEvent& event) const {
|
||||||
return (shouldProcessPointerEvent(event) && shouldProcessEntity(id));
|
return (shouldProcessPointerEvent(event) && shouldProcessEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Keyboard::shouldProcessPointerEvent(const PointerEvent& event) const {
|
bool Keyboard::shouldProcessPointerEvent(const PointerEvent& event) const {
|
||||||
|
@ -470,7 +480,7 @@ bool Keyboard::shouldProcessPointerEvent(const PointerEvent& event) const {
|
||||||
|
|
||||||
void Keyboard::handleTriggerBegin(const QUuid& id, const PointerEvent& event) {
|
void Keyboard::handleTriggerBegin(const QUuid& id, const PointerEvent& event) {
|
||||||
auto buttonType = event.getButton();
|
auto buttonType = event.getButton();
|
||||||
if (!shouldProcessEntityAndPointerEvent(event, id) || buttonType != PointerEvent::PrimaryButton) {
|
if (!shouldProcessEntityAndPointerEvent(event) || buttonType != PointerEvent::PrimaryButton) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,7 +582,7 @@ void Keyboard::setRightHandLaser(unsigned int rightHandLaser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Keyboard::handleTriggerEnd(const QUuid& id, const PointerEvent& event) {
|
void Keyboard::handleTriggerEnd(const QUuid& id, const PointerEvent& event) {
|
||||||
if (!shouldProcessEntityAndPointerEvent(event, id)) {
|
if (!shouldProcessEntityAndPointerEvent(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +609,7 @@ void Keyboard::handleTriggerEnd(const QUuid& id, const PointerEvent& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Keyboard::handleTriggerContinue(const QUuid& id, const PointerEvent& event) {
|
void Keyboard::handleTriggerContinue(const QUuid& id, const PointerEvent& event) {
|
||||||
if (!shouldProcessEntityAndPointerEvent(event, id)) {
|
if (!shouldProcessEntityAndPointerEvent(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,7 +649,7 @@ void Keyboard::handleTriggerContinue(const QUuid& id, const PointerEvent& event)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Keyboard::handleHoverBegin(const QUuid& id, const PointerEvent& event) {
|
void Keyboard::handleHoverBegin(const QUuid& id, const PointerEvent& event) {
|
||||||
if (!shouldProcessEntityAndPointerEvent(event, id)) {
|
if (!shouldProcessEntityAndPointerEvent(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,7 +665,7 @@ void Keyboard::handleHoverBegin(const QUuid& id, const PointerEvent& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Keyboard::handleHoverEnd(const QUuid& id, const PointerEvent& event) {
|
void Keyboard::handleHoverEnd(const QUuid& id, const PointerEvent& event) {
|
||||||
if (!shouldProcessEntityAndPointerEvent(event, id)) {
|
if (!shouldProcessEntityAndPointerEvent(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,26 +760,28 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) {
|
||||||
|
|
||||||
{
|
{
|
||||||
QJsonObject backPlateObject = jsonObject["backPlate"].toObject();
|
QJsonObject backPlateObject = jsonObject["backPlate"].toObject();
|
||||||
|
glm::vec3 position = vec3FromVariant(backPlateObject["position"].toVariant());
|
||||||
glm::vec3 dimensions = vec3FromVariant(backPlateObject["dimensions"].toVariant());
|
glm::vec3 dimensions = vec3FromVariant(backPlateObject["dimensions"].toVariant());
|
||||||
|
glm::quat rotation = quatFromVariant(backPlateObject["rotation"].toVariant());
|
||||||
|
|
||||||
EntityItemProperties properties;
|
EntityItemProperties properties;
|
||||||
properties.setType(EntityTypes::Box);
|
properties.setType(EntityTypes::Box);
|
||||||
properties.setName("BackPlate");
|
properties.setName("Keyboard-BackPlate");
|
||||||
properties.setVisible(true);
|
properties.setVisible(true);
|
||||||
properties.getGrab().setGrabbable(false);
|
properties.getGrab().setGrabbable(false);
|
||||||
properties.setAlpha(0.0f);
|
properties.setAlpha(0.0f);
|
||||||
properties.setIgnorePickIntersection(false);
|
properties.setIgnorePickIntersection(false);
|
||||||
properties.setDimensions(dimensions);
|
properties.setDimensions(dimensions);
|
||||||
properties.setPosition(vec3FromVariant(backPlateObject["position"].toVariant()));
|
properties.setPosition(position);
|
||||||
properties.setRotation(quatFromVariant(backPlateObject["rotation"].toVariant()));
|
properties.setRotation(rotation);
|
||||||
properties.setParentID(_anchor.entityID);
|
properties.setParentID(_anchor.entityID);
|
||||||
|
|
||||||
BackPlate backPlate;
|
BackPlate backPlate;
|
||||||
backPlate.entityID = entityScriptingInterface->addEntityInternal(properties, entity::HostType::LOCAL);
|
backPlate.entityID = entityScriptingInterface->addEntityInternal(properties, entity::HostType::LOCAL);
|
||||||
backPlate.dimensions = dimensions;
|
backPlate.dimensions = dimensions;
|
||||||
EntityPropertyFlags desiredProperties;
|
glm::quat anchorEntityInverseWorldOrientation = glm::inverse(rotation);
|
||||||
desiredProperties += PROP_LOCAL_POSITION;
|
glm::vec3 anchorEntityLocalTranslation = anchorEntityInverseWorldOrientation * -position;
|
||||||
backPlate.localPosition = entityScriptingInterface->getEntityProperties(backPlate.entityID, desiredProperties).getLocalPosition();
|
backPlate.localPosition = (anchorEntityInverseWorldOrientation * position) + anchorEntityLocalTranslation;
|
||||||
_backPlate = backPlate;
|
_backPlate = backPlate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -797,6 +809,19 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) {
|
||||||
QString modelUrl = keyboardKeyValue["modelURL"].toString();
|
QString modelUrl = keyboardKeyValue["modelURL"].toString();
|
||||||
QString url = (useResourcePath ? (resourcePath + modelUrl) : modelUrl);
|
QString url = (useResourcePath ? (resourcePath + modelUrl) : modelUrl);
|
||||||
|
|
||||||
|
EntityItemProperties properties;
|
||||||
|
properties.setType(EntityTypes::Model);
|
||||||
|
properties.setDimensions(vec3FromVariant(keyboardKeyValue["dimensions"].toVariant()));
|
||||||
|
properties.setPosition(vec3FromVariant(keyboardKeyValue["position"].toVariant()));
|
||||||
|
properties.setVisible(false);
|
||||||
|
properties.setEmissive(true);
|
||||||
|
properties.setParentID(_anchor.entityID);
|
||||||
|
properties.setModelURL(url);
|
||||||
|
properties.setTextures(QVariant(textureMap).toString());
|
||||||
|
properties.getGrab().setGrabbable(false);
|
||||||
|
properties.setLocalRotation(quatFromVariant(keyboardKeyValue["localOrientation"].toVariant()));
|
||||||
|
QUuid id = entityScriptingInterface->addEntityInternal(properties, entity::HostType::LOCAL);
|
||||||
|
|
||||||
QString keyType = keyboardKeyValue["type"].toString();
|
QString keyType = keyboardKeyValue["type"].toString();
|
||||||
QString keyString = keyboardKeyValue["key"].toString();
|
QString keyString = keyboardKeyValue["key"].toString();
|
||||||
|
|
||||||
|
@ -810,19 +835,6 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) {
|
||||||
key.setSwitchToLayerIndex(switchToLayer);
|
key.setSwitchToLayerIndex(switchToLayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityItemProperties properties;
|
|
||||||
properties.setType(EntityTypes::Model);
|
|
||||||
properties.setDimensions(vec3FromVariant(keyboardKeyValue["dimensions"].toVariant()));
|
|
||||||
properties.setPosition(vec3FromVariant(keyboardKeyValue["position"].toVariant()));
|
|
||||||
properties.setVisible(false);
|
|
||||||
properties.setEmissive(true);
|
|
||||||
properties.setParentID(_anchor.entityID);
|
|
||||||
properties.setModelURL(url);
|
|
||||||
properties.setTextures(QVariant(textureMap).toString());
|
|
||||||
properties.getGrab().setGrabbable(false);
|
|
||||||
properties.setLocalRotation(quatFromVariant(keyboardKeyValue["localOrientation"].toVariant()));
|
|
||||||
QUuid id = entityScriptingInterface->addEntityInternal(properties, entity::HostType::LOCAL);
|
|
||||||
key.setID(id);
|
key.setID(id);
|
||||||
key.setKeyString(keyString);
|
key.setKeyString(keyString);
|
||||||
key.saveDimensionsAndLocalPosition();
|
key.saveDimensionsAndLocalPosition();
|
||||||
|
@ -886,8 +898,8 @@ QUuid Keyboard::getAnchorID() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Keyboard::shouldProcessEntity(const QUuid& id) const {
|
bool Keyboard::shouldProcessEntity() const {
|
||||||
return (!_keyboardLayers.empty() && isLayerSwitchTimerFinished() && id != _backPlate.entityID);
|
return (!_keyboardLayers.empty() && isLayerSwitchTimerFinished());
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QUuid> Keyboard::getKeysID() {
|
QVector<QUuid> Keyboard::getKeysID() {
|
||||||
|
|
|
@ -81,6 +81,7 @@ private:
|
||||||
glm::vec3 _originalLocalPosition;
|
glm::vec3 _originalLocalPosition;
|
||||||
glm::vec3 _originalDimensions;
|
glm::vec3 _originalDimensions;
|
||||||
glm::vec3 _currentLocalPosition;
|
glm::vec3 _currentLocalPosition;
|
||||||
|
bool _originalDimensionsAndLocalPositionSaved { false };
|
||||||
|
|
||||||
std::shared_ptr<QTimer> _timer { std::make_shared<QTimer>() };
|
std::shared_ptr<QTimer> _timer { std::make_shared<QTimer>() };
|
||||||
};
|
};
|
||||||
|
@ -146,14 +147,16 @@ private:
|
||||||
void raiseKeyboardAnchor(bool raise) const;
|
void raiseKeyboardAnchor(bool raise) const;
|
||||||
void enableStylus();
|
void enableStylus();
|
||||||
void disableStylus();
|
void disableStylus();
|
||||||
|
void enableSelectionLists();
|
||||||
|
void disableSelectionLists();
|
||||||
|
|
||||||
void setLayerIndex(int layerIndex);
|
void setLayerIndex(int layerIndex);
|
||||||
void clearKeyboardKeys();
|
void clearKeyboardKeys();
|
||||||
void switchToLayer(int layerIndex);
|
void switchToLayer(int layerIndex);
|
||||||
void updateTextDisplay();
|
void updateTextDisplay();
|
||||||
bool shouldProcessEntityAndPointerEvent(const PointerEvent& event, const QUuid& id) const;
|
bool shouldProcessEntityAndPointerEvent(const PointerEvent& event) const;
|
||||||
bool shouldProcessPointerEvent(const PointerEvent& event) const;
|
bool shouldProcessPointerEvent(const PointerEvent& event) const;
|
||||||
bool shouldProcessEntity(const QUuid& id) const;
|
bool shouldProcessEntity() const;
|
||||||
|
|
||||||
void startLayerSwitchTimer();
|
void startLayerSwitchTimer();
|
||||||
bool isLayerSwitchTimerFinished() const;
|
bool isLayerSwitchTimerFinished() const;
|
||||||
|
|
|
@ -264,6 +264,30 @@ QString Overlays::overlayToEntityType(const QString& type) {
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define GROUP_ENTITY_TO_OVERLAY_PROP(g, e, o) \
|
||||||
|
{ \
|
||||||
|
auto iter = overlayProps.find(#g); \
|
||||||
|
if (iter != overlayProps.end()) { \
|
||||||
|
auto map = iter.value().toMap(); \
|
||||||
|
auto iter2 = map.find(#e); \
|
||||||
|
if (iter2 != map.end()) { \
|
||||||
|
overlayProps[#o] = iter2.value(); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GROUP_ENTITY_TO_OVERLAY_PROP_CONVERT(g, e, o, C) \
|
||||||
|
{ \
|
||||||
|
auto iter = overlayProps.find(#g); \
|
||||||
|
if (iter != overlayProps.end()) { \
|
||||||
|
auto map = iter.value().toMap(); \
|
||||||
|
auto iter2 = map.find(#e); \
|
||||||
|
if (iter2 != map.end()) { \
|
||||||
|
overlayProps[#o] = C(iter2.value()); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& overlayProps, const QString& type, bool add, const QUuid& id) {
|
EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& overlayProps, const QString& type, bool add, const QUuid& id) {
|
||||||
overlayProps["type"] = type;
|
overlayProps["type"] = type;
|
||||||
|
|
||||||
|
@ -279,7 +303,8 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove
|
||||||
RENAME_PROP(localOrientation, localRotation);
|
RENAME_PROP(localOrientation, localRotation);
|
||||||
RENAME_PROP(ignoreRayIntersection, ignorePickIntersection);
|
RENAME_PROP(ignoreRayIntersection, ignorePickIntersection);
|
||||||
|
|
||||||
{
|
// Model overlays didn't support wireframe drawing
|
||||||
|
if (type != "Model") {
|
||||||
RENAME_PROP(solid, isSolid);
|
RENAME_PROP(solid, isSolid);
|
||||||
RENAME_PROP(isFilled, isSolid);
|
RENAME_PROP(isFilled, isSolid);
|
||||||
RENAME_PROP(filled, isSolid);
|
RENAME_PROP(filled, isSolid);
|
||||||
|
@ -327,6 +352,7 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove
|
||||||
RENAME_PROP(url, sourceUrl);
|
RENAME_PROP(url, sourceUrl);
|
||||||
RENAME_PROP_CONVERT(inputMode, inputMode, [](const QVariant& v) { return v.toString() == "Mouse" ? "mouse" : "touch"; });
|
RENAME_PROP_CONVERT(inputMode, inputMode, [](const QVariant& v) { return v.toString() == "Mouse" ? "mouse" : "touch"; });
|
||||||
} else if (type == "Gizmo") {
|
} else if (type == "Gizmo") {
|
||||||
|
RENAME_PROP(radius, outerRadius);
|
||||||
if (add || overlayProps.contains("outerRadius")) {
|
if (add || overlayProps.contains("outerRadius")) {
|
||||||
float ratio = 2.0f;
|
float ratio = 2.0f;
|
||||||
{
|
{
|
||||||
|
@ -435,7 +461,7 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove
|
||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
auto iter2 = overlayProps.find("position");
|
auto iter2 = overlayProps.find("position");
|
||||||
if (iter2 != overlayProps.end()) {
|
if (iter2 != overlayProps.end()) {
|
||||||
position = vec3FromVariant(iter.value());
|
position = vec3FromVariant(iter2.value());
|
||||||
} else if (!add) {
|
} else if (!add) {
|
||||||
EntityPropertyFlags desiredProperties;
|
EntityPropertyFlags desiredProperties;
|
||||||
desiredProperties += PROP_POSITION;
|
desiredProperties += PROP_POSITION;
|
||||||
|
@ -493,6 +519,119 @@ QVariantMap Overlays::convertEntityToOverlayProperties(const EntityItemPropertie
|
||||||
QScriptEngine scriptEngine;
|
QScriptEngine scriptEngine;
|
||||||
QVariantMap overlayProps = EntityItemPropertiesToScriptValue(&scriptEngine, properties).toVariant().toMap();
|
QVariantMap overlayProps = EntityItemPropertiesToScriptValue(&scriptEngine, properties).toVariant().toMap();
|
||||||
|
|
||||||
|
QString type = overlayProps["type"].toString();
|
||||||
|
overlayProps["type"] = entityToOverlayType(type);
|
||||||
|
|
||||||
|
if (type != "PolyLine") {
|
||||||
|
RENAME_PROP(position, p1);
|
||||||
|
RENAME_PROP(position, start);
|
||||||
|
}
|
||||||
|
RENAME_PROP(position, point);
|
||||||
|
RENAME_PROP(dimensions, scale);
|
||||||
|
RENAME_PROP(dimensions, size);
|
||||||
|
RENAME_PROP(rotation, orientation);
|
||||||
|
RENAME_PROP(localRotation, localOrientation);
|
||||||
|
RENAME_PROP(ignorePickIntersection, ignoreRayIntersection);
|
||||||
|
|
||||||
|
{
|
||||||
|
RENAME_PROP_CONVERT(primitiveMode, isSolid, [](const QVariant& v) { return v.toString() == "solid" ? true : false; });
|
||||||
|
RENAME_PROP(isSolid, solid);
|
||||||
|
RENAME_PROP(isSolid, isFilled);
|
||||||
|
RENAME_PROP(isSolid, filled);
|
||||||
|
|
||||||
|
RENAME_PROP_CONVERT(primitiveMode, isWire, [](const QVariant& v) { return v.toString() == "lines" ? true : false; });
|
||||||
|
RENAME_PROP(isWire, wire);
|
||||||
|
}
|
||||||
|
|
||||||
|
RENAME_PROP_CONVERT(renderLayer, drawInFront, [](const QVariant& v) { return v.toString() == "front" ? true : false; });
|
||||||
|
RENAME_PROP_CONVERT(renderLayer, drawHUDLayer, [](const QVariant& v) { return v.toString() == "hud" ? true : false; });
|
||||||
|
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(grab, grabbable, grabbable);
|
||||||
|
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(pulse, min, pulseMin);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(pulse, max, pulseMax);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(pulse, period, pulsePeriod);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP_CONVERT(pulse, colorMode, colorPulse, [](const QVariant& v) {
|
||||||
|
QString f = v.toString();
|
||||||
|
if (f == "in") {
|
||||||
|
return 1.0f;
|
||||||
|
} else if (f == "out") {
|
||||||
|
return -1.0f;
|
||||||
|
}
|
||||||
|
return 0.0f;
|
||||||
|
});
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP_CONVERT(pulse, alphaMode, alphaPulse, [](const QVariant& v) {
|
||||||
|
QString f = v.toString();
|
||||||
|
if (f == "in") {
|
||||||
|
return 1.0f;
|
||||||
|
} else if (f == "out") {
|
||||||
|
return -1.0f;
|
||||||
|
}
|
||||||
|
return 0.0f;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (type == "Model") {
|
||||||
|
RENAME_PROP(modelURL, url);
|
||||||
|
RENAME_PROP(animation, animationSettings);
|
||||||
|
} else if (type == "Image") {
|
||||||
|
RENAME_PROP(imageURL, url);
|
||||||
|
} else if (type == "Web") {
|
||||||
|
RENAME_PROP(sourceUrl, url);
|
||||||
|
RENAME_PROP_CONVERT(inputMode, inputMode, [](const QVariant& v) { return v.toString() == "mouse" ? "Mouse" : "Touch"; });
|
||||||
|
} else if (type == "Gizmo") {
|
||||||
|
RENAME_PROP_CONVERT(dimensions, outerRadius, [](const QVariant& v) { return vec3FromVariant(v).x; });
|
||||||
|
RENAME_PROP(outerRadius, radius);
|
||||||
|
|
||||||
|
RENAME_PROP_CONVERT(rotation, rotation, [](const QVariant& v) {
|
||||||
|
glm::quat rot = quatFromVariant(v);
|
||||||
|
// FIXME:
|
||||||
|
return quatToVariant(glm::angleAxis((float)M_PI_2, rot * Vectors::RIGHT) * rot);
|
||||||
|
});
|
||||||
|
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, startAngle, startAt);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, endAngle, endAt);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, innerRadius, innerRadius);
|
||||||
|
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, innerStartColor, innerStartColor);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, innerEndColor, innerEndColor);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, outerStartColor, outerStartColor);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, outerEndColor, outerEndColor);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, innerStartAlpha, innerStartAlpha);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, innerEndAlpha, innerEndAlpha);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, outerStartAlpha, outerStartAlpha);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, outerEndAlpha, outerEndAlpha);
|
||||||
|
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, hasTickMarks, hasTickMarks);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, majorTickMarksAngle, majorTickMarksAngle);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, minorTickMarksAngle, minorTickMarksAngle);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, majorTickMarksLength, majorTickMarksLength);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, minorTickMarksLength, minorTickMarksLength);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, majorTickMarksColor, majorTickMarksColor);
|
||||||
|
GROUP_ENTITY_TO_OVERLAY_PROP(ring, minorTickMarksColor, minorTickMarksColor);
|
||||||
|
} else if (type == "PolyLine") {
|
||||||
|
QVector<glm::vec3> points = qVectorVec3FromScriptValue(scriptEngine.newVariant(overlayProps["linePoints"]));
|
||||||
|
glm::vec3 position = vec3FromVariant(overlayProps["position"]);
|
||||||
|
if (points.length() > 1) {
|
||||||
|
overlayProps["p1"] = vec3toVariant(points[0] + position);
|
||||||
|
overlayProps["p2"] = vec3toVariant(points[1] + position);
|
||||||
|
|
||||||
|
overlayProps["localStart"] = vec3toVariant(points[0]);
|
||||||
|
overlayProps["localEnd"] = vec3toVariant(points[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
RENAME_PROP(p1, startPoint);
|
||||||
|
RENAME_PROP(p1, start);
|
||||||
|
RENAME_PROP(p2, endPoint);
|
||||||
|
RENAME_PROP(p2, end);
|
||||||
|
|
||||||
|
QVector<float> widths = qVectorFloatFromScriptValue(scriptEngine.newVariant(overlayProps["strokeWidths"]));
|
||||||
|
if (widths.length() > 0) {
|
||||||
|
overlayProps["lineWidth"] = widths[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
RENAME_PROP_CONVERT(glow, glow, [](const QVariant& v) { return v.toBool() ? 1.0f : 0.0f; });
|
||||||
|
}
|
||||||
|
|
||||||
return overlayProps;
|
return overlayProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1489,6 +1489,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
* minorGridEvery: 0.5,
|
* minorGridEvery: 0.5,
|
||||||
* lifetime: 300 // Delete after 5 minutes.
|
* lifetime: 300 // Delete after 5 minutes.
|
||||||
* });
|
* });
|
||||||
|
*/
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* The <code>"Gizmo"</code> {@link Entities.EntityType|EntityType} displays an entity that could be used as UI.
|
* The <code>"Gizmo"</code> {@link Entities.EntityType|EntityType} displays an entity that could be used as UI.
|
||||||
|
@ -1922,7 +1923,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
||||||
properties.setProperty("localEntity", convertScriptValue(engine, getEntityHostType() == entity::HostType::LOCAL));
|
properties.setProperty("localEntity", convertScriptValue(engine, getEntityHostType() == entity::HostType::LOCAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!psuedoPropertyFlagsActive || psueudoPropertyFlags.test(EntityPsuedoPropertyFlag::FaceCamera)) {
|
if (!psuedoPropertyFlagsActive || psueudoPropertyFlags.test(EntityPsuedoPropertyFlag::FaceCamera) && _type != EntityTypes::PolyLine) {
|
||||||
properties.setProperty("faceCamera", convertScriptValue(engine, getBillboardMode() == BillboardMode::YAW));
|
properties.setProperty("faceCamera", convertScriptValue(engine, getBillboardMode() == BillboardMode::YAW));
|
||||||
}
|
}
|
||||||
if (!psuedoPropertyFlagsActive || psueudoPropertyFlags.test(EntityPsuedoPropertyFlag::IsFacingAvatar)) {
|
if (!psuedoPropertyFlagsActive || psueudoPropertyFlags.test(EntityPsuedoPropertyFlag::IsFacingAvatar)) {
|
||||||
|
@ -2189,7 +2190,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle old "faceCamera" and "isFacingAvatar" props
|
// Handle old "faceCamera" and "isFacingAvatar" props
|
||||||
{
|
if (_type != EntityTypes::PolyLine) {
|
||||||
QScriptValue P = object.property("faceCamera");
|
QScriptValue P = object.property("faceCamera");
|
||||||
if (P.isValid() && !object.property("billboardMode").isValid()) {
|
if (P.isValid() && !object.property("billboardMode").isValid()) {
|
||||||
bool newValue = P.toVariant().toBool();
|
bool newValue = P.toVariant().toBool();
|
||||||
|
|
Loading…
Reference in a new issue