From 6f0a23caff70819890bc8c16d98e322b2b4daac2 Mon Sep 17 00:00:00 2001 From: SashaRX Date: Tue, 3 Mar 2026 20:49:58 +0100 Subject: [PATCH] Update triangle shell selection to 3-vertex majority vote --- Editor/TransferValidator.cs | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/Editor/TransferValidator.cs b/Editor/TransferValidator.cs index 620e6d00..bbfe497a 100644 --- a/Editor/TransferValidator.cs +++ b/Editor/TransferValidator.cs @@ -142,14 +142,47 @@ public static ValidationReport Validate( if (vertShell != null) { - // Determine triangle's shell from majority of its vertices + // Determine triangle shell by majority vote over all 3 vertices. + // If no majority exists, fallback to the first valid vertex shell, else -1. triShell = new int[faceCount]; var shellStretchLists = new Dictionary>(); for (int f = 0; f < faceCount; f++) { int i0 = tris[f * 3]; - int sh = (i0 < vertShell.Length) ? vertShell[i0] : -1; + int i1 = tris[f * 3 + 1]; + int i2 = tris[f * 3 + 2]; + + int sh0 = (i0 < vertShell.Length) ? vertShell[i0] : -1; + int sh1 = (i1 < vertShell.Length) ? vertShell[i1] : -1; + int sh2 = (i2 < vertShell.Length) ? vertShell[i2] : -1; + + int sh; + if (sh0 >= 0 && (sh0 == sh1 || sh0 == sh2)) + { + sh = sh0; + } + else if (sh1 >= 0 && sh1 == sh2) + { + sh = sh1; + } + else if (sh0 >= 0) + { + sh = sh0; + } + else if (sh1 >= 0) + { + sh = sh1; + } + else if (sh2 >= 0) + { + sh = sh2; + } + else + { + sh = -1; + } + triShell[f] = sh; float sr = report.stretchRatios[f];