Skip to content

Commit 2985890

Browse files
committed
fix(paint3d): refine rotation logic for Y-up/Z-up conversion
Update the rotation handling in the _bounds_axis_swap_x_rad function to clarify the axis swap logic between Y-tall and Z-tall meshes. Adjust comments for better understanding of the rotation conventions and ensure consistent behavior when restoring Y-up orientation. This change enhances the accuracy of mesh orientation adjustments during processing.
1 parent c110495 commit 2985890

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

Paint3D/src/paint3d/painter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,11 @@ def _bounds_axis_swap_x_rad(
207207
yz_after = extent_after[1] / extent_after[2]
208208
# Toleramos ±10% (mesh de saída pode ter pequenas variações por remesh).
209209
if yz_before > 1.0 and yz_after < 1.0 and abs(yz_before - 1.0 / yz_after) < max(yz_before, 1.0 / yz_after) * 0.30:
210-
# Input era Y-tall, output é Z-tall → mesh rodou -90° X (Y foi para Z).
211-
# Para repor, rodamos +90° em X.
212-
return float(np.pi / 2.0)
213-
if yz_before < 1.0 and yz_after > 1.0 and abs(1.0 / yz_before - yz_after) < max(1.0 / yz_before, yz_after) * 0.30:
210+
# Input era Y-tall, output é Z-tall → Hunyuan rodou +90° em X
211+
# ((0,1,0)→(0,0,1)); para repor a convenção Y-up rodamos -90° em X.
214212
return float(-np.pi / 2.0)
213+
if yz_before < 1.0 and yz_after > 1.0 and abs(1.0 / yz_before - yz_after) < max(1.0 / yz_before, yz_after) * 0.30:
214+
return float(np.pi / 2.0)
215215
return 0.0
216216

217217

Rigging3D/src/rigging3d/unirig/src/inference/merge.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,19 @@ def get_correct_orientation_kdtree(
214214
for y in [1, -1]
215215
for z in [1, -1]]
216216
if fix_up_axis is not None:
217-
# Apenas permutações onde o eixo "up" se mapeia a si mesmo, e
218-
# restrigimos sign(up) a +1 — evita inversão cabeça/pés.
219-
axis_permutations = [p for p in axis_permutations if p[fix_up_axis] == fix_up_axis]
220-
sign_combinations = [s for s in sign_combinations if s[fix_up_axis] == 1]
217+
# Quando o "up" está fixo confiamos na convenção do pipeline
218+
# (Y-up, +Z forward) e desligamos a procura: identidade pura.
219+
# Para reactivar a procura completa do KDTree, exporta
220+
# ``RIGGING3D_FIX_UP_AXIS=auto``.
221+
# Alternativa intermédia (procura restringida ao eixo up apenas):
222+
# ``RIGGING3D_ORIENT_SEARCH=relaxed``.
223+
mode = os.environ.get("RIGGING3D_ORIENT_SEARCH", "").strip().lower()
224+
if mode == "relaxed":
225+
axis_permutations = [p for p in axis_permutations if p[fix_up_axis] == fix_up_axis]
226+
sign_combinations = [s for s in sign_combinations if s[fix_up_axis] == 1]
227+
else:
228+
# Modo "lock" (default): nada de procura — devolve a, bones intactos.
229+
return a, bones
221230
_bones = bones.copy()
222231
# Use a deterministic sample for stability across runs.
223232
rng = np.random.default_rng(seed=12345)

0 commit comments

Comments
 (0)