3ba86b2ea8
Bulk import of the working lanes that were living untracked on the PC. Content: - characters/ Lena/male body lanes, bakes, texture work, run logs - clothing/ garment pipeline, configs, gates, contract docs - garments/ MD-authored garment sources (.zprj/.zpac) - UAL-Lib/ Universal Animation Library 2 source (.blend/.fbx/.glb) - tools/ blender_bridge, iclone_bridge, md_bridge, tailor, glm_agent - docs/, plans/, dev/, .agents/plans/ Repo hygiene: - .gitattributes: LFS now covers .blend, .zprj, .zpac, .obj, .npy and the Reallusion .iAvatar/.ccAvatar/.ccRestore containers. Without this the ~3.8 GB in this commit would land as raw blobs. .png/.jpg are left out on purpose — ~250 are already tracked raw and converting them would rewrite every one without shrinking history. - .gitignore: exclude /accurig/ (~1 GB AccuRig program files, redistributable from Reallusion, nothing authored here) and /dev/null/ (git-lfs hook copies dropped by a `>/dev/null` redirect on Windows). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
90 lines
2.8 KiB
Python
90 lines
2.8 KiB
Python
# Stage 6d: self-locating spot melt of remaining flaps in the thigh gap.
|
|
# Finds high-roughness verts inside the gap box (an open-slit flap the membrane pulled),
|
|
# grows a 2-ring collar, melts. Prints the cluster it found so the fix is auditable.
|
|
# blender --background --python 06d_spot_melt.py -- <in.blend> <out.blend>
|
|
import bpy, sys, time
|
|
import numpy as np
|
|
|
|
argv = sys.argv[sys.argv.index("--") + 1:]
|
|
BLEND, OUT = argv[0], argv[1]
|
|
t0 = time.time()
|
|
|
|
BOX = lambda co: (np.abs(co[:, 0]) < 0.075) & (co[:, 2] > 0.345) & (co[:, 2] < 0.475)
|
|
ROUGH_THR = 0.0012
|
|
MELT_ITERS = 80
|
|
|
|
|
|
def log(m):
|
|
print(f"[spot {time.time()-t0:6.1f}s] {m}", flush=True)
|
|
|
|
|
|
bpy.ops.wm.open_mainfile(filepath=BLEND)
|
|
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)
|
|
|
|
n_e = len(me.edges)
|
|
ev = np.empty(n_e * 2, dtype=np.int32)
|
|
me.edges.foreach_get("vertices", ev)
|
|
ev = ev.reshape(-1, 2)
|
|
order = np.concatenate([ev[:, 0], ev[:, 1]])
|
|
nbr = np.concatenate([ev[:, 1], ev[:, 0]])
|
|
srt = np.argsort(order, kind="stable")
|
|
o_s = order[srt]
|
|
n_s = nbr[srt]
|
|
ptr = np.searchsorted(o_s, np.arange(n_v + 1))
|
|
cnt = np.maximum(ptr[1:] - ptr[:-1], 1)
|
|
|
|
|
|
def smooth_field(Q, iters):
|
|
X = Q.copy()
|
|
for _ in range(iters):
|
|
acc = np.zeros_like(X)
|
|
np.add.at(acc, o_s, X[n_s])
|
|
X = acc / cnt[:, None]
|
|
return X
|
|
|
|
|
|
sm = smooth_field(co, 8)
|
|
rough = np.linalg.norm(co - sm, axis=1)
|
|
box = BOX(co)
|
|
hot = box & (rough > ROUGH_THR)
|
|
log(f"box {box.sum()} verts, hot {hot.sum()} (rough>{ROUGH_THR})")
|
|
if hot.sum():
|
|
hc = co[hot]
|
|
log(f"hot cluster: x [{hc[:,0].min():+.4f}..{hc[:,0].max():+.4f}] "
|
|
f"y [{hc[:,1].min():+.4f}..{hc[:,1].max():+.4f}] "
|
|
f"z [{hc[:,2].min():+.4f}..{hc[:,2].max():+.4f}]")
|
|
m = hot.copy()
|
|
for _ in range(2):
|
|
h = m[ev[:, 0]] | m[ev[:, 1]]
|
|
m2 = m.copy()
|
|
m2[ev[:, 0]] |= h
|
|
m2[ev[:, 1]] |= h
|
|
m = m2
|
|
sidx = np.nonzero(m)[0]
|
|
Q = co.copy()
|
|
for _ in range(MELT_ITERS):
|
|
acc = np.zeros_like(Q)
|
|
np.add.at(acc, o_s, Q[n_s])
|
|
mean = acc / cnt[:, None]
|
|
Q[sidx] = 0.5 * Q[sidx] + 0.5 * mean[sidx]
|
|
d = np.linalg.norm(Q - co, axis=1)
|
|
log(f"melted {len(sidx)} verts, max move {d.max():.4f}")
|
|
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))
|
|
else:
|
|
log("nothing hot — no melt applied")
|
|
bpy.context.preferences.filepaths.save_version = 0 # no .blend1 autosave
|
|
bpy.ops.wm.save_as_mainfile(filepath=OUT)
|
|
log(f"WROTE {OUT}")
|
|
print("SPOT_DONE")
|