From b10ddf976217c511a1f4dbeb6a0dd1b35dd31d03 Mon Sep 17 00:00:00 2001 From: "s0wlz (Matthias Puchstein)" Date: Wed, 11 Feb 2026 00:35:39 +0100 Subject: [PATCH] Prioritize boundary inflow over boundary outflow on ghost cells --- .../Networking/Server/SweServerRuntime.cs | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Networking/Server/SweServerRuntime.cs b/Assets/Scripts/Networking/Server/SweServerRuntime.cs index 8db30f212..5eb3fa065 100644 --- a/Assets/Scripts/Networking/Server/SweServerRuntime.cs +++ b/Assets/Scripts/Networking/Server/SweServerRuntime.cs @@ -753,7 +753,9 @@ namespace FloodSWE.Networking var ghostIndices = new List(128); var ghostLevels = new List(128); var ghostVelocities = new List(128); + var ghostInflowCells = new HashSet(); var ghostOutflowCells = new HashSet(); + var suppressedOutflowCells = new HashSet(); var boundarySinkIdsWithGhostOutflow = new HashSet(); foreach (var pair in activeBoundaryInflowGhostCells) @@ -778,9 +780,16 @@ namespace FloodSWE.Networking Vector2 velocity = new Vector2(profile.velocityUMps, profile.velocityVMps); for (int i = 0; i < cells.Length; i++) { - ghostIndices.Add(cells[i]); + int idx = cells[i]; + if (idx < 0) + { + continue; + } + + ghostIndices.Add(idx); ghostLevels.Add(level); ghostVelocities.Add(velocity); + ghostInflowCells.Add(idx); } } @@ -817,10 +826,18 @@ namespace FloodSWE.Networking for (int i = 0; i < cells.Length; i++) { int idx = cells[i]; - if (idx >= 0) + if (idx < 0) { - ghostOutflowCells.Add(idx); + continue; } + + if (ghostInflowCells.Contains(idx)) + { + suppressedOutflowCells.Add(idx); + continue; + } + + ghostOutflowCells.Add(idx); } } @@ -988,7 +1005,7 @@ namespace FloodSWE.Networking if (verboseDiagnostics) { Debug.Log( - $"SweServerRuntime: forcing applied status={lastForcingStatus} ghost={ghostIndices.Count} depth={forcedDepthCells} freeOutflow={ghostOutflowCells.Count}"); + $"SweServerRuntime: forcing applied status={lastForcingStatus} ghost={ghostIndices.Count} depth={forcedDepthCells} freeOutflow={ghostOutflowCells.Count} suppressedOutflowByInflow={suppressedOutflowCells.Count}"); } }