Skip to content

Commit

Permalink
Merge pull request #227 from jetelain/elevation-out-of-bounds-limiter
Browse files Browse the repository at this point in the history
Ensures that out-of-bounds terrain does creates a gap with actual terrain
  • Loading branch information
jetelain authored May 31, 2024
2 parents da16226 + c847ecc commit cbbb009
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion GameRealisticMap.Arma3/GameEngine/GameConfigGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions GameRealisticMap/ElevationModel/RawElevationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
{
Expand Down

0 comments on commit cbbb009

Please sign in to comment.