fixed switching
This commit is contained in:
parent
ec1f6274e3
commit
d71c1d97c5
1 changed files with 7 additions and 41 deletions
|
|
@ -13,8 +13,6 @@ public class WorldMap : IDisposable
|
|||
private int _frameCount;
|
||||
private int _consecutiveMatchFails;
|
||||
private Mat? _prevWallMask; // for frame deduplication
|
||||
private bool _modeSwitchPending; // suppress blind bootstrap after mode switch
|
||||
private bool _hasCanvasData; // true after first successful stitch
|
||||
|
||||
public MapPosition Position => _position;
|
||||
public bool LastMatchSucceeded { get; private set; }
|
||||
|
|
@ -38,9 +36,7 @@ public class WorldMap : IDisposable
|
|||
|
||||
var isCorner = mode == MinimapMode.Corner;
|
||||
var warmupFrames = isCorner ? 2 : _config.WarmupFrames;
|
||||
// After mode switch, don't blindly stitch — wait for template match to confirm alignment
|
||||
var needsBootstrap = !_modeSwitchPending
|
||||
&& (_frameCount <= warmupFrames || _consecutiveMatchFails >= 30);
|
||||
var needsBootstrap = _frameCount <= warmupFrames || _consecutiveMatchFails >= 30;
|
||||
|
||||
// Block-based noise filter: only needed for overlay (game effects bleed through)
|
||||
if (!isCorner)
|
||||
|
|
@ -78,7 +74,6 @@ public class WorldMap : IDisposable
|
|||
if (needsBootstrap)
|
||||
{
|
||||
StitchWithConfidence(classifiedMat, _position, boosted: true, mode: mode);
|
||||
_hasCanvasData = true;
|
||||
if (_consecutiveMatchFails >= 30)
|
||||
{
|
||||
Log.Information("Re-bootstrap: stitching at current position after {Fails} match failures ({Ms:F1}ms)",
|
||||
|
|
@ -102,38 +97,11 @@ public class WorldMap : IDisposable
|
|||
{
|
||||
_consecutiveMatchFails++;
|
||||
LastMatchSucceeded = false;
|
||||
if (_modeSwitchPending)
|
||||
{
|
||||
// After 60 failures, give up on cross-mode alignment and force bootstrap
|
||||
if (_consecutiveMatchFails >= 60)
|
||||
{
|
||||
Log.Information("Mode switch: giving up on alignment after {Fails} tries, force bootstrap",
|
||||
_consecutiveMatchFails);
|
||||
_modeSwitchPending = false;
|
||||
_consecutiveMatchFails = 0;
|
||||
_frameCount = 0; // will trigger warmup bootstrap next frame
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Information("Mode switch: match failed x{Fails}, waiting for alignment ({Ms:F1}ms)",
|
||||
_consecutiveMatchFails, sw.Elapsed.TotalMilliseconds);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Information("MatchAndStitch: dedup={Dedup:F1}ms match={Match:F1}ms (FAILED x{Fails}) total={Total:F1}ms",
|
||||
dedupMs, matchMs, _consecutiveMatchFails, sw.Elapsed.TotalMilliseconds);
|
||||
}
|
||||
return _position; // don't stitch — wrong position would corrupt the canvas
|
||||
}
|
||||
|
||||
// Successful match — clear mode switch pending (alignment confirmed)
|
||||
if (_modeSwitchPending)
|
||||
{
|
||||
Log.Information("Mode switch: alignment confirmed after {Fails} tries", _consecutiveMatchFails);
|
||||
_modeSwitchPending = false;
|
||||
}
|
||||
|
||||
_consecutiveMatchFails = 0;
|
||||
LastMatchSucceeded = true;
|
||||
_position = matched;
|
||||
|
|
@ -535,20 +503,18 @@ public class WorldMap : IDisposable
|
|||
_position = new MapPosition(_config.CanvasSize / 2.0, _config.CanvasSize / 2.0);
|
||||
_frameCount = 0;
|
||||
_consecutiveMatchFails = 0;
|
||||
_hasCanvasData = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-bootstrap without clearing the canvas. Used when minimap mode switches
|
||||
/// so new frames get stitched onto existing map data.
|
||||
/// Mode switch: clear frame dedup cache (frame sizes differ between modes)
|
||||
/// but keep template matching active — no blind bootstrap needed since scales match.
|
||||
/// </summary>
|
||||
public void Rebootstrap()
|
||||
{
|
||||
_prevWallMask?.Dispose();
|
||||
_prevWallMask = null;
|
||||
_frameCount = 0;
|
||||
_consecutiveMatchFails = 0;
|
||||
_modeSwitchPending = _hasCanvasData; // only suppress if canvas has data worth protecting
|
||||
// Don't reset _frameCount or _consecutiveMatchFails —
|
||||
// template matching continues seamlessly with the new frame size
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue