Skip to content

Commit

Permalink
[jak3] Fix crash in subrails (#3863)
Browse files Browse the repository at this point in the history
After the change to vector ops, subrails was crashing. This fixes the
crash by fixing a stack type and also marks those new vector op
functions as inline.

Co-authored-by: water111 <[email protected]>
  • Loading branch information
water111 and water111 authored Feb 16, 2025
1 parent af9a8dd commit 23118be
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion decompiler/config/jak3/ntsc_v1/stack_structures.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,7 @@
],
"(method 97 h-sled)": [
[16, "collide-query"],
[560, ["inline-array", "vector", 1]],
[560, ["inline-array", "matrix", 1]],
[624, "vector"]
],
"(method 152 h-sled)": [[16, "comb-sentry-stack-var0"]],
Expand Down
5 changes: 5 additions & 0 deletions goal_src/jak3/engine/math/vector.gc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

(defun vector-cross! ((arg0 vector) (arg1 vector) (arg2 vector))
"Compute the cross product. The w component is set to junk."
(declare (inline))
(rlet ((acc :class vf)
(vf1 :class vf)
(vf2 :class vf)
Expand Down Expand Up @@ -62,6 +63,7 @@

(defun vector*! ((arg0 vector) (arg1 vector) (arg2 vector))
"Elementwise product. Set w = 1."
(declare (inline))
(rlet ((vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
Expand All @@ -79,6 +81,7 @@

(defun vector+*! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float))
"set arg0 = arg1 + (arg3 * arg2). The w component will be set to 1."
(declare (inline))
(rlet ((acc :class vf)
(vf0 :class vf)
(vf4 :class vf)
Expand All @@ -100,6 +103,7 @@

(defun vector-*! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float))
"Set arg0 = arg1 - (arg3 * arg2). The w component will be set to 1."
(declare (inline))
(rlet ((acc :class vf)
(vf0 :class vf)
(vf4 :class vf)
Expand Down Expand Up @@ -194,6 +198,7 @@

(defun vector+float*! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float))
"arg0 = arg1 + arg2 * arg3."
(declare (inline))
(rlet ((acc :class vf)
(vf0 :class vf)
(vf1 :class vf)
Expand Down
6 changes: 3 additions & 3 deletions goal_src/jak3/levels/comb/h-sled.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1483,9 +1483,9 @@
(vector-normalize! (-> this side-dir) 1.0)
)
(when (logtest? (-> this v-flags) (vehicle-flag on-ground))
(let ((s2-1 (new 'stack-no-clear 'inline-array 'vector 1)))
(matrix-from-two-vectors! (the-as matrix (-> s2-1 0)) (-> this prev-tunnel-dir) (-> this tunnel-dir))
(vector-rotate*! (-> s3-0 lin-momentum) (-> s3-0 lin-momentum) (the-as matrix (-> s2-1 0)))
(let ((s2-1 (new 'stack-no-clear 'inline-array 'matrix 1)))
(matrix-from-two-vectors! (-> s2-1 0) (-> this prev-tunnel-dir) (-> this tunnel-dir))
(vector-rotate*! (-> s3-0 lin-momentum) (-> s3-0 lin-momentum) (-> s2-1 0))
)
(init-velocities! (-> this rbody))
)
Expand Down
6 changes: 3 additions & 3 deletions test/decompiler/reference/jak3/levels/comb/h-sled_REF.gc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 23118be

Please sign in to comment.