Skip to main content

Module kfa_draw

Module kfa_draw 

Source
Expand description

KFA (animated kv6) bone solver — the bone-transform helpers genperp, mat0, and setlimb.

A KFA sprite is a hierarchy of bones; each bone carries an optional Sprite (= one kv6 limb) plus a hinge tying it to its parent. Per frame, the user updates kfaval[i] (a 16-bit angle) for each animated bone; solve_kfa_limbs walks the hinge tree in topological order and computes each limb’s world transform from its parent’s. The caller then draws each posed limb via crate::dda_sprite::draw_sprite_dda.

Animation-curve playback (advancing kfaval[] from a baked keyframe sequence) lives in roxlap_formats::kfa::KfaSprite::animsprite — call it to advance kfaval[] from a baked curve, or poke kfaval[] directly for procedural animation, then render here. The bone posing this module computes is also exposed standalone as solve_kfa_limbs for non-CPU backends (the GPU sprite pass).

No oracle pose exercises KFA, so this module’s correctness gate is “looks right + tests verify the bone math”. We can tighten validation when a real .kfa asset lands.

Functions§

compose_attachment
Compose a bone’s solved world transform with an attachment’s local_offset (VCL.6), giving the attachment’s world pose (s, h, f, p) — the basis columns + position to hand a sprite/clip instance.
solve_kfa_limbs
Pose every limb of a KFA sprite. Walks the hinge tree in topological order (parents first) and writes each limb’s world (s, h, f, p) from its parent’s via the per-limb setlimb math, reading the current KfaSprite::kfaval angles. Mirror of the bone-hierarchy transform solve.