Files
jak-project/goal_src/engine/math/transformq-h.gc
T
ManDude 24578b64b9 proper support for hardcoded "time" types (#1141)
* hardcode `time-frame`things

* Update cam-states_REF.gc

* Update level-info_REF.gc

* update refs 1

* update refs 2

* update refs 3

* update refs 4

* update refs 5

* update detection and casting

* Update FormExpressionAnalysis.cpp

* update refs 6

* update mood decomp

* update refs 7

* update refs 8

* remove temp entity birth code

* update time-frame casts

* fix compiler

* hardcode stuff and fix some types

* fix some bitfield detection being wrong

* bug fixes

* detect seconds on adds with immediate

* update refs 9

* fix casts and rand-vu-int-range bugs (update refs 10)

* update refs 11

* update 12

* update 13

* update 14

* Update game-info_REF.gc

* improve cpad macros detection

* remove unused code

* update refs

* clang

* update source code

* Update cam-states.gc

* `lavatube-energy` finish

* update refs

* fix actor bank stuff

* Update navigate.gc

* reduce entity default stack size

* Update transformq-h.gc

* oops forgot these

* fix code and tests

* fix mood sound stuff

* Update load-dgo.gc

* Update README.md
2022-02-12 12:26:19 -05:00

89 lines
4.0 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: transformq-h.gc
;; name in dgo: transformq-h
;; dgos: GAME, ENGINE
;; the transformq is a transform, but _replaces_ the rotation field with a quaternion.
;; it is much more commonly used than transform.
(deftype transformq (transform)
;; this overlays the rot field of transform.
((quat quaternion :inline :offset 16)
)
:method-count-assert 9
:size-assert #x30
:flag-assert #x900000030
)
;; trsq is the quaternion version of trs (trs is like a transform, but is basic.)
(deftype trsq (trs)
;; this overlays the rot field of trs.
((quat quaternion :inline :offset 32)
)
:method-count-assert 9
:size-assert #x40
:flag-assert #x900000040
)
;; Representing a translate/rotate/scale with a quaternion and a velocity.
;; This is often used as the base type for the position of a game object that can move around
;; so it has methods to do common control functions.
;; many of these functions assume that y is up and assume that roll/pitch is small
;; (a reasonable assumption for most in-game objects that don't do flips)
;; note: Jak's control uses this as a base class.
(deftype trsqv (trsq)
((pause-adjust-distance meters :offset 4) ;; hack: adjusts the distance where actor logic is paused, if this is an actor
(nav-radius meters :offset 8) ;; hack: the radius of the bounding sphere used by the navigate system.
(transv vector :inline :offset-assert 64) ;; velocity (meters/second)
(rotv vector :inline :offset-assert 80) ;; angular velocity (deg/second)
(scalev vector :inline :offset-assert 96) ;; scale velocity (unused?)
;; there's a hacky ~first-order orientation yaw control with hysteresis
;; it makes the yaw change smoothly and attempts to cancel out oscillations from the collision system
(dir-targ quaternion :inline :offset-assert 112) ;; direction target
(angle-change-time time-frame :offset-assert 128) ;; the time when we change rotation directions
(old-y-angle-diff float :offset-assert 136) ;; the amount we moved last time
)
:method-count-assert 28
:size-assert #x8c
:flag-assert #x1c0000008c
(:methods
(seek-toward-heading-vec! (_type_ vector float time-frame) quaternion 9)
(set-heading-vec! (_type_ vector) quaternion 10)
(seek-to-point-toward-point! (_type_ vector float time-frame) quaternion 11)
(point-toward-point! (_type_ vector) quaternion 12)
(seek-toward-yaw-angle! (_type_ float float time-frame) quaternion 13)
(set-yaw-angle-clear-roll-pitch! (_type_ float) quaternion 14)
(set-roll-to-grav! (_type_ float) quaternion 15)
(set-roll-to-grav-2! (_type_ float) quaternion 16)
(rotate-toward-orientation! (_type_ quaternion float float) quaternion 17)
(set-quaternion! (_type_ quaternion) quaternion 18)
(set-heading-vec-clear-roll-pitch! (_type_ vector) quaternion 19)
(point-toward-point-clear-roll-pitch! (_type_ vector) quaternion 20)
(rot->dir-targ! (_type_) quaternion 21)
(y-angle (_type_) float 22)
(global-y-angle-to-point (_type_ vector) float 23)
(relative-y-angle-to-point (_type_ vector) float 24)
(roll-relative-to-gravity (_type_) float 25)
(TODO-RENAME-26 (_type_ int vector float) trsqv 26)
;; note: child classes can override this method to use a different quaternion
;; to represent the "current" orientation for the above methods.
(get-quaternion (_type_) quaternion 27)
)
)
(defmethod global-y-angle-to-point trsqv ((obj trsqv) (arg0 vector))
"Get the angle in the xy plane from the position of this trsqv to the point arg0."
(vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj trans)))
)
(defmethod relative-y-angle-to-point trsqv ((obj trsqv) (arg0 vector))
"Get the y angle between the current orientation and arg0."
(deg-diff
(y-angle obj)
(vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj trans)))
)
)