jak-project/goal_src/engine/math/quaternion-h.gc
water111 69e24ae577
recognize vector, matrix, quaternion constructors in a better way (#630)
* recognize vector, matrix, quaternion constructors in a better way

* fix bad bug
2021-06-26 18:30:35 -04:00

36 lines
1 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: quaternion-h.gc
;; name in dgo: quaternion-h
;; dgos: GAME, ENGINE
(deftype quaternion (structure)
((x float :offset-assert 0)
(y float :offset-assert 4)
(z float :offset-assert 8)
(w float :offset-assert 12)
(data float 4 :score -9999 :offset 0)
(vec vector :inline :offset 0)
(quad uint128 :offset 0)
)
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
(define *unity-quaternion* (new 'static 'quaternion :x 0.0 :y 0.0 :z 0.0 :w 1.0))
(define-extern matrix->quaternion (function quaternion matrix quaternion))
(define-extern vector-y-angle (function vector float))
(defmacro new-stack-quaternion0 ()
"Get a stack quaternion that's set to 0.
This is more efficient than (new 'stack 'quaternion) because
this doesn't call the constructor."
`(let ((q (new 'stack-no-clear 'quaternion)))
(set! (-> q quad) (the-as uint128 0))
q
)
)