From 3b41a8f209d50572b24ecaa795a081b03256c7a8 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 17 Jun 2015 16:31:38 +0200 Subject: [PATCH] Cancel display names roll This is annoying in HMD --- interface/src/avatar/Avatar.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 89847d6cd6..22ac352941 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -699,17 +699,21 @@ Transform Avatar::calculateDisplayNameTransform(const ViewFrustum& frustum, floa // Compute correct scale to apply float scale = DESIRED_HIGHT_ON_SCREEN / (fontSize * pixelHeight) * devicePixelRatio; + // Compute pixel alignment offset float clipToPix = 0.5f * windowSizeY / p1.w; // Got from clip to pixel coordinates glm::vec4 screenPos = clipToPix * p1; // in pixels coords glm::vec4 screenOffset = (glm::round(screenPos) - screenPos) / clipToPix; // in clip coords glm::vec3 worldOffset = glm::vec3(screenOffset.x, screenOffset.y, 0.0f) / (float)pixelHeight; + // Compute orientation + glm::vec3 eulerAngles = ::safeEulerAngles(frustum.getOrientation()); + eulerAngles.z = 0.0f; // Cancel roll + glm::quat orientation(eulerAngles); // back to quaternions + + // Set transform (The order IS important) result.setTranslation(textPosition); - result.setRotation(frustum.getOrientation()); // Always face the screen - - // Pixel alignment - result.postTranslate(worldOffset); - + result.setRotation(orientation); // Always face the screen + result.postTranslate(worldOffset); // Pixel alignment result.setScale(scale); return result; }