fix(vagrant): substrate leg.scl cycle restored; feet inherit_scale=false

User feedback after iteration-4: legs SHOULD cycle through +1/0/-1
(substrate-style — leg renders forward, under body, then behind body).
But feet must NOT Y-flip when leg.scl_y goes negative, and must NOT
collapse when leg.scl_y=0. They should follow leg-end position only.

Three changes:
1. walk_fwd_lower keyframes restored to substrate-style (leg.scl_y
   sign-flip on both halves: leg_l +1↔-1, leg_r -1↔+1). foot.pos
   animations REMOVED — cascade through leg.world.scl now correctly
   moves foot to leg-end position automatically (foot.local.pos
   stays at rest 25 in y).
2. foot.rest.scl: [1, -1] → [1, 1] (no Y-flip in rest, natural
   sprite orientation). inherit_scale=false → foot.world.scl stays
   at foot.local.scl=[1,1] regardless of leg.scl_y. Foot sprite
   never flips, never collapses.
3. Procedural extended: writes foot.local.rot = -leg.local.rot so
   foot.world.rot = body.world.rot (feet stay body-oriented even
   when legs rotate to walk-direction).

Speed slowed further from 0.5 → 0.4 (user: still too fast at 0.5).
This commit is contained in:
Axel Meyer
2026-05-18 22:31:42 +02:00
parent bf5fe12e4c
commit b66c4ca4dd
4 changed files with 29 additions and 27 deletions

View File

@@ -113,11 +113,10 @@ local function update_lower_anim(moving, move_x, move_y)
end
puppet.stop(state.player, "idle_lower")
puppet.stop(state.player, "idle")
-- Slow walk to ~0.5x substrate speed (user preference: too fast for
-- actual map traversal at substrate's 0.8s/cycle).
puppet.play(state.player, anim_id, { loop = true, speed = 0.5 })
-- Slow walk to 0.4x substrate speed (user pref: still too fast at 0.5).
puppet.play(state.player, anim_id, { loop = true, speed = 0.4 })
if not puppet.is_playing(state.player, "walk_upper") then
puppet.play(state.player, "walk_upper", { loop = true, speed = 0.5 })
puppet.play(state.player, "walk_upper", { loop = true, speed = 0.4 })
end
state.walk_anim_current = anim_id
if CI_FRAME_PERF and ci_last_state ~= "walk" then
@@ -156,17 +155,25 @@ function M.init(ctx)
puppet.play(state.player, "idle", { loop = true })
puppet.play(state.player, "idle_lower", { loop = true })
-- Procedural leg-orientation: hips are body-relative (legs.parent=body, so
-- cascade-position follows body); the leg ROTATION is overridden each
-- frame to align with walk-direction (independent of body rotation).
-- leg.local.rot = walk_dir_world - body.world.rot → leg.world.rot = walk_dir.
-- write_bone allowed on leg.rot because walk_fwd_lower only writes leg.scl
-- (per-channel guard v0.4.2).
puppet.set_procedural(state.player, "leg_orientation", function(handle, dt)
-- Procedural leg+foot orientation:
-- * Hips are body-relative (legs.parent=body, position cascade follows body).
-- * leg.world.rot = walk_dir (independent of body). Set leg.local.rot =
-- walk_dir - body.world.rot so cascade gives correct world rot.
-- * foot.world.rot = body.world.rot (user pref: feet stay body-oriented
-- even when legs swing to walk-direction = "tactical twist"). Cascade:
-- foot.world.rot = leg.world.rot + foot.local.rot = body.rot.
-- → foot.local.rot = body.rot - leg.world.rot = body.rot - walk_dir
-- = -leg_local_deg.
-- Per-channel guard v0.4.2 allows leg.rot + foot.rot writes alongside
-- walk_fwd_lower (which only writes leg.scl).
puppet.set_procedural(state.player, "leg_foot_orientation", function(handle, dt)
local _, _, body_rot = puppet.bone_world_transform(handle, "body")
local leg_local_deg = state.lower_control_rot_deg - math.deg(body_rot)
puppet.write_bone(handle, "leg_l", { rot = leg_local_deg })
puppet.write_bone(handle, "leg_r", { rot = leg_local_deg })
local leg_local_deg = state.lower_control_rot_deg - math.deg(body_rot)
local foot_local_deg = -leg_local_deg
puppet.write_bone(handle, "leg_l", { rot = leg_local_deg })
puppet.write_bone(handle, "leg_r", { rot = leg_local_deg })
puppet.write_bone(handle, "foot_l", { rot = foot_local_deg })
puppet.write_bone(handle, "foot_r", { rot = foot_local_deg })
end)
-- Furniture textures.