;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/math/vector-h.gc")

;; These "wind" types are used in the tie/shrub renderers to make things sway in the breeze.
;; It generates vectors that are applied as shear to the instance matrices.

;; DECOMP BEGINS

(deftype wind-vector (structure)
  ((wind-pos vector2w :inline)
   (wind-vel vector2w :inline)))

(define *wind-scales*
  (new 'static
       'boxed-array
       :type
       uint8
       #x2
       #x5
       #x2
       #x3
       #x2
       #x2
       #x3
       #x10
       #xa
       #x2
       #x4
       #x2
       #x8
       #x2
       #x2
       #x10
       #x2
       #x2
       #x8
       #x2
       #x10
       #x2
       #x4
       #x10
       #xa
       #x2
       #x4
       #x2
       #x8
       #x2
       #x2
       #x10))

(deftype wind-work (basic)
  ((wind-array  vector 64 :inline)
   (wind-normal vector :inline)
   (wind-temp   vector :inline)
   (wind-force  float 64)
   (wind-time   uint32)))

; This was likely originally defined inside `wind-h`
; but the decompiler won't output it, so we have to manually define it
(define-extern *wind-work* wind-work)

(defun wind-get-hashed-index ((arg0 vector))
  (logand (+ (the int (-> arg0 x)) (the int (-> arg0 z)) (-> *wind-work* wind-time)) 63))
