From 52061d9040423bb5143f2825ad5532bc9c713a0d Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 21 Nov 2022 21:56:59 +0000 Subject: [PATCH] Big improvement to disruptor better handling for NPC controlling (though it still doesn't feel very good) --- Projects/Android/AndroidManifest.xml | 4 +-- .../Android/jni/JKVR/JKVR_SurfaceView.cpp | 4 +-- Projects/Android/jni/JKVR/VrClientInfo.h | 2 +- Projects/Android/jni/JKVR/VrInputDefault.cpp | 35 ++++++++++++------- .../Android/jni/JKVR/VrInputWeaponAlign.cpp | 6 ++-- .../Android/jni/OpenJK/code/game/bg_local.h | 1 + .../Android/jni/OpenJK/code/game/bg_misc.cpp | 7 +++- .../OpenJK/code/game/wp_blaster_pistol.cpp | 2 +- .../jni/OpenJK/code/game/wp_blaster_rifle.cpp | 2 +- .../jni/OpenJK/code/game/wp_bowcaster.cpp | 2 +- .../jni/OpenJK/code/game/wp_concussion.cpp | 2 +- .../Android/jni/OpenJK/code/game/wp_demp2.cpp | 2 +- .../jni/OpenJK/code/game/wp_disruptor.cpp | 6 ++-- .../jni/OpenJK/code/game/wp_flechette.cpp | 2 +- .../jni/OpenJK/code/game/wp_repeater.cpp | 4 +-- .../OpenJK/code/game/wp_rocket_launcher.cpp | 2 +- .../jni/OpenJK/code/game/wp_stun_baton.cpp | 2 +- .../jni/OpenJK/codeJK2/cgame/cg_draw.cpp | 14 ++++---- .../jni/OpenJK/codeJK2/cgame/cg_weapons.cpp | 4 +-- .../jni/OpenJK/codeJK2/game/bg_local.h | 1 + .../jni/OpenJK/codeJK2/game/bg_misc.cpp | 9 +++-- .../jni/OpenJK/codeJK2/game/g_active.cpp | 3 ++ .../OpenJK/codeJK2/game/wp_blaster_rifle.cpp | 2 +- .../jni/OpenJK/codeJK2/game/wp_bowcaster.cpp | 4 +-- .../OpenJK/codeJK2/game/wp_bryar_pistol.cpp | 2 +- .../jni/OpenJK/codeJK2/game/wp_demp2.cpp | 4 +-- .../jni/OpenJK/codeJK2/game/wp_disruptor.cpp | 6 ++-- .../jni/OpenJK/codeJK2/game/wp_flechette.cpp | 2 +- .../jni/OpenJK/codeJK2/game/wp_repeater.cpp | 4 +-- .../codeJK2/game/wp_rocket_launcher.cpp | 2 +- .../jni/OpenJK/codeJK2/game/wp_saber.cpp | 4 +-- .../jni/OpenJK/codeJK2/game/wp_stun_baton.cpp | 2 +- .../jni/OpenJK/codeJK2/game/wp_thermal.cpp | 2 +- 33 files changed, 89 insertions(+), 61 deletions(-) diff --git a/Projects/Android/AndroidManifest.xml b/Projects/Android/AndroidManifest.xml index 8cb4631..8b6d8af 100644 --- a/Projects/Android/AndroidManifest.xml +++ b/Projects/Android/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="29" + android:versionName="0.4.0" android:installLocation="auto" > diff --git a/Projects/Android/jni/JKVR/JKVR_SurfaceView.cpp b/Projects/Android/jni/JKVR/JKVR_SurfaceView.cpp index b117b7b..c50725b 100644 --- a/Projects/Android/jni/JKVR/JKVR_SurfaceView.cpp +++ b/Projects/Android/jni/JKVR/JKVR_SurfaceView.cpp @@ -888,7 +888,7 @@ void JKVR_GetMove(float *forward, float *side, float *pos_forward, float *pos_si *up = 0.0f; *side = 0.0f; *pos_side = 0.0f; - *yaw = vr.snapTurn + vr.weaponangles[YAW]; + *yaw = vr.snapTurn; *pitch = vr.weaponangles[PITCH]; *roll = vr.hmdorientation[ROLL]; } @@ -898,7 +898,7 @@ void JKVR_GetMove(float *forward, float *side, float *pos_forward, float *pos_si *up = 0.0f; *side = remote_movementSideways; *pos_side = 0.0f; - *yaw = vr.hmdorientation[YAW] - vr.hmdorientation_first[YAW]; + *yaw = vr.snapTurn + vr.hmdorientation[YAW] - vr.hmdorientation_first[YAW]; *pitch = vr.hmdorientation[PITCH]; *roll = 0.0f; } diff --git a/Projects/Android/jni/JKVR/VrClientInfo.h b/Projects/Android/jni/JKVR/VrClientInfo.h index 6c1327a..5e5c163 100644 --- a/Projects/Android/jni/JKVR/VrClientInfo.h +++ b/Projects/Android/jni/JKVR/VrClientInfo.h @@ -64,7 +64,7 @@ typedef struct { vec3_t offhandangles_last; // Don't use this, it is just for calculating delta! vec3_t offhandangles_delta; - vec3_t offhandposition; + vec3_t offhandposition[5]; // store last 5 vec3_t offhandoffset; float maxHeight; diff --git a/Projects/Android/jni/JKVR/VrInputDefault.cpp b/Projects/Android/jni/JKVR/VrInputDefault.cpp index 5748b95..b823e75 100644 --- a/Projects/Android/jni/JKVR/VrInputDefault.cpp +++ b/Projects/Android/jni/JKVR/VrInputDefault.cpp @@ -383,16 +383,23 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG } } + vec3_t offhandPositionAverage; + VectorClear(offhandPositionAverage); + for (int i = 0; i < 5; ++i) + { + VectorAdd(offhandPositionAverage, vr.offhandposition[i], offhandPositionAverage); + } + VectorScale(offhandPositionAverage, 0.2f, offhandPositionAverage); if (vr.weapon_stabilised) { if (vr_virtual_stock->integer == 1) { //offset to the appropriate eye a little bit vec2_t xy; rotateAboutOrigin(Cvar_VariableValue("cg_stereoSeparation") / 2.0f, 0.0f, -vr.hmdorientation[YAW], xy); - float x = pOff->HeadPose.Pose.Position.x - (vr.hmdposition[0] + xy[0]); - float y = pOff->HeadPose.Pose.Position.y - + float x = offhandPositionAverage[0] - (vr.hmdposition[0] + xy[0]); + float y = offhandPositionAverage[1] - (vr.hmdposition[1] - 0.1f); // Use a point lower - float z = pOff->HeadPose.Pose.Position.z - (vr.hmdposition[2] + xy[1]); + float z = offhandPositionAverage[2] - (vr.hmdposition[2] + xy[1]); float zxDist = length(x, z); if (zxDist != 0.0f && z != 0.0f) { @@ -403,11 +410,11 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG else if (vr.cgzoommode == 2 || vr.cgzoommode == 4) { float x = - pOff->HeadPose.Pose.Position.x - vr.hmdposition[0]; + offhandPositionAverage[0] - vr.hmdposition[0]; float y = - pOff->HeadPose.Pose.Position.y - (vr.hmdposition[1] - 0.1f); + offhandPositionAverage[1] - (vr.hmdposition[1] - 0.1f); float z = - pOff->HeadPose.Pose.Position.z - vr.hmdposition[2]; + offhandPositionAverage[2] - vr.hmdposition[2]; float zxDist = length(x, z); if (zxDist != 0.0f && z != 0.0f) { @@ -472,9 +479,13 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG //off-hand stuff (done here as I reference it in the save state thing { - vr.offhandposition[0] = pOff->HeadPose.Pose.Position.x; - vr.offhandposition[1] = pOff->HeadPose.Pose.Position.y; - vr.offhandposition[2] = pOff->HeadPose.Pose.Position.z; + for (int i = 4; i > 0; --i) + { + VectorCopy(vr.offhandposition[i-1], vr.offhandposition[i]); + } + vr.offhandposition[0][0] = pOff->HeadPose.Pose.Position.x; + vr.offhandposition[0][1] = pOff->HeadPose.Pose.Position.y; + vr.offhandposition[0][2] = pOff->HeadPose.Pose.Position.z; vr.offhandoffset[0] = pOff->HeadPose.Pose.Position.x - vr.hmdposition[0]; vr.offhandoffset[1] = pOff->HeadPose.Pose.Position.y - vr.hmdposition[1]; @@ -731,7 +742,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG (!vr.third_person && vr_turn_mode->integer == 1); static int increaseSnap = true; - if (!vr.item_selector && !vr.remote_npc) { + if (!vr.item_selector) { if (usingSnapTurn) { if (primaryJoystickX > 0.7f) { if (increaseSnap) { @@ -786,7 +797,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG { if (!vr.secondaryVelocityTriggeredAttack) { - VectorCopy(vr.offhandposition, vr.secondaryVelocityTriggerLocation); + VectorCopy(vr.offhandposition[0], vr.secondaryVelocityTriggerLocation); vr.secondaryVelocityTriggeredAttack = true; } } @@ -796,7 +807,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG { vec3_t start, end; VectorSubtract(vr.secondaryVelocityTriggerLocation, vr.hmdposition, start); - VectorSubtract(vr.offhandposition, vr.hmdposition, end); + VectorSubtract(vr.offhandposition[0], vr.hmdposition, end); float deltaLength = VectorLength(end) - VectorLength(start); if (fabs(deltaLength) > 0.2f) { if (deltaLength < 0) { diff --git a/Projects/Android/jni/JKVR/VrInputWeaponAlign.cpp b/Projects/Android/jni/JKVR/VrInputWeaponAlign.cpp index 4874cff..efad098 100644 --- a/Projects/Android/jni/JKVR/VrInputWeaponAlign.cpp +++ b/Projects/Android/jni/JKVR/VrInputWeaponAlign.cpp @@ -93,9 +93,9 @@ void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemote float controllerYawHeading = 0.0f; //off-hand stuff { - vr.offhandposition[0] = pOffTracking->HeadPose.Pose.Position.x; - vr.offhandposition[1] = pOffTracking->HeadPose.Pose.Position.y; - vr.offhandposition[2] = pOffTracking->HeadPose.Pose.Position.z; + vr.offhandposition[0][0] = pOffTracking->HeadPose.Pose.Position.x; + vr.offhandposition[0][1] = pOffTracking->HeadPose.Pose.Position.y; + vr.offhandposition[0][2] = pOffTracking->HeadPose.Pose.Position.z; vr.offhandoffset[0] = pOffTracking->HeadPose.Pose.Position.x - vr.hmdposition[0]; vr.offhandoffset[1] = pOffTracking->HeadPose.Pose.Position.y - vr.hmdposition[1]; diff --git a/Projects/Android/jni/OpenJK/code/game/bg_local.h b/Projects/Android/jni/OpenJK/code/game/bg_local.h index 9f0c247..eb02e4f 100644 --- a/Projects/Android/jni/OpenJK/code/game/bg_local.h +++ b/Projects/Android/jni/OpenJK/code/game/bg_local.h @@ -79,6 +79,7 @@ qboolean PM_SlideMove( float gravity ); void PM_StepSlideMove( float gravity ); void rotateAboutOrigin(float x, float y, float rotation, vec2_t out); +bool BG_UseVRPosition( gentity_t *ent ); void BG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles ); void BG_CalculateVRSaberPosition( vec3_t origin, vec3_t angles ); void BG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles ); diff --git a/Projects/Android/jni/OpenJK/code/game/bg_misc.cpp b/Projects/Android/jni/OpenJK/code/game/bg_misc.cpp index 512469c..10d2f8f 100644 --- a/Projects/Android/jni/OpenJK/code/game/bg_misc.cpp +++ b/Projects/Android/jni/OpenJK/code/game/bg_misc.cpp @@ -757,7 +757,7 @@ void BG_CalculateVRPositionInWorld( const vec3_t in_position, vec3_t in_offset, void BG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles ) { - BG_CalculateVRPositionInWorld(vr->offhandposition, vr->offhandoffset, vr->offhandangles, origin, angles); + BG_CalculateVRPositionInWorld(vr->offhandposition[0], vr->offhandoffset, vr->offhandangles, origin, angles); } void BG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles ) @@ -770,6 +770,11 @@ void BG_CalculateVRSaberPosition( vec3_t origin, vec3_t angles ) BG_CalculateVRPositionInWorld(vr->weaponposition, vr->weaponoffset, vr->weaponangles_saber, origin, angles); } +bool BG_UseVRPosition( gentity_t *ent ) +{ + return ( ent->client && (!ent->NPC || ent->client->ps.clientNum == 0 || ent->client->ps.clientNum == cg_entities[0].gent->client->ps.viewEntity)); +} + /* ============ BG_PlayerTouchesItem diff --git a/Projects/Android/jni/OpenJK/code/game/wp_blaster_pistol.cpp b/Projects/Android/jni/OpenJK/code/game/wp_blaster_pistol.cpp index a2fb2a8..49546ea 100644 --- a/Projects/Android/jni/OpenJK/code/game/wp_blaster_pistol.cpp +++ b/Projects/Android/jni/OpenJK/code/game/wp_blaster_pistol.cpp @@ -40,7 +40,7 @@ void WP_FireBryarPistol( gentity_t *ent, qboolean alt_fire ) int damage = !alt_fire ? weaponData[WP_BRYAR_PISTOL].damage : weaponData[WP_BRYAR_PISTOL].altDamage; vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(muzzle, angs); AngleVectors(angs, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/code/game/wp_blaster_rifle.cpp b/Projects/Android/jni/OpenJK/code/game/wp_blaster_rifle.cpp index 1bdec39..236dc4d 100644 --- a/Projects/Android/jni/OpenJK/code/game/wp_blaster_rifle.cpp +++ b/Projects/Android/jni/OpenJK/code/game/wp_blaster_rifle.cpp @@ -119,7 +119,7 @@ void WP_FireBlaster( gentity_t *ent, qboolean alt_fire ) { vec3_t dir, angs; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(muzzle, angs); } diff --git a/Projects/Android/jni/OpenJK/code/game/wp_bowcaster.cpp b/Projects/Android/jni/OpenJK/code/game/wp_bowcaster.cpp index 29c0e9e..e25b35a 100644 --- a/Projects/Android/jni/OpenJK/code/game/wp_bowcaster.cpp +++ b/Projects/Android/jni/OpenJK/code/game/wp_bowcaster.cpp @@ -40,7 +40,7 @@ static void WP_BowcasterMainFire( gentity_t *ent ) vec3_t angs, forward, dir, start; gentity_t *missile; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(muzzle, angs); AngleVectors(angs, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/code/game/wp_concussion.cpp b/Projects/Android/jni/OpenJK/code/game/wp_concussion.cpp index 2536723..16f2960 100644 --- a/Projects/Android/jni/OpenJK/code/game/wp_concussion.cpp +++ b/Projects/Android/jni/OpenJK/code/game/wp_concussion.cpp @@ -258,7 +258,7 @@ static void WP_FireConcussion( gentity_t *ent ) float vel = CONC_VELOCITY; vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(muzzle, angs); AngleVectors(angs, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/code/game/wp_demp2.cpp b/Projects/Android/jni/OpenJK/code/game/wp_demp2.cpp index 99172d8..fbc42a1 100644 --- a/Projects/Android/jni/OpenJK/code/game/wp_demp2.cpp +++ b/Projects/Android/jni/OpenJK/code/game/wp_demp2.cpp @@ -39,7 +39,7 @@ static void WP_DEMP2_MainFire( gentity_t *ent ) int damage = weaponData[WP_DEMP2].damage; vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(muzzle, angs); AngleVectors(angs, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/code/game/wp_disruptor.cpp b/Projects/Android/jni/OpenJK/code/game/wp_disruptor.cpp index e09268d..202431c 100644 --- a/Projects/Android/jni/OpenJK/code/game/wp_disruptor.cpp +++ b/Projects/Android/jni/OpenJK/code/game/wp_disruptor.cpp @@ -60,7 +60,7 @@ static void WP_DisruptorMainFire( gentity_t *ent ) } vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(muzzle, angs); AngleVectors(angs, forward, NULL, NULL); @@ -168,7 +168,7 @@ void WP_DisruptorAltFire( gentity_t *ent ) qboolean hitDodged = qfalse, fullCharge = qfalse; vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(muzzle, angs); AngleVectors(angs, forward, NULL, NULL); @@ -371,7 +371,7 @@ void WP_FireDisruptor( gentity_t *ent, qboolean alt_fire ) } vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(muzzle, angs); AngleVectors(angs, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/code/game/wp_flechette.cpp b/Projects/Android/jni/OpenJK/code/game/wp_flechette.cpp index 6c29b4d..7597c14 100644 --- a/Projects/Android/jni/OpenJK/code/game/wp_flechette.cpp +++ b/Projects/Android/jni/OpenJK/code/game/wp_flechette.cpp @@ -58,7 +58,7 @@ static void WP_FlechetteMainFire( gentity_t *ent ) for ( int i = 0; i < FLECHETTE_SHOTS; i++ ) { vec3_t angs; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(muzzle, angs); } diff --git a/Projects/Android/jni/OpenJK/code/game/wp_repeater.cpp b/Projects/Android/jni/OpenJK/code/game/wp_repeater.cpp index 958c3e4..9baee72 100644 --- a/Projects/Android/jni/OpenJK/code/game/wp_repeater.cpp +++ b/Projects/Android/jni/OpenJK/code/game/wp_repeater.cpp @@ -99,7 +99,7 @@ static void WP_RepeaterAltFire( gentity_t *ent ) else { vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(muzzle, angs); AngleVectors(angs, forward, NULL, NULL); @@ -162,7 +162,7 @@ void WP_FireRepeater( gentity_t *ent, qboolean alt_fire ) //--------------------------------------------------------- { vec3_t dir, angs; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(muzzle, angs); } diff --git a/Projects/Android/jni/OpenJK/code/game/wp_rocket_launcher.cpp b/Projects/Android/jni/OpenJK/code/game/wp_rocket_launcher.cpp index 436301f..aa8dec6 100644 --- a/Projects/Android/jni/OpenJK/code/game/wp_rocket_launcher.cpp +++ b/Projects/Android/jni/OpenJK/code/game/wp_rocket_launcher.cpp @@ -184,7 +184,7 @@ void WP_FireRocket( gentity_t *ent, qboolean alt_fire ) } vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(muzzle, angs); AngleVectors(angs, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/code/game/wp_stun_baton.cpp b/Projects/Android/jni/OpenJK/code/game/wp_stun_baton.cpp index aa2672f..1831f2c 100644 --- a/Projects/Android/jni/OpenJK/code/game/wp_stun_baton.cpp +++ b/Projects/Android/jni/OpenJK/code/game/wp_stun_baton.cpp @@ -37,7 +37,7 @@ void WP_FireStunBaton( gentity_t *ent, qboolean alt_fire ) G_Sound( ent, G_SoundIndex( "sound/weapons/baton/fire" )); vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(muzzle, angs); AngleVectors(angs, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_draw.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_draw.cpp index cb3c081..a39f094 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_draw.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_draw.cpp @@ -1885,7 +1885,7 @@ static void CG_DrawCrosshair3D(int type) // 0 - force, 1 - weapons return; } - if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD ) + if ( in_misccamera ) { //Not while viewing from another entity (such as a camera) return; @@ -2851,11 +2851,13 @@ void CG_DrawActive( stereoFrame_t stereoView ) { CG_Error( "CG_DrawActive: Undefined stereoView" ); } + char modelName[256]; + Q_strncpyz(modelName, g_entities[cg.snap->ps.viewEntity].NPC_type, sizeof modelName); + vr->remote_npc = !Q_stricmp( "NPC", g_entities[cg.snap->ps.viewEntity].classname ); vr->remote_droid = vr->remote_npc && - ( !Q_stricmp( "mouse", g_entities[cg.snap->ps.viewEntity].NPC_type) || - !Q_stricmp( "r2d2", g_entities[cg.snap->ps.viewEntity].NPC_type) || - !Q_stricmp( "r5d2", g_entities[cg.snap->ps.viewEntity].NPC_type)); + ( !Q_stricmp( "gonk", modelName ) || !Q_stricmp( "seeker", modelName ) || !Q_stricmp( "remote", modelName ) + || !Q_strncmp( "r2d2", modelName, 4 ) || !Q_strncmp( "r5d2", modelName, 4 ) || !Q_stricmp( "mouse", modelName ) ); vr->remote_turret = (!Q_stricmp( "misc_panel_turret", g_entities[cg.snap->ps.viewEntity].classname )); in_misccamera = ( !Q_stricmp( "misc_camera", g_entities[cg.snap->ps.viewEntity].classname )) @@ -2885,7 +2887,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) { !vr->remote_droid) { VectorCopy(vr->hmdorientation, cg.refdef.viewangles); - cg.refdef.viewangles[YAW] = cg.refdefViewAngles[YAW]; // Need to do this better.. results in laggy YAW, which is unpleasant + cg.refdef.viewangles[YAW] = cg.refdefViewAngles[YAW]; AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis); } @@ -2894,7 +2896,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) { { cg.refdef.viewangles[ROLL] = vr->clientviewangles[ROLL]; cg.refdef.viewangles[PITCH] = vr->weaponangles[PITCH]; - cg.refdef.viewangles[YAW] = (vr->clientviewangles[YAW] - vr->hmdorientation[YAW]) + cg.refdef.viewangles[YAW] = vr->clientviewangles[YAW] + vr->weaponangles[YAW] + SHORT2ANGLE(cg.snap->ps.delta_angles[YAW]); AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis); } diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_weapons.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_weapons.cpp index a7a76e1..8de4030 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_weapons.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_weapons.cpp @@ -2787,7 +2787,7 @@ void CG_DrawItemSelector( void ) if (vr->item_selector == 2) { cg.itemSelectorType = 3; - VectorCopy(vr->offhandposition, cg.itemSelectorOrigin); + VectorCopy(vr->offhandposition[0], cg.itemSelectorOrigin); VectorCopy(vr->offhandoffset, cg.itemSelectorOffset); } else { @@ -2812,7 +2812,7 @@ void CG_DrawItemSelector( void ) if (cg.itemSelectorType == 3) { BG_CalculateVROffHandPosition(controllerOrigin, controllerAngles); - VectorSubtract(vr->offhandposition, cg.itemSelectorOrigin, controllerOffset); + VectorSubtract(vr->offhandposition[0], cg.itemSelectorOrigin, controllerOffset); } else { diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/bg_local.h b/Projects/Android/jni/OpenJK/codeJK2/game/bg_local.h index 9f0c247..eb02e4f 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/bg_local.h +++ b/Projects/Android/jni/OpenJK/codeJK2/game/bg_local.h @@ -79,6 +79,7 @@ qboolean PM_SlideMove( float gravity ); void PM_StepSlideMove( float gravity ); void rotateAboutOrigin(float x, float y, float rotation, vec2_t out); +bool BG_UseVRPosition( gentity_t *ent ); void BG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles ); void BG_CalculateVRSaberPosition( vec3_t origin, vec3_t angles ); void BG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles ); diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/bg_misc.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/bg_misc.cpp index 99854e1..567aca8 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/bg_misc.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/bg_misc.cpp @@ -655,7 +655,7 @@ void rotateAboutOrigin(float x, float y, float rotation, vec2_t out) float getHMDYawForCalc() { - if (!vr->third_person) { + if (!vr->third_person && vr->cgzoommode != 2 && vr->cgzoommode != 4 ) { return vr->hmdorientation[YAW]; } return 0.0f; @@ -698,7 +698,7 @@ void BG_CalculateVRPositionInWorld( const vec3_t in_position, vec3_t in_offset, void BG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles ) { - BG_CalculateVRPositionInWorld(vr->offhandposition, vr->offhandoffset, vr->offhandangles, origin, angles); + BG_CalculateVRPositionInWorld(vr->offhandposition[0], vr->offhandoffset, vr->offhandangles, origin, angles); } void BG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles ) @@ -711,6 +711,11 @@ void BG_CalculateVRSaberPosition( vec3_t origin, vec3_t angles ) BG_CalculateVRPositionInWorld(vr->weaponposition, vr->weaponoffset, vr->weaponangles_saber, origin, angles); } +bool BG_UseVRPosition( gentity_t *ent ) +{ + return ( ent->client && (!ent->NPC || ent->client->ps.clientNum == cg_entities[0].gent->client->ps.viewEntity)); +} + /* ============ BG_PlayerTouchesItem diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp index c1fedf3..ca179f6 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp @@ -29,6 +29,7 @@ along with this program; if not, see . #include "Q3_Interface.h" #include "wp_saber.h" #include "g_icarus.h" +#include #ifdef _DEBUG #include @@ -216,6 +217,8 @@ void G_SetViewEntity( gentity_t *self, gentity_t *viewEntity ) { //vec3_t clear = {0,0,0}; CG_SetClientViewAngles( viewEntity->client->ps.viewangles, qtrue ); + vr->snapTurn = 0; + //SetClientViewAngle( self, viewEntity->client->ps.viewangles ); //SetClientViewAngle( viewEntity, clear ); /* diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/wp_blaster_rifle.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/wp_blaster_rifle.cpp index ffabf37..030616d 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/wp_blaster_rifle.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/wp_blaster_rifle.cpp @@ -110,7 +110,7 @@ void WP_FireBlaster( gentity_t *ent, qboolean alt_fire ) { vec3_t dir, angs, start; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent) ) { BG_CalculateVRWeaponPosition(start, angs); } diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/wp_bowcaster.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/wp_bowcaster.cpp index ab53582..c5e6b6d 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/wp_bowcaster.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/wp_bowcaster.cpp @@ -41,7 +41,7 @@ static void WP_BowcasterMainFire( gentity_t *ent ) vec3_t angs, forward, dir, start; gentity_t *missile; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(wpMuzzle, angs); AngleVectors(angs, forward, NULL, NULL); @@ -144,7 +144,7 @@ static void WP_BowcasterAltFire( gentity_t *ent ) vec3_t start, forward, angs; int damage = weaponData[WP_BOWCASTER].altDamage; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(start, angs); AngleVectors(angs, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/wp_bryar_pistol.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/wp_bryar_pistol.cpp index a70e261..d2c4d60 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/wp_bryar_pistol.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/wp_bryar_pistol.cpp @@ -41,7 +41,7 @@ void WP_FireBryarPistol( gentity_t *ent, qboolean alt_fire ) int damage = !alt_fire ? weaponData[ent->s.weapon].damage : weaponData[ent->s.weapon].altDamage; vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(wpMuzzle, angs); AngleVectors(angs, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/wp_demp2.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/wp_demp2.cpp index ef3e313..b2e5a0e 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/wp_demp2.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/wp_demp2.cpp @@ -40,7 +40,7 @@ static void WP_DEMP2_MainFire( gentity_t *ent ) vec3_t start, angs, forward; int damage = weaponData[WP_DEMP2].damage; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(start, angs); AngleVectors(angs, forward, NULL, NULL); @@ -211,7 +211,7 @@ static void WP_DEMP2_AltFire( gentity_t *ent ) vec3_t start, angs, forward; trace_t tr; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(start, angs); AngleVectors(angs, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/wp_disruptor.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/wp_disruptor.cpp index a209197..60d69f0 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/wp_disruptor.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/wp_disruptor.cpp @@ -83,7 +83,7 @@ static void WP_DisruptorMainFire( gentity_t *ent ) } vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(start, angs); AngleVectors(angs, forward, NULL, NULL); @@ -189,7 +189,7 @@ void WP_DisruptorAltFire( gentity_t *ent ) qboolean hitDodged = qfalse, fullCharge = qfalse; vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(wpMuzzle, angs); AngleVectors(angs, forward, NULL, NULL); @@ -380,7 +380,7 @@ void WP_FireDisruptor( gentity_t *ent, qboolean alt_fire ) } vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(wpMuzzle, angs); AngleVectors(wpMuzzle, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/wp_flechette.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/wp_flechette.cpp index 3e3bddf..6d45815 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/wp_flechette.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/wp_flechette.cpp @@ -43,7 +43,7 @@ static void WP_FlechetteMainFire( gentity_t *ent ) vec3_t forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(start, angs); AngleVectors(angs, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/wp_repeater.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/wp_repeater.cpp index 18ef27c..f82bce8 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/wp_repeater.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/wp_repeater.cpp @@ -87,7 +87,7 @@ static void WP_RepeaterAltFire( gentity_t *ent ) gentity_t *missile = NULL; vec3_t forward, start, angs; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(start, angs); AngleVectors(angs, forward, NULL, NULL); @@ -160,7 +160,7 @@ void WP_FireRepeater( gentity_t *ent, qboolean alt_fire ) vec3_t dir, angs; vec3_t forward, start; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(start, angs); } diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/wp_rocket_launcher.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/wp_rocket_launcher.cpp index a81e8ad..8ab0177 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/wp_rocket_launcher.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/wp_rocket_launcher.cpp @@ -153,7 +153,7 @@ void WP_FireRocket( gentity_t *ent, qboolean alt_fire ) } vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(start, angs); AngleVectors(angs, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/wp_saber.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/wp_saber.cpp index 48c4f55..fea516a 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/wp_saber.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/wp_saber.cpp @@ -8197,7 +8197,7 @@ static void WP_ForcePowerRun( gentity_t *self, forcePowers_t forcePower, usercmd self->client->ps.forceGripEntityInitialDist == ENTITYNUM_NONE) { vec3_t diff; - VectorSubtract(vr->offhandposition, vr->hmdposition, diff); + VectorSubtract(vr->offhandposition[0], vr->hmdposition, diff); self->client->ps.forceGripEntityInitialDist = VectorLength(diff); } @@ -8216,7 +8216,7 @@ static void WP_ForcePowerRun( gentity_t *self, forcePowers_t forcePower, usercmd {//carry if (isFirstPersonPlayer) { vec3_t diff; - VectorSubtract(vr->offhandposition, vr->hmdposition, diff); + VectorSubtract(vr->offhandposition[0], vr->hmdposition, diff); float length = VectorLength(diff); float movedLength = (length - self->client->ps.forceGripEntityInitialDist) * cg_worldScale.value; if (fabs(movedLength) > 1.0f) { diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/wp_stun_baton.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/wp_stun_baton.cpp index 65acc07..92343cd 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/wp_stun_baton.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/wp_stun_baton.cpp @@ -39,7 +39,7 @@ void WP_FireStunBaton( gentity_t *ent, qboolean alt_fire ) G_Sound( ent, G_SoundIndex( "sound/weapons/baton/fire" )); vec3_t angs, forward; - if ( ent->client && !ent->NPC) + if ( BG_UseVRPosition(ent)) { BG_CalculateVRWeaponPosition(wpMuzzle, angs); AngleVectors(angs, forward, NULL, NULL); diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/wp_thermal.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/wp_thermal.cpp index 57e2b7d..00ef764 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/wp_thermal.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/wp_thermal.cpp @@ -283,7 +283,7 @@ gentity_t *WP_FireThermalDetonator( gentity_t *ent, qboolean alt_fire ) bolt = G_Spawn(); bool realThrow = false; - if ( ent->client && !ent->NPC && ent->client->ps.clientNum == 0) + if ( BG_UseVRPosition(ent) ) { vec3_t angs; BG_CalculateVRWeaponPosition(start, angs);