Files
jak-project/test/decompiler/reference/jak3/engine/collide/collide-mesh-h_REF.gc
T
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

195 lines
5.9 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type collide-tri-result
(deftype collide-tri-result (structure)
"A triangle result of a collision."
((vertex vector 3 :inline)
(intersect vector :inline)
(normal vector :inline)
(pat pat-surface)
(collide-ptr basic)
)
)
;; definition for method 3 of type collide-tri-result
(defmethod inspect ((this collide-tri-result))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'collide-tri-result)
(format #t "~1Tvertex[3] @ #x~X~%" (-> this vertex))
(format #t "~1Tintersect: ~`vector`P~%" (-> this intersect))
(format #t "~1Tnormal: ~`vector`P~%" (-> this normal))
(format #t "~1Tpat: ~D~%" (-> this pat))
(format #t "~1Tcollide-ptr: ~A~%" (-> this collide-ptr))
(label cfg-4)
this
)
;; definition of type collide-mesh-tri
(deftype collide-mesh-tri (structure)
"A triangle for foreground collision meshes."
((vertex-index uint8 3)
(unused uint8)
(pat pat-surface)
)
:pack-me
)
;; definition for method 3 of type collide-mesh-tri
(defmethod inspect ((this collide-mesh-tri))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'collide-mesh-tri)
(format #t "~1Tvertex-index[3] @ #x~X~%" (-> this vertex-index))
(format #t "~1Tunused: ~D~%" (-> this unused))
(format #t "~1Tpat: ~D~%" (-> this pat))
(label cfg-4)
this
)
;; definition of type collide-mesh
(deftype collide-mesh (basic)
"A collision mesh for foreground objects,
bound to the joint specified by `joint-id`."
((joint-id int32)
(num-tris uint32)
(num-verts uint32)
(vertex-data (inline-array vector))
(tris collide-mesh-tri 1 :inline :offset 32)
)
(:methods
(debug-draw-tris (_type_ process-drawable int) none)
(overlap-test (_type_ collide-mesh-cache-tri vector) symbol)
(should-push-away-test (_type_ collide-mesh-cache-tri collide-tri-result vector float) float)
(sphere-on-platform-test (_type_ collide-mesh-cache-tri collide-tri-result vector float) float)
(unpack-mesh-to-cache! (_type_ (inline-array collide-mesh-cache-tri) matrix) none)
(collide-mesh-math-1 (_type_ object object) none)
(collide-mesh-math-2 (_type_ object object object) none)
)
)
;; definition for method 3 of type collide-mesh
(defmethod inspect ((this collide-mesh))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tjoint-id: ~D~%" (-> this joint-id))
(format #t "~1Tnum-tris: ~D~%" (-> this num-tris))
(format #t "~1Tnum-verts: ~D~%" (-> this num-verts))
(format #t "~1Tvertex-data: #x~X~%" (-> this vertex-data))
(format #t "~1Ttris[1] @ #x~X~%" (-> this tris))
(label cfg-4)
this
)
;; definition of type collide-mesh-cache-tri
(deftype collide-mesh-cache-tri (structure)
"A triangle stored in the foreground mesh collide cache."
((vertex vector 3 :inline)
(normal vector :inline)
(bbox4w bounding-box4w :inline)
(pat pat-surface :overlay-at (-> normal data 3))
)
)
;; definition for method 3 of type collide-mesh-cache-tri
(defmethod inspect ((this collide-mesh-cache-tri))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'collide-mesh-cache-tri)
(format #t "~1Tvertex[3] @ #x~X~%" (-> this vertex))
(format #t "~1Tnormal: ~`vector`P~%" (-> this normal))
(format #t "~1Tbbox4w: #<bounding-box4w @ #x~X>~%" (-> this bbox4w))
(format #t "~1Tpat: ~D~%" (-> this pat))
(label cfg-4)
this
)
;; definition of type collide-mesh-cache-entry
(deftype collide-mesh-cache-entry (structure)
"A foreground mesh collide cache entry."
((mat matrix :inline)
(tris collide-mesh-cache-tri :inline :dynamic)
)
)
;; definition for method 3 of type collide-mesh-cache-entry
(defmethod inspect ((this collide-mesh-cache-entry))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'collide-mesh-cache-entry)
(format #t "~1Tmat: #<matrix @ #x~X>~%" (-> this mat))
(format #t "~1Ttris[0] @ #x~X~%" (-> this tris))
(label cfg-4)
this
)
;; definition of type collide-mesh-cache
(deftype collide-mesh-cache (basic)
"A collide cache for foreground meshes."
((used-size uint32)
(max-size uint32)
(id uint32)
(data uint8 48000)
)
(:methods
(populate-for-prim-mesh (_type_ collide-shape-prim-mesh) collide-mesh-cache-entry)
(is-id? (_type_ int) symbol)
(next-id! (_type_) uint)
(allocate! (_type_ int) collide-mesh-cache-entry)
)
)
;; definition for method 3 of type collide-mesh-cache
(defmethod inspect ((this collide-mesh-cache))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tused-size: ~D~%" (-> this used-size))
(format #t "~1Tmax-size: ~D~%" (-> this max-size))
(format #t "~1Tid: ~D~%" (-> this id))
(format #t "~1Tdata[48000] @ #x~X~%" (-> this data))
(label cfg-4)
this
)
;; definition for method 11 of type collide-mesh-cache
;; ERROR: function was not converted to expressions. Cannot decompile.
;; definition for method 10 of type collide-mesh-cache
(defmethod is-id? ((this collide-mesh-cache) (id int))
"Does this cache have the given ID?"
(= (-> this id) id)
)
;; failed to figure out what this is:
(kmemopen global "collide-mesh-cache")
;; definition (perm) for symbol *collide-mesh-cache*, type collide-mesh-cache
(define-perm *collide-mesh-cache* collide-mesh-cache (new 'global 'collide-mesh-cache))
;; failed to figure out what this is:
(set! (-> *collide-mesh-cache* id) (the-as uint 1))
;; failed to figure out what this is:
(set! (-> *collide-mesh-cache* used-size) (the-as uint 0))
;; failed to figure out what this is:
(set! (-> *collide-mesh-cache* max-size) (the-as uint #xbb80))
;; failed to figure out what this is:
(kmemclose)