mirror of
https://github.com/open-goal/jak-project
synced 2026-05-30 08:56:59 -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>
81 lines
3.2 KiB
Common Lisp
81 lines
3.2 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: transformq-h.gc
|
|
;; name in dgo: transformq-h
|
|
;; dgos: ENGINE, GAME
|
|
|
|
;; the transformq is a transform, but _replaces_ the rotation field with a quaternion.
|
|
;; it is much more commonly used than transform.
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype transformq (transform)
|
|
((quat quaternion :inline :overlay-at (-> rot data 0))
|
|
)
|
|
)
|
|
|
|
|
|
(deftype trsq (trs)
|
|
((quat quaternion :inline :overlay-at (-> rot data 0))
|
|
)
|
|
)
|
|
|
|
;; a transform with:
|
|
;; - type information (child of basic)
|
|
;; - rotation stored as quaternion
|
|
;; - velocity information.
|
|
;; This is a very commonly used type to represent the position of an in-game object.
|
|
;; The "root" of a process-drawable (the parent "in-game object" type) is a trsqv.
|
|
;; Additionally, the collision system uses trsqv as the parent type for foreground
|
|
;; collision objects (collide-shape, collide-shape-moving)
|
|
;; As a result, this type has a lot of weird methods and extra stuff hidden in it.
|
|
(deftype trsqv (trsq)
|
|
;; some extra info for game objects, hidden in the unused space.
|
|
((pause-adjust-distance meters :offset 4)
|
|
(nav-radius meters :offset 8)
|
|
;; velocities
|
|
(transv vector :inline)
|
|
(rotv vector :inline)
|
|
(scalev vector :inline)
|
|
;; trsqv also supports the ability to adjust its orientation
|
|
;; to face a target. This has some logic to prevent chattering
|
|
;; that requires some additional state here:
|
|
(dir-targ quaternion :inline)
|
|
(angle-change-time time-frame)
|
|
(old-y-angle-diff float)
|
|
)
|
|
(:methods
|
|
(seek-toward-heading-vec! (_type_ vector float time-frame) quaternion)
|
|
(set-heading-vec! (_type_ vector) quaternion)
|
|
(seek-to-point-toward-point! (_type_ vector float time-frame) quaternion)
|
|
(point-toward-point! (_type_ vector) quaternion)
|
|
(seek-toward-yaw-angle! (_type_ float float time-frame) quaternion)
|
|
(set-yaw-angle-clear-roll-pitch! (_type_ float) quaternion)
|
|
(set-roll-to-grav! (_type_ float) quaternion)
|
|
(set-roll-to-grav-2! (_type_ float) quaternion)
|
|
(rotate-toward-orientation! (_type_ quaternion float float int int float) quaternion)
|
|
(set-quaternion! (_type_ quaternion) quaternion)
|
|
(set-heading-vec-clear-roll-pitch! (_type_ vector) quaternion)
|
|
(point-toward-point-clear-roll-pitch! (_type_ vector) quaternion)
|
|
(rot->dir-targ! (_type_) quaternion)
|
|
(y-angle (_type_) float)
|
|
(global-y-angle-to-point (_type_ vector) float)
|
|
(relative-y-angle-to-point (_type_ vector) float)
|
|
(roll-relative-to-gravity (_type_) float)
|
|
(set-and-limit-velocity (_type_ int vector float) trsqv :behavior process)
|
|
(get-quaternion (_type_) quaternion)
|
|
)
|
|
)
|
|
|
|
(defmethod global-y-angle-to-point ((this trsqv) (arg0 vector))
|
|
"Get the angle in the xz plane from the position of this trsqv to the point arg0.
|
|
(ignores our current yaw)"
|
|
(vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg0 (-> this trans)))
|
|
)
|
|
|
|
(defmethod relative-y-angle-to-point ((this trsqv) (arg0 vector))
|
|
"Get the y angle between the current orientation and arg0. (how much we'd have to yaw to point at arg0)"
|
|
(deg-diff (y-angle this) (vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg0 (-> this trans))))
|
|
)
|