Skip to content

Commit

Permalink
jak3: fix some collide decomp + fix projectiles aiming at intangible …
Browse files Browse the repository at this point in the history
…objects (#3485)

Say goodbye to half of the laser needle shots spinning around doing
nothing. This is toggleable with `fix-projectile-focus` in the pc
settings.
  • Loading branch information
ManDude authored Apr 26, 2024
1 parent 6675538 commit 889fdcd
Show file tree
Hide file tree
Showing 62 changed files with 246 additions and 513 deletions.
10 changes: 5 additions & 5 deletions decompiler/config/jak3/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -23598,8 +23598,8 @@
:size-assert #x30
:flag-assert #xb00000030
(:methods
(resolve-moving-sphere-tri (_type_ collide-tri-result collide-prim-core vector float collide-action) float) ;; 9
(resolve-moving-sphere-sphere (_type_ collide-tri-result collide-prim-core vector float collide-action) float) ;; 10
(resolve-moving-sphere-tri (_type_ collide-query sphere vector float collide-action) float) ;; 9
(resolve-moving-sphere-sphere (_type_ collide-query sphere vector float collide-action) float) ;; 10
)
)

Expand Down Expand Up @@ -28704,7 +28704,7 @@
(new (symbol type int int) _type_) ;; 0
(spatial-hash-method-33 (_type_ vector hash-object-info) none) ;; 33
(add-an-object (_type_ bounding-box (pointer collide-shape) int) int) ;; 34
(fill-actor-list-for-box (_type_ bounding-box (pointer collide-shape) int) int) ;; 35
(fill-actor-list-for-box (_type_ vector (pointer collide-shape) int) int) ;; 35
(fill-actor-list-for-sphere (_type_ vector vector float (pointer collide-shape) int int) int) ;; 36
(fill-actor-list-for-line-sphere (_type_ vector vector float (pointer collide-shape) int int) int) ;; 37
(fill-actor-list-for-vec+r (_type_ vector (pointer collide-shape) int) int) ;; 38
Expand Down Expand Up @@ -36405,7 +36405,7 @@
(define-extern gun-blue-shot-3-move (function gun-blue-shot-3 none))
(define-extern *blue-shot-trail* light-trail-composition)
(define-extern gun-fire-blue-3 (function object :behavior target))
(define-extern draw-beam-segment (function none))
(define-extern draw-beam-segment (function symbol))
(define-extern *found-objects* (pointer handle))
(define-extern *gun-blue-2-last-attack-id* uint)
(define-extern *gun-blue-2-last-attack-id-time* timeframe-wrapper)
Expand Down Expand Up @@ -60312,7 +60312,7 @@
(des-beast-method-164 (_type_) none) ;; 164
(des-beast-method-165 (_type_) none) ;; 165
(des-beast-method-166 (_type_) none) ;; 166
(des-beast-method-167 (_type_ bounding-box) symbol) ;; 167
(des-beast-method-167 (_type_ vector) symbol) ;; 167
)
)

Expand Down
10 changes: 5 additions & 5 deletions decompiler/config/jak3/ntsc_v1/stack_structures.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
],
"board-turn-around?": [[48, "vector"]],
"target-board-green-eco-attack": [
[16, "bounding-box"],
[16, "vector"],
[32, ["array", "collide-shape", 384]]
],
"(enter target-board-jump)": [[48, "vector"]],
Expand Down Expand Up @@ -502,7 +502,7 @@
[128, "vector"],
[1696, "vector"]
],
"(method 26 gun-red-shot)": [[16, "bounding-box"]],
"(method 26 gun-red-shot)": [[16, "vector"]],
"gun-dark-reaction": [[112, "vector"]],
"gun-fire-red-1": [
[16, "vector"],
Expand Down Expand Up @@ -613,7 +613,7 @@
"(method 50 collide-shape)": [[32, "vector"]],
"(method 45 collide-shape)": [[16, "do-push-aways-work"]],
"(method 18 collide-shape-prim-mesh)": [[16, "collide-tri-result"]],
"(method 15 collide-shape-prim-sphere)": [[16, "collide-tri-result"]],
"(method 15 collide-shape-prim-sphere)": [[16, "collide-query"]],
"cshape-reaction-update-state": [
[16, "vector"],
[32, "vector"]
Expand Down Expand Up @@ -642,7 +642,7 @@
"(method 33 spatial-hash)": [[16, ["inline-array", "vector", 2]]],
"(method 24 grid-hash)": [[16, "vector"]],
"(method 14 collide-cache)": [[16, "bounding-box"]],
"(method 16 collide-cache)": [[16, "collide-cache-tri"]],
"(method 16 collide-cache)": [[16, "collide-puls-work"]],
"(method 20 collide-cache)": [[16, "matrix"]],
"col-rend-draw": [[16, "matrix"]],
"(method 11 collide-mesh)": [[16, "spat-work"]],
Expand Down Expand Up @@ -1579,7 +1579,7 @@
],
"(method 62 wascity-turret)": [
[16, "matrix"],
[80, "bounding-box"],
[80, "vector"],
[752, "vector"],
[624, "vector"],
[656, "vector"],
Expand Down
2 changes: 1 addition & 1 deletion decompiler/config/jak3/ntsc_v1/type_casts.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -3516,7 +3516,7 @@
[43, "s3", "process-focusable"],
[93, "s3", "process-focusable"],
[122, "s3", "process-focusable"],
["_stack_", 32, "bounding-box"]
["_stack_", 32, "vector"]
],
"gun-fire-red-3": [
[216, "s1", "process-focusable"],
Expand Down
4 changes: 2 additions & 2 deletions goal_src/jak3/engine/collide/collide-cache-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ This can represent a sphere, a triangle mesh, or a group of other primitives wit
(prim-type prim-type :overlay-at (-> prim-core prim-type))
)
(:methods
(resolve-moving-sphere-tri (_type_ collide-tri-result collide-prim-core vector float collide-action) float)
(resolve-moving-sphere-sphere (_type_ collide-tri-result collide-prim-core vector float collide-action) float)
(resolve-moving-sphere-tri (_type_ collide-query sphere vector float collide-action) float)
(resolve-moving-sphere-sphere (_type_ collide-query sphere vector float collide-action) float)
)
)

Expand Down
20 changes: 10 additions & 10 deletions goal_src/jak3/engine/collide/collide-cache.gc
Original file line number Diff line number Diff line change
Expand Up @@ -790,14 +790,14 @@
(vf4 :class vf)
)
(init-vf0-vector)
(let ((s5-0 (new 'stack-no-clear 'collide-cache-tri)))
(let ((s5-0 (new 'stack-no-clear 'collide-puls-work)))
(.lvf vf4 (&-> arg0 exit-planes 0 quad))
(.lvf vf3 (&-> arg0 start-pos quad))
(.lvf vf2 (&-> arg0 move-dist quad))
(set! (-> s5-0 vertex 0 x) (the-as float (-> arg0 ignore-pat)))
(set! (-> s5-0 ignore-pat) (-> arg0 ignore-pat))
(.mul.w.vf vf3 vf0 vf4 :mask #b1000)
(.svf (&-> s5-0 vertex 2 quad) vf2)
(.svf (&-> s5-0 vertex 1 quad) vf3)
(.svf (&-> s5-0 move-dist quad) vf2)
(.svf (&-> s5-0 bsphere quad) vf3)
(let ((s4-0 (the-as object (-> this prims)))
(f30-0 -100000000.0)
)
Expand All @@ -809,9 +809,9 @@
((>= (-> (the-as collide-cache-prim s4-0) prim-core prim-type) 0)
(let ((f0-0 ((method-of-type collide-cache-prim resolve-moving-sphere-tri)
(the-as collide-cache-prim s4-0)
(the-as collide-tri-result arg0)
(the-as collide-prim-core (-> s5-0 vertex 1))
(-> s5-0 vertex 2)
arg0
(-> s5-0 bsphere)
(-> s5-0 move-dist)
f30-0
(collide-action solid)
)
Expand All @@ -829,9 +829,9 @@
)
(let ((f0-1 ((method-of-type collide-cache-prim resolve-moving-sphere-sphere)
(the-as collide-cache-prim s4-0)
(the-as collide-tri-result arg0)
(the-as collide-prim-core (-> s5-0 vertex 1))
(-> s5-0 vertex 2)
arg0
(-> s5-0 bsphere)
(-> s5-0 move-dist)
f30-0
(collide-action solid)
)
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak3/engine/collide/collide-shape-rider.gc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
(set! *actor-list-length* 0)
(if (logtest? s5-0 (collide-spec hit-by-others-list))
(set! *actor-list-length*
(fill-actor-list-for-box *actor-hash* (the-as bounding-box (-> s4-0 prim-core)) *actor-list* 256)
(fill-actor-list-for-box *actor-hash* (the-as vector (-> s4-0 prim-core)) *actor-list* 256)
)
)
(when (logtest? s5-0 (collide-spec player-list))
Expand Down
58 changes: 22 additions & 36 deletions goal_src/jak3/engine/collide/collide-shape.gc
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,11 @@
(vf4 :class vf)
(vf5 :class vf)
)
(let* ((gp-0 (new 'stack-no-clear 'collide-tri-result))
(let* ((gp-0 (new 'stack-no-clear 'collide-query))
(f0-1 (resolve-moving-sphere-tri
arg1
gp-0
(-> this prim-core)
(the-as sphere (-> this prim-core))
(-> arg0 move-dist)
(-> arg0 best-dist)
(-> this prim-core action)
Expand All @@ -442,13 +442,13 @@
(b! (= v1-5 #f) cfg-5 :likely-delay (set! a2-2 (the-as collide-shape-prim #f)))
(b! (logtest? (-> a0-3 penetrate-using) (-> v1-5 penetrated-by)) cfg-6 :delay (nop!))
(label cfg-5)
(.lvf vf3 (&-> gp-0 vertex 0 quad))
(.lvf vf4 (&-> gp-0 vertex 1 quad))
(.lvf vf5 (&-> gp-0 vertex 2 quad))
(.lvf vf1 (&-> gp-0 intersect quad))
(.lvf vf2 (&-> gp-0 normal quad))
(let ((a0-6 (-> gp-0 pat))
(a1-4 (-> gp-0 collide-ptr))
(.lvf vf3 (&-> gp-0 best-other-tri vertex 0 quad))
(.lvf vf4 (&-> gp-0 best-other-tri vertex 1 quad))
(.lvf vf5 (&-> gp-0 best-other-tri vertex 2 quad))
(.lvf vf1 (&-> gp-0 best-other-tri intersect quad))
(.lvf vf2 (&-> gp-0 best-other-tri normal quad))
(let ((a0-6 (-> gp-0 best-other-tri pat))
(a1-4 (-> gp-0 best-other-tri collide-ptr))
)
(set! (-> arg0 best-dist) f0-1)
(.svf (&-> arg0 best-other-tri vertex 0 quad) vf3)
Expand All @@ -464,14 +464,7 @@
(label cfg-6)
(b! (not v1-5) cfg-8 :delay (empty-form))
)
(add-touching-prims
*touching-list*
this
a2-2
f0-1
(the-as collide-tri-result #f)
(the-as collide-tri-result (-> gp-0 vertex))
)
(add-touching-prims *touching-list* this a2-2 f0-1 (the-as collide-tri-result #f) (-> gp-0 best-other-tri))
)
)
)
Expand Down Expand Up @@ -515,11 +508,11 @@
(vf4 :class vf)
(vf5 :class vf)
)
(let* ((gp-0 (new 'stack-no-clear 'collide-tri-result))
(let* ((gp-0 (new 'stack-no-clear 'collide-query))
(f0-1 (resolve-moving-sphere-sphere
arg1
gp-0
(-> this prim-core)
(the-as sphere (-> this prim-core))
(-> arg0 move-dist)
(-> arg0 best-dist)
(-> arg1 prim-core action)
Expand All @@ -539,13 +532,13 @@
(b! (zero? a1-2) cfg-4 :delay (nop!))
(b! (logtest? (-> v1-4 penetrate-using) (-> a0-4 penetrated-by)) cfg-4 :delay (nop!))
)
(.lvf vf3 (&-> gp-0 vertex 0 quad))
(.lvf vf4 (&-> gp-0 vertex 1 quad))
(.lvf vf5 (&-> gp-0 vertex 2 quad))
(.lvf vf1 (&-> gp-0 intersect quad))
(.lvf vf2 (&-> gp-0 normal quad))
(let ((v1-7 (-> gp-0 pat))
(a0-6 (-> gp-0 collide-ptr))
(.lvf vf3 (&-> gp-0 best-other-tri vertex 0 quad))
(.lvf vf4 (&-> gp-0 best-other-tri vertex 1 quad))
(.lvf vf5 (&-> gp-0 best-other-tri vertex 2 quad))
(.lvf vf1 (&-> gp-0 best-other-tri intersect quad))
(.lvf vf2 (&-> gp-0 best-other-tri normal quad))
(let ((v1-7 (-> gp-0 best-other-tri pat))
(a0-6 (-> gp-0 best-other-tri collide-ptr))
)
(set! (-> arg0 best-dist) f0-1)
(.svf (&-> arg0 best-other-tri vertex 0 quad) vf3)
Expand All @@ -559,14 +552,7 @@
(set! (-> arg0 best-other-prim) a2-2)
(set! (-> arg0 best-my-prim) this)
(label cfg-4)
(add-touching-prims
*touching-list*
this
a2-2
f0-1
(the-as collide-tri-result #f)
(the-as collide-tri-result (-> gp-0 vertex))
)
(add-touching-prims *touching-list* this a2-2 f0-1 (the-as collide-tri-result #f) (-> gp-0 best-other-tri))
)
)
(label cfg-5)
Expand Down Expand Up @@ -2386,7 +2372,7 @@
(set! *actor-list-length* 0)
(if (logtest? s4-0 (collide-spec hit-by-others-list))
(set! *actor-list-length*
(fill-actor-list-for-box *actor-hash* (the-as bounding-box (-> this root-prim prim-core)) *actor-list* 256)
(fill-actor-list-for-box *actor-hash* (the-as vector (-> this root-prim prim-core)) *actor-list* 256)
)
)
(when (logtest? s4-0 (collide-spec player-list))
Expand Down Expand Up @@ -2567,7 +2553,7 @@
(set! *actor-list-length* 0)
(b! (not (logtest? (the-as collide-spec s2-0) 512)) cfg-2 :delay (empty-form))
(set! *actor-list-length*
(fill-actor-list-for-box *actor-hash* (the-as bounding-box (-> s3-0 prim-core)) *actor-list* 256)
(fill-actor-list-for-box *actor-hash* (the-as vector (-> s3-0 prim-core)) *actor-list* 256)
)
(label cfg-2)
(b! (not (logtest? (the-as collide-spec s2-0) 1024)) cfg-11 :delay (empty-form))
Expand Down
3 changes: 2 additions & 1 deletion goal_src/jak3/engine/collide/find-nearest.gc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
(let* ((s2-1 (get-trans (the-as process-focusable s3-0) 3))
(f30-0 (- (vector-vector-distance (-> gp-0 point) s2-1) (-> s2-1 w)))
)
(when (nonzero? (-> s0-0 root-prim prim-core collide-as))
(when (#if PC_PORT (and (nonzero? (-> s0-0 root-prim prim-core collide-as)) (or (not (-> *pc-settings* fix-projectile-focus)) (logtest? (collide-action solid) (-> s0-0 root-prim prim-core action))))
(nonzero? (-> s0-0 root-prim prim-core collide-as)))
(let ((s0-1 (search-info-flag)))
0.0
(set! sv-736 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) s2-1 (-> gp-0 point)) 1.0))
Expand Down
4 changes: 1 addition & 3 deletions goal_src/jak3/engine/common-obs/water-flow.gc
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,7 @@
(init-vf0-vector)
(set! *actor-list-length* 0)
(if #t
(set! *actor-list-length*
(fill-actor-list-for-box *actor-hash* (the-as bounding-box (-> this collide-bounds)) *actor-list* 256)
)
(set! *actor-list-length* (fill-actor-list-for-box *actor-hash* (-> this collide-bounds) *actor-list* 256))
)
(when #t
(let ((a0-2 (-> *collide-player-list* alive-list next0)))
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak3/engine/physics/trajectory.gc
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
)
)
(else
(let ((s1-0 (new 'stack-no-clear 'bounding-box))
(let ((s1-0 (new 'stack-no-clear 'vector))
(s2-1 (new 'stack 'boxed-array collide-shape 32))
)
(sphere<-vector+r! (the-as sphere s1-0) arg1 arg2)
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak3/engine/spatial-hash/spatial-hash-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ O(n^2) 'check everybody against everybody' collision loop."
(new (symbol type int int) _type_)
(spatial-hash-method-33 (_type_ vector hash-object-info) none)
(add-an-object (_type_ bounding-box (pointer collide-shape) int) int)
(fill-actor-list-for-box (_type_ bounding-box (pointer collide-shape) int) int)
(fill-actor-list-for-box (_type_ vector (pointer collide-shape) int) int)
(fill-actor-list-for-sphere (_type_ vector vector float (pointer collide-shape) int int) int)
(fill-actor-list-for-line-sphere (_type_ vector vector float (pointer collide-shape) int int) int)
(fill-actor-list-for-vec+r (_type_ vector (pointer collide-shape) int) int)
Expand Down
6 changes: 3 additions & 3 deletions goal_src/jak3/engine/spatial-hash/spatial-hash.gc
Original file line number Diff line number Diff line change
Expand Up @@ -884,9 +884,9 @@
(arg4 int)
(arg5 int)
)
(let ((v1-0 (new 'stack-no-clear 'bounding-box)))
(set! (-> v1-0 min quad) (-> arg0 quad))
(set! (-> v1-0 min w) 0.0)
(let ((v1-0 (new 'stack-no-clear 'vector)))
(set! (-> v1-0 quad) (-> arg0 quad))
(set! (-> v1-0 w) 0.0)
(fill-actor-list-for-box this v1-0 (the-as (pointer collide-shape) arg1) (the-as int arg2))
)
)
Expand Down
22 changes: 11 additions & 11 deletions goal_src/jak3/engine/target/board/target-board.gc
Original file line number Diff line number Diff line change
Expand Up @@ -501,16 +501,16 @@
(vf2 :class vf)
)
(init-vf0-vector)
(let ((gp-0 (new 'stack-no-clear 'bounding-box)))
(let ((gp-0 (new 'stack-no-clear 'vector)))
(cond
(arg0
(set! (-> gp-0 min quad) (-> self control trans quad))
(set! (-> gp-0 min w) 49152.0)
(set! (-> gp-0 quad) (-> self control trans quad))
(set! (-> gp-0 w) 49152.0)
)
(else
(vector-normalize! (vector-z-quaternion! (the-as vector gp-0) (-> self control quat)) -12288.0)
(vector+! (the-as vector gp-0) (the-as vector gp-0) (-> self control trans))
(set! (-> gp-0 min w) 24576.0)
(vector-normalize! (vector-z-quaternion! gp-0 (-> self control quat)) -12288.0)
(vector+! gp-0 gp-0 (-> self control trans))
(set! (-> gp-0 w) 24576.0)
)
)
(let ((s5-1 (new 'stack-no-clear 'array 'collide-shape 384)))
Expand All @@ -530,7 +530,7 @@
)
(when a0-11
(when (!= *target* a0-11)
(let ((v1-13 (vector-! (new 'stack-no-clear 'vector) (-> a0-11 root trans) (the-as vector gp-0))))
(let ((v1-13 (vector-! (new 'stack-no-clear 'vector) (-> a0-11 root trans) gp-0)))
0.0
(.lvf vf1 (&-> v1-13 quad))
)
Expand All @@ -541,7 +541,7 @@
(.add.mul.z.vf vf1 vf2 vf1 acc :mask #b1)
(.mov v1-14 vf1)
(let ((f0-3 v1-14)
(f1-0 (-> gp-0 min w))
(f1-0 (-> gp-0 w))
)
(if (>= (* f1-0 f1-0) f0-3)
(send-event a0-11 'green-eco-attack)
Expand All @@ -560,9 +560,9 @@
)
)
)
(when (and s5-2 (< (vector-vector-distance (get-trans s5-2 0) (the-as vector gp-0)) (-> gp-0 min w)))
(when (and s5-2 (< (vector-vector-distance (get-trans s5-2 0) gp-0) (-> gp-0 w)))
(when (!= *target* s5-2)
(let ((v1-24 (vector-! (new 'stack-no-clear 'vector) (-> s5-2 control trans) (the-as vector gp-0))))
(let ((v1-24 (vector-! (new 'stack-no-clear 'vector) (-> s5-2 control trans) gp-0)))
0.0
(.lvf vf1 (&-> v1-24 quad))
)
Expand All @@ -573,7 +573,7 @@
(.add.mul.z.vf vf1 vf2 vf1 acc :mask #b1)
(.mov v1-25 vf1)
(let ((f0-6 v1-25)
(f1-4 (-> gp-0 min w))
(f1-4 (-> gp-0 w))
)
(if (>= (* f1-4 f1-4) f0-6)
(send-event s5-2 'green-eco-attack)
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak3/engine/target/flut/flut-racer.gc
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@
(vector+! s5-1 s5-1 (-> this root trans))
(set! (-> s5-1 w) 16384.0)
(let ((s4-1 (new 'stack-no-clear 'array 'collide-shape 384)))
(countdown (s3-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box s5-1) s4-1 384))
(countdown (s3-0 (fill-actor-list-for-box *actor-hash* s5-1 s4-1 384))
(let* ((s2-0 (-> s4-1 s3-0))
(v1-21 (if (type? s2-0 collide-shape)
s2-0
Expand Down
Loading

0 comments on commit 889fdcd

Please sign in to comment.