jak-project/goal_src/jak3/engine/collide/collide-debug.gc
Hat Kid 93afb02cf4
decomp3: spawn target, add merc and particle buckets and some temporary hacks (#3445)
This includes all the collision stuff needed to spawn `target`,
decompiles the sparticle code and adds some of the PC hacks needed for
merc to run (it doesn't work quite right and looks bad, likely due to a
combination of code copied from Jak 2 and the time of day hacks).

There are a bunch of temporary hacks (see commits) in place to prevent
the game from crashing quite as much, but it is still extremely prone to
doing so due to lots of missing functions/potentially bad decomp.

---------

Co-authored-by: water <awaterford111445@gmail.com>
2024-04-05 00:07:39 -04:00

295 lines
11 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: collide-debug.gc
;; name in dgo: collide-debug
;; dgos: GAME
;; DECOMP BEGINS
;; this file is debug only
(declare-file (debug))
(defmethod debug-draw ((this collide-cache))
(let ((gp-0 (the-as object (-> this tris))))
(countdown (s4-0 (-> this num-tris))
(let ((t1-0 (copy-and-set-field (-> *pat-mode-info* (-> (the-as collide-cache-tri gp-0) pat mode) color) a 64)))
(add-debug-flat-triangle
#t
(bucket-id debug-no-zbuf1)
(the-as vector (-> (the-as collide-cache-tri gp-0) vertex))
(-> (the-as collide-cache-tri gp-0) vertex 1)
(-> (the-as collide-cache-tri gp-0) vertex 2)
t1-0
)
)
(set! gp-0 (&+ (the-as collide-cache-tri gp-0) 64))
)
)
(let ((gp-1 (the-as object (-> this prims))))
(countdown (s5-1 (-> this num-prims))
(when (= (-> (the-as collide-cache-prim gp-1) prim-core prim-type) -1)
(let ((t0-1
(copy-and-set-field
(-> *pat-mode-info*
(-> (the-as collide-shape-prim-sphere (-> (the-as collide-shape-prim gp-1) prim-core action)) pat mode)
color
)
a
64
)
)
)
(add-debug-sphere
#t
(bucket-id debug-no-zbuf1)
(the-as vector (-> (the-as collide-cache-prim gp-1) prim-core))
(-> (the-as collide-cache-prim gp-1) prim-core world-sphere w)
t0-1
)
)
)
(set! gp-1 (&+ (the-as collide-cache-prim gp-1) 48))
)
)
(print-collide-cache-tri-count)
0
(none)
)
(deftype col-rend-filter (structure)
((show-pat-set pat-surface)
(show-pat-clear pat-surface)
(event-mask uint32)
)
)
;; WARN: Return type mismatch symbol vs none.
(defun col-rend-draw ((arg0 col-rend) (arg1 col-rend-filter))
(let ((s4-0 (new 'stack-no-clear 'matrix)))
(set! (-> s4-0 rvec quad) (-> (math-camera-matrix) fvec quad))
(vector-normalize! (-> s4-0 rvec) 1.0)
(let ((s3-1 (the-as collide-cache-tri (-> *collide-cache* tris))))
(countdown (s2-0 (-> *collide-cache* num-tris))
(vector-3pt-cross! (-> s4-0 uvec) (the-as vector (-> s3-1 vertex)) (-> s3-1 vertex 1) (-> s3-1 vertex 2))
(vector-normalize! (-> s4-0 uvec) 1.0)
(when (or (-> arg0 show-back-faces?) (>= 0.0 (vector-dot (-> s4-0 rvec) (-> s4-0 uvec))))
(let ((v1-9 (-> s3-1 pat)))
(cond
((and (or (zero? (-> arg1 show-pat-set)) (logtest? v1-9 (-> arg1 show-pat-set)))
(or (zero? (-> arg1 show-pat-clear)) (not (logtest? v1-9 (-> arg1 show-pat-clear))))
(or (zero? (-> arg1 event-mask)) (logtest? (-> arg1 event-mask) (ash 1 (the-as int (-> v1-9 event)))))
)
(let ((t1-0 (copy-and-set-field (-> *pat-mode-info* (-> v1-9 mode) color) a 64)))
(add-debug-flat-triangle
#t
(bucket-id debug-no-zbuf1)
(the-as vector (-> s3-1 vertex))
(-> s3-1 vertex 1)
(-> s3-1 vertex 2)
t1-0
)
)
(if (-> arg0 outline?)
(add-debug-outline-triangle
#t
(bucket-id debug-no-zbuf1)
(the-as vector (-> s3-1 vertex))
(-> s3-1 vertex 1)
(-> s3-1 vertex 2)
(new 'static 'rgba :r #x10 :g #x10 :b #x10 :a #x80)
)
)
(when (-> arg0 show-normals?)
(vector+! (-> s4-0 fvec) (the-as vector (-> s3-1 vertex)) (-> s3-1 vertex 1))
(vector+! (-> s4-0 fvec) (-> s4-0 fvec) (-> s3-1 vertex 2))
(vector-float/! (-> s4-0 fvec) (-> s4-0 fvec) 3.0)
(add-debug-vector
#t
(bucket-id debug-no-zbuf1)
(-> s4-0 fvec)
(-> s4-0 uvec)
(meters 0.75)
(new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80)
)
)
)
((-> arg0 ghost-hidden?)
(add-debug-flat-triangle
#t
(bucket-id debug-no-zbuf1)
(the-as vector (-> s3-1 vertex))
(-> s3-1 vertex 1)
(-> s3-1 vertex 2)
(new 'static 'rgba :r #x20 :g #x20 :b #x20 :a #x20)
)
(if (-> arg0 outline?)
(add-debug-outline-triangle
#t
(bucket-id debug-no-zbuf1)
(the-as vector (-> s3-1 vertex))
(-> s3-1 vertex 1)
(-> s3-1 vertex 2)
(new 'static 'rgba :r #x10 :g #x10 :b #x10 :a #x10)
)
)
)
)
)
)
(&+! s3-1 64)
)
)
)
(let ((s5-1 (the-as object (-> *collide-cache* prims))))
(countdown (s4-1 (-> *collide-cache* num-prims))
(when (= (-> (the-as collide-cache-prim s5-1) prim-core prim-type) -1)
(let ((v1-37 (-> (the-as collide-shape-prim-sphere (-> (the-as collide-cache-prim s5-1) prim)) pat)))
(when (and (or (zero? (-> arg1 show-pat-set)) (logtest? v1-37 (-> arg1 show-pat-set)))
(or (zero? (-> arg1 show-pat-clear)) (not (logtest? v1-37 (-> arg1 show-pat-clear))))
(or (zero? (-> arg1 event-mask)) (logtest? (-> arg1 event-mask) (ash 1 (the-as int (-> v1-37 event)))))
)
(let ((t0-5 (copy-and-set-field (-> *pat-mode-info* (-> v1-37 mode) color) a 64)))
(add-debug-sphere
#t
(bucket-id debug-no-zbuf1)
(the-as vector (-> (the-as collide-cache-prim s5-1) prim-core))
(-> (the-as collide-cache-prim s5-1) prim-core world-sphere w)
t0-5
)
)
)
)
)
(set! s5-1 (&+ (the-as collide-cache-prim s5-1) 48))
)
)
(none)
)
(defmethod draw ((this col-rend))
(let ((s5-0 (new 'stack-no-clear 'collide-query)))
(let ((f30-0 (-> this bbox-radius)))
(let ((v1-0 (-> this track)))
(cond
((zero? v1-0)
(set! (-> this bbox-center quad) (-> (target-pos 0) quad))
(+! (-> this bbox-center y) (* 0.7 f30-0))
)
((= v1-0 1)
(position-in-front-of-camera!
(-> this bbox-center)
(+ (-> this camera-to-bbox-dist) (-> this bbox-radius))
0.0
)
)
)
)
(set! (-> s5-0 bbox min quad) (-> this bbox-center quad))
(set! (-> s5-0 bbox min x) (- (-> s5-0 bbox min x) f30-0))
(set! (-> s5-0 bbox min y) (- (-> s5-0 bbox min y) f30-0))
(set! (-> s5-0 bbox min z) (- (-> s5-0 bbox min z) f30-0))
(set! (-> s5-0 bbox max quad) (-> this bbox-center quad))
(+! (-> s5-0 bbox max x) f30-0)
(+! (-> s5-0 bbox max y) f30-0)
(+! (-> s5-0 bbox max z) f30-0)
)
(let ((v1-9 -1))
(let ((a0-9 (-> this cspec)))
(if (not (logtest? a0-9 (collide-spec crate)))
(set! v1-9 (logxor v1-9 1))
)
(if (not (logtest? a0-9 (collide-spec civilian)))
(set! v1-9 (logxor v1-9 64))
)
(if (not (logtest? a0-9 (collide-spec enemy)))
(set! v1-9 (logxor #x100000 v1-9))
)
(if (not (logtest? a0-9 (collide-spec obstacle)))
(set! v1-9 (logxor v1-9 2))
)
(if (not (logtest? a0-9 (collide-spec vehicle-sphere)))
(set! v1-9 (logand #x100743 v1-9))
)
)
(set! (-> s5-0 collide-with) (the-as collide-spec v1-9))
)
(set! (-> s5-0 ignore-pat) (new 'static 'pat-surface))
(set! (-> s5-0 ignore-process0) #f)
(set! (-> s5-0 ignore-process1) #f)
(add-debug-box
#t
(bucket-id debug)
(the-as vector (-> s5-0 bbox))
(-> s5-0 bbox max)
(if (logtest? (current-time) 128)
(new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x20)
(new 'static 'rgba :a #x20)
)
)
(fill-using-bounding-box *collide-cache* s5-0)
)
(let ((s5-1 (-> this show-only))
(a1-17 (new 'stack 'col-rend-filter))
)
(when (nonzero? s5-1)
(cond
((logtest? s5-1 8)
(set! (-> a1-17 show-pat-clear) (new 'static 'pat-surface :noboard #x1))
)
((logtest? s5-1 16)
(set! (-> a1-17 show-pat-clear) (new 'static 'pat-surface :nogrind #x1))
)
((logtest? s5-1 32)
(set! (-> a1-17 show-pat-clear) (new 'static 'pat-surface :nogrind #x1))
(set! (-> a1-17 show-pat-set) (new 'static 'pat-surface :nojak #x1 :board #x1))
)
(else
(if (logtest? s5-1 8192)
(logior! (-> a1-17 show-pat-set) (new 'static 'pat-surface :nolineofsight #x1))
)
(if (logtest? s5-1 1024)
(set! (-> a1-17 show-pat-set noentity) 1)
)
(if (logtest? s5-1 64)
(set! (-> a1-17 show-pat-set noboard) 1)
)
(if (logtest? s5-1 2048)
(set! (-> a1-17 show-pat-set nogrind) 1)
)
(if (logtest? s5-1 128)
(set! (-> a1-17 show-pat-set nocamera) 1)
)
(if (logtest? s5-1 4096)
(set! (-> a1-17 show-pat-set nojak) 1)
)
(if (logtest? s5-1 256)
(set! (-> a1-17 show-pat-set noedge) 1)
)
(if (logtest? s5-1 #x8000)
(set! (-> a1-17 show-pat-set nopilot) 1)
)
(if (logtest? s5-1 512)
(logior! (-> a1-17 show-pat-set) (new 'static 'pat-surface :noendlessfall #x1))
)
(if (logtest? s5-1 #x4000)
(logior! (-> a1-17 show-pat-set) (new 'static 'pat-surface :nomech #x1))
)
(if (logtest? #x10000 s5-1)
(logior! (-> a1-17 show-pat-set) (new 'static 'pat-surface :noproj #x1))
)
(if (logtest? #x40000 s5-1)
(logior! (-> a1-17 show-pat-set) (new 'static 'pat-surface :probe #x1))
)
(if (logtest? #x20000 s5-1)
(logior! (-> a1-17 event-mask) 64)
)
)
)
)
(col-rend-draw this a1-17)
)
(none)
)