From ba89997b27f58220d4612b49e6840121e703a141 Mon Sep 17 00:00:00 2001 From: radwan92 Date: Fri, 7 Jan 2022 22:32:28 +0100 Subject: [PATCH 1/5] fix: libs unpacking --- Projects/Android/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Android/AndroidManifest.xml b/Projects/Android/AndroidManifest.xml index 42196b3..0216a66 100644 --- a/Projects/Android/AndroidManifest.xml +++ b/Projects/Android/AndroidManifest.xml @@ -17,7 +17,7 @@ - + From 2296e36b011e7d1ff056a45f0996517bd5349995 Mon Sep 17 00:00:00 2001 From: radwan92 Date: Fri, 7 Jan 2022 22:34:08 +0100 Subject: [PATCH 2/5] fix: specify required NDK version --- Projects/Android/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/Projects/Android/build.gradle b/Projects/Android/build.gradle index cdd6c61..3516884 100644 --- a/Projects/Android/build.gradle +++ b/Projects/Android/build.gradle @@ -42,6 +42,7 @@ android { } compileSdkVersion = 26 buildToolsVersion = '29.0.1' + ndkVersion '21.4.7075529' } dependencies { From b856fd2ce62854c5cfdc31231d4ef6d70814fd0e Mon Sep 17 00:00:00 2001 From: radwan92 Date: Fri, 7 Jan 2022 23:29:12 +0100 Subject: [PATCH 3/5] fix: silent stepping --- Projects/Android/jni/rtcw/src/client/cl_input.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Projects/Android/jni/rtcw/src/client/cl_input.c b/Projects/Android/jni/rtcw/src/client/cl_input.c index 9a16b3f..3278381 100644 --- a/Projects/Android/jni/rtcw/src/client/cl_input.c +++ b/Projects/Android/jni/rtcw/src/client/cl_input.c @@ -595,6 +595,13 @@ void CL_JoystickMove( usercmd_t *cmd ) { cmd->forwardmove = ClampChar( cmd->forwardmove + (new_move.forward * 127) + (new_move.pos_forward * 127)); cmd->rightmove = ClampChar( cmd->rightmove + (new_move.side * 127) + (new_move.pos_side * 127)); + + float moveMagnitude = sqrt(new_move.forward * new_move.forward + new_move.side * new_move.side); + if(moveMagnitude < 0.35) + { + // Triggers silent-stepping + cmd->buttons |= BUTTON_WALKING; + } } /* From d1bfb6e9a2c9f6e2a993896ec48e09d2dfa513de Mon Sep 17 00:00:00 2001 From: radwan92 Date: Fri, 7 Jan 2022 23:34:14 +0100 Subject: [PATCH 4/5] fix: backpack reach detection --- Projects/Android/jni/RTCWVR/VrInputDefault.c | 99 ++++++++++++++------ 1 file changed, 70 insertions(+), 29 deletions(-) diff --git a/Projects/Android/jni/RTCWVR/VrInputDefault.c b/Projects/Android/jni/RTCWVR/VrInputDefault.c index 9eabd48..fd1a21f 100644 --- a/Projects/Android/jni/RTCWVR/VrInputDefault.c +++ b/Projects/Android/jni/RTCWVR/VrInputDefault.c @@ -27,6 +27,11 @@ void SV_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const ve void RTCWVR_HapticEvent(const char* event, int position, int flags, int intensity, float angle, float yHeight ); +static inline float AngleBetweenVectors(const vec3_t a, const vec3_t b) +{ + return degrees(acosf(DotProduct(a, b)/(VectorLength(a) * VectorLength(b)))); +} + void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateGamepad *pFootTrackingOld, ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking, ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTracking* pOffTracking, @@ -42,7 +47,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG static qboolean dominantGripPushed = false; static float dominantGripPushTime = 0.0f; static bool canUseBackpack = false; - + static bool canUseQuickSave = false; //Need this for the touch screen ovrTracking * pWeapon = pDominantTracking; @@ -134,33 +139,6 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG { resetCursor = qtrue; - static bool canUseQuickSave = false; - if (pOffTracking->Status & (VRAPI_TRACKING_STATUS_POSITION_TRACKED | VRAPI_TRACKING_STATUS_POSITION_VALID)) { - canUseQuickSave = false; - } - else if (!canUseQuickSave) { - int channel = (vr_control_scheme->integer >= 10) ? 1 : 0; - RTCWVR_Vibrate(40, channel, 0.5); // vibrate to let user know they can switch - canUseQuickSave = true; - } - - if (canUseQuickSave) - { - if (((pOffTrackedRemoteNew->Buttons & offButton1) != - (pOffTrackedRemoteOld->Buttons & offButton1)) && - (pOffTrackedRemoteNew->Buttons & offButton1)) { - sendButtonActionSimple("savegame quicksave"); - } - - if (((pOffTrackedRemoteNew->Buttons & offButton2) != - (pOffTrackedRemoteOld->Buttons & offButton2)) && - (pOffTrackedRemoteNew->Buttons & offButton2)) { - sendButtonActionSimple("loadgame quicksave"); - } - } - - - float distance = sqrtf(powf(pOff->HeadPose.Pose.Position.x - pWeapon->HeadPose.Pose.Position.x, 2) + powf(pOff->HeadPose.Pose.Position.y - pWeapon->HeadPose.Pose.Position.y, 2) + powf(pOff->HeadPose.Pose.Position.z - pWeapon->HeadPose.Pose.Position.z, 2)); @@ -311,7 +289,70 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG finishReloadNextFrame = false; } - if (pDominantTracking->Status & (VRAPI_TRACKING_STATUS_POSITION_TRACKED | VRAPI_TRACKING_STATUS_POSITION_VALID)) { + // Calculate if player tries to reach backpack + bool handInBackpack = false; + bool bpDistToHMDOk = false, bpWeaponHeightOk = false, bpWeaponAngleOk = false, bpHmdToWeaponAngleOk = false; + vec3_t hmdForwardXY = {}, weaponForwardXY = {}; + float weaponToDownAngle = 0, hmdToWeaponDotProduct = 0; + static vec3_t downVector = {0.0, 0.0, -1.0}; + + bool bpTrackOk = pOffTracking->Status & VRAPI_TRACKING_STATUS_POSITION_TRACKED; // 1) Position must be tracked + if (bpTrackOk && (bpDistToHMDOk = distanceToHMD >= 0.2 && distanceToHMD <= 0.35) // 2) Weapon-to-HMD distance must be within <0.2-0.35> range + && (bpWeaponHeightOk = vr.current_weaponoffset[1] >= -0.10 && vr.current_weaponoffset[1] <= 0.10)) // 3) Weapon height in relation to HMD must be within <-0.10, 0.10> range + { + AngleVectors(&vr.hmdorientation, &hmdForwardXY, NULL, NULL); + AngleVectors(&vr.weaponangles, &weaponForwardXY, NULL, NULL); + + float weaponToDownAngle = AngleBetweenVectors(downVector, weaponForwardXY); + // 4) Angle between weapon forward vector and a down vector must be within 80-140 degrees + if(bpWeaponAngleOk = weaponToDownAngle >= 80.0 && weaponToDownAngle <= 140.0) + { + hmdForwardXY[2] = 0; + VectorNormalize(&hmdForwardXY); + + weaponForwardXY[2] = 0; + VectorNormalize(&weaponForwardXY); + + hmdToWeaponDotProduct = DotProduct(hmdForwardXY, weaponForwardXY); + // 5) HMD and weapon forward on XY plane must go in opposite directions (i.e. dot product < 0) + handInBackpack = bpHmdToWeaponAngleOk = hmdToWeaponDotProduct < 0; + } + } + + // Uncomment to debug backpack reaching + /* + ALOGV("Backpack> Dist: %f | WpnToDownAngle: %f | WpnOffs: %f %f %f\nHmdWpnDot: %f | HmdFwdXY: %f %f | WpnFwdXY: %f %f\nTrackOk: %i, DistOk: %i, HeightOk: %i, WpnAngleOk: %i, HmdWpnDotOk: %i", + distanceToHMD, weaponToDownAngle, vr.current_weaponoffset[0], vr.current_weaponoffset[1], vr.current_weaponoffset[2], + hmdToWeaponDotProduct, hmdForwardXY[0], hmdForwardXY[1], weaponForwardXY[0], weaponForwardXY[1], + bpTrackOk, bpDistToHMDOk, bpWeaponHeightOk, bpWeaponAngleOk, bpHmdToWeaponAngleOk); + */ + + // Check quicksave + if (!handInBackpack) { + canUseQuickSave = false; + } + else if (!canUseQuickSave) { + int channel = (vr_control_scheme->integer >= 10) ? 1 : 0; + RTCWVR_Vibrate(40, channel, 0.5); // vibrate to let user know they can switch + canUseQuickSave = true; + } + + if (canUseQuickSave) + { + if (((pOffTrackedRemoteNew->Buttons & offButton1) != + (pOffTrackedRemoteOld->Buttons & offButton1)) && + (pOffTrackedRemoteNew->Buttons & offButton1)) { + sendButtonActionSimple("savegame quicksave"); + } + + if (((pOffTrackedRemoteNew->Buttons & offButton2) != + (pOffTrackedRemoteOld->Buttons & offButton2)) && + (pOffTrackedRemoteNew->Buttons & offButton2)) { + sendButtonActionSimple("loadgame quicksave"); + } + } + + if (!handInBackpack) { canUseBackpack = false; } else if (!canUseBackpack && vr.backpackitemactive == 0) { From dc4eea689544f6d6373dec718d45fef3dfa70a75 Mon Sep 17 00:00:00 2001 From: mietszczyslaw Date: Sat, 8 Jan 2022 00:18:43 +0100 Subject: [PATCH 5/5] fix: cleaned up backpack detection code --- Projects/Android/jni/RTCWVR/VrInputDefault.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Projects/Android/jni/RTCWVR/VrInputDefault.c b/Projects/Android/jni/RTCWVR/VrInputDefault.c index fd1a21f..9589633 100644 --- a/Projects/Android/jni/RTCWVR/VrInputDefault.c +++ b/Projects/Android/jni/RTCWVR/VrInputDefault.c @@ -300,18 +300,18 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG if (bpTrackOk && (bpDistToHMDOk = distanceToHMD >= 0.2 && distanceToHMD <= 0.35) // 2) Weapon-to-HMD distance must be within <0.2-0.35> range && (bpWeaponHeightOk = vr.current_weaponoffset[1] >= -0.10 && vr.current_weaponoffset[1] <= 0.10)) // 3) Weapon height in relation to HMD must be within <-0.10, 0.10> range { - AngleVectors(&vr.hmdorientation, &hmdForwardXY, NULL, NULL); - AngleVectors(&vr.weaponangles, &weaponForwardXY, NULL, NULL); + AngleVectors(vr.hmdorientation, hmdForwardXY, NULL, NULL); + AngleVectors(vr.weaponangles, weaponForwardXY, NULL, NULL); float weaponToDownAngle = AngleBetweenVectors(downVector, weaponForwardXY); // 4) Angle between weapon forward vector and a down vector must be within 80-140 degrees if(bpWeaponAngleOk = weaponToDownAngle >= 80.0 && weaponToDownAngle <= 140.0) { hmdForwardXY[2] = 0; - VectorNormalize(&hmdForwardXY); + VectorNormalize(hmdForwardXY); weaponForwardXY[2] = 0; - VectorNormalize(&weaponForwardXY); + VectorNormalize(weaponForwardXY); hmdToWeaponDotProduct = DotProduct(hmdForwardXY, weaponForwardXY); // 5) HMD and weapon forward on XY plane must go in opposite directions (i.e. dot product < 0) @@ -749,4 +749,4 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG //Save state rightTrackedRemoteState_old = rightTrackedRemoteState_new; leftTrackedRemoteState_old = leftTrackedRemoteState_new; -} \ No newline at end of file +}