;;-*-Lisp-*-
(in-package goal)

;; definition of type edge-grab-info
(deftype edge-grab-info (structure)
  ((world-vertex             vector 6 :inline :offset-assert   0)
   (local-vertex             vector 6 :inline :offset-assert  96)
   (actor-cshape-prim-offset int32            :offset-assert 192)
   (actor-handle             handle           :offset-assert 200)
   (hanging-matrix           matrix :inline   :offset-assert 208)
   (edge-vertex              vector 2 :inline :offset          0)
   (center-hold              vector :inline   :offset         32)
   (tri-vertex               vector 3 :inline :offset         48)
   (left-hand-hold           vector :inline   :offset-assert 272)
   (right-hand-hold          vector :inline   :offset-assert 288)
   (center-hold-old          vector :inline   :offset-assert 304)
   (edge-tri-pat             uint32           :offset-assert 320)
   )
  :method-count-assert 11
  :size-assert         #x144
  :flag-assert         #xb00000144
  (:methods
    (dummy-9 (_type_) symbol 9)
    (debug-draw (_type_) symbol 10)
    )
  )

;; definition for method 3 of type edge-grab-info
(defmethod inspect edge-grab-info ((obj edge-grab-info))
  (format #t "[~8x] ~A~%" obj 'edge-grab-info)
  (format #t "~Tworld-vertex[6] @ #x~X~%" (-> obj world-vertex))
  (format #t "~Tlocal-vertex[6] @ #x~X~%" (-> obj local-vertex))
  (format #t "~Tactor-cshape-prim-offset: ~D~%" (-> obj actor-cshape-prim-offset))
  (format #t "~Tactor-handle: ~D~%" (-> obj actor-handle))
  (format #t "~Thanging-matrix: #<matrix @ #x~X>~%" (-> obj hanging-matrix))
  (format #t "~Tedge-vertex[2] @ #x~X~%" (-> obj world-vertex))
  (format #t "~Tcenter-hold: ~`vector`P~%" (-> obj center-hold))
  (format #t "~Ttri-vertex[3] @ #x~X~%" (-> obj tri-vertex))
  (format #t "~Tleft-hand-hold: #<vector @ #x~X>~%" (-> obj left-hand-hold))
  (format #t "~Tright-hand-hold: #<vector @ #x~X>~%" (-> obj right-hand-hold))
  (format #t "~Tcenter-hold-old: ~`vector`P~%" (-> obj center-hold-old))
  (format #t "~Tedge-tri-pat: ~D~%" (-> obj edge-tri-pat))
  obj
  )

;; definition of type collide-edge-tri
(deftype collide-edge-tri (structure)
  ((ctri   collide-cache-tri         :offset-assert   0)
   (normal vector            :inline :offset-assert  16)
   )
  :method-count-assert 9
  :size-assert         #x20
  :flag-assert         #x900000020
  )

;; definition for method 3 of type collide-edge-tri
(defmethod inspect collide-edge-tri ((obj collide-edge-tri))
  (format #t "[~8x] ~A~%" obj 'collide-edge-tri)
  (format #t "~Tctri: #<collide-cache-tri @ #x~X>~%" (-> obj ctri))
  (format #t "~Tnormal: #<vector @ #x~X>~%" (-> obj normal))
  obj
  )

;; definition of type collide-edge-edge
(deftype collide-edge-edge (structure)
  ((ignore        basic                         :offset-assert   0)
   (etri          collide-edge-tri              :offset-assert   4)
   (vertex-ptr    (inline-array vector) 2       :offset-assert   8)
   (outward       vector                :inline :offset-assert  16)
   (edge-vec-norm vector                :inline :offset-assert  32)
   )
  :method-count-assert 9
  :size-assert         #x30
  :flag-assert         #x900000030
  )

;; definition for method 3 of type collide-edge-edge
(defmethod inspect collide-edge-edge ((obj collide-edge-edge))
  (format #t "[~8x] ~A~%" obj 'collide-edge-edge)
  (format #t "~Tignore: ~A~%" (-> obj ignore))
  (format #t "~Tetri: #<collide-edge-tri @ #x~X>~%" (-> obj etri))
  (format #t "~Tvertex-ptr[2] @ #x~X~%" (-> obj vertex-ptr))
  (format #t "~Toutward: #<vector @ #x~X>~%" (-> obj outward))
  (format #t "~Tedge-vec-norm: #<vector @ #x~X>~%" (-> obj edge-vec-norm))
  obj
  )

;; definition of type collide-edge-hold-item
(deftype collide-edge-hold-item (structure)
  ((next       collide-edge-hold-item         :offset-assert   0)
   (rating     float                          :offset-assert   4)
   (split      int8                           :offset-assert   8)
   (edge       collide-edge-edge              :offset-assert  12)
   (center-pt  vector                 :inline :offset-assert  16)
   (outward-pt vector                 :inline :offset-assert  32)
   )
  :method-count-assert 9
  :size-assert         #x30
  :flag-assert         #x900000030
  )

;; definition for method 3 of type collide-edge-hold-item
(defmethod inspect collide-edge-hold-item ((obj collide-edge-hold-item))
  (format #t "[~8x] ~A~%" obj 'collide-edge-hold-item)
  (format #t "~Tnext: #<collide-edge-hold-item @ #x~X>~%" (-> obj next))
  (format #t "~Trating: ~f~%" (-> obj rating))
  (format #t "~Tsplit: ~D~%" (-> obj split))
  (format #t "~Tedge: #<collide-edge-edge @ #x~X>~%" (-> obj edge))
  (format #t "~Tcenter-pt: #<vector @ #x~X>~%" (-> obj center-pt))
  (format #t "~Toutward-pt: #<vector @ #x~X>~%" (-> obj outward-pt))
  obj
  )

;; definition of type collide-edge-hold-list
(deftype collide-edge-hold-list (structure)
  ((num-allocs   uint32                            :offset-assert   0)
   (num-attempts uint32                            :offset-assert   4)
   (head         collide-edge-hold-item            :offset-assert   8)
   (items        collide-edge-hold-item 32 :inline :offset-assert  16)
   (attempts     qword                  32 :inline :offset-assert 1552)
   )
  :method-count-assert 11
  :size-assert         #x810
  :flag-assert         #xb00000810
  (:methods
    (debug-draw (_type_) object 9)
    (add-to-list! (_type_ collide-edge-hold-item) none 10)
    )
  )

;; definition for method 3 of type collide-edge-hold-list
(defmethod inspect collide-edge-hold-list ((obj collide-edge-hold-list))
  (format #t "[~8x] ~A~%" obj 'collide-edge-hold-list)
  (format #t "~Tnum-allocs: ~D~%" (-> obj num-allocs))
  (format #t "~Tnum-attempts: ~D~%" (-> obj num-attempts))
  (format #t "~Thead: #<collide-edge-hold-item @ #x~X>~%" (-> obj head))
  (format #t "~Titems[32] @ #x~X~%" (-> obj items))
  (format #t "~Tattempts[32] @ #x~X~%" (-> obj attempts))
  obj
  )

;; definition of type collide-edge-work
(deftype collide-edge-work (structure)
  ((ccache                       collide-cache                     :offset-assert   0)
   (cshape                       collide-shape                     :offset-assert   4)
   (num-verts                    uint32                            :offset-assert   8)
   (num-edges                    uint32                            :offset-assert  12)
   (num-tris                     uint32                            :offset-assert  16)
   (cache-fill-box               bounding-box           :inline    :offset-assert  32)
   (within-reach-box             bounding-box           :inline    :offset-assert  64)
   (within-reach-box4w           bounding-box4w         :inline    :offset-assert  96)
   (search-pt                    vector                 :inline    :offset-assert 128)
   (search-dir-vec               vector                 :inline    :offset-assert 144)
   (max-dist-sqrd-to-outward-pt  float                             :offset-assert 160)
   (max-dir-cosa-delta           float                             :offset-assert 164)
   (split-dists                  float                  2          :offset-assert 168)
   (outward-offset               vector                 :inline    :offset-assert 176)
   (local-cache-fill-box         bounding-box           :inline    :offset-assert 192)
   (local-within-reach-box       bounding-box           :inline    :offset-assert 224)
   (local-player-spheres         sphere                 12 :inline :offset-assert 256)
   (world-player-spheres         sphere                 12 :inline :offset-assert 448)
   (local-player-hanging-spheres sphere                 6 :inline  :offset        256)
   (world-player-hanging-spheres sphere                 6 :inline  :offset        448)
   (local-player-leap-up-spheres sphere                 6 :inline  :offset        352)
   (world-player-leap-up-spheres sphere                 6 :inline  :offset        544)
   (verts                        vector                 64 :inline :offset-assert 640)
   (edges                        collide-edge-edge      96 :inline :offset-assert 1664)
   (tris                         collide-edge-tri       48 :inline :offset-assert 6272)
   (hold-list                    collide-edge-hold-list :inline    :offset-assert 7808)
   )
  :method-count-assert 20
  :size-assert         #x2690
  :flag-assert         #x1400002690
  (:methods
    (search-for-edges (_type_ collide-edge-hold-list) symbol 9)
    (debug-draw-edges (_type_) object 10)
    (debug-draw-tris (_type_) none 11)
    (debug-draw-sphere (_type_) symbol 12)
    (compute-center-point! (_type_ collide-edge-edge vector) float 13)
    (dummy-14 (_type_ vector vector int) float 14)
    (find-grabbable-edges! (_type_) none 15)
    (find-grabbable-tris! (_type_) none 16)
    (should-add-to-list? (_type_ collide-edge-hold-item collide-edge-edge) symbol 17)
    (find-best-grab! (_type_ collide-edge-hold-list edge-grab-info) symbol 18)
    (check-grab-for-collisions (_type_ collide-edge-hold-item edge-grab-info) symbol 19)
    )
  )

;; definition for method 3 of type collide-edge-work
(defmethod inspect collide-edge-work ((obj collide-edge-work))
  (format #t "[~8x] ~A~%" obj 'collide-edge-work)
  (format #t "~Tccache: ~A~%" (-> obj ccache))
  (format #t "~Tcshape: ~A~%" (-> obj cshape))
  (format #t "~Tnum-verts: ~D~%" (-> obj num-verts))
  (format #t "~Tnum-edges: ~D~%" (-> obj num-edges))
  (format #t "~Tnum-tris: ~D~%" (-> obj num-tris))
  (format #t "~Tcache-fill-box: #<bounding-box @ #x~X>~%" (-> obj cache-fill-box))
  (format #t "~Twithin-reach-box: #<bounding-box @ #x~X>~%" (-> obj within-reach-box))
  (format #t "~Twithin-reach-box4w: #<bounding-box4w @ #x~X>~%" (-> obj within-reach-box4w))
  (format #t "~Tsearch-pt: #<vector @ #x~X>~%" (-> obj search-pt))
  (format #t "~Tsearch-dir-vec: #<vector @ #x~X>~%" (-> obj search-dir-vec))
  (format #t "~Tmax-dist-sqrd-to-outward-pt: ~f~%" (-> obj max-dist-sqrd-to-outward-pt))
  (format #t "~Tmax-dir-cosa-delta: ~f~%" (-> obj max-dir-cosa-delta))
  (format #t "~Tsplit-dists[2] @ #x~X~%" (-> obj split-dists))
  (format #t "~Toutward-offset: #<vector @ #x~X>~%" (-> obj outward-offset))
  (format #t "~Tlocal-cache-fill-box: #<bounding-box @ #x~X>~%" (-> obj local-cache-fill-box))
  (format #t "~Tlocal-within-reach-box: #<bounding-box @ #x~X>~%" (-> obj local-within-reach-box))
  (format #t "~Tlocal-player-spheres[12] @ #x~X~%" (-> obj local-player-spheres))
  (format #t "~Tworld-player-spheres[12] @ #x~X~%" (-> obj world-player-spheres))
  (format #t "~Tlocal-player-hanging-spheres[6] @ #x~X~%" (-> obj local-player-spheres))
  (format #t "~Tworld-player-hanging-spheres[6] @ #x~X~%" (-> obj world-player-spheres))
  (format #t "~Tlocal-player-leap-up-spheres[6] @ #x~X~%" (-> obj local-player-leap-up-spheres))
  (format #t "~Tworld-player-leap-up-spheres[6] @ #x~X~%" (-> obj world-player-leap-up-spheres))
  (format #t "~Tverts[64] @ #x~X~%" (-> obj verts))
  (format #t "~Tedges[96] @ #x~X~%" (-> obj edges))
  (format #t "~Ttris[48] @ #x~X~%" (-> obj tris))
  (format #t "~Thold-list: #<collide-edge-hold-list @ #x~X>~%" (-> obj hold-list))
  obj
  )

;; definition for symbol *collide-edge-work*, type collide-edge-work
(define *collide-edge-work* (new 'static 'collide-edge-work
                              :max-dist-sqrd-to-outward-pt 37748736.0
                              :max-dir-cosa-delta 0.6
                              :split-dists (new 'static 'array float 2 1024.0 1433.6)
                              :outward-offset (new 'static 'vector :x 708.608 :y 13312.0 :w 1.0)
                              :local-cache-fill-box (new 'static 'bounding-box
                                :min (new 'static 'vector :x -8192.0 :y -11059.2 :z -8192.0 :w 1.0)
                                :max (new 'static 'vector :x 8192.0 :y 24576.0 :z 8192.0 :w 1.0)
                                )
                              :local-within-reach-box (new 'static 'bounding-box
                                :min (new 'static 'vector :x -6144.0 :y 5324.8 :z -6144.0 :w 1.0)
                                :max (new 'static 'vector :x 6144.0 :y 11059.2 :z 6144.0 :w 1.0)
                                )
                              :local-player-spheres (new 'static 'inline-array sphere 12
                                (new 'static 'sphere :x 1720.32 :y -819.2 :w 1433.6)
                                (new 'static 'sphere :x 2293.76 :y -3276.8 :w 1884.16)
                                (new 'static 'sphere :x 1966.08 :y -6144.0 :w 1556.48)
                                (new 'static 'sphere :x 1966.08 :y -8601.6 :w 1556.48)
                                (new 'static 'sphere :x 1761.28 :y -11059.2 :w 1351.68)
                                (new 'static 'sphere :x 1679.36 :y -13312.0 :w 1269.76)
                                (new 'static 'sphere :x -737.28 :y 4096.0 :w 3072.0)
                                (new 'static 'sphere :x -737.28 :y 6553.6 :w 3072.0)
                                (new 'static 'sphere :x -737.28 :y 9420.8 :w 3072.0)
                                (new 'static 'sphere :x 1720.32 :y 3686.4 :w 2949.12)
                                (new 'static 'sphere :x 1720.32 :y 5734.4 :w 2949.12)
                                (new 'static 'sphere :x 1720.32 :y 8601.6 :w 2949.12)
                                )
                              )
        )

;; definition (perm) for symbol *edge-grab-info*, type edge-grab-info
(define-perm *edge-grab-info* edge-grab-info (new 'global 'edge-grab-info))
