@@ -570,14 +570,16 @@ public static void ClearShapeData(TTModel ttModel, Action<bool, string> loggingF
570
570
ttModel . MeshGroups . ForEach ( x => x . ShapeParts . Clear ( ) ) ;
571
571
}
572
572
573
- // Forces all UV Coordinates in UV1 Layer to [1,-1] Quadrant.
573
+ // Forces all UV Coordinates in UV1 Layer to [1,1] (pre-flip) Quadrant.
574
574
public static void ForceUVQuadrant ( TTModel model , Action < bool , string > loggingFunction = null )
575
575
{
576
576
if ( loggingFunction == null )
577
577
{
578
578
loggingFunction = NoOp ;
579
579
}
580
580
581
+ MakeExportReady ( model , loggingFunction ) ;
582
+
581
583
loggingFunction ( false , "Forcing UV1 to [1,-1]..." ) ;
582
584
foreach ( var m in model . MeshGroups )
583
585
{
@@ -586,11 +588,37 @@ public static void ForceUVQuadrant(TTModel model, Action<bool, string> loggingFu
586
588
foreach ( var v in p . Vertices )
587
589
{
588
590
589
- v . UV1 . X = Math . Abs ( ( v . UV1 . X % 1 ) ) ;
590
- v . UV1 . Y = Math . Abs ( ( v . UV1 . Y % 1 ) ) ;
591
+ v . UV1 . X = ( v . UV1 . X % 1 ) ;
592
+ v . UV1 . Y = ( v . UV1 . Y % 1 ) ;
593
+
594
+ if ( v . UV1 . X < 0 )
595
+ {
596
+ v . UV1 . X += 1 ;
597
+ }
598
+
599
+ if ( v . UV1 . Y > 0 )
600
+ {
601
+ v . UV1 . Y -= 1 ;
602
+ }
603
+ }
604
+ }
605
+ }
606
+
607
+ // Tangents have to be recalculated because we moved the UVs.
608
+ foreach ( var m in model . MeshGroups )
609
+ {
610
+ foreach ( var p in m . Parts )
611
+ {
612
+ foreach ( var v in p . Vertices )
613
+ {
614
+ v . Tangent = Vector3 . Zero ;
615
+ v . Binormal = Vector3 . Zero ;
616
+ v . Handedness = false ;
591
617
}
592
618
}
593
619
}
620
+ MakeImportReady ( model , loggingFunction ) ;
621
+
594
622
}
595
623
596
624
// Resets UV2 to [0,0]
0 commit comments