mirror of
https://github.com/open-goal/jak-project
synced 2026-07-11 07:25:37 -04:00
d1ece445d4
Relates to #1353 This adds no new functionality or overhead to the compiler, yet. This is the preliminary work that has: - added code to the compiler in several spots to flag when something is used without being properly required/imported/whatever (disabled by default) - that was used to generate project wide file dependencies (some circulars were manually fixed) - then that graph underwent a transitive reduction and the result was written to all `jak1` source files. The next step will be making this actually produce and use a dependency graph. Some of the reasons why I'm working on this: - eliminates more `game.gp` boilerplate. This includes the `.gd` files to some extent (`*-ag` files and `tpage` files will still need to be handled) this is the point of the new `bundles` form. This should make it even easier to add a new file into the source tree. - a build order that is actually informed from something real and compiler warnings that tell you when you are using something that won't be available at build time. - narrows the search space for doing LSP actions -- like searching for references. Since it would be way too much work to store in the compiler every location where every symbol/function/etc is used, I have to do ad-hoc searches. By having a dependency graph i can significantly reduce that search space. - opens the doors for common shared code with a legitimate pattern. Right now jak 2 shares code from the jak 1 folder. This is basically a hack -- but by having an explicit require syntax, it would be possible to reference arbitrary file paths, such as a `common` folder. Some stats: - Jak 1 has about 2500 edges between files, including transitives - With transitives reduced at the source code level, each file seems to have a modest amount of explicit requirements. Known issues: - Tracking the location for where `defmacro`s and virtual state definitions were defined (and therefore the file) is still problematic. Because those forms are in a macro environment, the reader does not track them. I'm wondering if a workaround could be to search the reader's text_db by not just the `goos::Object` but by the text position. But for the purposes of finishing this work, I just statically analyzed and searched the code with throwaway python code.
140 lines
4.5 KiB
Common Lisp
140 lines
4.5 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
|
|
(require "engine/level/bsp.gc")
|
|
(require "engine/draw/draw-node-h.gc")
|
|
|
|
;; 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)) |