mirror of
https://github.com/open-goal/jak-project
synced 2026-08-07 02:06:59 -04:00
c162c66118
This PR does two main things: 1. Work through the main low-hanging fruit issues in the formatter keeping it from feeling mature and usable 2. Iterate and prove that point by formatting all of the Jak 1 code base. **This has removed around 100K lines in total.** - The decompiler will now format it's results for jak 1 to keep things from drifting back to where they were. This is controlled by a new config flag `format_code`. How am I confident this hasn't broken anything?: - I compiled the entire project and stored it's `out/jak1/obj` files separately - I then recompiled the project after formatting and wrote a script that md5's each file and compares it (`compare-compilation-outputs.py` - The results (eventually) were the same:  > This proves that the only difference before and after is non-critical whitespace for all code/macros that is actually in use. I'm still aware of improvements that could be made to the formatter, as well as general optimization of it's performance. But in general these are for rare or non-critical situations in my opinion and I'll work through them before doing Jak 2. The vast majority looks great and is working properly at this point. Those known issues are the following if you are curious: 
80 lines
2.8 KiB
Common Lisp
80 lines
2.8 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
(require "kernel/gcommon.gc")
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
;; this file contains types for the skeletal animation system.
|
|
;; the "bones" are the actual matrix data consumed by the renderers.
|
|
;; the "joints" describe how bones are connected.
|
|
;; a "cspace" links together a bone, joint, and a way to control the joint (and bone)
|
|
|
|
;; There's three main container types:
|
|
;; - The cspace-array. This contains references to the bones and the joints. (called node-list)
|
|
;; - The skeleton: This is an inline array of bones. (called skeleton)
|
|
;; - The joint-control (not in this file): this has the logic for running joint animations. (called skel)
|
|
|
|
;; First, the joint. This type just describes how the skeleton is connected and the bind pose.
|
|
(deftype joint (basic)
|
|
((name string)
|
|
(number int32)
|
|
(parent joint)
|
|
(bind-pose matrix :inline)))
|
|
|
|
;; I believe this stores offsets, in bytes, of where there are stored
|
|
;; (possibly in the scratchpad)
|
|
(deftype bone-cache (structure)
|
|
((bone-matrix uint32)
|
|
(parent-matrix uint32)
|
|
(dummy uint32)
|
|
(frame uint32)))
|
|
|
|
;; The "bone" stores the final positions of the bodies.
|
|
;; This is a world space transform.
|
|
(deftype bone (structure)
|
|
((transform matrix :inline)
|
|
(position vector :inline :overlay-at (-> transform vector 3))
|
|
(scale vector :inline)
|
|
(cache bone-cache :inline)))
|
|
|
|
;; Like a real skeleton, this is a collection of bones for a single character.
|
|
(deftype skeleton (inline-array-class)
|
|
((bones bone :inline :dynamic)))
|
|
|
|
(set! (-> skeleton heap-base) (the-as uint 96))
|
|
|
|
;; The "cspace" seems to be a system for linking bones and joints.
|
|
;; The tree structure matches the tree of joints.
|
|
;; For example: (-> *target* node-list data 14 parent joint) is the same as
|
|
;; (-> *target* node-list data 14 joint parent)
|
|
;; But, we appear to use bone indices here.
|
|
;; So the joint index is always 1 less than the node index.
|
|
;; By convention, node 0 is not a joint.
|
|
;; node 1 is an "align" joint. It has parent #f, and is joint 0.
|
|
;; node 2 is a "prejoint". It also has parent #f, and is joint 1.
|
|
;; node 3 is "main". It has parent prejoint, and is joint 2.
|
|
;; node 4 is the first real joint (for jak, it's upper body).
|
|
|
|
(deftype cspace (structure)
|
|
((parent cspace)
|
|
(joint joint)
|
|
(joint-num int16)
|
|
(geo basic)
|
|
(bone bone)
|
|
(param0 function)
|
|
(param1 basic)
|
|
(param2 basic))
|
|
(:methods
|
|
(new (symbol type basic) _type_)
|
|
(reset-and-assign-geo! (_type_ basic) _type_)))
|
|
|
|
(deftype cspace-array (inline-array-class)
|
|
((data cspace :inline :dynamic)))
|
|
|
|
(set! (-> cspace-array heap-base) (the-as uint 32))
|
|
|
|
(defmethod print ((this cspace))
|
|
(format #t "#<cspace ~S @ #x~X>" (if (-> this joint) (-> this joint name) "nojoint") this)
|
|
this)
|