mirror of
https://github.com/open-goal/jak-project
synced 2026-08-03 00:47:12 -04:00
d1ece445d4
Relates to #1353 This adds no new functionality or overhead to the compiler, yet. This is the preliminary work that has: - added code to the compiler in several spots to flag when something is used without being properly required/imported/whatever (disabled by default) - that was used to generate project wide file dependencies (some circulars were manually fixed) - then that graph underwent a transitive reduction and the result was written to all `jak1` source files. The next step will be making this actually produce and use a dependency graph. Some of the reasons why I'm working on this: - eliminates more `game.gp` boilerplate. This includes the `.gd` files to some extent (`*-ag` files and `tpage` files will still need to be handled) this is the point of the new `bundles` form. This should make it even easier to add a new file into the source tree. - a build order that is actually informed from something real and compiler warnings that tell you when you are using something that won't be available at build time. - narrows the search space for doing LSP actions -- like searching for references. Since it would be way too much work to store in the compiler every location where every symbol/function/etc is used, I have to do ad-hoc searches. By having a dependency graph i can significantly reduce that search space. - opens the doors for common shared code with a legitimate pattern. Right now jak 2 shares code from the jak 1 folder. This is basically a hack -- but by having an explicit require syntax, it would be possible to reference arbitrary file paths, such as a `common` folder. Some stats: - Jak 1 has about 2500 edges between files, including transitives - With transitives reduced at the source code level, each file seems to have a modest amount of explicit requirements. Known issues: - Tracking the location for where `defmacro`s and virtual state definitions were defined (and therefore the file) is still problematic. Because those forms are in a macro environment, the reader does not track them. I'm wondering if a workaround could be to search the reader's text_db by not just the `goos::Object` but by the text position. But for the purposes of finishing this work, I just statically analyzed and searched the code with throwaway python code.
188 lines
6.5 KiB
Common Lisp
188 lines
6.5 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
|
|
(require "engine/anim/aligner-h.gc")
|
|
(require "engine/common-obs/process-drawable.gc")
|
|
|
|
;; name: aligner.gc
|
|
;; name in dgo: aligner
|
|
;; dgos: GAME, ENGINE
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
;; ERROR: Unsupported inline assembly instruction kind - [lw ra, return-from-thread(s7)]
|
|
;; ERROR: Unsupported inline assembly instruction kind - [jr ra]
|
|
(defmethod compute-alignment! ((this align-control))
|
|
(local-vars (a0-9 symbol) (s7-0 none) (ra-0 int))
|
|
(with-pp
|
|
(let ((s5-0 (-> this process skel active-channels)))
|
|
(dotimes (s4-0 s5-0)
|
|
(let* ((a0-3 (-> this process skel channel s4-0))
|
|
(v1-5 (-> a0-3 frame-group))
|
|
(a0-4 (-> a0-3 command))
|
|
(a1-0 'stack)
|
|
(a2-0 (= a0-4 a1-0))
|
|
)
|
|
(cond
|
|
((or a2-0 (begin (set! a1-0 'stack1) (= a0-4 a1-0)))
|
|
)
|
|
(else
|
|
(when (!= (-> v1-5 type) art-joint-anim)
|
|
;; og:preserve-this
|
|
(go process-drawable-art-error "align joint-anim")
|
|
(abandon-thread)
|
|
0
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(let* ((a0-8 (-> this process skel root-channel 0))
|
|
(v1-16 (-> a0-8 frame-group))
|
|
(f0-0 (-> a0-8 frame-num))
|
|
)
|
|
(= (-> a0-8 num-func) num-func-loop!)
|
|
(cond
|
|
((or (not v1-16) (!= (-> this frame-group) v1-16))
|
|
(set! a0-9 #t)
|
|
)
|
|
((= (-> a0-8 num-func) num-func-loop!)
|
|
(set! a0-9 (< (* (-> a0-8 param 0) (- f0-0 (-> this frame-num))) 0.0))
|
|
)
|
|
(else
|
|
(set! a0-9 (= f0-0 0.0))
|
|
)
|
|
)
|
|
(if a0-9
|
|
(logior! (-> this flags) (align-flags disabled))
|
|
(logclear! (-> this flags) (align-flags disabled))
|
|
)
|
|
(set! (-> this frame-group) v1-16)
|
|
(set! (-> this frame-num) f0-0)
|
|
)
|
|
(mem-copy! (the-as pointer (-> this transform 1)) (the-as pointer (-> this transform)) 48)
|
|
(quaternion-copy! (the-as quaternion (-> this transform 1 rot)) (-> this align quat))
|
|
(set! (-> this transform 1 scale quad) (-> this align scale quad))
|
|
(let* ((a2-5 (-> this matrix 1 vector))
|
|
(a3-0 (-> this matrix))
|
|
(v1-19 (-> a3-0 0 vector 0 quad))
|
|
(a0-18 (-> a3-0 0 vector 1 quad))
|
|
(a1-12 (-> a3-0 0 vector 2 quad))
|
|
(a3-1 (-> a3-0 0 vector 3 quad))
|
|
)
|
|
(set! (-> a2-5 0 quad) v1-19)
|
|
(set! (-> a2-5 1 quad) a0-18)
|
|
(set! (-> a2-5 2 quad) a1-12)
|
|
(set! (-> a2-5 3 quad) a3-1)
|
|
)
|
|
(let ((s5-1 (-> this process node-list data 1)))
|
|
(cspace<-matrix-no-push-joint! s5-1 (-> this process skel))
|
|
(let* ((v1-23 (-> this matrix))
|
|
(a3-2 (-> s5-1 bone transform))
|
|
(a0-21 (-> a3-2 vector 0 quad))
|
|
(a1-14 (-> a3-2 vector 1 quad))
|
|
(a2-6 (-> a3-2 vector 2 quad))
|
|
(a3-3 (-> a3-2 vector 3 quad))
|
|
)
|
|
(set! (-> v1-23 0 vector 0 quad) a0-21)
|
|
(set! (-> v1-23 0 vector 1 quad) a1-14)
|
|
(set! (-> v1-23 0 vector 2 quad) a2-6)
|
|
(set! (-> v1-23 0 vector 3 quad) a3-3)
|
|
)
|
|
(vector*! (the-as vector (-> this transform)) (-> s5-1 bone transform vector 3) (-> this process root scale))
|
|
)
|
|
(vector-!
|
|
(the-as vector (-> this delta))
|
|
(the-as vector (-> this transform))
|
|
(the-as vector (-> this transform 1))
|
|
)
|
|
(set-vector!
|
|
(-> this align scale)
|
|
(vector-length (the-as vector (-> this matrix)))
|
|
(vector-length (-> this matrix 0 vector 1))
|
|
(vector-length (-> this matrix 0 vector 2))
|
|
1.0
|
|
)
|
|
(vector-! (-> this delta scale) (-> this align scale) (-> this transform 1 scale))
|
|
(let ((a2-8 (matrix-inv-scale! (new 'stack-no-clear 'matrix) (-> this align scale))))
|
|
(quaternion-normalize!
|
|
(matrix->quaternion (-> this align quat) (matrix*! a2-8 (the-as matrix (-> this matrix)) a2-8))
|
|
)
|
|
)
|
|
(let ((a1-24 (quaternion-inverse! (new 'stack-no-clear 'quaternion) (the-as quaternion (-> this transform 1 rot))))
|
|
)
|
|
(quaternion-normalize! (quaternion*! (-> this delta quat) a1-24 (-> this align quat)))
|
|
)
|
|
(-> this delta)
|
|
)
|
|
)
|
|
|
|
(defmethod first-transform ((this align-control))
|
|
(the-as transform (-> this transform))
|
|
)
|
|
|
|
(defmethod snd-transform ((this align-control))
|
|
(-> this transform 1)
|
|
)
|
|
|
|
(defmethod align! ((this align-control) (arg0 align-opts) (arg1 float) (arg2 float) (arg3 float))
|
|
(when (not (logtest? (-> this flags) (align-flags disabled)))
|
|
(let* ((a0-1 (-> this process))
|
|
(t9-0 (method-of-object a0-1 apply-alignment))
|
|
(v1-4 (-> this delta))
|
|
(t1-0 (new 'stack-no-clear 'vector))
|
|
)
|
|
(set! (-> t1-0 x) arg1)
|
|
(set! (-> t1-0 y) arg2)
|
|
(set! (-> t1-0 z) arg3)
|
|
(set! (-> t1-0 w) 1.0)
|
|
(t9-0 a0-1 arg0 v1-4 t1-0)
|
|
)
|
|
)
|
|
(-> this process root)
|
|
)
|
|
|
|
(defmethod set-and-limit-velocity ((this trsqv) (arg0 int) (arg1 vector) (arg2 float))
|
|
(let ((gp-0 (-> this transv)))
|
|
(when (logtest? arg0 4)
|
|
(set! (-> gp-0 x) (-> arg1 x))
|
|
(set! (-> gp-0 z) (-> arg1 z))
|
|
(let ((f0-4 (fmin (* (vector-xz-length arg1) (-> *display* frames-per-second)) arg2)))
|
|
(vector-xz-normalize! gp-0 f0-4)
|
|
)
|
|
)
|
|
)
|
|
this
|
|
)
|
|
|
|
(defmethod align-vel-and-quat-only! ((this align-control) (arg0 align-opts) (arg1 vector) (arg2 int) (arg3 float) (arg4 float))
|
|
(when (not (logtest? (-> this flags) (align-flags disabled)))
|
|
(let ((s5-0 (-> this delta)))
|
|
(let ((s3-0 (-> this process root transv)))
|
|
(if (logtest? arg0 (align-opts adjust-y-vel))
|
|
(set! (-> s3-0 y) (* (-> s5-0 trans y) arg3 (-> *display* frames-per-second)))
|
|
)
|
|
(when (logtest? arg0 (align-opts adjust-xz-vel))
|
|
(set! (-> s3-0 x) (-> arg1 x))
|
|
(set! (-> s3-0 z) (-> arg1 z))
|
|
(let ((f0-8 (* (fmin (vector-xz-length arg1) (* (vector-xz-length (-> s5-0 trans)) arg4))
|
|
(-> *display* frames-per-second)
|
|
)
|
|
)
|
|
(t9-2 vector-xz-normalize!)
|
|
)
|
|
(set! (-> this last-speed) f0-8)
|
|
(t9-2 s3-0 f0-8)
|
|
)
|
|
)
|
|
)
|
|
(if (logtest? arg0 (align-opts adjust-quat))
|
|
(quaternion-normalize! (quaternion*! (-> this process root quat) (-> this process root quat) (-> s5-0 quat)))
|
|
)
|
|
)
|
|
)
|
|
(-> this process root)
|
|
)
|