mirror of
https://github.com/open-goal/jak-project
synced 2026-06-10 04:54:31 -04:00
79d14af0b5
I finally read through all the joint code and wrote up some documentation. I think this will be really helpful when we try to understand all the functions in `process-drawable`, or if somebody ever wants to import/export animations. This switches all three games to using a new faster GOAL joint decompressor. It is on by default, but you can go back to the old version by setting `*use-new-decompressor*` to false. Also fix the log-related crash, fix the clock speed used in timer math.
74 lines
2.2 KiB
Common Lisp
74 lines
2.2 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: matrix-h.gc
|
|
;; name in dgo: matrix-h
|
|
;; dgos: ENGINE, GAME
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
;; A 4x4 matrix, stored in row-major order
|
|
;; some, but not all, functions assume that a matrix is an affine transform.
|
|
;; others assume that the rotation has no scale or shear (and that its inverse is its transpose)
|
|
(deftype matrix (structure)
|
|
((data float 16)
|
|
(vector vector 4 :inline :overlay-at (-> data 0))
|
|
(quad uint128 4 :overlay-at (-> data 0))
|
|
(trans vector :inline :overlay-at (-> data 12))
|
|
)
|
|
(:methods
|
|
(transform-vectors! (_type_ (inline-array vector) (inline-array vector) int) none)
|
|
)
|
|
)
|
|
|
|
;; A 3x3 matrix, stored in row-major order.
|
|
;; NOTE: the rows each have an extra 4-bytes of padding
|
|
;; so this is really a 3x4 matrix.
|
|
;; this type is rarely used
|
|
(deftype matrix3 (structure)
|
|
((data float 12)
|
|
(vector vector 3 :inline :overlay-at (-> data 0))
|
|
(quad uint128 3 :overlay-at (-> data 0))
|
|
)
|
|
)
|
|
|
|
;; a matrix stored using 16-bit integers.
|
|
;; note that these usually have different scaling for the 4th row which
|
|
;; contains the translation in an affine transform.
|
|
;; so you generally should not unpack these to floats without knowing where they came from
|
|
;; and how they were originally packed (for example, in tie/shrub)
|
|
(deftype matrix4h (structure)
|
|
((data int16 16)
|
|
(vector4h vector4h 4 :inline :overlay-at (-> data 0))
|
|
(long int64 4 :overlay-at (-> data 0))
|
|
)
|
|
)
|
|
|
|
|
|
(defun matrix-copy! ((arg0 matrix) (arg1 matrix))
|
|
"Copy arg1 to arg0"
|
|
(declare (inline))
|
|
(let ((v1-0 (-> arg1 quad 0))
|
|
(a2-0 (-> arg1 quad 1))
|
|
(a3-0 (-> arg1 quad 2))
|
|
(a1-1 (-> arg1 trans quad))
|
|
)
|
|
(set! (-> arg0 quad 0) v1-0)
|
|
(set! (-> arg0 quad 1) a2-0)
|
|
(set! (-> arg0 quad 2) a3-0)
|
|
(set! (-> arg0 trans quad) a1-1)
|
|
)
|
|
arg0
|
|
)
|
|
|
|
(defmacro new-stack-matrix0 ()
|
|
"Get a new matrix on the stack that's set to zero."
|
|
`(let ((mat (new 'stack-no-clear 'matrix)))
|
|
(set! (-> mat quad 0) (the-as uint128 0))
|
|
(set! (-> mat quad 1) (the-as uint128 0))
|
|
(set! (-> mat quad 2) (the-as uint128 0))
|
|
(set! (-> mat quad 3) (the-as uint128 0))
|
|
mat
|
|
)
|
|
)
|