diff --git a/neo/d3xp/Player.cpp b/neo/d3xp/Player.cpp index 5b10eb374..894787b0f 100644 --- a/neo/d3xp/Player.cpp +++ b/neo/d3xp/Player.cpp @@ -110,6 +110,7 @@ idAngles pdaAngle2( 0, 0, 76.5); idAngles pdaAngle3( 0, 0, 0); extern idCVar g_useWeaponDepthHack; +extern idCVar in_independentAim; /* @@ -16954,7 +16955,17 @@ void idPlayer::CalculateViewWeaponPosVR( int hand, idVec3 &origin, idMat3 &axis angQuat = idAngles( commonVr->independentWeaponPitch, commonVr->independentWeaponYaw, 0 ).ToQuat(); idQuat gunAxis = angQuat; - gunAxis *= bodyAxis.ToQuat(); + if( game->isVR || in_independentAim.GetInteger() ) + { + gunAxis *= bodyAxis.ToQuat(); + } + else + { + idMat3 headAxis = idAngles( viewAngles.pitch, viewAngles.yaw, 0.0f ).ToMat3(); + gunAxis *= headAxis.ToQuat(); + commonVr->independentWeaponPitch = 0; + commonVr->independentWeaponYaw = 0; + } newAx = gunAxis.ToMat3(); int flip = vr_weaponHand.GetInteger() == 0 ? 1 : -1; diff --git a/neo/d3xp/Weapon.cpp b/neo/d3xp/Weapon.cpp index 03452a2da..9d7041d65 100644 --- a/neo/d3xp/Weapon.cpp +++ b/neo/d3xp/Weapon.cpp @@ -163,6 +163,7 @@ idCVar g_useWeaponDepthHack( "g_useWeaponDepthHack", "0", CVAR_BOOL | CVAR_GAME idCVar g_weaponShadows( "g_weaponShadows", "1", CVAR_BOOL | CVAR_GAME | CVAR_ARCHIVE, "Cast shadows from weapons" ); // Koz extern idCVar cg_predictedSpawn_debug; +extern idCVar in_independentAim; /*********************************************************************** @@ -4848,7 +4849,8 @@ idWeapon::GetProjectileLaunchOriginAndAxis void idWeapon::GetProjectileLaunchOriginAndAxis( idVec3& origin, idMat3& axis ) { assert( owner != NULL ); - if ( game->isVR ) + // Carl: in VR, or when using independent aim, we fire from the weapon model itself + if( game->isVR || in_independentAim.GetInteger() ) { static weapon_t curWeap = WEAPON_NONE; @@ -4886,6 +4888,7 @@ void idWeapon::GetProjectileLaunchOriginAndAxis( idVec3& origin, idMat3& axis ) return; } + // Carl: When not in VR, we usually fire from our eyes (the centre of the screen) // calculate the muzzle position if( barrelJointView != INVALID_JOINT && projectileDict.GetBool( "launchFromBarrel" ) ) { diff --git a/neo/framework/UsercmdGen.cpp b/neo/framework/UsercmdGen.cpp index 4673450c7..c68d154ff 100644 --- a/neo/framework/UsercmdGen.cpp +++ b/neo/framework/UsercmdGen.cpp @@ -63,6 +63,8 @@ idCVar vr_joyCurves( "vr_joyCurves", "0", CVAR_ARCHIVE | CVAR_INTEGER, "Joy powe idCVar vr_joyCurveSensitivity( "vr_joyCurveSensitivity", "9", CVAR_ARCHIVE | CVAR_FLOAT, "Sensitivity val 0 - 9\n" ); idCVar vr_joyCurveLin( "vr_joyCurveLin", "4", CVAR_ARCHIVE | CVAR_FLOAT, "Linear point for joyCurves\n sens < lin = power curve\n, sens = lin = linear\n, sens > lin = frac power curve.\n" ); +// Carl: Non-VR-mode independent weapon control +idCVar in_independentAim( "in_independentAim", "0", CVAR_ARCHIVE | CVAR_INTEGER, "Independent weapon aim. 0 = normal look/aim, 1 = mouse aims weapon, 2 = keys aim weapon, 3 = both aim weapon", 0, 3 ); /* @@ -477,11 +479,23 @@ void idUsercmdGenLocal::AdjustAngles() if ( !game->isVR ) { - viewangles[YAW] -= speed * in_yawSpeed.GetFloat() * ButtonState( UB_LOOKRIGHT ); - viewangles[YAW] += speed * in_yawSpeed.GetFloat() * ButtonState( UB_LOOKLEFT ); + if( in_independentAim.GetInteger() & 2 ) + { + float yawdelta, pitchdelta; + yawdelta = speed * in_yawSpeed.GetFloat() * ( ButtonState( UB_LOOKLEFT ) - ButtonState( UB_LOOKRIGHT ) ); + pitchdelta = speed * in_pitchSpeed.GetFloat() * ( ButtonState( UB_LOOKDOWN ) - ButtonState( UB_LOOKUP ) ); + commonVr->CalcAimMove( yawdelta, pitchdelta ); // update the independent weapon angles and return any movement changes. + viewangles[YAW] += yawdelta; + viewangles[PITCH] += pitchdelta; + } + else + { + viewangles[YAW] -= speed * in_yawSpeed.GetFloat() * ButtonState( UB_LOOKRIGHT ); + viewangles[YAW] += speed * in_yawSpeed.GetFloat() * ButtonState( UB_LOOKLEFT ); - viewangles[PITCH] -= speed * in_pitchSpeed.GetFloat() * ButtonState( UB_LOOKUP ); - viewangles[PITCH] += speed * in_pitchSpeed.GetFloat() * ButtonState( UB_LOOKDOWN ); + viewangles[PITCH] -= speed * in_pitchSpeed.GetFloat() * ButtonState( UB_LOOKUP ); + viewangles[PITCH] += speed * in_pitchSpeed.GetFloat() * ButtonState( UB_LOOKDOWN ); + } } else // Koz add independent weapon aiming { @@ -603,7 +617,7 @@ void idUsercmdGenLocal::MouseMove() pitchdelta = m_pitch.GetFloat() * in_mouseSpeed.GetFloat() * (in_mouseInvertLook.GetBool() ? -my : my); // Koz begin add mouse control here - if( commonVr->hasHMD && vr_enable.GetBool() ) + if( ( commonVr->hasHMD && vr_enable.GetBool() ) || in_independentAim.GetInteger() & 1 ) { // update the independent weapon angles and return any view changes based on current aim mode commonVr->CalcAimMove( yawdelta, pitchdelta ); diff --git a/neo/vr/Vr.cpp b/neo/vr/Vr.cpp index e0573db8e..88d2754f6 100644 --- a/neo/vr/Vr.cpp +++ b/neo/vr/Vr.cpp @@ -56,9 +56,9 @@ idCVar vr_forward_keyhole( "vr_forward_keyhole", "11.25", CVAR_FLOAT | CVAR_ARCH idCVar vr_PDAfixLocation( "vr_PDAfixLocation", "0", CVAR_BOOL | CVAR_ARCHIVE | CVAR_GAME, "Fix PDA position in space in front of player\n instead of holding in hand." ); -idCVar vr_weaponPivotOffsetForward( "vr_weaponPivotOffsetForward", "3", CVAR_GAME | CVAR_ARCHIVE | CVAR_FLOAT, "" ); -idCVar vr_weaponPivotOffsetHorizontal( "vr_weaponPivotOffsetHorizontal", "0", CVAR_GAME | CVAR_ARCHIVE | CVAR_FLOAT, "" ); -idCVar vr_weaponPivotOffsetVertical( "vr_weaponPivotOffsetVertical", "0", CVAR_GAME | CVAR_ARCHIVE | CVAR_FLOAT, "" ); +idCVar vr_weaponPivotOffsetForward( "vr_weaponPivotOffsetForward", "4", CVAR_GAME | CVAR_ARCHIVE | CVAR_FLOAT, "" ); +idCVar vr_weaponPivotOffsetHorizontal( "vr_weaponPivotOffsetHorizontal", "-4", CVAR_GAME | CVAR_ARCHIVE | CVAR_FLOAT, "" ); +idCVar vr_weaponPivotOffsetVertical( "vr_weaponPivotOffsetVertical", "-12", CVAR_GAME | CVAR_ARCHIVE | CVAR_FLOAT, "" ); idCVar vr_weaponPivotForearmLength( "vr_weaponPivotForearmLength", "16", CVAR_GAME | CVAR_ARCHIVE | CVAR_FLOAT, "" ); idCVar vr_guiScale( "vr_guiScale", "1", CVAR_FLOAT | CVAR_RENDERER | CVAR_ARCHIVE, "scale reduction factor for full screen menu/pda scale in VR", 0.0001f, 1.0f ); // Koz allow scaling of full screen guis/pda