refactor(packages): 0.R5 - a question no longer starts its state - 64 lazy starts ('if st.x == null { st.x = ... }' inside a getter) are the state's defaults, gear__ensure is gone, and ludic migrate state --tighten took mut off 208 package parameters: things_all, thing_find, gear_charge, gear_level, jobs_state and the rest read

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-27 00:51:03 +03:00
parent 54f5efb23f
commit 9862ec82e3
102 changed files with 320 additions and 351 deletions

View file

@ -17,7 +17,7 @@ export property Clip {
}
export state AnimState {
clips: []Clip = null
clips: []Clip = new []Clip
positions: bool = false
q_a: floats = null
q_b: floats = null
@ -31,19 +31,18 @@ export state AnimState {
# Keyed translations are off unless asked for: baking keys location on every bone, and a skeleton
# does not translate its joints, so applying them turns rounding into a pose.
function clips_init(anim_st: mut AnimState) -> void {
if anim_st.clips == null { anim_st.clips = new []Clip }
function clips_init() -> void {
}
# the clip of that name, or null; names are per file (per body, per species), never shared
export function anim_find(anim_st: mut AnimState, name: string) -> Clip {
clips_init(anim_st)
export function anim_find(anim_st: AnimState, name: string) -> Clip {
clips_init()
for i in 0 .. len(anim_st.clips) { if anim_st.clips[i].name == name { return anim_st.clips[i] } }
return null
}
export function anim_count(anim_st: mut AnimState) -> int {
clips_init(anim_st)
export function anim_count(anim_st: AnimState) -> int {
clips_init()
return len(anim_st.clips)
}

View file

@ -4,7 +4,7 @@
# Call it straight after a load and before the next one: `gltf_doc` and `gltf_bin` point at
# whichever file was read last, so a clip that is not taken now cannot be taken later.
export function anim_read_doc(anim_st: mut AnimState, render3d_st: mut Render3dState, dir: string) -> int {
clips_init(anim_st)
clips_init()
if render3d_st.gltf_doc == null { return 0 }
if value_has(render3d_st.gltf_doc, "animations") == 0 { return 0 }
# REOPEN THE .bin. `gltf_load` closes it before it returns, and an accessor read through a closed
@ -39,7 +39,7 @@ function kept_path(ch: Val) -> string {
return path
}
function read_one(anim_st: mut AnimState, render3d_st: mut Render3dState, a: Val) -> Clip {
function read_one(anim_st: AnimState, render3d_st: mut Render3dState, a: Val) -> Clip {
var nm = ""
if value_has(a, "name") != 0 { nm = value_as_str(value_get(a, "name")) }
if anim_find(anim_st, nm) != null { return null } # a second rig's file, same clip