Merge lang/i18n-data-fill 96798c0f: ludic.anim transitions go via a one-shot
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
2288feeb59
5 changed files with 45 additions and 4 deletions
|
|
@ -33,7 +33,7 @@ function as_blend(s: AnimSet, from: int, to: int) -> float {
|
||||||
if s.transitions != null {
|
if s.transitions != null {
|
||||||
for i in 0 .. len(s.transitions) {
|
for i in 0 .. len(s.transitions) {
|
||||||
let tr = s.transitions[i]
|
let tr = s.transitions[i]
|
||||||
if tr.when == null and tr.to == s.states[to].key and as_leaves(s, tr, from) { return tr.blend }
|
if tr.when == null and tr.via == "" and tr.to == s.states[to].key and as_leaves(s, tr, from) { return tr.blend }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s.states[to].blend
|
return s.states[to].blend
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,22 @@ export function animset_request(pl: AnimPlayer, key: string) -> void {
|
||||||
if pl.set < 0 or key == pl.asked { return }
|
if pl.set < 0 or key == pl.asked { return }
|
||||||
let i = as_state(AnimSets[pl.set], key)
|
let i = as_state(AnimSets[pl.set], key)
|
||||||
if i < 0 { return }
|
if i < 0 { return }
|
||||||
|
let v = as_via(pl, key)
|
||||||
pl.asked = key
|
pl.asked = key
|
||||||
pl.want = i
|
pl.want = i
|
||||||
|
if v >= 0 { pl.want = v }
|
||||||
|
}
|
||||||
|
|
||||||
|
# the one-shot a request goes by: a `via` edge from where the code last asked (or "*") to this state,
|
||||||
|
# whose clip the rig carries; -1 for none
|
||||||
|
function as_via(pl: AnimPlayer, key: string) -> int {
|
||||||
|
let s = AnimSets[pl.set]
|
||||||
|
if s.transitions == null { return -1 }
|
||||||
|
for i in 0 .. len(s.transitions) {
|
||||||
|
let tr = s.transitions[i]
|
||||||
|
if tr.via != "" and tr.to == key and (tr.from == "*" or tr.from == pl.asked) and animset_can(pl, tr.via) { return as_state(s, tr.via) }
|
||||||
|
}
|
||||||
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
# the state is in the set and the rig carries one of its clips: a one-shot with none is not asked for
|
# the state is in the set and the rig carries one of its clips: a one-shot with none is not asked for
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ export property AnimTransition {
|
||||||
to: string = ""
|
to: string = ""
|
||||||
blend: float = 0.2
|
blend: float = 0.2
|
||||||
@frame when: fn() -> bool = null
|
@frame when: fn() -> bool = null
|
||||||
|
via: string = "" # a one-shot the code's request goes by when the rig carries its clip (its next hands on to `to`)
|
||||||
}
|
}
|
||||||
|
|
||||||
# a graph for a kind of rig: its parameters, its states (the first is where it starts unless
|
# a graph for a kind of rig: its parameters, its states (the first is where it starts unless
|
||||||
|
|
|
||||||
|
|
@ -124,4 +124,22 @@ program AnimSetTest {
|
||||||
expect(not animset_can(pl, "bow"))
|
expect(not animset_can(pl, "bow"))
|
||||||
expect(not animset_can(pl, "nope"))
|
expect(not animset_can(pl, "nope"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "a request goes by its via one-shot when the rig carries it, which hands on; else straight there" (anim_st: mut AnimState, render3d_st: mut Render3dState) {
|
||||||
|
let sk = skin(render3d_st)
|
||||||
|
let pl = rig(anim_st)
|
||||||
|
animset_request(pl, "seat")
|
||||||
|
animset_tick(anim_st, pl, sk, 0.1)
|
||||||
|
expect(playing(pl) == "rig_wave")
|
||||||
|
animset_tick(anim_st, pl, sk, 0.3)
|
||||||
|
animset_tick(anim_st, pl, sk, 0.3)
|
||||||
|
animset_tick(anim_st, pl, sk, 0.016)
|
||||||
|
expect(playing(pl) == "rig_hop")
|
||||||
|
animset_request(pl, "seat")
|
||||||
|
animset_tick(anim_st, pl, sk, 0.016)
|
||||||
|
expect(playing(pl) == "rig_hop")
|
||||||
|
animset_request(pl, "perch")
|
||||||
|
animset_tick(anim_st, pl, sk, 0.016)
|
||||||
|
expect(playing(pl) == "rig_walk")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
# sets.lres - the test's one set: a ground state picking by speed bands, a one-shot that hands back,
|
# sets.lres - the test's one set: a ground state picking by speed bands, a one-shot that hands back,
|
||||||
# a hop the code never asks for, taken when toy_hops says so, and a bow no rig carries
|
# a hop the code never asks for, taken when toy_hops says so, a bow no rig carries, and a seat and a
|
||||||
|
# perch the code asks for by way of a one-shot (settle, which the rig has; bow, which it has not)
|
||||||
toy {
|
toy {
|
||||||
entry: "ground"
|
entry: "ground"
|
||||||
params: ["speed"]
|
params: ["speed"]
|
||||||
|
|
@ -15,7 +16,14 @@ toy {
|
||||||
},
|
},
|
||||||
{ key: "wave", loop: false, next: "ground", choices: [{ clip: "wave" }] },
|
{ key: "wave", loop: false, next: "ground", choices: [{ clip: "wave" }] },
|
||||||
{ key: "hop", choices: [{ clip: "hop" }] },
|
{ key: "hop", choices: [{ clip: "hop" }] },
|
||||||
{ key: "bow", loop: false, next: "ground", choices: [{ clip: "bow" }] }
|
{ key: "bow", loop: false, next: "ground", choices: [{ clip: "bow" }] },
|
||||||
|
{ key: "settle", loop: false, next: "seat", choices: [{ clip: "wave" }] },
|
||||||
|
{ key: "seat", choices: [{ clip: "hop" }] },
|
||||||
|
{ key: "perch", choices: [{ clip: "walk" }] }
|
||||||
|
]
|
||||||
|
transitions: [
|
||||||
|
{ from: "ground", to: "hop", blend: 0.1, when: fn toy_hops },
|
||||||
|
{ from: "*", to: "seat", via: "settle" },
|
||||||
|
{ from: "*", to: "perch", via: "bow" }
|
||||||
]
|
]
|
||||||
transitions: [{ from: "ground", to: "hop", blend: 0.1, when: fn toy_hops }]
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue