Files
jak-project/test/decompiler/reference/jak1/engine/collide/collide-mesh-h_REF.gc
T
ManDude cd68cb671e deftype and defmethod syntax major changes (#3094)
Major change to how `deftype` shows up in our code:
- the decompiler will no longer emit the `offset-assert`,
`method-count-assert`, `size-assert` and `flag-assert` parameters. There
are extremely few cases where having this in the decompiled code is
helpful, as the types there come from `all-types` which already has
those parameters. This also doesn't break type consistency because:
  - the asserts aren't compared.
- the first step of the test uses `all-types`, which has the asserts,
which will throw an error if they're bad.
- the decompiler won't emit the `heap-base` parameter unless necessary
now.
- the decompiler will try its hardest to turn a fixed-offset field into
an `overlay-at` field. It falls back to the old offset if all else
fails.
- `overlay-at` now supports field "dereferencing" to specify the offset
that's within a field that's a structure, e.g.:
```lisp
(deftype foobar (structure)
  ((vec    vector  :inline)
   (flags  int32   :overlay-at (-> vec w))
   )
  )
```
in this structure, the offset of `flags` will be 12 because that is the
final offset of `vec`'s `w` field within this structure.
- **removed ID from all method declarations.** IDs are only ever
automatically assigned now. Fixes #3068.
- added an `:overlay` parameter to method declarations, in order to
declare a new method that goes on top of a previously-defined method.
Syntax is `:overlay <method-name>`. Please do not ever use this.
- added `state-methods` list parameter. This lets you quickly specify a
list of states to be put in the method table. Same syntax as the
`states` list parameter. The decompiler will try to put as many states
in this as it can without messing with the method ID order.

Also changes `defmethod` to make the first type definition (before the
arguments) optional. The type can now be inferred from the first
argument. Fixes #3093.

---------

Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
2023-10-30 03:20:02 +00:00

133 lines
4.3 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type collide-tri-result
(deftype collide-tri-result (structure)
((vertex vector 3 :inline)
(intersect vector :inline)
(normal vector :inline)
(pat pat-surface)
)
)
;; definition for method 3 of type collide-tri-result
(defmethod inspect ((this collide-tri-result))
(format #t "[~8x] ~A~%" this 'collide-tri-result)
(format #t "~Tvertex[3] @ #x~X~%" (-> this vertex))
(format #t "~Tintersect: ~`vector`P~%" (-> this intersect))
(format #t "~Tnormal: ~`vector`P~%" (-> this normal))
(format #t "~Tpat: ~D~%" (-> this pat))
this
)
;; definition of type collide-mesh-tri
(deftype collide-mesh-tri (structure)
((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))
(format #t "[~8x] ~A~%" this 'collide-mesh-tri)
(format #t "~Tvertex-index[3] @ #x~X~%" (-> this vertex-index))
(format #t "~Tunused: ~D~%" (-> this unused))
(format #t "~Tpat: ~D~%" (-> this pat))
this
)
;; definition of type collide-mesh
(deftype collide-mesh (basic)
((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)
(populate-cache! (_type_ 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))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tjoint-id: ~D~%" (-> this joint-id))
(format #t "~Tnum-tris: ~D~%" (-> this num-tris))
(format #t "~Tnum-verts: ~D~%" (-> this num-verts))
(format #t "~Tvertex-data: #x~X~%" (-> this vertex-data))
(format #t "~Ttris[1] @ #x~X~%" (-> this tris))
this
)
;; definition of type collide-mesh-cache
(deftype collide-mesh-cache (basic)
((used-size uint32)
(max-size uint32)
(id uint64)
(data uint8 40960 :offset 32)
)
(:methods
(allocate! (_type_ int) int)
(is-id? (_type_ int) symbol)
(next-id! (_type_) uint)
)
)
;; definition for method 3 of type collide-mesh-cache
(defmethod inspect ((this collide-mesh-cache))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tused-size: ~D~%" (-> this used-size))
(format #t "~Tmax-size: ~D~%" (-> this max-size))
(format #t "~Tid: ~D~%" (-> this id))
(format #t "~Tdata[40960] @ #x~X~%" (-> this data))
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) (arg0 int))
(= (-> this id) arg0)
)
;; definition of type collide-mesh-cache-tri
(deftype collide-mesh-cache-tri (structure)
((vertex vector 3 :inline)
(normal vector :inline)
(bbox4w bounding-box4w :inline)
(pat pat-surface :overlay-at (-> normal w))
)
)
;; definition for method 3 of type collide-mesh-cache-tri
(defmethod inspect ((this collide-mesh-cache-tri))
(format #t "[~8x] ~A~%" this 'collide-mesh-cache-tri)
(format #t "~Tvertex[3] @ #x~X~%" (-> this vertex))
(format #t "~Tnormal: ~`vector`P~%" (-> this normal))
(format #t "~Tbbox4w: #<bounding-box4w @ #x~X>~%" (-> this bbox4w))
(format #t "~Tpat: ~D~%" (-> this normal w))
this
)
;; 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 #xa000))