refactor: Remove unused List<int> overlaps in the MergeAndFilterLayerRegions function.

This commit is contained in:
ikpil 2024-01-20 00:56:31 +09:00 committed by Ikpil
parent 66a3d73b8f
commit 17f13dd681
1 changed files with 14 additions and 10 deletions

View File

@ -1163,7 +1163,7 @@ namespace DotRecast.Recast
} }
} }
private static int MergeAndFilterLayerRegions(RcContext ctx, int minRegionArea, int maxRegionId, RcCompactHeightfield chf, int[] srcReg, List<int> overlaps) private static bool MergeAndFilterLayerRegions(RcContext ctx, int minRegionArea, ref int maxRegionId, RcCompactHeightfield chf, int[] srcReg)
{ {
int w = chf.width; int w = chf.width;
int h = chf.height; int h = chf.height;
@ -1398,7 +1398,7 @@ namespace DotRecast.Recast
} }
} }
return maxRegionId; return true;
} }
/// @par /// @par
@ -1781,7 +1781,7 @@ namespace DotRecast.Recast
} }
} }
public static void BuildLayerRegions(RcContext ctx, RcCompactHeightfield chf, int minRegionArea) public static bool BuildLayerRegions(RcContext ctx, RcCompactHeightfield chf, int minRegionArea)
{ {
using var timer = ctx.ScopedTimer(RcTimerLabel.RC_TIMER_BUILD_REGIONS); using var timer = ctx.ScopedTimer(RcTimerLabel.RC_TIMER_BUILD_REGIONS);
@ -1924,13 +1924,15 @@ namespace DotRecast.Recast
} }
} }
ctx.StartTimer(RcTimerLabel.RC_TIMER_BUILD_REGIONS_FILTER); using (var timerFilter = ctx.ScopedTimer(RcTimerLabel.RC_TIMER_BUILD_REGIONS_FILTER))
{
// Merge monotone regions to layers and remove small regions. // Merge monotone regions to layers and remove small regions.
List<int> overlaps = new List<int>(); chf.maxRegions = id;
chf.maxRegions = MergeAndFilterLayerRegions(ctx, minRegionArea, id, chf, srcReg, overlaps); if (!MergeAndFilterLayerRegions(ctx, minRegionArea, ref chf.maxRegions, chf, srcReg))
{
ctx.StopTimer(RcTimerLabel.RC_TIMER_BUILD_REGIONS_FILTER); return false;
}
}
// Store the result out. // Store the result out.
for (int i = 0; i < chf.spanCount; ++i) for (int i = 0; i < chf.spanCount; ++i)
@ -1940,6 +1942,8 @@ namespace DotRecast.Recast
.WithReg(srcReg[i]) .WithReg(srcReg[i])
.Build(); .Build();
} }
return true;
} }
} }
} }