mesh polish: boundary_root, the cut-root formula cut_parts shared with the rig
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
82196e5f26
commit
e141782a60
2 changed files with 7 additions and 1 deletions
|
|
@ -667,7 +667,7 @@ class BROKKR_MESH_POLISH_OT_cut_parts(PolishOperator):
|
|||
raise Refused(f"Part {name!r} came out empty: move its seed onto the surface.")
|
||||
lengths = np.array([e.calc_length() for e in cut])
|
||||
mids = np.array([((e.verts[0].co + e.verts[1].co) / 2)[:] for e in cut]).reshape(-1, 3)
|
||||
root_local = (mids * lengths[:, None]).sum(axis=0) / lengths.sum() if len(cut) else np.zeros(3)
|
||||
root_local = core.boundary_root(mids, lengths)
|
||||
spread = mids - root_local
|
||||
normal_local = np.linalg.eigh((spread * lengths[:, None]).T @ spread)[1][:, 0] if len(cut) >= 3 else np.array([0.0, 0.0, 1.0])
|
||||
mean_radius = float((np.linalg.norm(spread, axis=1) * lengths).sum() / lengths.sum()) if len(cut) else 0.0
|
||||
|
|
|
|||
|
|
@ -259,6 +259,12 @@ def grow_parts(count: int, pairs: np.ndarray, costs: np.ndarray, seeds: list[tup
|
|||
return np.asarray(part, dtype=np.int64), np.asarray(best)
|
||||
|
||||
|
||||
def boundary_root(mids: np.ndarray, lengths: np.ndarray) -> np.ndarray:
|
||||
"""Where a part is rooted: the length-weighted mean of the midpoints of the edges along its cut (zeros when
|
||||
it has no cut)."""
|
||||
return (mids * lengths[:, None]).sum(axis=0) / lengths.sum() if len(lengths) else np.zeros(3)
|
||||
|
||||
|
||||
def parse_seeds(text: str) -> list[tuple[str, tuple[float, float, float]]]:
|
||||
"""'hull=0,0,0; pod1=1,0,0.5; pod1=1.2,0,0.4' as [(name, (x, y, z))]; ValueError names the bad entry."""
|
||||
seeds = []
|
||||
|
|
|
|||
Loading…
Reference in a new issue