From 204206b14e6b33f4f16977a39b5d7222f69f56d1 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Mon, 8 Jun 2020 23:32:00 +0100 Subject: [PATCH] Fix menu pointer --- Quake/shader.cpp | 2 +- Quake/vr.cpp | 22 +++++++++------------- Quake/vr.hpp | 1 - Quake/vr_showfn.cpp | 6 +++--- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Quake/shader.cpp b/Quake/shader.cpp index 221dab75..dda7fd3b 100644 --- a/Quake/shader.cpp +++ b/Quake/shader.cpp @@ -14,7 +14,7 @@ namespace quake namespace { -[[nodiscard]] constexpr bool is_valid_shader_type( +[[nodiscard, maybe_unused]] constexpr bool is_valid_shader_type( const GLenum shader_type) noexcept { return shader_type == GL_COMPUTE_SHADER || diff --git a/Quake/vr.cpp b/Quake/vr.cpp index 1b7164e9..79a033ea 100644 --- a/Quake/vr.cpp +++ b/Quake/vr.cpp @@ -179,7 +179,6 @@ qvec3 lastHudPosition{}; qvec3 lastMenuPosition{}; qvec3 vr_menu_target{}; qvec3 vr_menu_angles{}; -qvec3 vr_menu_normal{}; qvec3 vr_menu_intersection_point{}; vr::IVRSystem* ovrHMD; @@ -3442,7 +3441,6 @@ void VR_Draw2D() const auto fwd = getFwdVecFromPitchYawRoll(vr_menu_angles); vr_menu_target = r_refdef.vieworg + qfloat(vr_menu_distance.value) * fwd; - vr_menu_normal = fwd; } else { @@ -3454,7 +3452,6 @@ void VR_Draw2D() const auto fwd = getFwdVecFromPitchYawRoll(vr_menu_angles); vr_menu_target = cl.handpos[hand] + qfloat(vr_menu_distance.value) * fwd; - vr_menu_normal = fwd; } // TODO VR: (P2) control smoothing with cvar @@ -3736,16 +3733,15 @@ static void VR_DoInput_UpdateVRMouse() const auto dir = getFwdVecFromPitchYawRoll(cl.handrot[handIdx]); const auto& planeOrig = vr_menu_target; - const auto planeDir = getFwdVecFromPitchYawRoll(vr_menu_angles); - const auto [fwd, right, up] = getAngledVectors(vr_menu_normal); + auto adjMenuAngles = vr_menu_angles; + adjMenuAngles[PITCH] -= 90.f; + adjMenuAngles[YAW] += 90.f; - const auto yr = [](const auto& v) { - return redirectVectorByYaw(v, VR_GetTurnYawAngle()); - }; + const auto [fwd, right, up] = getAngledVectors(adjMenuAngles); qfloat intersectionDist{}; - glm::intersectRayPlane(orig, dir, planeOrig, yr(fwd), intersectionDist); + glm::intersectRayPlane(orig, dir, planeOrig, fwd, intersectionDist); const auto intersectionPoint = orig + intersectionDist * dir; const auto res = intersectionPoint - planeOrig; @@ -3759,12 +3755,12 @@ static void VR_DoInput_UpdateVRMouse() return -1.f; }; - const auto xProj = glm::proj(res, yr(right)); - const float xSign = -sign(glm::dot(xProj, yr(right))); + const auto xProj = glm::proj(res, right); + const float xSign = sign(glm::dot(xProj, right)); vr_menu_mouse_x = glm::length(xProj) * xSign / scale_hud + 320 / 2; - const auto yProj = glm::proj(res, yr(up)); - const float ySign = -sign(glm::dot(yProj, yr(up))); + const auto yProj = glm::proj(res, up); + const float ySign = -sign(glm::dot(yProj, up)); vr_menu_mouse_y = glm::length(yProj) * ySign / scale_hud + 240 / 2; }; diff --git a/Quake/vr.hpp b/Quake/vr.hpp index 6fe7fa83..220a149f 100644 --- a/Quake/vr.hpp +++ b/Quake/vr.hpp @@ -539,7 +539,6 @@ extern float vr_menu_mouse_y; extern bool vr_menu_mouse_click; extern qvec3 vr_menu_target; extern qvec3 vr_menu_angles; -extern qvec3 vr_menu_normal; extern qvec3 vr_menu_intersection_point; // TODO VR: (P1) used by show fns diff --git a/Quake/vr_showfn.cpp b/Quake/vr_showfn.cpp index 72827bcf..39052204 100644 --- a/Quake/vr_showfn.cpp +++ b/Quake/vr_showfn.cpp @@ -588,9 +588,9 @@ void show_menu_intersection_point() // gl_vertex(cl.handpos[hand_idx]); // gl_vertex(vr_menu_target); - glColor4f(1, 0, 0, 0.5); - gl_vertex(vr_menu_target); - gl_vertex(vr_menu_target + vr_menu_normal * 205.f); + // glColor4f(1, 0, 0, 0.5); + // gl_vertex(vr_menu_target); + // gl_vertex(vr_menu_target + vr_menu_normal * 205.f); }; do_hand(cVR_MainHand);