Skip to content

Commit

Permalink
New CorrectDirFromWorldToHud
Browse files Browse the repository at this point in the history
Co-Authored-By: Alex <[email protected]>
  • Loading branch information
2 people authored and xrSimpodin committed Jun 8, 2024
1 parent 8b36d8c commit 792c64b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ogsr_engine/xrGame/HudItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ActorCondition.h"
#include "Missile.h"
#include "../xr_3da/x_ray.h"
#include "../../xr_3da/igame_persistent.h"

ENGINE_API extern float psHUD_FOV_def;

Expand Down Expand Up @@ -1271,16 +1272,17 @@ void CHudItem::GetBoneOffsetPosDir(const shared_str& bone_name, Fvector& dest_po

extern ENGINE_API float psHUD_FOV;

void CHudItem::CorrectDirFromWorldToHud(Fvector& dir)
void CHudItem::CorrectDirFromWorldToHud(Fvector& worldPos)
{
const float Fov = Device.fFOV;
const float HudFov = psHUD_FOV <= 1.f ? psHUD_FOV * Device.fFOV : psHUD_FOV;
const float diff = hud_recalc_koef * Fov / HudFov;
const auto& CamDir = Device.vCameraDirection;
dir.sub(CamDir);
dir.mul(diff);
dir.add(CamDir);
dir.normalize();
Fmatrix hud_project;
hud_project.build_projection(deg2rad(psHUD_FOV <= 1.f ? psHUD_FOV * Device.fFOV : psHUD_FOV), Device.fASPECT, HUD_VIEWPORT_NEAR,
g_pGamePersistent->Environment().CurrentEnv->far_plane);

Device.mView.transform_dir(worldPos);
hud_project.transform_dir(worldPos);

Fmatrix{Device.mProject}.invert().transform_dir(worldPos);
Fmatrix{Device.mView}.invert().transform_dir(worldPos);
}

void CHudItem::TimeLockAnimation()
Expand Down

0 comments on commit 792c64b

Please sign in to comment.