Closed Echo1707 closed 4 months ago
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.
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.
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.