Files
jak-project/goal_src/jak2/engine/gfx/math-camera-h.gc
T
ManDude cd68cb671e deftype and defmethod syntax major changes (#3094)
Major change to how `deftype` shows up in our code:
- the decompiler will no longer emit the `offset-assert`,
`method-count-assert`, `size-assert` and `flag-assert` parameters. There
are extremely few cases where having this in the decompiled code is
helpful, as the types there come from `all-types` which already has
those parameters. This also doesn't break type consistency because:
  - the asserts aren't compared.
- the first step of the test uses `all-types`, which has the asserts,
which will throw an error if they're bad.
- the decompiler won't emit the `heap-base` parameter unless necessary
now.
- the decompiler will try its hardest to turn a fixed-offset field into
an `overlay-at` field. It falls back to the old offset if all else
fails.
- `overlay-at` now supports field "dereferencing" to specify the offset
that's within a field that's a structure, e.g.:
```lisp
(deftype foobar (structure)
  ((vec    vector  :inline)
   (flags  int32   :overlay-at (-> vec w))
   )
  )
```
in this structure, the offset of `flags` will be 12 because that is the
final offset of `vec`'s `w` field within this structure.
- **removed ID from all method declarations.** IDs are only ever
automatically assigned now. Fixes #3068.
- added an `:overlay` parameter to method declarations, in order to
declare a new method that goes on top of a previously-defined method.
Syntax is `:overlay <method-name>`. Please do not ever use this.
- added `state-methods` list parameter. This lets you quickly specify a
list of states to be put in the method table. Same syntax as the
`states` list parameter. The decompiler will try to put as many states
in this as it can without messing with the method ID order.

Also changes `defmethod` to make the first type definition (before the
arguments) optional. The type can now be inferred from the first
argument. Fixes #3093.

---------

Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
2023-10-30 03:20:02 +00:00

117 lines
4.1 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: math-camera-h.gc
;; name in dgo: math-camera-h
;; dgos: ENGINE, GAME
#|@file
The "math-camera" is responsible for computing the projection matrix used in the renderer
from the position of the in-game camera. It also computes some other common camera info.
See cam-update.gc for how the game camera updates the math-camera.
It also contains some GIF stuff, but these seem to be wrong/unused.
Some of the code here may be extremely old and unused, but this does compute the camera projection
matrix used almost everywhere.
|#
;; DECOMP BEGINS
;; unused...
(deftype vis-gif-tag (structure)
((fog0 uint32)
(strip uint32)
(regs uint32)
(fan uint32)
)
)
;; also seems unused?
(deftype cull-info (structure)
((x-fact float)
(y-fact float)
(z-fact float)
(cam-radius float)
(cam-x float)
(cam-y float)
(xz-dir-ax float)
(xz-dir-az float)
(xz-dir-bx float)
(xz-dir-bz float)
(xz-cross-ab float)
(yz-dir-ay float)
(yz-dir-az float)
(yz-dir-by float)
(yz-dir-bz float)
(yz-cross-ab float)
)
:allow-misaligned
)
(deftype math-camera (basic)
((d meters)
(f meters)
(fov degrees)
(x-ratio float)
(y-ratio float)
(x-pix float)
(x-clip float)
(x-clip-ratio-in float)
(x-clip-ratio-over float)
(y-pix float)
(y-clip float)
(y-clip-ratio-in float)
(y-clip-ratio-over float)
(cull-info cull-info :inline)
(fog-start meters)
(fog-end meters)
(fog-max float)
(fog-min float)
(reset int32)
(smooth-step float)
(smooth-t float)
(perspective matrix :inline)
(isometric matrix :inline)
(sprite-2d matrix :inline)
(sprite-2d-hvdf vector :inline)
(camera-rot matrix :inline)
(inv-camera-rot matrix :inline)
(inv-camera-rot-smooth matrix :inline)
(inv-camera-rot-smooth-from quaternion :inline)
(camera-temp matrix :inline)
(prev-camera-temp matrix :inline)
(prev-inv-camera-rot matrix :inline)
(prev-trans vector :inline)
(hmge-scale vector :inline)
(inv-hmge-scale vector :inline)
(hvdf-off vector :inline)
(guard vector :inline)
(vis-gifs vis-gif-tag 4 :inline)
(giftex uint128 :overlay-at (-> vis-gifs 0 fog0))
(gifgr uint128 :offset 864)
(giftex-trans uint128 :offset 880)
(gifgr-trans uint128 :offset 896)
(pfog0 float)
(pfog1 float)
(trans vector :inline)
(plane plane 4 :inline)
(guard-plane plane 4 :inline)
(shrub-mat matrix :inline)
(quat-other quaternion :inline)
(trans-other vector :inline)
(shrub-mat-other matrix :inline)
(camera-temp-other matrix :inline)
(camera-rot-other matrix :inline)
(inv-camera-rot-other matrix :inline)
(plane-other plane 4 :inline)
(guard-plane-other plane 4 :inline)
(mirror-trans vector :inline)
(mirror-normal vector :inline)
(fov-correction-factor float)
)
(:methods
(new (symbol type) _type_)
)
)