Skip to content

Commit

Permalink
Force activated weapon scopes to render in 2D to make them usable
Browse files Browse the repository at this point in the history
  • Loading branch information
fholger committed Apr 13, 2023
1 parent 9560d48 commit 3c6e48f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Code/HUD/HUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3277,8 +3277,11 @@ void CHUD::OnPostUpdate(float frameTime)
int zoommode = m_pHUDScopes->m_iZoomLevel;

Vec3 vWorldPos;
if(!pCurrentWeapon->GetScopePosition(vWorldPos))
vWorldPos = gEnv->pRenderer->GetCamera().GetPosition();
if (!pCurrentWeapon->GetScopePosition(vWorldPos))
{
//vWorldPos = gEnv->pRenderer->GetCamera().GetPosition();
vWorldPos = gVRRenderer->GetCurrentViewCamera().GetPosition();
}

//float color[] = {1,1,1,0.5f};
//gEnv->pRenderer->Draw2dLabel(100,100,2,color,false,"%f, %f, %f",vWorldPos.x,vWorldPos.y,vWorldPos.z);
Expand Down
3 changes: 2 additions & 1 deletion Code/Single.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,8 @@ bool CSingle::CrosshairAssistAiming(const Vec3& firingPos, Vec3& firingDir, ray_
if (pEntity && m_pWeapon->IsValidAssistTarget(pEntity, pSelf, false))
return false;

const CCamera& cam = gEnv->pRenderer->GetCamera();
//const CCamera& cam = gEnv->pRenderer->GetCamera();
const CCamera& cam = gVRRenderer->GetCurrentViewCamera();
Lineseg lineseg(cam.GetPosition(), cam.GetPosition()+m_fireparams.crosshair_assist_range*cam.GetViewdir());

float t = 0.f;
Expand Down
15 changes: 15 additions & 0 deletions Code/VR/VRRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "GameCVars.h"
#include "Hooks.h"
#include "IRenderAuxGeom.h"
#include "IronSight.h"
#include "IVehicleSystem.h"
#include "OpenXRManager.h"
#include "Player.h"
Expand Down Expand Up @@ -185,6 +186,20 @@ bool VRRenderer::ShouldRenderVR() const
if (g_pGameCVars->vr_cutscenes_2d && g_pGame->GetIGameFramework()->GetIViewSystem()->IsPlayingCutScene())
return false;

CPlayer *pPlayer = static_cast<CPlayer *>(gEnv->pGame->GetIGameFramework()->GetClientActor());
if (pPlayer)
{
if (CWeapon* weapon = pPlayer->GetWeapon(pPlayer->GetCurrentItemId(true)))
{
IZoomMode* zoom = weapon->GetZoomMode(weapon->GetCurrentZoomMode());
if (CIronSight *sight = dynamic_cast<CIronSight*>(zoom))
{
if (sight->IsScope() && (sight->IsZoomed() || sight->IsZooming()))
return false;
}
}
}

return !m_binocularsActive;
}

Expand Down

0 comments on commit 3c6e48f

Please sign in to comment.