diff --git a/src/DotRecast.Detour.Dynamic/DtDynamicTile.cs b/src/DotRecast.Detour.Dynamic/DtDynamicTile.cs index 7712497..4f31dcd 100644 --- a/src/DotRecast.Detour.Dynamic/DtDynamicTile.cs +++ b/src/DotRecast.Detour.Dynamic/DtDynamicTile.cs @@ -100,7 +100,7 @@ namespace DotRecast.Detour.Dynamic Math.Min(DtDynamicNavMesh.MAX_VERTS_PER_POLY, config.vertsPerPoly), config.detailSampleDistance, config.detailSampleMaxError, true, true, true, default, true); - RcBuilderResult r = builder.Build(context, vt.tileX, vt.tileZ, null, rcConfig, heightfield); + RcBuilderResult r = builder.Build(context, vt.tileX, vt.tileZ, null, rcConfig, heightfield, false); if (config.keepIntermediateResults) { recastResult = r; diff --git a/src/DotRecast.Recast.Toolset/Builder/SoloNavMeshBuilder.cs b/src/DotRecast.Recast.Toolset/Builder/SoloNavMeshBuilder.cs index 71d2c0f..10b4c09 100644 --- a/src/DotRecast.Recast.Toolset/Builder/SoloNavMeshBuilder.cs +++ b/src/DotRecast.Recast.Toolset/Builder/SoloNavMeshBuilder.cs @@ -80,22 +80,7 @@ namespace DotRecast.Recast.Toolset.Builder { RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax()); RcBuilder rcBuilder = new RcBuilder(); - var result = rcBuilder.Build(geom, bcfg); - if (!keepInterResults) - { - return new RcBuilderResult( - result.TileX, - result.TileZ, - null, - null, - null, - result.Mesh, - result.MeshDetail, - result.Context - ); - } - - return result; + return rcBuilder.Build(geom, bcfg, keepInterResults); } public DtMeshData BuildMeshData(DemoInputGeomProvider geom, diff --git a/src/DotRecast.Recast/RcBuilder.cs b/src/DotRecast.Recast/RcBuilder.cs index 8cad533..0620809 100644 --- a/src/DotRecast.Recast/RcBuilder.cs +++ b/src/DotRecast.Recast/RcBuilder.cs @@ -132,30 +132,17 @@ namespace DotRecast.Recast public RcBuilderResult BuildTile(IInputGeomProvider geom, RcConfig cfg, RcVec3f bmin, RcVec3f bmax, int tx, int ty, RcAtomicInteger progress, int total, bool keepInterResults) { var bcfg = new RcBuilderConfig(cfg, bmin, bmax, tx, ty); - RcBuilderResult result = Build(geom, bcfg); + RcBuilderResult result = Build(geom, bcfg, keepInterResults); if (_progressListener != null) { _progressListener.OnProgress(progress.IncrementAndGet(), total); } - if (!keepInterResults) - { - return new RcBuilderResult( - result.TileX, - result.TileZ, - null, - null, - null, - result.Mesh, - result.MeshDetail, - result.Context - ); - } return result; } - public RcBuilderResult Build(IInputGeomProvider geom, RcBuilderConfig bcfg) + public RcBuilderResult Build(IInputGeomProvider geom, RcBuilderConfig bcfg, bool keepInterResults) { RcConfig cfg = bcfg.cfg; RcContext ctx = new RcContext(); @@ -163,10 +150,10 @@ namespace DotRecast.Recast // Step 1. Rasterize input polygon soup. // RcHeightfield solid = RcVoxelizations.BuildSolidHeightfield(ctx, geom, bcfg); - return Build(ctx, bcfg.tileX, bcfg.tileZ, geom, cfg, solid); + return Build(ctx, bcfg.tileX, bcfg.tileZ, geom, cfg, solid, keepInterResults); } - public RcBuilderResult Build(RcContext ctx, int tileX, int tileZ, IInputGeomProvider geom, RcConfig cfg, RcHeightfield solid) + public RcBuilderResult Build(RcContext ctx, int tileX, int tileZ, IInputGeomProvider geom, RcConfig cfg, RcHeightfield solid, bool keepInterResults) { FilterHeightfield(ctx, solid, cfg); RcCompactHeightfield chf = BuildCompactHeightfield(ctx, geom, cfg, solid); @@ -237,7 +224,17 @@ namespace DotRecast.Recast RcPolyMeshDetail dmesh = cfg.BuildMeshDetail ? RcMeshDetails.BuildPolyMeshDetail(ctx, pmesh, chf, cfg.DetailSampleDist, cfg.DetailSampleMaxError) : null; - return new RcBuilderResult(tileX, tileZ, solid, chf, cset, pmesh, dmesh, ctx); + + return new RcBuilderResult( + tileX, + tileZ, + keepInterResults ? solid : null, + keepInterResults ? chf : null, + keepInterResults ? cset : null, + pmesh, + dmesh, + ctx + ); } /* diff --git a/test/DotRecast.Detour.Crowd.Test/RecastTestMeshBuilder.cs b/test/DotRecast.Detour.Crowd.Test/RecastTestMeshBuilder.cs index 7fd70c3..bacecb9 100644 --- a/test/DotRecast.Detour.Crowd.Test/RecastTestMeshBuilder.cs +++ b/test/DotRecast.Detour.Crowd.Test/RecastTestMeshBuilder.cs @@ -72,7 +72,7 @@ public class RecastTestMeshBuilder SampleAreaModifications.SAMPLE_AREAMOD_GROUND, true); RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax()); RcBuilder rcBuilder = new RcBuilder(); - RcBuilderResult rcResult = rcBuilder.Build(geom, bcfg); + RcBuilderResult rcResult = rcBuilder.Build(geom, bcfg, false); RcPolyMesh m_pmesh = rcResult.Mesh; for (int i = 0; i < m_pmesh.npolys; ++i) { diff --git a/test/DotRecast.Detour.Test/RecastTestMeshBuilder.cs b/test/DotRecast.Detour.Test/RecastTestMeshBuilder.cs index b1830bb..12c618e 100644 --- a/test/DotRecast.Detour.Test/RecastTestMeshBuilder.cs +++ b/test/DotRecast.Detour.Test/RecastTestMeshBuilder.cs @@ -72,7 +72,7 @@ public class RecastTestMeshBuilder SampleAreaModifications.SAMPLE_AREAMOD_GROUND, true); RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax()); RcBuilder rcBuilder = new RcBuilder(); - RcBuilderResult rcResult = rcBuilder.Build(geom, bcfg); + RcBuilderResult rcResult = rcBuilder.Build(geom, bcfg, false); RcPolyMesh m_pmesh = rcResult.Mesh; for (int i = 0; i < m_pmesh.npolys; ++i) { diff --git a/test/DotRecast.Detour.Test/TestDetourBuilder.cs b/test/DotRecast.Detour.Test/TestDetourBuilder.cs index d7b9268..4df7c6d 100644 --- a/test/DotRecast.Detour.Test/TestDetourBuilder.cs +++ b/test/DotRecast.Detour.Test/TestDetourBuilder.cs @@ -27,7 +27,7 @@ public class TestDetourBuilder : DetourBuilder float agentMaxClimb, int x, int y, bool applyRecastDemoFlags) { RcBuilder rcBuilder = new RcBuilder(); - RcBuilderResult rcResult = rcBuilder.Build(geom, rcConfig); + RcBuilderResult rcResult = rcBuilder.Build(geom, rcConfig, false); RcPolyMesh pmesh = rcResult.Mesh; if (applyRecastDemoFlags) diff --git a/test/DotRecast.Recast.Test/RecastTileMeshTest.cs b/test/DotRecast.Recast.Test/RecastTileMeshTest.cs index 8d98546..6fa4676 100644 --- a/test/DotRecast.Recast.Test/RecastTileMeshTest.cs +++ b/test/DotRecast.Recast.Test/RecastTileMeshTest.cs @@ -69,27 +69,27 @@ public class RecastTileMeshTest true, true, true, SampleAreaModifications.SAMPLE_AREAMOD_GROUND, true); RcBuilderConfig bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 7, 8); - RcBuilderResult rcResult = builder.Build(geom, bcfg); + RcBuilderResult rcResult = builder.Build(geom, bcfg, false); Assert.That(rcResult.Mesh.npolys, Is.EqualTo(1)); Assert.That(rcResult.Mesh.nverts, Is.EqualTo(5)); bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 6, 9); - rcResult = builder.Build(geom, bcfg); + rcResult = builder.Build(geom, bcfg, false); Assert.That(rcResult.Mesh.npolys, Is.EqualTo(2)); Assert.That(rcResult.Mesh.nverts, Is.EqualTo(7)); bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 2, 9); - rcResult = builder.Build(geom, bcfg); + rcResult = builder.Build(geom, bcfg, false); Assert.That(rcResult.Mesh.npolys, Is.EqualTo(2)); Assert.That(rcResult.Mesh.nverts, Is.EqualTo(9)); bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 4, 3); - rcResult = builder.Build(geom, bcfg); + rcResult = builder.Build(geom, bcfg, false); Assert.That(rcResult.Mesh.npolys, Is.EqualTo(3)); Assert.That(rcResult.Mesh.nverts, Is.EqualTo(6)); bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 2, 8); - rcResult = builder.Build(geom, bcfg); + rcResult = builder.Build(geom, bcfg, false); Assert.That(rcResult.Mesh.npolys, Is.EqualTo(5)); Assert.That(rcResult.Mesh.nverts, Is.EqualTo(17)); bcfg = new RcBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), 0, 8); - rcResult = builder.Build(geom, bcfg); + rcResult = builder.Build(geom, bcfg, false); Assert.That(rcResult.Mesh.npolys, Is.EqualTo(6)); Assert.That(rcResult.Mesh.nverts, Is.EqualTo(15)); }