jak-project/goal_src/jak2/engine/camera/cam-interface.gc
ManDude 04269ffa86
[jak2] fill in a lot of flags for decomp + mouse macros (#2927)
Also changed the default type of enums to `int64` (same as `int`).
2023-08-22 16:39:52 +01:00

95 lines
2.7 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: cam-interface.gc
;; name in dgo: cam-interface
;; dgos: ENGINE, GAME
;; DECOMP BEGINS
(defun position-in-front-of-camera! ((arg0 vector) (arg1 float) (arg2 float))
(vector-float*! arg0 (-> *math-camera* inv-camera-rot vector 2) arg1)
(vector+float*! arg0 arg0 (-> *math-camera* inv-camera-rot vector 1) arg2)
(vector+! arg0 arg0 (-> *math-camera* trans))
arg0
)
(defun position-in-front-of-screen! ((arg0 vector) (arg1 float) (arg2 vector))
(let ((a2-1 (vector-negate! (new 'stack-no-clear 'vector) (-> *math-camera* inv-camera-rot vector 2)))
(a1-3 (vector-float*! (new 'stack-no-clear 'vector) (-> *math-camera* inv-camera-rot vector 2) arg1))
)
(vector+! a1-3 a1-3 (-> *math-camera* trans))
(reverse-transform-point! arg0 a1-3 a2-1 arg2)
)
arg0
)
(defun matrix-local->world ((smooth? symbol) (arg1 symbol))
"Returns [[*math-camera*]]'s `inv-camera-rot-smooth` if `smooth?` is true, else return `inv-camera-rot`"
(if smooth?
(-> *math-camera* inv-camera-rot-smooth)
(-> *math-camera* inv-camera-rot)
)
)
(defun matrix-world->local ((arg0 symbol) (arg1 object))
"Returns [[*math-camera*]]'s `camera-rot`"
(-> *math-camera* camera-rot)
)
(define-perm *camera-dummy-vector* vector (vector-reset! (new 'global 'vector)))
(defun camera-pos ()
"Returns the `trans` vector from whatever is first determined to exist:
- [[*camera-combiner*]]
- [[*math-camera*]]
- else, [[*camera-dummy-vector*]]"
(cond
(*camera-combiner*
(-> *camera-combiner* trans)
)
(*math-camera*
(-> *math-camera* trans)
)
(else
*camera-dummy-vector*
)
)
)
(defun math-camera-pos ()
"Returns [[*math-camera*]]'s `trans`"
(-> *math-camera* trans)
)
(defun camera-matrix ()
"If [[*camera-combiner*]] exists, return it's `inv-camera-rot`. Else, return [[*math-camera*]]'s"
(if *camera-combiner*
(-> *camera-combiner* inv-camera-rot)
(-> *math-camera* inv-camera-rot)
)
)
(defun math-camera-matrix ()
"Returns [[*math-camera*]]'s `inv-camera-rot`"
(-> *math-camera* inv-camera-rot)
)
(defun camera-angle ()
(let ((f0-0 (-> *math-camera* camera-rot vector 0 x))
(f1-0 (-> *math-camera* camera-rot vector 0 z))
)
(atan f1-0 f0-0)
)
)
;; WARN: Return type mismatch object vs symbol.
(defbehavior camera-teleport-to-entity process ((arg0 entity-actor))
(let ((gp-0 (new 'stack 'transformq)))
(set! (-> gp-0 trans quad) (-> arg0 extra trans quad))
(quaternion-copy! (-> gp-0 quat) (-> arg0 quat))
(vector-identity! (-> gp-0 scale))
(the-as symbol (send-event *camera* 'teleport-to-transformq gp-0))
)
)