Fixed GUI pointer angles

Made sure that left/right handed selection in menu works correctly
This commit is contained in:
Simon 2020-09-23 23:06:34 +01:00
parent 7df7a5410d
commit 66c7052713
6 changed files with 29 additions and 22 deletions

View file

@ -1604,18 +1604,19 @@ void Doom3Quest_getTrackedRemotesOrientation(int controlscheme) {
acquireTrackedRemotesData(gAppState.Ovr, gAppState.DisplayTime[gAppState.MainThreadFrameIndex % MAX_TRACKING_SAMPLES]);
//Call additional control schemes here
switch (controlscheme)
{
case RIGHT_HANDED_DEFAULT:
HandleInput_Default(controlscheme, &rightTrackedRemoteState_new, &rightTrackedRemoteState_old, &rightRemoteTracking_new,
&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, &leftRemoteTracking_new,
if (controlscheme == RIGHT_HANDED_DEFAULT) {
HandleInput_Default(controlscheme, &rightTrackedRemoteState_new,
&rightTrackedRemoteState_old, &rightRemoteTracking_new,
&leftTrackedRemoteState_new, &leftTrackedRemoteState_old,
&leftRemoteTracking_new,
ovrButton_A, ovrButton_B, ovrButton_X, ovrButton_Y);
break;
case LEFT_HANDED_DEFAULT:
HandleInput_Default(controlscheme, &leftTrackedRemoteState_new, &leftTrackedRemoteState_old, &leftRemoteTracking_new,
&rightTrackedRemoteState_new, &rightTrackedRemoteState_old, &rightRemoteTracking_new,
} else {
//Left handed
HandleInput_Default(controlscheme, &leftTrackedRemoteState_new, &leftTrackedRemoteState_old,
&leftRemoteTracking_new,
&rightTrackedRemoteState_new, &rightTrackedRemoteState_old,
&rightRemoteTracking_new,
ovrButton_X, ovrButton_Y, ovrButton_A, ovrButton_B);
break;
}
}

View file

@ -31,6 +31,7 @@ typedef struct {
vec3_t hmdorientation_last; // Don't use this, it is just for calculating delta!
vec3_t hmdorientation_delta;
vec3_t weaponangles_unadjusted;
vec3_t weaponangles;
vec3_t weaponangles_last; // Don't use this, it is just for calculating delta!
vec3_t weaponangles_delta;

View file

@ -60,6 +60,7 @@ extern bool inGameGuiActive;
extern bool objectiveSystemActive;
extern bool inCinematic;
void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTracking* pOffTracking,
int domButton1, int domButton2, int offButton1, int offButton2 )
@ -127,6 +128,9 @@ void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDomina
{
//Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick
vec3_t rotation = {0};
rotation[PITCH] = 30;
QuatToYawPitchRoll(pWeapon->HeadPose.Pose.Orientation, rotation, pVRClientInfo->weaponangles_unadjusted);
rotation[PITCH] = vr_weapon_pitchadjust;
QuatToYawPitchRoll(pWeapon->HeadPose.Pose.Orientation, rotation, pVRClientInfo->weaponangles);

View file

@ -4449,7 +4449,7 @@ void idPlayer::UpdateFocus( void ) {
//Use unadjusted weapon angles to control GUIs
idMat3 weaponViewAxis;
idAngles weaponViewAngles;
CalculateViewWeaponPos(start, weaponViewAxis, weaponViewAngles);
CalculateViewWeaponPos(true, start, weaponViewAxis, weaponViewAngles);
end = start + (weaponViewAngles.ToForward() * 80.0f);
// player identification -> names to the hud
@ -7276,7 +7276,7 @@ void idPlayer::UpdateLaserSight( )
idVec3 muzzleOrigin;
idMat3 muzzleAxis;
idAngles muzzleAngles;
CalculateViewWeaponPos( muzzleOrigin, muzzleAxis, muzzleAngles );
CalculateViewWeaponPos( false, muzzleOrigin, muzzleAxis, muzzleAngles );
idVec3 end, start;
trace_t traceResults;
@ -7361,7 +7361,7 @@ Calculate the bobbing position of the view weapon
==============
*/
void idPlayer::CalculateViewWeaponPos( idVec3 &origin, idMat3 &axis, idAngles &angles ) {
void idPlayer::CalculateViewWeaponPos( bool pointer, idVec3 &origin, idMat3 &axis, idAngles &angles ) {
float scale;
float fracsin;
int delta;
@ -7373,10 +7373,11 @@ void idPlayer::CalculateViewWeaponPos( idVec3 &origin, idMat3 &axis, idAngles &a
if (pVRClientInfo &&
currentWeapon != weapon_pda)
{
angles.pitch = pVRClientInfo->weaponangles[PITCH];
float *pAngles = pointer ? pVRClientInfo->weaponangles_unadjusted : pVRClientInfo->weaponangles;
angles.pitch = pAngles[PITCH];
angles.yaw = viewAngles.yaw +
(pVRClientInfo->weaponangles[YAW] - pVRClientInfo->hmdorientation[YAW]);
angles.roll = pVRClientInfo->weaponangles[ROLL];
(pAngles[YAW] - pVRClientInfo->hmdorientation[YAW]);
angles.roll = pAngles[ROLL];
axis = angles.ToMat3();

View file

@ -432,7 +432,7 @@ public:
float DefaultFov( void ) const;
float CalcFov( bool honorZoom );
void CalculateViewWeaponPos( idVec3 &origin, idMat3 &axis, idAngles &angles );
void CalculateViewWeaponPos( bool pointer, idVec3 &origin, idMat3 &axis, idAngles &angles );
idVec3 GetEyePosition( void ) const;
void GetViewPos( idVec3 &origin, idMat3 &axis ) const;
void OffsetThirdPersonView( float angle, float range, float height, bool clip );

View file

@ -1884,7 +1884,7 @@ void idWeapon::PresentWeapon( bool showViewModel ) {
int currentWeaponId = owner->GetCurrentWeapon();
// calculate weapon position based on player movement bobbing
owner->CalculateViewWeaponPos( viewWeaponOrigin, viewWeaponAxis, viewWeaponAngles );
owner->CalculateViewWeaponPos( false, viewWeaponOrigin, viewWeaponAxis, viewWeaponAngles );
//This isn't really the right place to do this, but works for now
if (currentWeaponId == WEAPON_CHAINGUN) {