mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
cd68cb671e
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>
136 lines
4.4 KiB
Common Lisp
136 lines
4.4 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: draw-node.gc
|
|
;; name in dgo: draw-node
|
|
;; dgos: GAME, ENGINE
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Draw Node Collisions
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; The collision stuff is a bit weird.
|
|
;; The method takes an integer argument. For some types, you must provide a length and calling the method
|
|
;; will automatically run on all the brothers of the node. For other types, you don't have to provide a length.
|
|
|
|
;; The output of the collision are stored in the collide-list that's passed through all the methods.
|
|
;; For an unknown reason, the input to the collision query (the box we're colliding with) is not.
|
|
;; It's stored in *collide-work*
|
|
|
|
(defmethod collide-with-box ((this draw-node) (arg0 int) (arg1 collide-list))
|
|
"Find collisions with the box in the current collision query, add results to collide-list."
|
|
|
|
;; loop over ourself and our brothers
|
|
(dotimes (s3-0 arg0)
|
|
(if (collide-cache-using-box-test (-> this bsphere)) ;; do we collide with the bounding sphere?
|
|
;; if so, do the collision check with the geometry.
|
|
(collide-with-box (-> this child) (the-as int (-> this child-count)) arg1)
|
|
)
|
|
(&+! this 32)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod collide-y-probe ((this draw-node) (arg0 int) (arg1 collide-list))
|
|
(dotimes (s3-0 arg0)
|
|
(if (collide-cache-using-y-probe-test (-> this bsphere))
|
|
(collide-y-probe (-> this child) (the-as int (-> this child-count)) arg1)
|
|
)
|
|
(&+! this 32)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod collide-ray ((this draw-node) (arg0 int) (arg1 collide-list))
|
|
(dotimes (s3-0 arg0)
|
|
(if (collide-cache-using-line-sphere-test (-> this bsphere))
|
|
(collide-ray (-> this child) (the-as int (-> this child-count)) arg1)
|
|
)
|
|
(&+! this 32)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod collect-ambients ((this draw-node) (arg0 sphere) (arg1 int) (arg2 ambient-list))
|
|
(dotimes (s2-0 arg1)
|
|
(if (spheres-overlap? arg0 (the-as sphere (-> this bsphere)))
|
|
(collect-ambients (-> this child) arg0 (the-as int (-> this child-count)) arg2)
|
|
)
|
|
(&+! this 32)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Drawable Inline Array Node
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; This class is a convenient wrapper around an inline-array of draw-nodes.
|
|
;; It lets you treat this array like a normal drawable (at least for collisions).
|
|
|
|
(defmethod inspect drawable-inline-array-node ((this drawable-inline-array-node))
|
|
"Custom inspect for drawable-inline-array-node to print our nodes."
|
|
(format #t "[~8x] ~A~%" this (-> this type))
|
|
(format #t "~Tlength: ~D~%" (-> this length))
|
|
(format #t "~Tdata[~D]: @ #x~X~%" (-> this length) (-> this data))
|
|
(dotimes (s5-0 (-> this length))
|
|
(format #t "~T [~D] ~A~%" s5-0 (-> this data s5-0))
|
|
)
|
|
this
|
|
)
|
|
|
|
(defmethod mem-usage ((this drawable-inline-array-node) (arg0 memory-usage-block) (arg1 int))
|
|
"Compute the memory usage of a drawable-inline-array-node. Only counts the nodes, doesn't count the node children."
|
|
(set! (-> arg0 length) (max 62 (-> arg0 length)))
|
|
(set! (-> arg0 data 61 name) "draw-node")
|
|
(+! (-> arg0 data 61 count) (-> this length))
|
|
(let ((v1-6 (asize-of this)))
|
|
(+! (-> arg0 data 61 used) v1-6)
|
|
(+! (-> arg0 data 61 total) (logand -16 (+ v1-6 15)))
|
|
)
|
|
this
|
|
)
|
|
|
|
(defmethod asize-of ((this drawable-inline-array-node))
|
|
(the-as int (+ (-> drawable-inline-array-node size) (* (+ (-> this length) -1) 32)))
|
|
)
|
|
|
|
(defmethod collide-with-box ((this drawable-inline-array-node) (arg0 int) (arg1 collide-list))
|
|
;; call on the first in the array, then it will loop through all the brothers.
|
|
(collide-with-box (the-as drawable (-> this data)) (-> this length) arg1)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod collide-y-probe ((this drawable-inline-array-node) (arg0 int) (arg1 collide-list))
|
|
(collide-y-probe (the-as drawable (-> this data)) (-> this length) arg1)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod collide-ray ((this drawable-inline-array-node) (arg0 int) (arg1 collide-list))
|
|
(collide-ray (the-as drawable (-> this data)) (-> this length) arg1)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod collect-ambients ((this drawable-inline-array-node) (arg0 sphere) (arg1 int) (arg2 ambient-list))
|
|
(collect-ambients (the-as drawable (-> this data)) arg0 (-> this length) arg2)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; DRAW NODE CULL
|
|
;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; TODO: waiting on tfrag/tie stuff to worry about this.
|
|
(define-extern draw-node-cull (function pointer pointer (inline-array draw-node) int none)) |