Fix crash introduced by stabilised weapon logic

This commit is contained in:
Simon 2021-04-07 22:02:35 +01:00
parent 57ddffc72d
commit 4ee1197373
4 changed files with 21 additions and 13 deletions

View file

@ -13486,7 +13486,7 @@ void idPlayer::CalculateViewWeaponPosVR( int hand, idVec3 &origin, idMat3 &axis
commonVr->MotionControlGetHand( hand, hands[ hand ].motionPosition, hands[ hand ].motionRotation ); commonVr->MotionControlGetHand( hand, hands[ hand ].motionPosition, hands[ hand ].motionRotation );
if (!pVRClientInfo->weapon_stabilised) if (!commonVr->GetWeaponStabilised())
{ {
weaponPitch = idAngles( vr_motionWeaponPitchAdj.GetFloat(), 0.0f, 0.0f ).ToQuat(); weaponPitch = idAngles( vr_motionWeaponPitchAdj.GetFloat(), 0.0f, 0.0f ).ToQuat();
hands[hand].motionRotation = weaponPitch * hands[hand].motionRotation; hands[hand].motionRotation = weaponPitch * hands[hand].motionRotation;
@ -13762,7 +13762,7 @@ void idPlayer::CalculateViewFlashlightPos( idVec3 &origin, idMat3 &axis, idVec3
axis = idAngles( 0.0, viewAngles.yaw - commonVr->bodyYawOffset, 0.0f ).ToMat3(); axis = idAngles( 0.0, viewAngles.yaw - commonVr->bodyYawOffset, 0.0f ).ToMat3();
int flashlightMode = commonVr->GetCurrentFlashlightMode(); int flashlightMode = commonVr->GetCurrentFlashlightMode();
if (pVRClientInfo->weapon_stabilised && flashlightMode == FLASHLIGHT_HAND ) if (commonVr->GetWeaponStabilised() && flashlightMode == FLASHLIGHT_HAND )
{ {
flashlightMode = FLASHLIGHT_GUN; flashlightMode = FLASHLIGHT_GUN;
} }

View file

@ -1098,6 +1098,16 @@ void iVr::CalcAimMove( float &yawDelta, float &pitchDelta )
} }
bool iVr::GetWeaponStabilised()
{
if (pVRClientInfo)
{
return pVRClientInfo->weapon_stabilised;
}
return false;
}
/* /*

View file

@ -163,6 +163,8 @@ public:
void MotionControllerSetHapticOculus( float low, float hi ); void MotionControllerSetHapticOculus( float low, float hi );
void MotionControllerSetHapticOpenVR( int hand, unsigned short value ); void MotionControllerSetHapticOpenVR( int hand, unsigned short value );
bool GetWeaponStabilised();
//void MSAAResolve( void ); //void MSAAResolve( void );
//void FXAAResolve( idImage * leftCurrent, idImage * rightCurrent ); //void FXAAResolve( idImage * leftCurrent, idImage * rightCurrent );
//void FXAASetUniforms( Framebuffer FBO ); //void FXAASetUniforms( Framebuffer FBO );

View file

@ -2092,7 +2092,7 @@ void idWeapon::BeginAttack( void ) {
} }
if (currentWeapon == WEAPON_CHAINGUN) if (currentWeapon == WEAPON_CHAINGUN)
{ {
position = pVRClientInfo->weapon_stabilised ? 4 : position; position = commonVr->GetWeaponStabilised() ? 4 : position;
common->HapticEvent("chaingun_init", position, 0, 100, 0, 0); common->HapticEvent("chaingun_init", position, 0, 100, 0, 0);
} }
if (currentWeapon == WEAPON_BFG) if (currentWeapon == WEAPON_BFG)
@ -4049,21 +4049,19 @@ void idWeapon::Event_LaunchProjectiles( int num_projectiles, float spread, float
int position = vr_weaponHand.GetInteger() ? 1 : 2; int position = vr_weaponHand.GetInteger() ? 1 : 2;
vrClientInfo *pVRClientInfo = owner->GetVRClientInfo();
if (currentWeap == WEAPON_PISTOL) if (currentWeap == WEAPON_PISTOL)
{ {
position = pVRClientInfo->weapon_stabilised ? 4 : position; position = commonVr->GetWeaponStabilised() ? 4 : position;
common->HapticEvent("pistol_fire", position, 0, 100, 0, 0); common->HapticEvent("pistol_fire", position, 0, 100, 0, 0);
} }
if (currentWeap == WEAPON_SHOTGUN) if (currentWeap == WEAPON_SHOTGUN)
{ {
position = pVRClientInfo->weapon_stabilised ? 4 : position; position = commonVr->GetWeaponStabilised() ? 4 : position;
common->HapticEvent("shotgun_fire", position, 0, 100, 0, 0); common->HapticEvent("shotgun_fire", position, 0, 100, 0, 0);
} }
if (currentWeap == WEAPON_PLASMAGUN) if (currentWeap == WEAPON_PLASMAGUN)
{ {
position = pVRClientInfo->weapon_stabilised ? 4 : position; position = commonVr->GetWeaponStabilised() ? 4 : position;
common->HapticEvent("plasmagun_fire", position, 0, 100, 0, 0); common->HapticEvent("plasmagun_fire", position, 0, 100, 0, 0);
} }
if (currentWeap == WEAPON_HANDGRENADE) if (currentWeap == WEAPON_HANDGRENADE)
@ -4072,12 +4070,12 @@ void idWeapon::Event_LaunchProjectiles( int num_projectiles, float spread, float
} }
if (currentWeap == WEAPON_MACHINEGUN) if (currentWeap == WEAPON_MACHINEGUN)
{ {
position = pVRClientInfo->weapon_stabilised ? 4 : position; position = commonVr->GetWeaponStabilised() ? 4 : position;
common->HapticEvent("machinegun_fire", position, 0, 100, 0, 0); common->HapticEvent("machinegun_fire", position, 0, 100, 0, 0);
} }
if (currentWeap == WEAPON_CHAINGUN) if (currentWeap == WEAPON_CHAINGUN)
{ {
position = pVRClientInfo->weapon_stabilised ? 4 : position; position = commonVr->GetWeaponStabilised() ? 4 : position;
common->HapticEvent("chaingun_fire", position, 0, 100, 0, 0); common->HapticEvent("chaingun_fire", position, 0, 100, 0, 0);
} }
if (currentWeap == WEAPON_BFG) if (currentWeap == WEAPON_BFG)
@ -4086,7 +4084,7 @@ void idWeapon::Event_LaunchProjectiles( int num_projectiles, float spread, float
} }
if (currentWeap == WEAPON_ROCKETLAUNCHER) if (currentWeap == WEAPON_ROCKETLAUNCHER)
{ {
position = pVRClientInfo->weapon_stabilised ? 4 : position; position = commonVr->GetWeaponStabilised() ? 4 : position;
common->HapticEvent("rocket_fire", position, 0, 100, 0, 0); common->HapticEvent("rocket_fire", position, 0, 100, 0, 0);
} }
@ -4247,8 +4245,6 @@ void idWeapon::Event_Melee( void ) {
gameLocal.Error( "No meleeDef on '%s'", weaponDef->dict.GetString( "classname" ) ); gameLocal.Error( "No meleeDef on '%s'", weaponDef->dict.GetString( "classname" ) );
} }
vrClientInfo *pVRClientInfo = owner->GetVRClientInfo();
weapon_t currentWeapon = IdentifyWeapon(); weapon_t currentWeapon = IdentifyWeapon();
if (currentWeapon == WEAPON_FISTS) if (currentWeapon == WEAPON_FISTS)
{ {