[decompiler] Detect vector*! (#3846)

Detect use of `vector*!`, which is inlined in jak 2 and jak 3.

---------

Co-authored-by: water111 <awaterford1111445@gmail.com>
This commit is contained in:
water111
2025-01-20 12:21:28 -05:00
committed by GitHub
parent 3ee2b4423c
commit 98d6618a8b
37 changed files with 2449 additions and 3185 deletions
+97 -111
View File
@@ -13,121 +13,107 @@
;; ERROR: Unsupported inline assembly instruction kind - [jr ra]
(defmethod compute-alignment! ((this align-control))
(local-vars (a0-10 symbol) (s7-0 none) (ra-0 int))
(rlet ((vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
)
(init-vf0-vector)
(update-anim-data (-> this process skel))
(let ((s5-0 (-> this process skel active-channels)))
(dotimes (s4-0 (the-as int s5-0))
(let* ((a0-4 (-> this process skel channel s4-0))
(v1-7 (-> a0-4 frame-group))
)
(case (-> a0-4 command)
(((joint-control-command stack) (joint-control-command stack1))
(update-anim-data (-> this process skel))
(let ((s5-0 (-> this process skel active-channels)))
(dotimes (s4-0 (the-as int s5-0))
(let* ((a0-4 (-> this process skel channel s4-0))
(v1-7 (-> a0-4 frame-group))
)
(else
(when (!= (-> v1-7 type) art-joint-anim)
(go process-drawable-art-error "align joint-anim")
;; og:preserve-this
(abandon-thread)
0
)
(case (-> a0-4 command)
(((joint-control-command stack) (joint-control-command stack1))
)
(else
(when (!= (-> v1-7 type) art-joint-anim)
(go process-drawable-art-error "align joint-anim")
;; og:preserve-this
(abandon-thread)
;; (.lw ra-0 return-from-thread s7-0)
;; (.jr ra-0)
;; (nop!)
0
)
)
)
)
)
(let* ((a0-9 (-> this process skel root-channel 0))
(v1-18 (-> a0-9 frame-group))
(f0-0 (-> a0-9 frame-num))
)
(= (-> a0-9 num-func) num-func-loop!)
(cond
((or (not v1-18) (!= (-> this frame-group) v1-18))
(set! a0-10 #t)
)
((= (-> a0-9 num-func) num-func-loop!)
(set! a0-10 (< (* (-> a0-9 param 0) (- f0-0 (-> this frame-num))) 0.0))
)
(else
(set! a0-10 (= f0-0 0.0))
)
)
(if a0-10
(logior! (-> this flags) (align-flags disabled))
(logclear! (-> this flags) (align-flags disabled))
)
(set! (-> this frame-group) v1-18)
(set! (-> this frame-num) f0-0)
)
(mem-copy! (the-as pointer (-> this transform 1)) (the-as pointer (-> this transform)) 48)
(quaternion-copy! (the-as quaternion (-> this transform 1 rot)) (-> this align quat))
(set! (-> this transform 1 scale quad) (-> this align scale quad))
(let* ((a2-5 (-> this matrix 1))
(a3-0 (-> this matrix))
(v1-21 (-> a3-0 0 quad 0))
(a0-19 (-> a3-0 0 quad 1))
(a1-13 (-> a3-0 0 quad 2))
(a3-1 (-> a3-0 0 trans quad))
)
(set! (-> a2-5 quad 0) v1-21)
(set! (-> a2-5 quad 1) a0-19)
(set! (-> a2-5 quad 2) a1-13)
(set! (-> a2-5 trans quad) a3-1)
)
(let ((s5-1 (-> this process node-list data 1)))
(cspace<-matrix-no-push-joint! s5-1 (-> this process skel))
(let* ((v1-25 (-> this matrix))
(a3-2 (-> s5-1 bone transform))
(a0-22 (-> a3-2 quad 0))
(a1-15 (-> a3-2 quad 1))
(a2-6 (-> a3-2 quad 2))
(a3-3 (-> a3-2 trans quad))
)
(set! (-> v1-25 0 quad 0) a0-22)
(set! (-> v1-25 0 quad 1) a1-15)
(set! (-> v1-25 0 quad 2) a2-6)
(set! (-> v1-25 0 trans quad) a3-3)
)
(let ((v1-26 (-> this transform)))
(let ((a0-24 (-> s5-1 bone transform trans))
(a1-18 (-> this process root scale))
)
(.lvf vf4 (&-> a0-24 quad))
(.lvf vf5 (&-> a1-18 quad))
)
(.add.x.vf.w vf6 vf0 vf0)
(.mul.vf.xyz vf6 vf4 vf5)
(.svf (&-> v1-26 0 trans quad) vf6)
)
)
(vector-!
(the-as vector (-> this delta))
(the-as vector (-> this transform))
(the-as vector (-> this transform 1))
)
(set-vector!
(-> this align scale)
(vector-length (the-as vector (-> this matrix)))
(vector-length (-> this matrix 0 vector 1))
(vector-length (-> this matrix 0 vector 2))
1.0
)
(vector-! (-> this delta scale) (-> this align scale) (-> this transform 1 scale))
(let ((a2-7 (matrix-inv-scale! (new 'stack-no-clear 'matrix) (-> this align scale))))
(quaternion-normalize!
(matrix->quaternion (-> this align quat) (matrix*! a2-7 (the-as matrix (-> this matrix)) a2-7))
)
)
(let ((a1-27 (quaternion-inverse! (new 'stack-no-clear 'quaternion) (the-as quaternion (-> this transform 1 rot))))
)
(quaternion-normalize! (quaternion*! (-> this delta quat) a1-27 (-> this align quat)))
)
(-> this delta)
)
(let* ((a0-9 (-> this process skel root-channel 0))
(v1-18 (-> a0-9 frame-group))
(f0-0 (-> a0-9 frame-num))
)
(= (-> a0-9 num-func) num-func-loop!)
(cond
((or (not v1-18) (!= (-> this frame-group) v1-18))
(set! a0-10 #t)
)
((= (-> a0-9 num-func) num-func-loop!)
(set! a0-10 (< (* (-> a0-9 param 0) (- f0-0 (-> this frame-num))) 0.0))
)
(else
(set! a0-10 (= f0-0 0.0))
)
)
(if a0-10
(logior! (-> this flags) (align-flags disabled))
(logclear! (-> this flags) (align-flags disabled))
)
(set! (-> this frame-group) v1-18)
(set! (-> this frame-num) f0-0)
)
(mem-copy! (the-as pointer (-> this transform 1)) (the-as pointer (-> this transform)) 48)
(quaternion-copy! (the-as quaternion (-> this transform 1 rot)) (-> this align quat))
(set! (-> this transform 1 scale quad) (-> this align scale quad))
(let* ((a2-5 (-> this matrix 1))
(a3-0 (-> this matrix))
(v1-21 (-> a3-0 0 quad 0))
(a0-19 (-> a3-0 0 quad 1))
(a1-13 (-> a3-0 0 quad 2))
(a3-1 (-> a3-0 0 trans quad))
)
(set! (-> a2-5 quad 0) v1-21)
(set! (-> a2-5 quad 1) a0-19)
(set! (-> a2-5 quad 2) a1-13)
(set! (-> a2-5 trans quad) a3-1)
)
(let ((s5-1 (-> this process node-list data 1)))
(cspace<-matrix-no-push-joint! s5-1 (-> this process skel))
(let* ((v1-25 (-> this matrix))
(a3-2 (-> s5-1 bone transform))
(a0-22 (-> a3-2 quad 0))
(a1-15 (-> a3-2 quad 1))
(a2-6 (-> a3-2 quad 2))
(a3-3 (-> a3-2 trans quad))
)
(set! (-> v1-25 0 quad 0) a0-22)
(set! (-> v1-25 0 quad 1) a1-15)
(set! (-> v1-25 0 quad 2) a2-6)
(set! (-> v1-25 0 trans quad) a3-3)
)
(vector*! (the-as vector (-> this transform)) (-> s5-1 bone transform trans) (-> this process root scale))
)
(vector-!
(the-as vector (-> this delta))
(the-as vector (-> this transform))
(the-as vector (-> this transform 1))
)
(set-vector!
(-> this align scale)
(vector-length (the-as vector (-> this matrix)))
(vector-length (-> this matrix 0 vector 1))
(vector-length (-> this matrix 0 vector 2))
1.0
)
(vector-! (-> this delta scale) (-> this align scale) (-> this transform 1 scale))
(let ((a2-7 (matrix-inv-scale! (new 'stack-no-clear 'matrix) (-> this align scale))))
(quaternion-normalize!
(matrix->quaternion (-> this align quat) (matrix*! a2-7 (the-as matrix (-> this matrix)) a2-7))
)
)
(let ((a1-27 (quaternion-inverse! (new 'stack-no-clear 'quaternion) (the-as quaternion (-> this transform 1 rot))))
)
(quaternion-normalize! (quaternion*! (-> this delta quat) a1-27 (-> this align quat)))
)
(-> this delta)
)
;; WARN: Return type mismatch (inline-array transform) vs transform.
@@ -143,10 +129,10 @@
(defmethod align! ((this align-control) (options align-opts) (x float) (y float) (z float))
"As long as [[align-flags::0]] is not set call [[process-drawable::16]] on the process being controlled
using the arguments passed to construct a [[vector]] - <`x`, `y`, `z`, 1.0>
using the arguments passed to construct a [[vector]] - <`x`, `y`, `z`, 1.0>
@returns the `root` of the [[process-drawable]] after the method returns
@see [[process-drawable::16]]"
@returns the `root` of the [[process-drawable]] after the method returns
@see [[process-drawable::16]]"
(when (not (logtest? (-> this flags) (align-flags disabled)))
(let* ((process (-> this process))
(method-call (method-of-object process apply-alignment))
+82 -77
View File
@@ -60,6 +60,8 @@
;; DECOMP BEGINS
(deftype joint-mod (basic)
"Utility to modify a joint transform from code, rather than just getting it from animation.
This is used to make jak look toward an enemy, for example."
((mode joint-mod-mode)
(process process-drawable)
(joint cspace)
@@ -119,13 +121,15 @@
)
(defun-debug joint-mod-debug-draw ((arg0 joint-mod))
(add-debug-matrix #t (bucket-id debug-no-zbuf1) (-> arg0 joint bone transform) (meters 2))
(defun-debug joint-mod-debug-draw ((jmod joint-mod))
"Debug draw the bone transform for the associated bone of a joint-mod"
(add-debug-matrix #t (bucket-id debug-no-zbuf1) (-> jmod joint bone transform) (meters 2))
0
(none)
)
(defmethod reset-blend! ((this joint-mod))
"Set the blend to 0."
(set! (-> this blend) 0.0)
this
)
@@ -196,6 +200,7 @@
)
(deftype joint-mod-set-local (basic)
"Override the trans, quat, and scale of the joint transform. The component to override is selected by the flag."
((transform transformq :inline)
(set-rotation symbol)
(set-scale symbol)
@@ -209,6 +214,7 @@
(defun joint-mod-set-local-callback ((arg0 cspace) (arg1 transformq))
"Callback for joint-mod-rotate-local. See comment on that type."
(let ((v1-0 (the-as joint-mod-set-local (-> arg0 param1))))
(cond
((-> v1-0 enable)
@@ -256,6 +262,8 @@
)
(deftype joint-mod-add-local (basic)
"Add to the trans, rotate the quat, and multiply the scale of the joint transform. The components can be selected by the flag.
Unlike jak 2, this actually multiplies the scale, instead of adding."
((transform transformq :inline)
(add-rotation symbol)
(add-scale symbol)
@@ -269,6 +277,7 @@
(defun joint-mod-add-local-callback ((arg0 cspace) (arg1 transformq))
"Callback for joint-mod-add-local. See comment on that type."
(let ((s4-0 (the-as joint-mod-add-local (-> arg0 param1))))
(when (-> s4-0 enable)
(if (-> s4-0 add-translation)
@@ -311,6 +320,8 @@
)
(deftype joint-mod-set-world (basic)
"Directly overwrite the _bone_ transform (ignoring the parent entirely).
This does not pay attention to the flags."
((transform transformq :inline)
(node-index int32)
(enable symbol)
@@ -323,6 +334,7 @@
;; WARN: Return type mismatch object vs none.
(defun joint-mod-set-world-callback ((arg0 cspace) (arg1 transformq))
"Callback for joint-mod-set-world. See comment on that type."
(let ((v1-0 (the-as joint-mod-set-world (-> arg0 param1))))
(if (-> v1-0 enable)
(cspace<-transformq! arg0 (-> v1-0 transform))
@@ -348,6 +360,8 @@
)
(deftype joint-mod-blend-local (basic)
"Blend the _joint_ transform between this transform and the animated one.
Then, apply the normal parented transform."
((transform transformq :inline)
(blend-transform transformq :inline)
(node-index int32)
@@ -361,6 +375,7 @@
(defun joint-mod-blend-local-callback ((arg0 cspace) (arg1 transformq))
"Callback for joint-mod-blend-local. See comment on that type."
(let ((gp-0 (the-as joint-mod-blend-local (-> arg0 param1))))
(cond
((-> gp-0 enable)
@@ -399,6 +414,7 @@
)
(deftype joint-mod-spinner (basic)
"Control a joint by just spinning it around an axis."
((spin-axis vector :inline)
(angle float)
(spin-rate float)
@@ -410,29 +426,30 @@
)
(defun joint-mod-spinner-callback ((arg0 cspace) (arg1 transformq))
(let ((gp-0 (the-as joint-mod-spinner (-> arg0 param1))))
(defun joint-mod-spinner-callback ((bone-cspace cspace) (joint-transform transformq))
"cspace callback for joint-mod-spinner. Update the cspace's bone from the parent transformq, plus the rotation from this spinner."
(let ((gp-0 (the-as joint-mod-spinner (-> bone-cspace param1))))
(when (-> gp-0 enable)
(let ((f30-0
(the float (sar (shl (the int (+ (-> gp-0 angle) (* (-> gp-0 spin-rate) (seconds-per-frame)))) 48) 48))
)
)
(quaternion-vector-angle! (-> arg1 quat) (-> gp-0 spin-axis) f30-0)
(quaternion-vector-angle! (-> joint-transform quat) (-> gp-0 spin-axis) f30-0)
(set! (-> gp-0 angle) f30-0)
)
)
)
(cspace<-parented-transformq-joint! arg0 arg1)
(cspace<-parented-transformq-joint! bone-cspace joint-transform)
(none)
)
(defmethod new joint-mod-spinner ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 vector) (arg3 float))
(defmethod new joint-mod-spinner ((allocation symbol) (type-to-make type) (proc process-drawable) (bone-idx int) (axis vector) (rate float))
(let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
(set! (-> v0-0 spin-axis quad) (-> arg2 quad))
(set! (-> v0-0 spin-rate) arg3)
(set! (-> v0-0 spin-axis quad) (-> axis quad))
(set! (-> v0-0 spin-rate) rate)
(set! (-> v0-0 enable) #t)
(set! (-> v0-0 angle) 0.0)
(let ((a0-3 (-> arg0 node-list data arg1)))
(let ((a0-3 (-> proc node-list data bone-idx)))
(set! (-> a0-3 param0) joint-mod-spinner-callback)
(set! (-> a0-3 param1) v0-0)
)
@@ -441,6 +458,7 @@
)
(deftype joint-mod-blend-world (basic)
"Blend the _bone_ transform between this one and the animated one."
((transform transformq :inline)
(blend-transform transformq :inline)
(blend-flags joint-mod-blend-flags)
@@ -456,80 +474,66 @@
;; WARN: Return type mismatch object vs none.
(defun joint-mod-blend-world-callback ((arg0 cspace) (arg1 transformq))
(rlet ((vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
)
(init-vf0-vector)
(let ((gp-0 (the-as joint-mod-blend-world (-> arg0 param1))))
(cond
((-> gp-0 enable)
(let ((f30-0 (if (logtest? (-> gp-0 blend-flags) (joint-mod-blend-flags trans))
(-> gp-0 blend)
0.0
)
)
(f28-0 (if (logtest? (-> gp-0 blend-flags) (joint-mod-blend-flags scale))
(-> gp-0 blend)
0.0
)
)
(f26-0 (if (logtest? (-> gp-0 blend-flags) (joint-mod-blend-flags rotation))
(-> gp-0 blend)
0.0
)
)
(s0-0 (new 'stack-no-clear 'matrix))
(s2-0 (new 'stack-no-clear 'matrix))
(s3-0 (new 'stack-no-clear 'quaternion))
)
(let ((s1-0 (new 'stack-no-clear 'vector)))
(if (= (-> arg0 parent bone scale w) 0.0)
(matrix<-transformq! s0-0 arg1)
(matrix<-parented-transformq! s0-0 arg1 (-> arg0 parent bone scale))
)
(matrix*! s2-0 s0-0 (-> arg0 parent bone transform))
(set-vector!
s1-0
(vector-length (the-as vector (-> s2-0 vector)))
(vector-length (-> s2-0 vector 1))
(vector-length (-> s2-0 vector 2))
1.0
)
(let ((v1-19 (-> gp-0 blend-transform scale)))
(let ((a0-11 (-> arg1 scale)))
(.lvf vf4 (&-> s1-0 quad))
(.lvf vf5 (&-> a0-11 quad))
)
(.add.x.vf.w vf6 vf0 vf0)
(.mul.vf.xyz vf6 vf4 vf5)
(.svf (&-> v1-19 quad) vf6)
)
"Callback for joint-mod-blend-local. See comment on that type."
(let ((gp-0 (the-as joint-mod-blend-world (-> arg0 param1))))
(cond
((-> gp-0 enable)
(let ((f30-0 (if (logtest? (-> gp-0 blend-flags) (joint-mod-blend-flags trans))
(-> gp-0 blend)
0.0
)
)
(f28-0 (if (logtest? (-> gp-0 blend-flags) (joint-mod-blend-flags scale))
(-> gp-0 blend)
0.0
)
)
(f26-0 (if (logtest? (-> gp-0 blend-flags) (joint-mod-blend-flags rotation))
(-> gp-0 blend)
0.0
)
)
(s0-0 (new 'stack-no-clear 'matrix))
(s2-0 (new 'stack-no-clear 'matrix))
(s3-0 (new 'stack-no-clear 'quaternion))
)
(vector-lerp!
(the-as vector (-> gp-0 blend-transform))
(-> s2-0 trans)
(the-as vector (-> gp-0 transform))
f30-0
)
(vector-lerp! (-> gp-0 blend-transform scale) (-> gp-0 blend-transform scale) (-> gp-0 transform scale) f28-0)
(quaternion-slerp!
(-> gp-0 blend-transform quat)
(matrix->quaternion s3-0 s2-0)
(-> gp-0 transform quat)
f26-0
(let ((s1-0 (new 'stack-no-clear 'vector)))
(if (= (-> arg0 parent bone scale w) 0.0)
(matrix<-transformq! s0-0 arg1)
(matrix<-parented-transformq! s0-0 arg1 (-> arg0 parent bone scale))
)
(matrix*! s2-0 s0-0 (-> arg0 parent bone transform))
(set-vector!
s1-0
(vector-length (the-as vector (-> s2-0 vector)))
(vector-length (-> s2-0 vector 1))
(vector-length (-> s2-0 vector 2))
1.0
)
(vector*! (-> gp-0 blend-transform scale) s1-0 (-> arg1 scale))
)
(vector-lerp!
(the-as vector (-> gp-0 blend-transform))
(-> s2-0 trans)
(the-as vector (-> gp-0 transform))
f30-0
)
(vector-lerp! (-> gp-0 blend-transform scale) (-> gp-0 blend-transform scale) (-> gp-0 transform scale) f28-0)
(quaternion-slerp!
(-> gp-0 blend-transform quat)
(matrix->quaternion s3-0 s2-0)
(-> gp-0 transform quat)
f26-0
)
(cspace<-transformq! arg0 (-> gp-0 blend-transform))
)
(else
(cspace<-parented-transformq-joint! arg0 arg1)
)
(cspace<-transformq! arg0 (-> gp-0 blend-transform))
)
(else
(cspace<-parented-transformq-joint! arg0 arg1)
)
)
(none)
)
(none)
)
(defmethod new joint-mod-blend-world ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 symbol) (arg3 float))
@@ -559,6 +563,7 @@
(defun joint-mod-rotate-local-callback ((arg0 cspace) (arg1 transformq))
"Apply an additional rotation to the transform (left side quaternion multiplication"
(let ((v1-0 (the-as joint-mod-rotate-local (-> arg0 param1))))
(new 'stack-no-clear 'vector)
(if (-> v1-0 enable)
+217 -285
View File
@@ -303,10 +303,10 @@
)
)
(defmethod new joint-mod-ik ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 float))
(defmethod new joint-mod-ik ((allocation symbol) (type-to-make type) (proc process-drawable) (joint-id int) (hand-dist float))
(let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
(set! (-> v0-0 process) arg0)
(set! (-> v0-0 hand-dist) arg2)
(set! (-> v0-0 process) proc)
(set! (-> v0-0 hand-dist) hand-dist)
(set! (-> v0-0 elbow-pole-vector-axis) (the-as uint 0))
(logclear! (-> v0-0 flags) (joint-mod-ik-flags elbow-trans-neg))
(set! (-> v0-0 elbow-rotation-axis) (the-as uint 2))
@@ -314,10 +314,10 @@
(set! (-> v0-0 callback) #f)
(set! (-> v0-0 blend) 0.0)
(logclear! (-> v0-0 flags) (joint-mod-ik-flags enable))
(let ((a0-5 (-> arg0 node-list data arg1)))
(let ((a0-5 (-> proc node-list data joint-id)))
(set! (-> a0-5 param0) joint-mod-ik-callback)
(set! (-> a0-5 param1) v0-0)
(set! (-> a0-5 param2) (the-as basic arg1))
(set! (-> a0-5 param2) (the-as basic joint-id))
)
v0-0
)
@@ -329,8 +329,8 @@
(none)
)
(defmethod enable-set! ((this joint-mod-ik) (arg0 symbol))
(if arg0
(defmethod enable-set! ((this joint-mod-ik) (enable symbol))
(if enable
(logior! (-> this flags) (joint-mod-ik-flags enable))
(logclear! (-> this flags) (joint-mod-ik-flags enable))
)
@@ -348,103 +348,52 @@
(sv-168 vector)
(sv-172 symbol)
)
(rlet ((vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
)
(init-vf0-vector)
(set! sv-16 (the-as joint-mod (-> arg0 param1)))
(let ((a0-1 (-> arg1 scale)))
(let ((v1-1 (-> arg1 scale))
(a2-1 (-> sv-16 scale))
)
(.lvf vf4 (&-> v1-1 quad))
(.lvf vf5 (&-> a2-1 quad))
)
(.add.x.vf.w vf6 vf0 vf0)
(.mul.vf.xyz vf6 vf4 vf5)
(.svf (&-> a0-1 quad) vf6)
)
(cspace<-parented-transformq-joint! arg0 arg1)
(let ((s5-0 (-> arg0 bone transform)))
(let ((s4-0 (matrix->quat s5-0 (new 'stack-no-clear 'quaternion))))
(set! sv-64 (matrix->trans s5-0 (new 'stack-no-clear 'vector)))
(quaternion-rotate-y! s4-0 s4-0 (-> sv-16 twist z))
(set! sv-96 (quaternion-copy! (new 'stack-no-clear 'quaternion) s4-0))
(when (!= (-> sv-16 flex-blend) 0.0)
(set! sv-160 (vector-y-quaternion! (new 'stack-no-clear 'vector) sv-96))
(set! sv-164 (vector-z-quaternion! (new 'stack-no-clear 'vector) sv-96))
(set! sv-168 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> sv-16 target) sv-64) 1.0))
(set! sv-172 (the-as symbol #f))
(let* ((f30-0 (vector-y-angle sv-164))
(a0-13 (vector-flatten! (new 'stack-no-clear 'vector) sv-168 sv-160))
(f0-2 (vector-y-angle a0-13))
(f0-3 (deg-diff f30-0 f0-2))
(f30-1 (* f0-3 (-> sv-16 blend)))
)
(let ((f28-0 (fmax (fmin f30-1 (-> sv-16 twist-max y)) (- (-> sv-16 twist-max y)))))
(if (or (!= f30-1 f28-0) (= (-> sv-16 blend) 0.0))
(logclear! (-> sv-16 track-mode) (track-mode lock-on))
)
(cond
((or (< (-> sv-16 ignore-angle) (fabs f0-3))
(< (-> sv-16 twist-max w) (vector-vector-distance (-> sv-16 target) sv-64))
)
(set! f30-1 0.0)
(set! f28-0 0.0)
(set! sv-172 #t)
)
((< 5461.3335 (fabs (deg-diff f30-1 f28-0)))
(set! (-> sv-16 blend) 0.0001)
)
((< 182.04445 (fabs (deg-diff f30-1 f28-0)))
(logclear! (-> sv-16 track-mode) (track-mode track-x))
)
(set! sv-16 (the-as joint-mod (-> arg0 param1)))
(vector*! (-> arg1 scale) (-> arg1 scale) (-> sv-16 scale))
(cspace<-parented-transformq-joint! arg0 arg1)
(let ((s5-0 (-> arg0 bone transform)))
(let ((s4-0 (matrix->quat s5-0 (new 'stack-no-clear 'quaternion))))
(set! sv-64 (matrix->trans s5-0 (new 'stack-no-clear 'vector)))
(quaternion-rotate-y! s4-0 s4-0 (-> sv-16 twist z))
(set! sv-96 (quaternion-copy! (new 'stack-no-clear 'quaternion) s4-0))
(when (!= (-> sv-16 flex-blend) 0.0)
(set! sv-160 (vector-y-quaternion! (new 'stack-no-clear 'vector) sv-96))
(set! sv-164 (vector-z-quaternion! (new 'stack-no-clear 'vector) sv-96))
(set! sv-168 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> sv-16 target) sv-64) 1.0))
(set! sv-172 (the-as symbol #f))
(let* ((f30-0 (vector-y-angle sv-164))
(a0-14 (vector-flatten! (new 'stack-no-clear 'vector) sv-168 sv-160))
(f0-2 (vector-y-angle a0-14))
(f0-3 (deg-diff f30-0 f0-2))
(f30-1 (* f0-3 (-> sv-16 blend)))
)
(let ((f28-0 (fmax (fmin f30-1 (-> sv-16 twist-max y)) (- (-> sv-16 twist-max y)))))
(if (or (!= f30-1 f28-0) (= (-> sv-16 blend) 0.0))
(logclear! (-> sv-16 track-mode) (track-mode lock-on))
)
(if (or (and (logtest? (-> sv-16 track-mode) (track-mode track-y)) (= f30-1 f28-0))
(< (-> sv-16 twist-max y) (fabs (-> sv-16 twist y)))
)
(set! (-> sv-16 twist y)
(deg-seek (-> sv-16 twist y) f28-0 (* (fabs (deg-diff f28-0 (-> sv-16 twist y)))
(if (logtest? (-> sv-16 track-mode) (track-mode lock-on))
1.0
(-> sv-16 twist-speed-y)
)
(-> self clock time-adjust-ratio)
)
)
)
)
(cond
((or (< (-> sv-16 ignore-angle) (fabs f0-3))
(< (-> sv-16 twist-max w) (vector-vector-distance (-> sv-16 target) sv-64))
)
(set! f30-1 0.0)
(set! f28-0 0.0)
(set! sv-172 #t)
)
((< 5461.3335 (fabs (deg-diff f30-1 f28-0)))
(set! (-> sv-16 blend) 0.0001)
)
((< 182.04445 (fabs (deg-diff f30-1 f28-0)))
(logclear! (-> sv-16 track-mode) (track-mode track-x))
)
)
(if (and (< (fabs (deg-diff f30-1 (-> sv-16 twist y))) 728.1778) (and (not sv-172) (!= (-> sv-16 blend) 0.0)))
(logior! (-> sv-16 track-mode) (track-mode lock-on))
)
)
(quaternion-rotate-local-y! sv-96 sv-96 (-> sv-16 twist y))
(let* ((s3-1 (vector-x-quaternion! (new 'stack-no-clear 'vector) sv-96))
(f30-2 (vector-x-angle sv-164))
(s3-2 (vector-flatten! (new 'stack-no-clear 'vector) sv-168 s3-1))
(f0-24 (vector-x-angle s3-2))
(f30-3 (fmax
(fmin (* (- (deg-diff f30-2 f0-24)) (-> sv-16 blend)) (-> sv-16 twist-max x))
(- (-> sv-16 twist-max x))
)
)
)
(if (or (< (vector-dot s3-2 sv-164) 0.1)
(< (-> sv-16 twist-max z) (vector-vector-distance (-> sv-16 target) sv-64))
(if (or (and (logtest? (-> sv-16 track-mode) (track-mode track-y)) (= f30-1 f28-0))
(< (-> sv-16 twist-max y) (fabs (-> sv-16 twist y)))
)
(set! f30-3 0.0)
)
(if (or (logtest? (-> sv-16 track-mode) (track-mode track-x))
(< (-> sv-16 twist-max x) (fabs (-> sv-16 twist x)))
)
(set! (-> sv-16 twist x)
(deg-seek (-> sv-16 twist x) f30-3 (* (fabs (deg-diff f30-3 (-> sv-16 twist x)))
(set! (-> sv-16 twist y)
(deg-seek (-> sv-16 twist y) f28-0 (* (fabs (deg-diff f28-0 (-> sv-16 twist y)))
(if (logtest? (-> sv-16 track-mode) (track-mode lock-on))
1.0
(-> sv-16 twist-speed-x)
(-> sv-16 twist-speed-y)
)
(-> self clock time-adjust-ratio)
)
@@ -452,55 +401,89 @@
)
)
)
(quaternion-rotate-x! sv-96 sv-96 (-> sv-16 twist x))
(quaternion-normalize! (quaternion*! sv-96 sv-96 (-> sv-16 quat)))
(if (and (< (fabs (deg-diff f30-1 (-> sv-16 twist y))) 728.1778) (and (not sv-172) (!= (-> sv-16 blend) 0.0)))
(logior! (-> sv-16 track-mode) (track-mode lock-on))
)
)
(let ((a1-27 (quaternion-slerp! (new 'stack-no-clear 'quaternion) s4-0 sv-96 (-> sv-16 flex-blend))))
(matrix<-quat s5-0 a1-27)
(quaternion-rotate-local-y! sv-96 sv-96 (-> sv-16 twist y))
(let* ((s3-1 (vector-x-quaternion! (new 'stack-no-clear 'vector) sv-96))
(f30-2 (vector-x-angle sv-164))
(s3-2 (vector-flatten! (new 'stack-no-clear 'vector) sv-168 s3-1))
(f0-24 (vector-x-angle s3-2))
(f30-3 (fmax
(fmin (* (- (deg-diff f30-2 f0-24)) (-> sv-16 blend)) (-> sv-16 twist-max x))
(- (-> sv-16 twist-max x))
)
)
)
(if (or (< (vector-dot s3-2 sv-164) 0.1)
(< (-> sv-16 twist-max z) (vector-vector-distance (-> sv-16 target) sv-64))
)
(set! f30-3 0.0)
)
(if (or (logtest? (-> sv-16 track-mode) (track-mode track-x))
(< (-> sv-16 twist-max x) (fabs (-> sv-16 twist x)))
)
(set! (-> sv-16 twist x)
(deg-seek (-> sv-16 twist x) f30-3 (* (fabs (deg-diff f30-3 (-> sv-16 twist x)))
(if (logtest? (-> sv-16 track-mode) (track-mode lock-on))
1.0
(-> sv-16 twist-speed-x)
)
(-> self clock time-adjust-ratio)
)
)
)
)
)
(quaternion-rotate-x! sv-96 sv-96 (-> sv-16 twist x))
(quaternion-normalize! (quaternion*! sv-96 sv-96 (-> sv-16 quat)))
)
(let ((f30-4 (-> sv-16 trans x))
(s4-1 (-> s5-0 vector 1))
(v1-97 (vector<-matrix! (new 'stack-no-clear 'vector) s5-0))
)
(let ((f0-43 (- f30-4 (-> v1-97 y))))
(if (< 614.4 (fabs f0-43))
(+! (-> sv-16 trans z) (* 8.0 f0-43))
)
)
(+! (-> sv-16 trans z) (* -260.0 (seconds-per-frame) (-> sv-16 trans y)))
(let ((f0-48 (-> sv-16 trans y)))
(+! (-> sv-16 trans y) (* (-> sv-16 trans z) (seconds-per-frame)))
(set! (-> sv-16 trans y) (* 0.95 (-> sv-16 trans y)))
(when (< (* f0-48 (-> sv-16 trans y)) 0.0)
(set! (-> sv-16 trans y) 0.0)
(set! (-> sv-16 trans z) 0.0)
)
)
(cond
((< 409.6 (-> sv-16 trans y))
(set! (-> sv-16 trans y) 409.6)
(set! (-> sv-16 trans z) 0.0)
)
((< (-> sv-16 trans y) -409.6)
(set! (-> sv-16 trans y) -409.6)
(set! (-> sv-16 trans z) 0.0)
)
)
(set! (-> sv-16 trans x) (-> v1-97 y))
(let ((f0-60 (* (-> sv-16 trans y) (-> sv-16 flex-blend))))
(if (!= f0-60 0.0)
(vector+float*! (-> s5-0 trans) v1-97 s4-1 f0-60)
)
)
(let ((a1-27 (quaternion-slerp! (new 'stack-no-clear 'quaternion) s4-0 sv-96 (-> sv-16 flex-blend))))
(matrix<-quat s5-0 a1-27)
)
)
(if (-> sv-16 parented-scale?)
(set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0)
(let ((f30-4 (-> sv-16 trans x))
(s4-1 (-> s5-0 vector 1))
(v1-97 (vector<-matrix! (new 'stack-no-clear 'vector) s5-0))
)
(let ((f0-43 (- f30-4 (-> v1-97 y))))
(if (< 614.4 (fabs f0-43))
(+! (-> sv-16 trans z) (* 8.0 f0-43))
)
)
0
(none)
(+! (-> sv-16 trans z) (* -260.0 (seconds-per-frame) (-> sv-16 trans y)))
(let ((f0-48 (-> sv-16 trans y)))
(+! (-> sv-16 trans y) (* (-> sv-16 trans z) (seconds-per-frame)))
(set! (-> sv-16 trans y) (* 0.95 (-> sv-16 trans y)))
(when (< (* f0-48 (-> sv-16 trans y)) 0.0)
(set! (-> sv-16 trans y) 0.0)
(set! (-> sv-16 trans z) 0.0)
)
)
(cond
((< 409.6 (-> sv-16 trans y))
(set! (-> sv-16 trans y) 409.6)
(set! (-> sv-16 trans z) 0.0)
)
((< (-> sv-16 trans y) -409.6)
(set! (-> sv-16 trans y) -409.6)
(set! (-> sv-16 trans z) 0.0)
)
)
(set! (-> sv-16 trans x) (-> v1-97 y))
(let ((f0-60 (* (-> sv-16 trans y) (-> sv-16 flex-blend))))
(if (!= f0-60 0.0)
(vector+float*! (-> s5-0 trans) v1-97 s4-1 f0-60)
)
)
)
)
(if (-> sv-16 parented-scale?)
(set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0)
)
0
(none)
)
(defbehavior joint-mod-gun-look-at-handler process ((arg0 cspace) (arg1 transformq))
@@ -703,40 +686,40 @@
(none)
)
(defmethod twist-set! ((this joint-mod) (arg0 float) (arg1 float) (arg2 float))
(if arg0
(set! (-> this twist x) arg0)
(defmethod twist-set! ((this joint-mod) (x float) (y float) (z float))
(if x
(set! (-> this twist x) x)
)
(if arg1
(set! (-> this twist y) arg1)
(if y
(set! (-> this twist y) y)
)
(if arg2
(set! (-> this twist z) arg2)
(if z
(set! (-> this twist z) z)
)
(-> this twist)
)
(defmethod trs-set! ((this joint-mod) (arg0 vector) (arg1 quaternion) (arg2 vector))
(if arg0
(set! (-> this trans quad) (-> arg0 quad))
(defmethod trs-set! ((this joint-mod) (trans vector) (quat quaternion) (scale vector))
(if trans
(set! (-> this trans quad) (-> trans quad))
)
(if arg1
(quaternion-copy! (-> this quat) arg1)
(if quat
(quaternion-copy! (-> this quat) quat)
)
(if arg2
(set! (-> this scale quad) (-> arg2 quad))
(if scale
(set! (-> this scale quad) (-> scale quad))
)
0
(none)
)
(defmethod target-set! ((this joint-mod) (arg0 vector))
(defmethod target-set! ((this joint-mod) (pos vector))
(if (= (-> this mode) (joint-mod-mode reset))
(mode-set! this (joint-mod-mode look-at))
)
(let ((f0-0 (vector-vector-distance (-> this process root trans) arg0)))
(let ((f0-0 (vector-vector-distance (-> this process root trans) pos)))
(set! (-> this shutting-down?) #f)
(set! (-> this target quad) (-> arg0 quad))
(set! (-> this target quad) (-> pos quad))
(if (< f0-0 (-> this max-dist))
(set! (-> this blend) 1.0)
(set! (-> this blend) 0.0)
@@ -1225,112 +1208,78 @@
)
(defbehavior joint-mod-rotate-handler process ((arg0 cspace) (arg1 transformq))
(rlet ((vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
)
(init-vf0-vector)
(let ((s5-0 (the-as joint-mod (-> arg0 param1))))
(let ((s3-0 (new 'static 'inline-array quaternion 3
(new 'static 'quaternion :x 1.0 :w 1.0)
(new 'static 'quaternion :y 1.0 :w 1.0)
(new 'static 'quaternion :z 1.0 :w 1.0)
)
(let ((s5-0 (the-as joint-mod (-> arg0 param1))))
(let ((s3-0 (new 'static 'inline-array quaternion 3
(new 'static 'quaternion :x 1.0 :w 1.0)
(new 'static 'quaternion :y 1.0 :w 1.0)
(new 'static 'quaternion :z 1.0 :w 1.0)
)
)
(if (not (logtest? (-> s5-0 track-mode) (track-mode no-trans)))
(vector+! (-> arg1 trans) (-> arg1 trans) (-> s5-0 trans))
)
(when (not (logtest? (-> s5-0 track-mode) (track-mode no-rotate)))
(let* ((v1-9 (-> s3-0 (-> s5-0 ear)))
(a1-4 (quaternion-axis-angle!
(new 'stack-no-clear 'quaternion)
(-> v1-9 x)
(-> v1-9 y)
(-> v1-9 z)
(* (-> s5-0 twist x) (-> s5-0 blend) (-> s5-0 flex-blend))
)
)
)
(quaternion-normalize! (quaternion*! (-> arg1 quat) a1-4 (-> arg1 quat)))
)
(let* ((v1-13 (-> s3-0 (-> s5-0 up)))
(a1-6 (quaternion-axis-angle!
(new 'stack-no-clear 'quaternion)
(-> v1-13 x)
(-> v1-13 y)
(-> v1-13 z)
(* (-> s5-0 twist y) (-> s5-0 blend) (-> s5-0 flex-blend))
)
)
)
(quaternion-normalize! (quaternion*! (-> arg1 quat) a1-6 (-> arg1 quat)))
)
(let* ((v1-17 (-> s3-0 (-> s5-0 nose)))
(a1-8 (quaternion-axis-angle!
(new 'stack-no-clear 'quaternion)
(-> v1-17 x)
(-> v1-17 y)
(-> v1-17 z)
(* (-> s5-0 twist z) (-> s5-0 blend) (-> s5-0 flex-blend))
)
)
)
(quaternion-normalize! (quaternion*! (-> arg1 quat) a1-8 (-> arg1 quat)))
)
)
)
(when (not (logtest? (-> s5-0 track-mode) (track-mode no-scale)))
(let ((a1-9 (-> arg1 scale)))
(let ((v1-22 (-> arg1 scale))
(a0-11 (-> s5-0 scale))
)
(.lvf vf4 (&-> v1-22 quad))
(.lvf vf5 (&-> a0-11 quad))
)
(.add.x.vf.w vf6 vf0 vf0)
(.mul.vf.xyz vf6 vf4 vf5)
(.svf (&-> a1-9 quad) vf6)
)
(if (not (logtest? (-> s5-0 track-mode) (track-mode no-trans)))
(vector+! (-> arg1 trans) (-> arg1 trans) (-> s5-0 trans))
)
(when (not (logtest? (-> s5-0 track-mode) (track-mode no-rotate)))
(let* ((v1-9 (-> s3-0 (-> s5-0 ear)))
(a1-4 (quaternion-axis-angle!
(new 'stack-no-clear 'quaternion)
(-> v1-9 x)
(-> v1-9 y)
(-> v1-9 z)
(* (-> s5-0 twist x) (-> s5-0 blend) (-> s5-0 flex-blend))
)
)
)
(quaternion-normalize! (quaternion*! (-> arg1 quat) a1-4 (-> arg1 quat)))
)
(let* ((v1-13 (-> s3-0 (-> s5-0 up)))
(a1-6 (quaternion-axis-angle!
(new 'stack-no-clear 'quaternion)
(-> v1-13 x)
(-> v1-13 y)
(-> v1-13 z)
(* (-> s5-0 twist y) (-> s5-0 blend) (-> s5-0 flex-blend))
)
)
)
(quaternion-normalize! (quaternion*! (-> arg1 quat) a1-6 (-> arg1 quat)))
)
(let* ((v1-17 (-> s3-0 (-> s5-0 nose)))
(a1-8 (quaternion-axis-angle!
(new 'stack-no-clear 'quaternion)
(-> v1-17 x)
(-> v1-17 y)
(-> v1-17 z)
(* (-> s5-0 twist z) (-> s5-0 blend) (-> s5-0 flex-blend))
)
)
)
(quaternion-normalize! (quaternion*! (-> arg1 quat) a1-8 (-> arg1 quat)))
)
)
(cspace<-parented-transformq-joint! arg0 arg1)
(if (-> s5-0 parented-scale?)
(set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0)
)
)
0
(none)
(if (not (logtest? (-> s5-0 track-mode) (track-mode no-scale)))
(vector*! (-> arg1 scale) (-> arg1 scale) (-> s5-0 scale))
)
(cspace<-parented-transformq-joint! arg0 arg1)
(if (-> s5-0 parented-scale?)
(set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0)
)
)
0
(none)
)
(defbehavior joint-mod-scale-handler process ((arg0 cspace) (arg1 transformq))
(rlet ((vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
)
(init-vf0-vector)
(let ((s5-0 (the-as joint-mod (-> arg0 param1))))
(let ((a2-0 (-> arg1 scale)))
(let ((v1-0 (-> arg1 scale))
(a0-1 (-> s5-0 scale))
)
(.lvf vf4 (&-> v1-0 quad))
(.lvf vf5 (&-> a0-1 quad))
)
(.add.x.vf.w vf6 vf0 vf0)
(.mul.vf.xyz vf6 vf4 vf5)
(.svf (&-> a2-0 quad) vf6)
(let ((s5-0 (the-as joint-mod (-> arg0 param1))))
(vector*! (-> arg1 scale) (-> arg1 scale) (-> s5-0 scale))
(cspace<-parented-transformq-joint! arg0 arg1)
(if (-> s5-0 parented-scale?)
(set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0)
)
(cspace<-parented-transformq-joint! arg0 arg1)
(if (-> s5-0 parented-scale?)
(set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0)
)
)
0
(none)
)
0
(none)
)
(defbehavior joint-mod-joint-set-handler process ((arg0 cspace) (arg1 transformq))
@@ -1434,40 +1383,23 @@
)
(defbehavior joint-mod-joint-set*-handler process ((arg0 cspace) (arg1 transformq))
(rlet ((vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
)
(init-vf0-vector)
(let ((s5-0 (the-as joint-mod (-> arg0 param1))))
(if (not (logtest? (-> s5-0 track-mode) (track-mode no-trans)))
(vector+! (-> arg1 trans) (-> arg1 trans) (-> s5-0 trans))
)
(if (not (logtest? (-> s5-0 track-mode) (track-mode no-rotate)))
(quaternion-normalize! (quaternion*! (-> arg1 quat) (-> arg1 quat) (-> s5-0 quat)))
)
(when (not (logtest? (-> s5-0 track-mode) (track-mode no-scale)))
(let ((a1-4 (-> arg1 scale)))
(let ((v1-11 (-> arg1 scale))
(a0-4 (-> s5-0 scale))
)
(.lvf vf4 (&-> v1-11 quad))
(.lvf vf5 (&-> a0-4 quad))
)
(.add.x.vf.w vf6 vf0 vf0)
(.mul.vf.xyz vf6 vf4 vf5)
(.svf (&-> a1-4 quad) vf6)
)
(let ((s5-0 (the-as joint-mod (-> arg0 param1))))
(if (not (logtest? (-> s5-0 track-mode) (track-mode no-trans)))
(vector+! (-> arg1 trans) (-> arg1 trans) (-> s5-0 trans))
)
(if (not (logtest? (-> s5-0 track-mode) (track-mode no-rotate)))
(quaternion-normalize! (quaternion*! (-> arg1 quat) (-> arg1 quat) (-> s5-0 quat)))
)
(if (not (logtest? (-> s5-0 track-mode) (track-mode no-scale)))
(vector*! (-> arg1 scale) (-> arg1 scale) (-> s5-0 scale))
)
(cspace<-parented-transformq-joint! arg0 arg1)
(if (-> s5-0 parented-scale?)
(set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0)
)
(cspace<-parented-transformq-joint! arg0 arg1)
(if (-> s5-0 parented-scale?)
(set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0)
)
)
0
(none)
)
0
(none)
)
(defbehavior joint-mod-joint-set*-world-handler process ((arg0 cspace) (arg1 transformq))