Files
animation/characters/work/lena/06b_strip_melt.py
T
jeremy 3d8825f5a9 reorg(characters): ship-time folders — lena_base_v01 ships, lane moves to work/lena
REGISTRY rewritten around the central rule: a character folder is born only
when a body ships to ariki-game (<character>_base_v<NN> = ship ordinal).
lena_nude dissolves accordingly:
- characters/female/lena_base_v01/ — SHIPPED 2026-08-10: AccuRig GLB carrier,
  T-pose/rig FBX + JSON, previews, frozen README
- characters/work/lena/ — the live lane: recipes 01-47 (incl. new 36-47:
  refill/sheets/clay/despeckle/musculature/spin/AccuRig export/graft/pose QC),
  masters (athletic_v04 blend + textures, accurig blend), lane-history README
- hires_claude/hires_work intermediates (blends, logs, probes) pruned

Supporting docs: AGENTS.md, working-files rule, rig-graft plan addendum,
originals README, prune_lane.py.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-12 07:17:15 -07:00

56 lines
2.0 KiB
Python

# Local melt of the crotch underside strip (residue from the donor snap's cage edge).
# blender --background --python 06b_strip_melt.py -- <in.blend> <out.blend>
import bpy, sys, time
import numpy as np
argv = sys.argv[sys.argv.index("--") + 1:]
t0 = time.time()
bpy.ops.wm.open_mainfile(filepath=argv[0])
ob = max([o for o in bpy.data.objects if o.type == 'MESH'],
key=lambda o: len(o.data.vertices))
me = ob.data
n_v = len(me.vertices)
co = np.empty(n_v * 3)
me.vertices.foreach_get("co", co)
co = co.reshape(-1, 3)
mid = (np.abs(co[:, 0]) < 0.01) & (co[:, 2] > 0.38) & (co[:, 2] < 0.50)
sad = co[mid][np.argmin(co[mid, 2])]
# ABSOLUTE bounds: the donor snap moved the saddle landmark, so a saddle-relative window
# centred 3.5 cm below the visible residue
strip = (np.abs(co[:, 0]) < 0.048) & (co[:, 2] > 0.368) & (co[:, 2] < 0.434)
sidx = np.nonzero(strip)[0]
print(f"[strip] {len(sidx)} verts around saddle {sad}")
ev = np.empty(len(me.edges) * 2, dtype=np.int32)
me.edges.foreach_get("vertices", ev)
ev = ev.reshape(-1, 2)
o_ = np.concatenate([ev[:, 0], ev[:, 1]])
n_ = np.concatenate([ev[:, 1], ev[:, 0]])
s_ = np.argsort(o_, kind="stable")
o_s = o_[s_]
n_s = n_[s_]
ptr = np.searchsorted(o_s, np.arange(n_v + 1))
cnt = np.maximum(np.diff(ptr), 1)
Q = co.copy()
for _ in range(120):
su = np.add.reduceat(Q[n_s], ptr[:-1], axis=0)
emp = np.diff(ptr) == 0
su[emp] = Q[emp]
mean = su / cnt[:, None]
for f in (0.55, -0.58):
pass
Q[sidx] = 0.45 * Q[sidx] + 0.55 * mean[sidx]
print(f"[strip] melted, max move {np.linalg.norm(Q-co,axis=1).max():.4f} "
f"({time.time()-t0:.1f}s)")
me.vertices.foreach_set("co", Q.reshape(-1))
me.update()
if me.has_custom_normals:
vn = np.empty(n_v * 3, dtype=np.float32)
me.vertices.foreach_get("normal", vn)
me.normals_split_custom_set_from_vertices(vn.reshape(-1, 3))
bpy.context.preferences.filepaths.save_version = 0 # no .blend1 autosave
bpy.ops.wm.save_as_mainfile(filepath=argv[1])
print("STRIP_DONE")