ModelTranslator: uv_gate_ok/pick_best_candidate 加 overlap_tol 参数

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
ud18010
2026-07-21 12:28:53 +08:00
co-authored by Claude Opus 4.8
parent 2673cda83a
commit b02877a2cf
2 changed files with 26 additions and 6 deletions
+7 -6
View File
@@ -28,9 +28,10 @@ UV_FLIP_TOL = 0.02 # 质量门:UV 翻转面占比超此值回退 smart_pr
UV_OVERLAP_TOL = 0.08 # 质量门:UV 重叠面占比阈值(手工 UV 同口径约 5%,灾难性失败 >20%)
def uv_gate_ok(flipped, overlap):
"""UV 质量门:翻转与重叠占比都在阈值内。overlap 为 None(op 不可用)按 0 处理。"""
return flipped <= UV_FLIP_TOL and (overlap or 0.0) <= UV_OVERLAP_TOL
def uv_gate_ok(flipped, overlap, overlap_tol=UV_OVERLAP_TOL):
"""UV 质量门:翻转按 UV_FLIP_TOL 固定,重叠按 overlap_tol(默认 UV_OVERLAP_TOL)。
overlap 为 Noneop 不可用)按 0 处理。"""
return flipped <= UV_FLIP_TOL and (overlap or 0.0) <= overlap_tol
def uvpm_mode_label(base, applied):
@@ -38,11 +39,11 @@ def uvpm_mode_label(base, applied):
return base + "+uvpm" if applied else base
def pick_best_candidate(candidates):
def pick_best_candidate(candidates, overlap_tol=UV_OVERLAP_TOL):
"""从候选 UV 指标 dict 列表选过质量门且岛数最少者;无过门候选返回 None。
每个 candidate 至少含 flipped/overlap/islands。"""
overlap_tol 覆盖重叠容忍。每个 candidate 至少含 flipped/overlap/islands。"""
passing = [c for c in candidates
if uv_gate_ok(c["flipped"], c["overlap"])]
if uv_gate_ok(c["flipped"], c["overlap"], overlap_tol)]
if not passing:
return None
return min(passing, key=lambda c: c["islands"])