Files
jak-project/goal_src/engine/collide/collide-cache-h.gc
T

205 lines
7.9 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: collide-cache-h.gc
;; name in dgo: collide-cache-h
;; dgos: GAME, ENGINE
(define-extern collide-cache-using-line-sphere-test (function vector symbol))
(define-extern collide-cache-using-y-probe-test (function vector symbol))
(define-extern collide-cache-using-box-test (function vector symbol))
;; The collide cache system tries to make collision queries faster by caching intermediate results.
;; Almost all collision operations are done by calling a method of the global *collide-cache*.
;; In cases where the collide cache does not have the data in its cache, it will fill itself
;; using the appropriate collision functions.
;;;;;;;;;;;;;;;;;;;;;;;
;; Collide Helpers
;;;;;;;;;;;;;;;;;;;;;;;
(deftype collide-using-spheres-params (structure)
((spheres (pointer sphere) :offset-assert 0)
(num-spheres uint32 :offset-assert 4)
(collide-with collide-kind :offset-assert 8)
(proc process-drawable :offset-assert 16)
(ignore-pat uint32 :offset-assert 20)
(solid-only basic :offset-assert 24)
)
:method-count-assert 9
:size-assert #x1c
:flag-assert #x90000001c
)
;; primitive using sphere-sphere
(deftype collide-puss-sphere (structure)
((bsphere sphere :inline :offset-assert 0)
(bbox4w bounding-box4w :inline :offset-assert 16)
)
:method-count-assert 9
:size-assert #x30
:flag-assert #x900000030
)
(deftype collide-puss-work (structure)
((closest-pt vector :inline :offset-assert 0)
(tri-normal vector :inline :offset-assert 16)
(tri-bbox4w bounding-box4w :inline :offset-assert 32)
(spheres-bbox4w bounding-box4w :inline :offset-assert 64)
(spheres collide-puss-sphere 64 :inline :offset-assert 96)
)
:method-count-assert 11
:size-assert #xc60
:flag-assert #xb00000c60
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
)
)
;; primitive using y probe
(deftype collide-puyp-work (structure)
((best-u float :offset-assert 0)
(ignore-pat pat-surface :offset-assert 4)
(tri-out collide-tri-result :offset-assert 8)
(start-pos vector :inline :offset-assert 16)
(move-dist vector :inline :offset-assert 32)
)
:method-count-assert 9
:size-assert #x30
:flag-assert #x900000030
)
;;;;;;;;;;;;;;;;;;;;;;;
;; Main Cache Types
;;;;;;;;;;;;;;;;;;;;;;;
;; The triangles stored in the cache.
;; This is a common return type of collision queries.
(deftype collide-cache-tri (structure)
((vertex vector 3 :inline :offset-assert 0) ;; actual locations
(pat pat-surface :offset-assert 48) ;; metadata about the surface of this tri
(prim-index uint16 :offset-assert 52) ;; in the collide-cache-prim list
(user16 uint16 :offset-assert 54)
(user32 uint32 2 :offset-assert 56)
)
:method-count-assert 9
:size-assert #x40
:flag-assert #x900000040
)
;; The primitives stored in the cache.
;; The "core" is extracted from the normal collide-shape-prim and placed inline here.
(deftype collide-cache-prim (structure)
((prim-core collide-prim-core :inline :offset-assert 0)
(ccache collide-cache :offset-assert 32)
(prim collide-shape-prim :offset-assert 36)
(first-tri uint16 :offset-assert 40)
(num-tris uint16 :offset-assert 42)
(unused uint8 4 :offset-assert 44)
(world-sphere vector :inline :offset 0)
;; overlays of the core
(collide-as collide-kind :offset 16)
(action collide-action :offset 24)
(offense collide-offense :offset 28)
(prim-type int8 :offset 29)
)
:method-count-assert 11
:size-assert #x30
:flag-assert #xb00000030
(:methods
(resolve-moving-sphere-tri (_type_ collide-tri-result collide-prim-core vector float collide-action) float 9)
(resolve-moving-sphere-sphere (_type_ collide-tri-result collide-prim-core vector float collide-action) float 10)
)
)
;; The actual cache!
(deftype collide-cache (basic)
((num-tris int32 :offset-assert 4)
;;(num-tris-u uint32 :offset 4) ;; added
(num-prims int32 :offset-assert 8)
(num-prims-u uint32 :offset 8 );; added
(ignore-mask pat-surface :offset-assert 12)
(proc process-drawable :offset-assert 16) ;; types: target
(collide-box bounding-box :inline :offset-assert 32)
(collide-box4w bounding-box4w :inline :offset-assert 64)
(collide-with collide-kind :offset-assert 96)
(prims collide-cache-prim 100 :inline :offset-assert 112)
(tris collide-cache-tri 461 :inline :offset-assert 4912)
)
:method-count-assert 33
:size-assert #x8670
:flag-assert #x2100008670
(:methods
(dummy-9 (_type_) none 9)
(fill-and-probe-using-line-sphere (_type_ vector vector float collide-kind process collide-tri-result int) float 10)
(fill-and-probe-using-spheres (_type_ collide-using-spheres-params) none 11)
(fill-and-probe-using-y-probe (_type_ vector float collide-kind process collide-tri-result uint) float 12)
(fill-using-bounding-box (_type_ bounding-box collide-kind process-drawable pat-surface) none 13)
(fill-using-line-sphere (_type_ vector vector float collide-kind process-drawable int) none 14)
(fill-using-spheres (_type_ collide-using-spheres-params) none 15)
(fill-using-y-probe (_type_ vector float collide-kind process-drawable uint) none 16)
(initialize (_type_) none 17)
(probe-using-line-sphere (_type_ vector vector float collide-kind collide-tri-result int) float 18)
(probe-using-spheres (_type_) none 19)
(probe-using-y-probe (_type_ vector float collide-kind collide-tri-result uint) float 20)
(fill-from-background (_type_ (function bsp-header int collide-list none) (function collide-cache none)) none 21) ;; second functiom is method 28
(fill-from-foreground-using-spheres (_type_) none 22)
(fill-from-foreground-using-line-sphere (_type_) none 23)
(fill-from-foreground-using-y-probe (_type_) none 24)
(fill-from-water (_type_ water-control) none 25) ;; or whatever is from 152 in the process passed to 16
(dummy-26 (_type_) none 26)
(dummy-27 (_type_) none 27)
(dummy-28 (_type_) none 28)
(dummy-29 (_type_ collide-frag-mesh) none 29)
(dummy-30 (_type_) none 30)
(dummy-31 (_type_ collide-puyp-work collide-cache-prim) vector 31)
(dummy-32 (_type_) none 32)
)
)
(deftype collide-list-item (structure)
((mesh collide-frag-mesh :offset-assert 0)
(inst basic :offset-assert 4)
)
:method-count-assert 9
:size-assert #x8
:flag-assert #x900000008
)
(deftype collide-list (structure)
((num-items int32 :offset-assert 0)
(items collide-list-item 256 :inline :offset-assert 16)
)
:method-count-assert 9
:size-assert #x1010
:flag-assert #x900001010
)
(deftype collide-work (structure)
((collide-sphere-neg-r sphere :inline :offset-assert 0)
(collide-box4w bounding-box4w :inline :offset-assert 16)
(inv-mat matrix :inline :offset-assert 48)
)
:method-count-assert 9
:size-assert #x70
:flag-assert #x900000070
)
(define-perm *collide-work* collide-work (new 'global 'collide-work))
(define-perm *collide-cache* collide-cache (new 'global 'collide-cache))
(define-perm *collide-list* collide-list (new 'global 'collide-list))