jak2: fix hud alignment (#4075)

There were a few things going on here.

Jak 2's menu wheel is zoomed in at 16:9 but zoomed out at 4:3. However,
the custom aspects use the scaling from the 4:3 mode, this makes sense
as you'd want the zoomed out wheel.

However I noticed HUD elements scaled correctly on PS2 16:9 but not PC
16:9, which was a hint.

The hardcoded values for every individual HUD element for 16:9 and 4:3
are in pixels, normalized across 480 being the stretch of the screen.

To fix the HUD alignment I scaled those offsets, scaling them inside
`set-hud-piece-position` meant both textures and merc models got scaled
at the same time.

Note that you can get (very tiny) snapping into different integer values
as you scale to different aspects. This is simply the result of scaling
integer offsets which is what the game uses.

<img width="1704" height="639" alt="2"
src="https://github.com/user-attachments/assets/81e75f7c-04ba-4c9a-8a50-215d13bd4089"
/>
This commit is contained in:
Grateful Forest 2025-12-09 11:03:01 +10:30 committed by GitHub
parent b369757207
commit abef970f58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 12 deletions

View File

@ -890,17 +890,19 @@
(let ((s3-0 (new 'stack-no-clear 'vector4w)))
(set! (-> s3-0 quad) (the-as uint128 0))
(when (transform-point-qword! s3-0 (the-as vector arg0))
(let ((s5-0 (new
'stack
'font-context
*font-default-matrix*
(+ (the int (/ (the float (+ (/ (-> s3-0 x) 16) -1792)) (-> *video-params* relative-x-scale))) -48)
(+ (/ (-> s3-0 y) 16) -1855)
0.0
(font-color orange)
(font-flags shadow kerning)
)
)
;; added for pc port, don't scale for high aspect
(let* ((scale (if (-> *pc-settings* use-vis?) (-> *video-params* relative-x-scale) 1.0))
(s5-0 (new
'stack
'font-context
*font-default-matrix*
(+ (the int (/ (the float (+ (/ (-> s3-0 x) 16) -1792)) scale)) -48)
(+ (/ (-> s3-0 y) 16) -1855)
0.0
(font-color orange)
(font-flags shadow kerning)
)
)
)
(set! (-> s5-0 scale) (lerp-scale 0.6 1.0 (the-as float arg1) 50.0 8000.0))
(let ((v1-9 s5-0))

View File

@ -1146,7 +1146,10 @@
)
(defun set-hud-piece-position! ((arg0 hud-sprite) (arg1 int) (arg2 int))
(set! (-> arg0 pos x) arg1)
;; og:preserve-this changed for pc port, scale hud for custom aspect
(if (or (not PC_PORT) (-> *pc-settings* use-vis?) (> arg1 200))
(set! (-> arg0 pos x) arg1)
(set! (-> arg0 pos x) (the int (* (the float arg1) (-> *video-params* relative-x-scale)))))
(set! (-> arg0 pos y) arg2)
0
(none)