Skip to content

fix(ui): fill build-zone overlay masks in one pass, not per texel - #116

Open
cubetribe wants to merge 1 commit into
mainfrom
fix/buildzone-overlay-repaint-cost
Open

fix(ui): fill build-zone overlay masks in one pass, not per texel#116
cubetribe wants to merge 1 commit into
mainfrom
fix/buildzone-overlay-repaint-cost

Conversation

@cubetribe

Copy link
Copy Markdown
Collaborator

Was

Hotfix für den Spielbericht „das Spiel ist komisch verzögert / ruckelt beim Bauen". Die Ursache lag im 21.4-Baubereich-Overlay (#112): Repaint fragte IsInsideBuildInfluence und HasMinimumBuildingSpacing pro Texel ab — ~16.000 Texel × Platzierungsregister-Scan × lineare Baustellenprobe (IsActiveSite) = mehrere hundert Millionen Operationen pro Repaint, 4× pro Sekunde, ausgerechnet während ein Bau-Ghost armiert ist.

Jetzt füllt ConstructionSystem.FillBuildZoneMasks beide Masken in einem Register-Pass pro Repaint. Das ist keine Annäherung: beide Prädikate sind Rechtecks-Chebyshev-Distanzen zwischen uniformen 3×3-Footprints, also ist die Antwortmenge pro Registereintrag exakt ein Quadrat von Kandidaten-Ursprüngen (Einfluss: Halbkante BuildInfluenceRadiusCells + f − 1; Abstand: MinimumBuildingDistanceCells + f − 2). Die Filter spiegeln die Direkt-Reads (Einfluss: eigene, lebende, fertiggestellte Gebäude — D-108; Abstand: alle Baustellen und lebenden Platzierungen aller Besitzer). Die Per-Zell-Reads bleiben der Weg des Validators; das Overlay liest nur noch Masken.

Selbes Bild, kein Hitch. Gemessen am Aufwand: ~140.000 statt ~300.000.000 Operationen pro Repaint.

Nachweis

  • dotnet test tools/Nova.SimRunner.Tests -c Release: 726/726 grün
  • Unity EditMode: 606/606 grün — neuer Test FillBuildZoneMasks_MatchesThePerCellReads_OnEveryCell pinnt die Masken über das gesamte Raster gegen die Direktaufrufe (inkl. aktiver Baustelle und feindlichem Gebäude), das Bild kann nicht von der Regel driften
  • Kein Simulationsverhalten geändert, keine Baseline bewegt; ConstructionSystem bekommt genau eine neue öffentliche Lese-Methode (Präzedenz feat(presentation): Baubereich als Overlay sichtbar machen (#91, Paket 21.4) #112: die zwei Overlay-Reads)
  • Spielabnahme: steht aus — Prüf-Build mit diesem Fix liegt vor (integration/s21-review, lokal); Befund war Ruckeln/Verzögerung in der Bauphase

Betroffene Bereiche

ConstructionSystem.cs (+1 öffentliche Lese-Methode + private Box-Füllung), BuildZoneOverlayView.cs (Repaint liest Masken), BuildZoneOverlayQueryTests.cs (+1 Test), CHANGELOG.md (eine Zeile unter [Unreleased] → Behoben).

Play-observation finding: the game hitched and felt 'delayed' exactly while
placing buildings. Root cause: the 21.4 overlay asked IsInsideBuildInfluence
and HasMinimumBuildingSpacing PER TEXEL — every texel rescanned the placement
register, and each entry paid a linear site-register probe for the D-108
finished-only rule. That is several hundred million operations per repaint at
the 4 Hz cadence — a main-thread hitch four times a second in the placement
phase.

FillBuildZoneMasks fills both masks in ONE pass: both predicates are
rectangle-Chebyshev distances between uniform footprints, so the exact answer
set per register entry is a square of candidate origins (influence half-extent
BuildInfluenceRadiusCells + f - 1; spacing half-extent
MinimumBuildingDistanceCells + f - 2). Filters mirror the per-cell reads
(finished own anchors for influence, all sites and living placements for
spacing). The per-cell reads stay the validator path; an EditMode test pins
mask == direct reads over the full grid, including an active site and an
enemy building.

Same picture, no hitch. No simulation behaviour change, no baseline movement.
Verified: dotnet test 726/726; Unity EditMode 606/606 (1 new).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant