Skip to content

Commit

Permalink
[jak3] joint-mod, subdivide, bsp (#3371)
Browse files Browse the repository at this point in the history
  • Loading branch information
water111 authored Feb 11, 2024
1 parent 79d14af commit d8181fb
Show file tree
Hide file tree
Showing 37 changed files with 6,113 additions and 210 deletions.
283 changes: 170 additions & 113 deletions decompiler/config/jak3/all-types.gc

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
[1, "(function none)"],
[2, "(function none)"]
],
"gsound": [[1, "(function none)"]]
"gsound": [[1, "(function none)"]],
"joint-mod": [[21, "(function cspace transformq none)"]]
}
6 changes: 5 additions & 1 deletion decompiler/config/jak3/ntsc_v1/hacks.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,11 @@
},

"blocks_ending_in_asm_branch": {
"light-merge!": [1, 2, 3, 5, 7]
"light-merge!": [1, 2, 3, 5, 7],
"bsp-camera-asm": [1, 2, 3, 4, 6, 7],
"level-remap-texture": [2, 3, 4, 5, 6],
"start-perf-stat-collection": [26],
"end-perf-stat-collection": [0]
},

// Sometimes the game might use format strings that are fetched dynamically,
Expand Down
3 changes: 3 additions & 0 deletions decompiler/config/jak3/ntsc_v1/label_types.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,8 @@
["L304", "cloth-params"],
["L303", "cloth-params"],
["L296", "cloth-params"]
],
"joint-mod": [
["L212", "(inline-array vector)", 3]
]
}
43 changes: 42 additions & 1 deletion decompiler/config/jak3/ntsc_v1/stack_structures.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,46 @@
[128, "vector"],
[192, "vector"]
],
"matrix<-parented-transformq!": [[16, "vector"]]
"matrix<-parented-transformq!": [[16, "vector"]],
"joint-mod-ik-callback": [
[16, "matrix"],
[80, "matrix"],
[144, "vector"],
[160, "vector"],
[176, "vector"],
[192, "vector"],
[208, "vector"],
[224, "vector"],
[240, "matrix"],
[272, "vector"],
[256, "vector"],
[288, "vector"],
[304, "vector"],
[320, "quaternion"],
[336, "quaternion"],
[352, "vector"],
[384, "vector"],
[448, "vector"],
[464, "vector"],
[480, "vector"],
[496, "quaternion"],
[512, "matrix"],
[576, "vector"],
[592, "matrix"],
[608, "matrix"],
[656, "matrix"],
[720, "matrix"],
[752, "matrix"]
],
"joint-mod-look-at-handler": [
[16, "matrix"],
[80, "quaternion"],
[96, "vector"],
[112, "vector"],
[128, "vector"]
],
"joint-mod-joint-set-world-handler": [
[32, "vector"],
[48, "vector"]
]
}
65 changes: 65 additions & 0 deletions decompiler/config/jak3/ntsc_v1/type_casts.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -584,5 +584,70 @@
[[48, 125], "v1", "joint-anim-frame"],
[[62, 67], "t2", "(inline-array vector)"],
[[67, 71], "a2", "(inline-array vector)"]
],
"joint-mod-ik-callback": [
[6, "gp", "joint-mod-ik"],
[9, "gp", "joint-mod-ik"],
[[1, 35], "gp", "joint-mod-ik"],
[[1, 422], "gp", "joint-mod-ik"]
],
"real-joint-mod-gun-look-at-handler": [
[1, "v1", "joint-mod"],
[2, "v1", "joint-mod"]
],
"joint-mod-foot-rot-handler": [
[[0, 7], "s5", "joint-mod"],
[[35, 152], "s5", "joint-mod"]
],
"(method 11 joint-mod)": [
[[0, 27], "s1", "process-drawable"],
[[19, 62], "s2", "fact-info-enemy"]
],
"joint-mod-look-at-handler": [
[[2, 406], "gp", "joint-mod"],
[409, "a3", "float"]
],
"joint-mod-world-look-at-handler": [
[[0, 217], "gp", "joint-mod"],
[220, "a3", "float"]
],
"joint-mod-rotate-handler": [[[2, 114], "s5", "joint-mod"]],
"joint-mod-scale-handler": [[[1, 14], "s5", "joint-mod"]],
"joint-mod-joint-set-handler": [[[2, 23], "s4", "joint-mod"]],
"joint-mod-joint-set-world-handler": [[[6, 197], "s5", "joint-mod"]],
"joint-mod-joint-set*-handler": [[[2, 39], "s5", "joint-mod"]],
"joint-mod-joint-set*-world-handler": [[[4, 53], "s5", "joint-mod"]],
"joint-mod-polar-look-at-callback": [
[[0, 363], "s5", "joint-mod-polar-look-at"]
],
"(method 10 bsp-header)": [
[27, "a1", "terrain-context"],
[31, "a0", "terrain-context"]
],
"bsp-camera-asm": [
[26, "v1", "pointer"],
[[26, 63], "t1", "bsp-node"],
[43, "t3", "uint"]
],
"level-remap-texture": [
[15, "t0", "(pointer uint32)"],
[21, "t0", "(pointer uint32)"],
[19, "t0", "(pointer uint64)"],
[12, "v1", "int"],
[12, "a3", "int"]
],
"build-masks": [
[[18, 22], "a1", "drawable-tree-tfrag"],
[24, "a2", "drawable-inline-array-tfrag"],
[[27, 31], "a2", "(inline-array tfragment)"],
[[38, 42], "a1", "drawable-tree-tfrag-trans"],
[44, "a2", "drawable-inline-array-tfrag"],
[[47, 51], "a2", "(inline-array tfragment)"],
[[58, 62], "a1", "drawable-tree-tfrag-water"],
[64, "a2", "drawable-inline-array-tfrag"],
[[67, 71], "a2", "(inline-array tfragment)"],
[[78, 79], "a1", "drawable-tree-instance-tie"],
[123, "a1", "drawable-tree-instance-shrub"],
[[129, 133], "a2", "(inline-array prototype-bucket-shrub)"]
]
}
101 changes: 101 additions & 0 deletions decompiler/config/jak3/ntsc_v1/var_names.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -1486,5 +1486,106 @@
"s2-0": "sizeof-frag",
"s1-0": "sizeof-geo"
}
},
"(method 9 joint-mod-polar-look-at)": {
"args": [
"this",
"proc",
"joint-id"
]
},
"(method 10 joint-mod-polar-look-at)": {
"args": [
"this",
"pos"
]
},
"(method 11 joint-mod-polar-look-at)": {
"args": [
"this",
"other",
"pos"
]
},
"(method 12 joint-mod-polar-look-at)": {
"args": [
"this",
"duration",
"final-val",
"restart-if-in-progress"
]
},
"(method 13 joint-mod-polar-look-at)": {
"args": [
"this",
"duration",
"restart-if-in-progress"
]
},
"(method 0 joint-mod-ik)": {
"args": [
"allocation",
"type-to-make",
"proc",
"joint-id",
"hand-dist"
]
},
"(method 9 joint-mod-ik)": {
"args": [
"this",
"pos"
]
},
"(method 10 joint-mod-ik)": {
"args": [
"this",
"enable"
]
},
"(method 0 joint-mod)": {
"args": [
"allocation",
"type-to-make",
"mode",
"proc",
"base-joint-id"
]
},
"(method 9 joint-mod)": {
"args": [
"this",
"mode"
]
},
"(method 10 joint-mod)": {
"args": [
"this",
"pos"
]
},
"(method 11 joint-mod)": {
"args": [
"this",
"target",
"mode",
"proc"
]
},
"(method 13 joint-mod)": {
"args": [
"thix",
"x",
"y",
"z"
]
},
"(method 14 joint-mod)": {
"args": [
"this",
"trans",
"quat",
"scale"
]
}
}
64 changes: 44 additions & 20 deletions goal_src/jak3/engine/anim/joint-mod-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
;; name in dgo: joint-mod-h
;; dgos: GAME

;; The joint-mod system is used to animate parts of a character from gameplay code.
;; For example, rotating the neck to make a character look at something.

;; This works by installing callbacks in the cspace of the joints, which are used by process-drawable to compute bones.
;; The default callbacks just read and apply transforms from the animation.

;; Generally, the use doesn't install the callback themselves, and uses a utility class from this file.
;; This is a little inconsistent and there's 3 patterns:
;; - using the `joint-mod` class, which can manage many different types of callbacks (no inheritance)
;; - using a class based on `joint-mod-base`, which is a new base class for new types of joint callbacks (joint-mod-blend-world)
;; - using a class that is just a standalone class (joint-mod-polar-look-at, for example)

;; the `joint-mod-base` was added in jak 3.

(defenum joint-mod-mode
:bitfield #t
:type uint32
Expand Down Expand Up @@ -54,6 +68,16 @@
(scale 3)
)

(defenum joint-mod-polar-flags
:type uint32
:bitfield #t
(no-z-rot 0)
(blending-to-zero 1)
(negate-nose 2)
(negate-ear 3)
(negate-up 4)
)

(deftype joint-mod-blend-world-work (structure)
((mat1 matrix :inline)
(mat2 matrix :inline)
Expand Down Expand Up @@ -100,14 +124,14 @@ This is used to make jak look toward an enemy, for example."
(parented-scale? symbol)
)
(:methods
(new (symbol type) _type_)
(joint-mod-method-9 () none)
(joint-mod-method-10 () none)
(joint-mod-method-11 () none)
(new (symbol type joint-mod-mode process-drawable int) _type_)
(mode-set! (_type_ joint-mod-mode) none)
(target-set! (_type_ vector) none)
(look-at! (_type_ vector symbol process) none)
(reset-blend! (_type_) _type_)
(joint-mod-method-13 () none)
(joint-mod-method-14 () none)
(joint-mod-method-15 () none)
(twist-set! (_type_ float float float) vector)
(trs-set! (_type_ vector quaternion vector) none)
(shut-down (_type_) none)
)
)

Expand All @@ -122,7 +146,7 @@ This is used to make jak look toward an enemy, for example."

(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 bucket577) (-> jmod joint bone transform) (meters 2))
(add-debug-matrix #t (bucket-id debug-no-zbuf1) (-> jmod joint bone transform) (meters 2))
0
(none)
)
Expand Down Expand Up @@ -627,9 +651,9 @@ Then, apply the normal parented transform."
(blend-interp float)
)
(:methods
(new (symbol type) _type_)
(joint-mod-ik-method-9 () none)
(joint-mod-ik-method-10 () none)
(new (symbol type process-drawable int float) _type_)
(set-ik-target! (_type_ vector) none)
(enable-set! (_type_ symbol) none)
)
)

Expand All @@ -640,7 +664,7 @@ Then, apply the normal parented transform."
)

(deftype joint-mod-polar-look-at (basic)
((flags uint32)
((flags joint-mod-polar-flags)
(ear int8)
(up int8)
(nose int8)
Expand All @@ -653,17 +677,17 @@ Then, apply the normal parented transform."
(forward-twist float)
(backward-twist float)
(target vector :inline)
(blend-duration uint64)
(blend-start-time uint64)
(blend-duration time-frame)
(blend-start-time time-frame)
(blend-start-value float)
(blend-max float)
)
(:methods
(joint-mod-polar-look-at-method-9 () none)
(joint-mod-polar-look-at-method-10 () none)
(joint-mod-polar-look-at-method-11 () none)
(joint-mod-polar-look-at-method-12 () none)
(joint-mod-polar-look-at-method-13 () none)
(joint-mod-polar-look-at-method-14 () none)
(initialize (_type_ process-drawable int) none)
(set-target! (_type_ vector) none)
(set-both-targets! (_type_ joint-mod-polar-look-at vector) none)
(blend-on! (_type_ time-frame float symbol) none)
(blend-to-off! (_type_ time-frame symbol) none)
(get-start-blend! (_type_) float)
)
)
Loading

0 comments on commit d8181fb

Please sign in to comment.