jak-project/goal_src/jak3/engine/collide/collide-edge-grab-h.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

208 lines
7.8 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: collide-edge-grab-h.gc
;; name in dgo: collide-edge-grab-h
;; dgos: GAME
;; +++collide-edge-spec-flags
(defenum collide-edge-spec-flags
:bitfield #t
:type uint64
(find-adjacent-edge 0)
(one 1)
(two 2)
(send-event 3)
)
;; ---collide-edge-spec-flags
(declare-type collide-cache-tri structure)
(declare-type collide-edge-work structure)
;; DECOMP BEGINS
(deftype pilot-edge-grab-info (structure)
"Info for edge grabs on zoomers."
((local-pos vector :inline)
(local-dir vector :inline)
(handle handle)
)
)
(deftype edge-grab-info (structure)
((world-vertex vector 8 :inline)
(local-vertex vector 8 :inline)
(status uint64)
(actor-cshape-prim-offset int32)
(actor-handle handle)
(hanging-matrix matrix :inline)
(edge-vertex vector 2 :inline :overlay-at (-> world-vertex 0))
(center-hold vector :inline :overlay-at (-> world-vertex 2))
(tri-vertex vector 3 :inline :overlay-at (-> world-vertex 3))
(adjacent-edge-left-vertex vector :inline :overlay-at (-> world-vertex 6))
(adjacent-edge-right-vertex vector :inline :overlay-at (-> world-vertex 7))
(left-hand-hold vector :inline)
(right-hand-hold vector :inline)
(center-hold-old vector :inline)
(edge-tri-pat pat-surface)
(found-edge? symbol)
(pilot-edge-grab? symbol)
(pilot-edge-grab pilot-edge-grab-info :inline)
(pilot-start-grab-pos vector :inline)
(pilot-grab-interp float)
)
(:methods
(edge-grab-info-method-9 (_type_) symbol)
(edge-grab-info-method-10 (_type_) none)
)
)
(deftype collide-edge-tri (structure)
"A triangle involved in edge grab collision."
((ctri collide-cache-tri)
(normal vector :inline)
)
)
(deftype collide-edge-edge (structure)
((ignore symbol)
(etri collide-edge-tri)
(vertex-ptr (inline-array vector) 2)
(outward vector :inline)
(edge-vec-norm vector :inline)
)
(:methods
(no-collision-at-edge (_type_ collide-edge-work edge-grab-info) symbol)
)
)
(deftype collide-edge-hold-item (structure)
((next collide-edge-hold-item)
(rating float)
(split int8)
(edge collide-edge-edge)
(center-pt vector :inline)
(outward-pt vector :inline)
)
)
(deftype collide-edge-hold-list (structure)
((num-allocs uint32)
(num-attempts uint32)
(head collide-edge-hold-item)
(items collide-edge-hold-item 32 :inline)
(attempts qword 32 :inline)
)
(:methods
(debug-draw (_type_) object)
(add-to-list! (_type_ collide-edge-hold-item) none)
)
)
(deftype collide-edge-spec (structure)
((split-dists float 2)
(outward-offset vector :inline)
(flags collide-edge-spec-flags)
(ignore-pat pat-surface)
(max-dist-sqrd-to-outward-pt float)
(max-dir-cosa-delta float)
(max-dir-cosa-player float)
(touching-segment symbol)
(local-cache-fill-box bounding-box :inline)
(local-within-reach-box bounding-box :inline)
(local-player-spheres sphere 12 :inline :offset 128)
(local-player-hanging-spheres sphere 6 :inline :overlay-at (-> local-player-spheres 0))
(local-player-leap-up-spheres sphere 6 :inline :overlay-at (-> local-player-spheres 6))
)
)
(deftype collide-edge-work (structure)
((ccache collide-cache)
(cshape collide-shape)
(num-verts uint32)
(num-edges uint32)
(num-tris uint32)
(cache-fill-box bounding-box :inline)
(within-reach-box bounding-box :inline)
(within-reach-box4w bounding-box4w :inline)
(search-pt vector :inline)
(search-dir-vec vector :inline)
(world-player-spheres sphere 12 :inline)
(world-player-hanging-spheres sphere 6 :inline :overlay-at (-> world-player-spheres 0))
(world-player-leap-up-spheres sphere 6 :inline :overlay-at (-> world-player-spheres 6))
(spec collide-edge-spec :inline)
(process (pointer process-drawable))
(verts vector 64 :inline)
(edges collide-edge-edge 96 :inline)
(tris collide-edge-tri 48 :inline)
(hold-list collide-edge-hold-list :inline)
)
(:methods
(search-for-edges (_type_ collide-edge-hold-list) none)
(debug-draw-edges (_type_) object)
(debug-draw-tris (_type_) none)
(debug-draw-sphere (_type_) none)
(find-adjacent-edge (_type_ collide-edge-hold-item edge-grab-info) none)
(compute-center-point! (_type_ collide-edge-edge vector) float)
(get-best-hand-point (_type_ vector vector int) float)
(find-grabbable-edges (_type_) none)
(find-grabbable-tris (_type_) none)
(should-add-to-list? (_type_ collide-edge-hold-item collide-edge-edge) symbol)
(find-best-grab! (_type_ collide-edge-hold-list edge-grab-info) symbol)
(check-grab-for-collisions (_type_ collide-edge-hold-item edge-grab-info) symbol)
)
)
(define *collide-edge-spec*
(new 'static 'collide-edge-spec
:split-dists (new 'static 'array float 2 1024.0 1433.6)
:outward-offset (new 'static 'vector :x 708.608 :y 13312.0 :w 1.0)
:flags (collide-edge-spec-flags send-event)
:ignore-pat (new 'static 'pat-surface :noentity #x1 :noedge #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1)
:max-dist-sqrd-to-outward-pt 37748736.0
:max-dir-cosa-delta 0.6
:touching-segment #f
:local-cache-fill-box (new 'static 'bounding-box
:min (new 'static 'vector :x -8192.0 :y -11059.2 :z -8192.0 :w 1.0)
:max (new 'static 'vector :x 8192.0 :y 24576.0 :z 8192.0 :w 1.0)
)
:local-within-reach-box (new 'static 'bounding-box
:min (new 'static 'vector :x -6144.0 :y 5324.8 :z -6144.0 :w 1.0)
:max (new 'static 'vector :x 6144.0 :y 11059.2 :z 6144.0 :w 1.0)
)
:local-player-spheres (new 'static 'inline-array sphere 12
(new 'static 'sphere :x 1720.32 :y -819.2 :r 1433.6)
(new 'static 'sphere :x 2293.76 :y -3276.8 :r 1884.16)
(new 'static 'sphere :x 1966.08 :y -6144.0 :r 1556.48)
(new 'static 'sphere :x 1966.08 :y -8601.6 :r 1556.48)
(new 'static 'sphere :x 1761.28 :y -11059.2 :r 1351.68)
(new 'static 'sphere :x 1679.36 :y -13312.0 :r 1269.76)
(new 'static 'sphere :x -737.28 :y 4096.0 :r 3072.0)
(new 'static 'sphere :x -737.28 :y 6553.6 :r 3072.0)
(new 'static 'sphere :x -737.28 :y 9420.8 :r 3072.0)
(new 'static 'sphere :x 1720.32 :y 3686.4 :r 2949.12)
(new 'static 'sphere :x 1720.32 :y 5734.4 :r 2949.12)
(new 'static 'sphere :x 1720.32 :y 8601.6 :r 2949.12)
)
)
)
(kmemopen global "collide-edge-work")
(define *collide-edge-work* (new 'global 'collide-edge-work))
(mem-copy! (the-as pointer (-> *collide-edge-work* spec)) (the-as pointer *collide-edge-spec*) 320)
(define-perm *edge-grab-info* edge-grab-info (new 'global 'edge-grab-info))
(kmemclose)