diff --git a/GameRealisticMap.Arma3/Arma3DemoMapGenerator.cs b/GameRealisticMap.Arma3/Arma3DemoMapGenerator.cs index ef071a0d..e868c534 100644 --- a/GameRealisticMap.Arma3/Arma3DemoMapGenerator.cs +++ b/GameRealisticMap.Arma3/Arma3DemoMapGenerator.cs @@ -13,7 +13,6 @@ using GameRealisticMap.ManMade.Places; using GameRealisticMap.ManMade.Roads; using GameRealisticMap.Osm; -using GameRealisticMap.Reporting; using HugeImages.Storage; using Pmad.ProgressTracking; @@ -129,9 +128,9 @@ private void BuildingAdjust(ElevationGrid grid, List places, List GetObjects(IProgressScope progress, IArma3MapConfig config, IContext context, Arma3LayerGeneratorCatalog generators, ElevationGrid grid) + protected override async Task> GetObjects(IProgressScope progress, IArma3MapConfig config, IContext context, Arma3LayerGeneratorCatalog generators, ElevationGrid grid) { - return base.GetObjects(progress, config, context, generators, grid) + return (await base.GetObjects(progress, config, context, generators, grid)) .Concat(context.GetData>()); } diff --git a/GameRealisticMap.Arma3/Arma3MapGenerator.cs b/GameRealisticMap.Arma3/Arma3MapGenerator.cs index 8e091b45..f0520df5 100644 --- a/GameRealisticMap.Arma3/Arma3MapGenerator.cs +++ b/GameRealisticMap.Arma3/Arma3MapGenerator.cs @@ -144,10 +144,10 @@ protected virtual async Task LoadOsmData(IProgressScope progress // Objects + WRP var wrpBuilder = new WrpCompiler(progress, projectDrive); - var grid = gridTask.Result.Elevation; + var grid = (await gridTask).Elevation; var size = area.SizeInMeters; - var objects = GetObjects(progress, config, context, generators, grid) + var objects = (await GetObjects(progress, config, context, generators, grid)) .Where(o => IsStrictlyInside(o, size)); wrpBuilder.Write(config, grid, tiles, objects); @@ -162,23 +162,24 @@ protected virtual IImagerySource CreateImagerySource(IProgressScope progress, Ar return new ImagerySource(assets.Materials, progress, projectDrive, config, context); } - protected virtual IEnumerable GetObjects(IProgressScope progress, IArma3MapConfig config, IContext context, Arma3LayerGeneratorCatalog generators, ElevationGrid grid) + protected virtual async Task> GetObjects(IProgressScope progress, IArma3MapConfig config, IContext context, Arma3LayerGeneratorCatalog generators, ElevationGrid grid) { - return GenerateObjects(progress, config, context, generators).Select(o => o.ToWrpObject(grid)); + return (await GenerateObjects(progress, config, context, generators)) + .SelectMany(o => o) + .Select(o => o.ToWrpObject(grid)); } - private IEnumerable GenerateObjects(IProgressScope progress, IArma3MapConfig config, IContext context, Arma3LayerGeneratorCatalog generators) + private async ValueTask>> GenerateObjects(IProgressScope progress, IArma3MapConfig config, IContext context, Arma3LayerGeneratorCatalog generators) { var result = new ConcurrentQueue>(); - using (var scope = progress.CreateScope("Objects", generators.Generators.Count)) { - Parallel.ForEachAsync(generators.Generators, new ParallelOptions() { CancellationToken = progress.CancellationToken, MaxDegreeOfParallelism = 4 }, async (tb, _) => + await Parallel.ForEachAsync(generators.Generators, new ParallelOptions() { CancellationToken = progress.CancellationToken, MaxDegreeOfParallelism = 4 }, async (tb, _) => { result.Enqueue(await tb.Generate(config, context, scope)); - }).Wait(); + }); } - return result.SelectMany(o => o); + return result; } private bool IsStrictlyInside(EditableWrpObject o, float size) diff --git a/GameRealisticMap.Arma3/Arma3TerrainBuilderGenerator.cs b/GameRealisticMap.Arma3/Arma3TerrainBuilderGenerator.cs index 2e9a3cfd..ed7a6666 100644 --- a/GameRealisticMap.Arma3/Arma3TerrainBuilderGenerator.cs +++ b/GameRealisticMap.Arma3/Arma3TerrainBuilderGenerator.cs @@ -11,7 +11,6 @@ using GameRealisticMap.ManMade.Roads; using GameRealisticMap.Osm; using GameRealisticMap.Preview; -using GameRealisticMap.Reporting; using HugeImages; using HugeImages.Processing; using HugeImages.Storage; @@ -66,7 +65,7 @@ private BuildContext CreateBuildContext(IProgressScope progress, Arma3MapConfig } #if DEBUG - PreviewRender.RenderHtml(context, "debug.html").Wait(); + await PreviewRender.RenderHtml(context, "debug.html"); #endif // Convert PAA @@ -191,7 +190,7 @@ private async Task> ExportImagery(IProgressScope progress, Arm { await WriteImage(progress, idMap, Path.Combine(targetDirectory, "idmap.png"), parts).ConfigureAwait(false); } - ImageryCompiler.CreateConfigCppImages(projectDrive, config, source); + await ImageryCompiler.CreateConfigCppImages(projectDrive, config, source); using (var satMap = await source.CreateSatMap()) { await WriteImage(progress, satMap, Path.Combine(targetDirectory, "satmap.png"), parts).ConfigureAwait(false); diff --git a/GameRealisticMap.Arma3/Demo/Arma3GdtDemoMapGenerator.cs b/GameRealisticMap.Arma3/Demo/Arma3GdtDemoMapGenerator.cs index aa433999..dee3eecb 100644 --- a/GameRealisticMap.Arma3/Demo/Arma3GdtDemoMapGenerator.cs +++ b/GameRealisticMap.Arma3/Demo/Arma3GdtDemoMapGenerator.cs @@ -9,7 +9,6 @@ using GameRealisticMap.ManMade.Roads; using GameRealisticMap.Nature.Weather; using GameRealisticMap.Osm; -using GameRealisticMap.Reporting; using HugeImages.Storage; using Pmad.ProgressTracking; @@ -68,9 +67,9 @@ protected override BuildContext CreateBuildContext(IProgressScope progress, Arma return context; } - protected override IEnumerable GetObjects(IProgressScope progress, IArma3MapConfig config, IContext context, Arma3LayerGeneratorCatalog generators, ElevationGrid grid) + protected override Task> GetObjects(IProgressScope progress, IArma3MapConfig config, IContext context, Arma3LayerGeneratorCatalog generators, ElevationGrid grid) { - return new List(); + return Task.FromResult((IEnumerable) new List()); } protected override IImagerySource CreateImagerySource(IProgressScope progress, Arma3MapConfig config, IContext context)