feat(lena-hands): exp09 graded cross-digit finger weights + honest tear metrics

The exp05 verdict ("weights alone cannot clear the bar on this mesh") was
measured against a hard partition that was itself causing much of the tearing.
exp01-exp05 gave every vert to exactly ONE digit -- 08_finger_weights.py had an
explicit `elif lo in FING: continue  # other digit: hard wall` -- which
guarantees the fused inter-digit bridges tear by the full finger separation,
because a single edge ring absorbs the whole gap.

Replace that with graded blending (WEB_BLEND_R0): a vert's fraction toward its
nearest other digit ramps 0 -> 0.5 as r = d_own/(d_own+d_other) goes 0.35 -> 0.5,
so both sides of the equidistance valley reach 50/50 and the field is continuous
across the boundary. Applied after the smoother (whose hard wall would erode beta
exactly where it must survive) and evaluated in the neighbour digit's own
arc-length frame. WEB_BLEND_SKIP excludes the thumb: its transform is opposition,
not curl, so its frame does not correspond to a finger's.

Measured against an identical baseline (same input, blend the only variable),
real tears (>=1mm rest length) drop 23-60% with NO regression on flat, the pose
that ships: fist_r 1178 -> 530, grip_r 561 -> 222, fist_l 979 -> 633,
grip_l 420 -> 322; total >5x 2487 -> 1307; p99.9 better on every pose;
flat unchanged at 0/1. fin_bones confirms the mechanism rather than just the
count -- the middle<->ring and pinky<->ring families leave the top classes while
the thumb/palm ones are untouched to the edge (182 -> 182, 148 -> 148).

This does NOT make fist/grip shippable: 222-633 real tears still reads as a
destroyed hand in clay renders, and the residual is now ~53% thumb-pad-fused-to
-palm, which is topology and needs mesh surgery or the v02 rebake. Flat and
relaxed are the shippable poses; fist/grip belong to the morph lane for now.

Also here:
- README: the solver's input is v02/..._exp03.glb, NOT exp01. exp01 is pre-hand
  -fit (converter steps 2b/2c); its finger groups sit on the wrist and overlap
  the real finger by 1.6cm, so a solve from it silently zeroes every _02/_03 bone
  -- rigid stick fingers and a torn flat -- while weight sums stay 1.0 and every
  assert passes. Cost three wasted bakes and one false "the solver regressed".
- Seed assert demanded >=100 seeds while the radius loop caps at
  SEED_AXIS_R_MAX, which left pinky (88 seeds at 16mm) can never satisfy; the two
  constants were mutually unsatisfiable. Now >=60, and it is documented as a
  sanity gate rather than a quality bar.
- Detwist poses tested at last: real but marginal (fist_r 38.7x -> 28.7x,
  grip_r 30.0x -> 17.3x, left hand flat). A knob, not a fix.
- edge_stretch_cmp.py / skin_bone_territory.py / handpose_trim_hand_obj.py:
  judge tears by rest length and absolute posed growth, not raw ratio; audit
  whether a bone owns any verts at all (thumb_01 owns ZERO in exp05); and trim
  an arm-sized skin dump to the hand before rendering.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-18 11:33:15 -07:00
parent 3f335ee2d7
commit cf336f3b5b
28 changed files with 3285 additions and 14 deletions
+71
View File
@@ -0,0 +1,71 @@
"""Strip axial roll (twist about the bone axis) from a hand-pose JSON, keeping the curl.
The pose delta vs the body's rest is swing-twist decomposed per bone; the twist factor is
dropped and the pose rebuilt as rest*swing. Thumb chains are left untouched (their roll is
functional opposition). usage: handpose_detwist.py body.glb pose_in.json pose_out.json"""
import json, math, struct, sys
from pathlib import Path
body, pose_in, pose_out = sys.argv[1:4]
data = Path(body).read_bytes()
jlen = struct.unpack_from("<I", data, 12)[0]
gltf = json.loads(data[20:20 + jlen].decode("utf-8"))
nodes = gltf["nodes"]
byname = {n.get("name"): i for i, n in enumerate(nodes)}
def qmul(a, b):
ax, ay, az, aw = a
bx, by, bz, bw = b
return [aw * bx + ax * bw + ay * bz - az * by,
aw * by - ax * bz + ay * bw + az * bx,
aw * bz + ax * by - ay * bx + az * bw,
aw * bw - ax * bx - ay * by - az * bz]
def qinv(q):
return [-q[0], -q[1], -q[2], q[3]]
def qnorm(q):
m = math.sqrt(sum(v * v for v in q))
return [v / m for v in q]
def bone_axis(i):
for c in nodes[i].get("children", []):
t = nodes[c].get("translation")
if t:
m = math.sqrt(sum(v * v for v in t))
if m > 1e-8:
return [v / m for v in t]
return None
pose = json.loads(Path(pose_in).read_text())["bones"]
out = {}
report = []
for name, p in pose.items():
i = byname.get(name)
if i is None or name.startswith("thumb"):
out[name] = p
continue
a = bone_axis(i)
if a is None: # leaf tips: twist is invisible, keep as-is
out[name] = p
continue
r = nodes[i].get("rotation", [0, 0, 0, 1])
d = qmul(qinv(r), p) # delta in the bone's rest-local frame
dot = d[0] * a[0] + d[1] * a[1] + d[2] * a[2]
twist = qnorm([dot * a[0], dot * a[1], dot * a[2], d[3]])
swing = qmul(d, qinv(twist))
out[name] = [round(v, 6) for v in qnorm(qmul(r, swing))]
deg = 2 * math.degrees(math.atan2(abs(dot), abs(d[3])))
if deg > 1.0:
report.append((deg, name))
Path(pose_out).write_text(json.dumps({"bones": out}, indent=1))
report.sort(reverse=True)
print("wrote %s (%d bones, thumbs untouched)" % (pose_out, len(out)))
for deg, name in report[:6]:
print(" stripped %5.1f deg %s" % (deg, name))