Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HUD Lua returns field_of_view in internal angle units #496

Closed
Echo1707 opened this issue Jun 4, 2024 · 1 comment
Closed

HUD Lua returns field_of_view in internal angle units #496

Echo1707 opened this issue Jun 4, 2024 · 1 comment

Comments

@Echo1707
Copy link

Echo1707 commented Jun 4, 2024

Screen.field_of_view.horizontal returns values that are neither the player's FOV in degrees, nor the player's FOV in radians, nor the player's FOV in degrees * 360 / 512. In addition to that, as stated by treellama, that function tries to derive the FOV from the 3D view window.

Instead, a read-only variable in HUD Lua that takes the exact value of the player's FOV as set in the preferences would allow to automatically calculate the size of the 3D view to prevent landscape smearing or mirroring when looking far up or far down in certain conditions.

@treellama
Copy link
Member

Screen.field_of_view.horizontal returns the player's FOV in internal units, not degrees; that should definitely be fixed.

I think you do want the real FOV, since it will change when the player picks up an extravision or activates zoom. I made this change to Basic HUD to verify:

  -- player name
  if true then
    local r = rects["player name"]

    draw_text_center(int_fonts["player name"],
                     math.floor(Screen.field_of_view.horizontal * 360 / 512),
                     r.x + 1, r.y + 1, r.width,
                     { 0, 0, 0, 1})
    draw_text_center(int_fonts["player name"],
                     math.floor(Screen.field_of_view.horizontal * 360 / 512),
      r.x, r.y, r.width,
      InterfaceColors[Player.color.mnemonic .. " player"])
  end

And the numbers match what I expect.

HouseofMonkey_0011
HouseofMonkey_0012
HouseofMonkey_0013

I'll change the Lua API to return the actual units, as I don't believe any HUD scripts use the field_of_view angles right now.

@treellama treellama changed the title [Feature Request] New read-only player's FOV variable in HUD Lua HUD Lua returns field_of_view in internal angle units Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants