Files
animation/characters/female/lena_nude/hires_claude/dbg_lines.py
T

38 lines
1.5 KiB
Python
Raw Normal View History

# Probe: (1) duplicate coincident verts along the stomach/waist lines, (2) where the heal
# strip actually was vs where the lines are.
# blender --background --python dbg_lines.py -- <blend> <masks.npz>
import bpy, sys
import numpy as np
argv = sys.argv[sys.argv.index("--") + 1:]
BLEND, MASKS = argv[0], argv[1]
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)
print(f"verts: {n_v}")
# coincident duplicates: exact-position hash
key = np.round(co * 1e5).astype(np.int64)
kview = key[:, 0] * 73856093 ^ key[:, 1] * 19349663 ^ key[:, 2] * 83492791
uniq, counts = np.unique(kview, return_counts=True)
dup_groups = (counts > 1).sum()
print(f"coincident position groups: {dup_groups} (verts in dups: {counts[counts>1].sum()})")
# where are the dups? histogram by z in the torso front
from collections import Counter
dupset = set(uniq[counts > 1].tolist())
isdup = np.array([k in dupset for k in kview])
front = (np.abs(co[:, 0]) < 0.06) & (co[:, 1] < 0)
print("z-slice | dup verts (front) | hemband verts (front)")
M = np.load(MASKS)
hemband = M["hemband"]
for z0 in np.arange(0.44, 0.68, 0.02):
zi = (co[:, 2] >= z0) & (co[:, 2] < z0 + 0.02) & front
print(f" {z0:.2f}-{z0+0.02:.2f}: dup {int((zi & isdup).sum()):6d} hem {int((zi & hemband).sum()):6d}")
print("PROBE_DONE")