ludic.anim: animation sets - the game's src/animset moved in as it stood (records, AnimPlayer, animset_bind / request / param / tick and the accessors); AnimSets is an open @ByKey registry a game fills with def AnimSets from; a test on a rig of hand-made clips

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-29 19:01:15 +03:00
parent d9a73d63bd
commit 5517873275
10 changed files with 442 additions and 1 deletions

View file

@ -0,0 +1,40 @@
# set_follow.ludic - moving between states: a `when` edge out of the current state that answers
# true, else the state the code asked for, faded by the edge between them or the target's own blend
function as_follow(pl: AnimPlayer) -> void {
pl.fresh = false
let s = AnimSets[pl.set]
var to = pl.want
var blend = -1.0
if s.transitions != null {
for i in 0 .. len(s.transitions) {
let tr = s.transitions[i]
if tr.when == null or not as_leaves(s, tr, pl.state) { continue }
if tr.when() {
to = as_state(s, tr.to)
blend = tr.blend
break
}
}
}
if to < 0 or to == pl.state { return }
if blend < 0.0 { blend = as_blend(s, pl.state, to) }
pl.state = to
pl.want = to
pl.fresh = true
pl.fade_next = blend
}
function as_leaves(s: AnimSet, tr: AnimTransition, from: int) -> bool {
return tr.from == "*" or tr.from == s.states[from].key
}
# the edge the code's request crosses, if the graph has one; else the target's own fade
function as_blend(s: AnimSet, from: int, to: int) -> float {
if s.transitions != null {
for i in 0 .. len(s.transitions) {
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 }
}
}
return s.states[to].blend
}