jak-project/goal_src/jak2/engine/physics/trajectory-h.gc
ManDude cd68cb671e
deftype and defmethod syntax major changes (#3094)
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>
2023-10-30 03:20:02 +00:00

132 lines
3.7 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: trajectory-h.gc
;; name in dgo: trajectory-h
;; dgos: ENGINE, GAME
(declare-type collide-query structure)
;; DECOMP BEGINS
(deftype trajectory (structure)
((initial-position vector :inline)
(initial-velocity vector :inline)
(time float)
(gravity meters)
)
(:methods
(compute-trans-at-time (_type_ float vector) vector)
(compute-transv-at-time (_type_ float vector) vector)
(compute-time-until-apex (_type_) float)
(setup-from-to-duration! (_type_ vector vector float float) none)
(setup-from-to-xz-vel! (_type_ vector vector float float) none)
(setup-from-to-y-vel! (_type_ vector vector float float) none)
(setup-from-to-height! (_type_ vector vector float float) none)
(setup-from-to-duration-and-height! (_type_ vector vector float float) none)
(debug-draw (_type_) none)
)
)
(deftype impact-control (structure)
((process (pointer process-drawable))
(radius float)
(joint int32)
(collide-with collide-spec)
(start-time time-frame)
(trans vector 2 :inline)
(dir vector :inline)
)
(:methods
(new (symbol type process-drawable int float collide-spec) _type_)
(initialize (_type_ process-drawable int float collide-spec) impact-control :behavior process)
(update-from-cspace (_type_) none)
(impact-control-method-11 (_type_ collide-query process pat-surface) float)
)
)
(defmethod new impact-control ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 float) (arg3 collide-spec))
(let ((t9-0 (method-of-type structure new))
(v1-1 type-to-make)
)
(-> type-to-make size)
((method-of-type impact-control initialize)
(the-as impact-control (t9-0 allocation v1-1))
arg0
arg1
arg2
arg3
)
)
)
(deftype point-tracker (structure)
((trans vector 2 :inline)
)
(:methods
(new (symbol type vector vector) _type_)
(initialize (_type_ vector vector) point-tracker)
(point-tracker-method-10 (_type_ vector vector vector float) vector)
(point-tracker-method-11 (_type_ vector vector vector float) vector)
)
)
(defmethod new point-tracker ((allocation symbol) (type-to-make type) (arg0 vector) (arg1 vector))
(let ((t9-0 (method-of-type structure new))
(v1-1 type-to-make)
)
(-> type-to-make size)
((method-of-type point-tracker initialize) (the-as point-tracker (t9-0 allocation v1-1)) arg0 arg1)
)
)
(deftype combo-tracker (point-tracker)
((target handle)
(move-start-time time-frame)
)
(:methods
(combo-tracker-method-12 (_type_ vector vector process time-frame) combo-tracker)
(combo-tracker-method-13 (_type_ handle vector float vector float) basic)
)
)
(deftype traj2d-params (structure)
((x float)
(y float)
(gravity float)
(initial-tilt float)
(initial-speed float)
(time float)
)
)
(deftype traj3d-params (structure)
((gravity float)
(initial-tilt float)
(initial-speed float)
(time float)
(src vector :inline)
(dest vector :inline)
(diff vector :inline)
(initial-velocity vector :inline)
)
)
(deftype cubic-curve (structure)
((mat matrix :inline)
)
(:methods
(cubic-curve-method-9 (_type_ vector vector vector vector) none)
(cubic-curve-method-10 (_type_ vector float) vector)
(cubic-curve-method-11 (_type_ vector float) vector)
(cubic-curve-method-12 (_type_ vector float) vector)
(debug-draw-curve (_type_) none)
)
)