ModelTranslator: QR tolerance soft-gate + precollapse target policy

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ud18010
2026-07-23 14:58:25 +08:00
co-authored by Claude Opus 4.8
parent eb92ecacfa
commit bb6f32b1c1
2 changed files with 47 additions and 5 deletions
+14 -5
View File
@@ -4,6 +4,9 @@ import glob
import os
QR_TIMEOUT = 120.0 # 引擎轮询超时(秒)
QR_INPUT_CAP = 50000 # quad 后端 QR 前预 collapse 的中等密度目标面数
QR_HOLE_MAX_SIDES = 6 # 补洞上限边数:只补 <=6 边的薄部位小洞
QR_CATASTROPHIC_TOL = 12 # 软水密门容忍:补洞后仍多出超此数的开边/非流形才判灾难性
def find_qr_engine():
@@ -65,8 +68,14 @@ def parse_progress(text):
def topology_acceptable(src_boundary, src_nonmanifold,
out_boundary, out_nonmanifold):
"""QR 输出拓扑是否可接受:不比输入引入更多开边(孔洞)/非流形边。
QR 引擎在激进减面下会非确定性地打出孔洞——封闭输入(0/0)时要求输出也 0/0,
输入本身开放(壳)时按其基线放行;否则判破损,交上层回退 collapse。"""
return out_boundary <= src_boundary and out_nonmanifold <= src_nonmanifold
out_boundary, out_nonmanifold, tol=0):
"""QR 输出拓扑是否可接受:不比输入多出超过 tol 的开边(孔洞)/非流形边。
tol=0(默认)为零容忍严格门;quad 后端补小洞后用 tol=QR_CATASTROPHIC_TOL 只挡灾难性破损。"""
return (out_boundary <= src_boundary + tol
and out_nonmanifold <= src_nonmanifold + tol)
def precollapse_target(face_count, cap=QR_INPUT_CAP):
"""QR 前预 collapse 目标:面数 > cap 返回 cap(先减到中等密度),否则 None(跳过)。
高密度网格直接 QR 必破洞,先 collapse 到中等密度给 QR 一个稳定输入。"""
return cap if face_count > cap else None