From 37720e9daafc252d75379f0f8d68588f71973ba2 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Fri, 22 Feb 2019 16:53:03 -0800 Subject: [PATCH] fix nametag rotation --- interface/src/ui/overlays/Overlays.cpp | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index 660220c731..62a6b88fc0 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -559,6 +559,42 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove SET_OVERLAY_PROP_DEFAULT(textures, PathUtils::resourcesUrl() + "images/whitePixel.png"); } + { // Overlays did this conversion for rotation + auto iter = overlayProps.find("rotation"); + if (iter != overlayProps.end() && !overlayProps.contains("localRotation")) { + QUuid parentID; + { + auto iter = overlayProps.find("parentID"); + if (iter != overlayProps.end()) { + parentID = iter.value().toUuid(); + } else if (!add) { + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_PARENT_ID; + parentID = DependencyManager::get()->getEntityProperties(id, desiredProperties).getParentID(); + } + } + + int parentJointIndex = -1; + { + auto iter = overlayProps.find("parentJointIndex"); + if (iter != overlayProps.end()) { + parentJointIndex = iter.value().toInt(); + } else if (!add) { + EntityPropertyFlags desiredProperties; + desiredProperties += PROP_PARENT_JOINT_INDEX; + parentJointIndex = DependencyManager::get()->getEntityProperties(id, desiredProperties).getParentJointIndex(); + } + } + + glm::quat rotation = quatFromVariant(iter.value()); + bool success = false; + glm::quat localRotation = SpatiallyNestable::worldToLocal(rotation, parentID, parentJointIndex, false, success); + if (success) { + overlayProps["rotation"] = quatToVariant(localRotation); + } + } + } + if (type == "Text" || type == "Image" || type == "Grid" || type == "Web") { glm::quat originalRotation = ENTITY_ITEM_DEFAULT_ROTATION; {