private Vector2 CalculateFollowerMarginUv(WeldSideSource biggerTerrain, WeldSideSource smallerTerrain)
        {
            var biggerSideRange = new Vector2(0, 0);

            if (biggerTerrain.SideType.GetOrientation() == WeldOrientation.Horizontal)
            {
                biggerSideRange = RectangleUtils.CalculateSubPosition(biggerTerrain.Terrain.DetailGlobalArea,
                                                                      biggerTerrain.Terrain.UvCoordsPositions2D).XRange;
            }
            else
            {
                biggerSideRange = RectangleUtils.CalculateSubPosition(biggerTerrain.Terrain.DetailGlobalArea,
                                                                      biggerTerrain.Terrain.UvCoordsPositions2D).YRange;
            }

            var smallerSideRange = new Vector2(0, 0);

            if (smallerTerrain.SideType.GetOrientation() == WeldOrientation.Horizontal)
            {
                smallerSideRange = RectangleUtils.CalculateSubPosition(smallerTerrain.Terrain.DetailGlobalArea,
                                                                       smallerTerrain.Terrain.UvCoordsPositions2D).XRange;
            }
            else
            {
                smallerSideRange = RectangleUtils.CalculateSubPosition(smallerTerrain.Terrain.DetailGlobalArea,
                                                                       smallerTerrain.Terrain.UvCoordsPositions2D).YRange;
            }

            var uv = VectorUtils.CalculateSubelementUv(biggerSideRange, smallerSideRange);

            Preconditions.Assert(uv.IsNormalized(),
                                 $"E76 Margin uv is not normalized: {uv}, biggerSideRange:{biggerSideRange}, smallerSideRange {smallerSideRange}");
            return(uv);
        }
 public void AddSide(WeldSideSource weldSideSource)
 {
     if (weldSideSource.SideType == WeldSideType.Bottom)
     {
         Preconditions.Assert(First == null,
                              $"E12 Bottom of weld is arleady taken. New {weldSideSource}, old {First}");
         First = weldSideSource;
     }
     else if (weldSideSource.SideType == WeldSideType.Left)
     {
         Preconditions.Assert(First == null,
                              $"E12 Left of weld is arleady taken. New {weldSideSource}, old {First}");
         First = weldSideSource;
     }
     else if (weldSideSource.SideType == WeldSideType.Top)
     {
         Preconditions.Assert(Second == null,
                              $"E12 Top of weld is arleady taken. New {weldSideSource}, old {Second}");
         Second = weldSideSource;
     }
     else if (weldSideSource.SideType == WeldSideType.Right)
     {
         Preconditions.Assert(Second == null,
                              $"E12 Right of weld is arleady taken. New {weldSideSource}, old {Second}");
         Second = weldSideSource;
     }
     else
     {
         Preconditions.Fail("Not supported sideType " + weldSideSource.SideType);
     }
 }
 private static StripSide CreateStripSide(WeldSideSource weldingTerrain, Vector2 normalizedMarginOfUvTerrain)
 {
     return(new StripSide()
     {
         HeightTexture = weldingTerrain.Terrain.Texture,
         HeightTextureUvs = weldingTerrain.Terrain.UvCoordsPositions2D,
         Lod = weldingTerrain.Terrain.TerrainLod,
         NormalizedMarginUvOfTerrain = normalizedMarginOfUvTerrain,
         Resolution = weldingTerrain.Terrain.Resolution,
         WeldSideType = weldingTerrain.SideType,
         TerrainId = weldingTerrain.Terrain.WeldingInputTerrainId
     });
 }