jak-project/goal_src/jak2/engine/spatial-hash/spatial-hash-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

120 lines
3.7 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: spatial-hash-h.gc
;; name in dgo: spatial-hash-h
;; dgos: ENGINE, GAME
(declare-type grid-hash-work basic)
;; DECOMP BEGINS
(deftype grid-hash-word (uint8)
()
)
(deftype grid-hash-box (structure)
((min int8 3)
(max int8 3)
)
:pack-me
)
(deftype grid-hash (basic)
((work grid-hash-work)
(search-box grid-hash-box :inline)
(bucket-size int16)
(axis-scale float 3)
(dimension-array int8 3)
(vertical-cell-count int8)
(bucket-array (pointer grid-hash-word))
(box-min float 3)
(box-max float 3)
(object-count int16)
(bucket-count int16)
(min-cell-size float)
(bucket-memory-size int32)
(mem-bucket-array (pointer grid-hash-word))
(spr-bucket-array (pointer grid-hash-word))
(debug-draw symbol)
(use-scratch-ram symbol)
)
(:methods
(new (symbol type int) _type_)
(update-grid-for-objects-in-box (_type_ int vector vector) none)
(clear-bucket-array (_type_) none)
(setup-search-box (_type_ int vector vector vector) none)
(search-for-point (_type_ vector) (pointer uint8))
(search-for-sphere (_type_ vector float) (pointer uint8))
(draw (_type_ rgba) none)
(dump-grid-info (_type_) none)
(verify-bits-in-bucket (_type_ grid-hash-box grid-hash-box) none)
(box-of-everything (_type_ object grid-hash-box) none)
(grid-hash-method-18 (_type_ grid-hash-box int) none)
(grid-hash-method-19 (_type_ grid-hash-box int) none)
(do-search! (_type_ grid-hash-box (pointer uint8)) none)
(set-up-box (_type_ grid-hash-box vector vector) none)
(sphere-to-grid-box (_type_ grid-hash-box sphere) none)
(line-sphere-to-grid-box (_type_ grid-hash-box vector vector float) none)
(update-grid (_type_) none)
)
)
(deftype find-nav-sphere-ids-params (structure)
((bsphere sphere :inline)
(y-threshold float)
(len int16)
(max-len int16)
(mask uint8)
(array (pointer uint8))
)
)
(deftype sphere-hash (grid-hash)
((sphere-array (inline-array sphere))
(max-object-count int16)
(pad int16)
(mem-sphere-array uint32)
(spr-sphere-array uint32)
)
(:methods
(new (symbol type int int) _type_)
(clear-objects! (_type_) none)
(add-a-sphere (_type_ vector) int)
(add-a-sphere-with-flag (_type_ vector int) int)
(update-from-spheres (_type_) none)
(sphere-hash-method-29 (_type_ find-nav-sphere-ids-params int int int) none)
(find-nav-sphere-ids (_type_ find-nav-sphere-ids-params) none)
(add-sphere-with-mask-and-id (_type_ vector int int) symbol)
(sphere-hash-method-32 (_type_ vector vector float int) symbol)
(remove-by-id (_type_ sphere int) none)
)
)
(deftype hash-object-info (structure)
((object basic)
)
)
(deftype spatial-hash (sphere-hash)
((object-array (inline-array hash-object-info))
(mem-object-array (inline-array hash-object-info))
(spr-object-array (inline-array hash-object-info))
)
(:methods
(new (symbol type int int) _type_)
(add-an-object (_type_ vector hash-object-info) int)
(fill-actor-list-for-box (_type_ bounding-box (pointer collide-shape) int) int)
(fill-actor-list-for-sphere (_type_ sphere (pointer collide-shape) int) int)
(fill-actor-list-for-line-sphere (_type_ vector vector float (pointer collide-shape) int int) int)
(fill-actor-list-for-vec+r (_type_ vector (pointer collide-shape) int) int)
(spatial-hash-method-39 (_type_ object hash-object-info) int)
(validate-objects (_type_) none)
)
)