Files
jak-project/goal_src/jak1/engine/debug/debug-sphere.gc
T
Tyler Wilding d1ece445d4 Dependency graph work - Part 1 - Preliminary work (#3505)
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.
2024-05-12 12:37:59 -04:00

102 lines
3.6 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/math/vector-h.gc")
(require "engine/debug/debug-h.gc")
(require "engine/math/math.gc")
;; name: debug-sphere.gc
;; name in dgo: debug-sphere
;; dgos: GAME, ENGINE
(defconstant DEBUG_SPHERE_SEC_AMT (#if (user? dass) 5 10))
(defconstant DEBUG_SPHERE_SEC_H DEBUG_SPHERE_SEC_AMT)
(defconstant DEBUG_SPHERE_SEC_W DEBUG_SPHERE_SEC_AMT)
;; DECOMP BEGINS
(deftype debug-sphere-table (basic)
((point vector 300 :inline)
)
)
(defun make-debug-sphere-table ((arg0 debug-sphere-table))
(local-vars (sv-80 int))
(let ((s5-0 (new-stack-vector0))
(f30-0 1.0)
(s4-0 0)
)
(set-vector! s5-0 0.0 0.0 0.0 1.0)
(dotimes (s3-0 DEBUG_SPHERE_SEC_H)
(let ((f28-0 (* f30-0 (sin (* (degrees (/ 180 DEBUG_SPHERE_SEC_H)) (the float s3-0)))))
(f26-0 (* f30-0 (sin (* (degrees (/ 180 DEBUG_SPHERE_SEC_H)) (the float (+ s3-0 1))))))
(s2-0 (new-stack-vector0))
(s1-0 (new-stack-vector0))
(s0-0 (new-stack-vector0))
)
(set! (-> s2-0 y) (+ (-> s5-0 y) (* (cos (* (degrees (/ 180 DEBUG_SPHERE_SEC_H)) (the float s3-0))) f30-0)))
(set! (-> s1-0 y) (-> s2-0 y))
(set! (-> s0-0 y) (+ (-> s5-0 y) (* (cos (* (degrees (/ 180 DEBUG_SPHERE_SEC_H)) (the float (+ s3-0 1)))) f30-0)))
(set! sv-80 0)
(while (< sv-80 DEBUG_SPHERE_SEC_W)
(set! (-> s2-0 x) (+ (-> s5-0 x) (* (cos (* (degrees (/ 360 DEBUG_SPHERE_SEC_W)) (the float sv-80))) f28-0)))
(set! (-> s2-0 z) (+ (-> s5-0 z) (* (sin (* (degrees (/ 360 DEBUG_SPHERE_SEC_W)) (the float sv-80))) f28-0)))
(set! (-> s1-0 x) (+ (-> s5-0 x) (* (cos (* (degrees (/ 360 DEBUG_SPHERE_SEC_W)) (the float (+ sv-80 1)))) f28-0)))
(set! (-> s1-0 z) (+ (-> s5-0 z) (* (sin (* (degrees (/ 360 DEBUG_SPHERE_SEC_W)) (the float (+ sv-80 1)))) f28-0)))
(set! (-> s0-0 x) (+ (-> s5-0 x) (* (cos (* (degrees (/ 360 DEBUG_SPHERE_SEC_W)) (the float sv-80))) f26-0)))
(set! (-> s0-0 z) (+ (-> s5-0 z) (* (sin (* (degrees (/ 360 DEBUG_SPHERE_SEC_W)) (the float sv-80))) f26-0)))
(set! (-> arg0 point s4-0 quad) (-> s2-0 quad))
(set! (-> arg0 point (+ s4-0 1) quad) (-> s1-0 quad))
(set! (-> arg0 point (+ s4-0 2) quad) (-> s0-0 quad))
(+! s4-0 3)
(set! sv-80 (+ sv-80 1))
)
)
)
)
(none)
)
(define *debug-sphere-table* (new 'static 'debug-sphere-table))
(make-debug-sphere-table *debug-sphere-table*)
(defun add-debug-sphere-from-table ((arg0 bucket-id) (arg1 vector) (arg2 float) (arg3 rgba))
"Draw a wireframe sphere"
(rlet ((vf1 :class vf)
(vf2 :class vf)
(vf3 :class vf)
(vf4 :class vf)
(vf5 :class vf)
)
(let ((s4-0 (new-stack-vector0))
(s3-0 (new-stack-vector0))
(s2-0 (new-stack-vector0))
(points (-> *debug-sphere-table* point))
)
(.lvf vf1 (&-> arg1 quad))
(.mov vf2 arg2)
(dotimes (s0-0 (* DEBUG_SPHERE_SEC_W DEBUG_SPHERE_SEC_H))
(.lvf vf3 (&-> points 0 quad))
(.lvf vf4 (&-> points 1 quad))
(.lvf vf5 (&-> points 2 quad))
(set! points (the-as (inline-array vector) (-> points 3)))
(.mul.x.vf vf3 vf3 vf2)
(.mul.x.vf vf4 vf4 vf2)
(.mul.x.vf vf5 vf5 vf2)
(.add.vf vf3 vf3 vf1)
(.add.vf vf4 vf4 vf1)
(.add.vf vf5 vf5 vf1)
(.svf (&-> s4-0 quad) vf3)
(.svf (&-> s3-0 quad) vf4)
(.svf (&-> s2-0 quad) vf5)
(add-debug-line #t arg0 s4-0 s3-0 arg3 #f (the-as rgba -1))
(add-debug-line #t arg0 s4-0 s2-0 arg3 #f (the-as rgba -1))
)
)
0
(none)
)
)