From c847eccc0c12a1e628966fbb30bbb21866e928af Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 31 May 2024 20:20:35 +0200 Subject: [PATCH] Ensures that out-of-bounds terrain does creates a gap with actual terrain --- GameRealisticMap.Arma3/GameEngine/GameConfigGenerator.cs | 2 +- GameRealisticMap/ElevationModel/RawElevationBuilder.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/GameRealisticMap.Arma3/GameEngine/GameConfigGenerator.cs b/GameRealisticMap.Arma3/GameEngine/GameConfigGenerator.cs index 5a1eefde..be8357af 100644 --- a/GameRealisticMap.Arma3/GameEngine/GameConfigGenerator.cs +++ b/GameRealisticMap.Arma3/GameEngine/GameConfigGenerator.cs @@ -126,7 +126,7 @@ private string GetTerrainSynth(bool isIsland, ElevationOutOfBoundsData outOfBoun private string Serialize(ElevationMinMax[] outOfBounds) { - return string.Join(",", outOfBounds.Select(p => FormattableString.Invariant($"{{{p.Min},{p.Max}}}"))); + return string.Join(",", outOfBounds.Select(p => FormattableString.Invariant($"{{{Math.Round(p.Min,2)},{Math.Round(p.Max,2)}}}"))); } private string GenerateConfigCpp(IArma3MapConfig config, CitiesData cities) diff --git a/GameRealisticMap/ElevationModel/RawElevationBuilder.cs b/GameRealisticMap/ElevationModel/RawElevationBuilder.cs index c0a783d8..52e96480 100644 --- a/GameRealisticMap/ElevationModel/RawElevationBuilder.cs +++ b/GameRealisticMap/ElevationModel/RawElevationBuilder.cs @@ -53,12 +53,12 @@ public RawElevationData Build(IBuildContext context) } // Out of bounds - var outOfBounds = GetOutOfBounds(context, source); + var outOfBounds = GetOutOfBounds(context, source, grid); return new RawElevationData(grid, source.Credits, outOfBounds); } - private ElevationMinMax[] GetOutOfBounds(IBuildContext context, RawElevationSource source) + private ElevationMinMax[] GetOutOfBounds(IBuildContext context, RawElevationSource source, ElevationGrid grid) { var outOfBounds = new ElevationMinMax[512]; using (var report = progress.CreateStep("OutOfBounds", 512)) @@ -71,7 +71,7 @@ private ElevationMinMax[] GetOutOfBounds(IBuildContext context, RawElevationSour var boundary = GetBoundaryPoint(a, center); var vector = Vector2.Normalize(boundary - center) * OutOfBoundsStep; var pos = boundary; - var min = source.GetElevationNoMask(context.Area.TerrainPointToLatLng(new TerrainPoint(pos))); ; + var min = (double)grid.ElevationAt(new TerrainPoint(pos)); var max = min; for (int i = 0; i < OutOfBoundsDistance; i += OutOfBoundsStep) {