From f5c84bd51dcabe98fbe4422180183beab14be519 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 12 Dec 2023 22:29:00 +0000 Subject: [PATCH] Fix issue with two handed weapons preventing force wheel from showing --- .../jni/OpenJK/JKXR/VrInputDefault.cpp | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/Projects/Android/jni/OpenJK/JKXR/VrInputDefault.cpp b/Projects/Android/jni/OpenJK/JKXR/VrInputDefault.cpp index 09f1654..1e3a523 100644 --- a/Projects/Android/jni/OpenJK/JKXR/VrInputDefault.cpp +++ b/Projects/Android/jni/OpenJK/JKXR/VrInputDefault.cpp @@ -295,30 +295,37 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, if (offhandGripPushed) { if (!vr.weapon_stabilised && vr.item_selector == 0 && - !vr.misc_camera && !vr.cgzoommode && vr_two_handed_weapons->integer) + !vr.misc_camera && !vr.cgzoommode) { - if (distance < STABILISATION_DISTANCE && - cl.frame.ps.weapon == WP_SABER) { - vr.weapon_stabilised = true; - } - else { - vec3_t dir, weaponposition, offhandposition; - VectorSet(weaponposition, pWeapon->Pose.position.z, pWeapon->Pose.position.x, pWeapon->Pose.position.y); - VectorSet(offhandposition, pOff->Pose.position.z, pOff->Pose.position.x, pOff->Pose.position.y); - VectorSubtract(weaponposition, offhandposition, dir); - VectorNormalize(dir); - - vec3_t weaponangles, weaponForward, rotation = { 0 }; - rotation[PITCH] = vr_weapon_pitchadjust->value; - QuatToYawPitchRoll(pWeapon->Pose.orientation, rotation, weaponangles); - AngleVectors(weaponangles, weaponForward, NULL, NULL); - VectorNormalize(weaponForward); - - if (cl.frame.ps.weapon > WP_SABER && - DotProduct(weaponForward, dir) > 0.8f) + if (vr_two_handed_weapons->integer) + { + if (distance < STABILISATION_DISTANCE && + cl.frame.ps.weapon == WP_SABER) { vr.weapon_stabilised = true; } + else + { + vec3_t dir, weaponposition, offhandposition; + VectorSet(weaponposition, pWeapon->Pose.position.z, + pWeapon->Pose.position.x, pWeapon->Pose.position.y); + VectorSet(offhandposition, pOff->Pose.position.z, pOff->Pose.position.x, + pOff->Pose.position.y); + VectorSubtract(weaponposition, offhandposition, dir); + VectorNormalize(dir); + + vec3_t weaponangles, weaponForward, rotation = {0}; + rotation[PITCH] = vr_weapon_pitchadjust->value; + QuatToYawPitchRoll(pWeapon->Pose.orientation, rotation, weaponangles); + AngleVectors(weaponangles, weaponForward, NULL, NULL); + VectorNormalize(weaponForward); + + if (cl.frame.ps.weapon > WP_SABER && + DotProduct(weaponForward, dir) > 0.8f) + { + vr.weapon_stabilised = true; + } + } } if (!vr.weapon_stabilised)