attack overlay#3996
Conversation
WalkthroughThis PR migrates attacking troop cluster labels from DOM-based rendering to WebGL. A new ChangesAttack Troop Labels Migration to WebGL
Sequence Diagram(s)sequenceDiagram
participant RAF as RequestAnimationFrame
participant Controller as AttackingTroopsController
participant Worker as myPlayer
participant WebGL as WebGLGameView
participant Pass as WorldTextPass
Controller->>Controller: tick() every 200ms
Controller->>Worker: attackClusteredPositions()
Worker-->>Controller: ClusteredCell[] response
Controller->>Controller: reconcileSlots() interpolate
Note over Controller: Smooth animation via Slot
RAF->>Controller: pushLabels() every frame
Controller->>WebGL: setAttackTroopLabels(AttackTroopLabel[])
WebGL->>Pass: setAttackTroopLabels()
Note over Pass: Generate GPU instances<br/>with zoom-scaled size
Pass-->>RAF: Render to screen
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly Related PRs
Suggested Labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/client/render/gl/passes/WorldTextPass.ts`:
- Around line 47-54: Move the hardcoded attack-label tuning values
(ATTACK_LABEL_SCREEN_SCALE, ATTACK_LABEL_OUTLINE_WIDTH and the other constants
used in WorldTextPass methods) into RenderSettings and read them from the
existing RenderSettings instance instead of using literals in WorldTextPass; add
corresponding keys and sane defaults to render-settings.json and the
RenderSettings type/interface, then replace uses of ATTACK_LABEL_SCREEN_SCALE,
ATTACK_LABEL_OUTLINE_WIDTH and the other pass constants inside the WorldTextPass
class (and any methods referencing them) with lookups like
renderSettings.attackLabelScreenScale / attackLabelOutlineWidth so the pass uses
configuration-driven values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a4d82013-e76d-4597-a84d-383c95f34691
⛔ Files ignored due to path filters (1)
src/client/render/gl/shaders/world-text/world-text.frag.glslis excluded by!**/*.glsl
📒 Files selected for processing (7)
src/client/controllers/AttackingTroopsController.tssrc/client/hud/GameRenderer.tssrc/client/hud/layers/AttackingTroopsOverlay.tssrc/client/render/gl/GameView.tssrc/client/render/gl/Renderer.tssrc/client/render/gl/passes/WorldTextPass.tstests/client/graphics/layers/AttackingTroopsOverlay.test.ts
💤 Files with no reviewable changes (1)
- src/client/hud/layers/AttackingTroopsOverlay.ts
| /** | ||
| * Screen-relative em scale for attack troop labels. Pre-divided by the current | ||
| * zoom each frame so the on-screen label size stays constant regardless of | ||
| * how far the camera is zoomed. | ||
| */ | ||
| const ATTACK_LABEL_SCREEN_SCALE = 34.0; | ||
| const ATTACK_LABEL_OUTLINE_WIDTH = 1.2; | ||
|
|
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
Move attack-label tuning values into RenderSettings.
Line 52, Line 53, Line 445, and Line 469 hardcode pass tuning values inside the pass. These should come from render-settings.json via RenderSettings.
♻️ Proposed refactor
-const ATTACK_LABEL_SCREEN_SCALE = 34.0;
-const ATTACK_LABEL_OUTLINE_WIDTH = 1.2;- const attackScale = ATTACK_LABEL_SCREEN_SCALE / Math.max(zoom, 0.0001);
+ const attackScale =
+ this.settings.worldText.attackLabelScreenScale / Math.max(zoom, 0.0001);
...
- this.instanceData[off + 9] = ATTACK_LABEL_OUTLINE_WIDTH;
+ this.instanceData[off + 9] =
+ this.settings.worldText.attackLabelOutlineWidth;As per coding guidelines, "All per-pass tuning constants must be defined in render-settings.json and accessed through RenderSettings, not hardcoded in pass classes."
Also applies to: 445-469
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/client/render/gl/passes/WorldTextPass.ts` around lines 47 - 54, Move the
hardcoded attack-label tuning values (ATTACK_LABEL_SCREEN_SCALE,
ATTACK_LABEL_OUTLINE_WIDTH and the other constants used in WorldTextPass
methods) into RenderSettings and read them from the existing RenderSettings
instance instead of using literals in WorldTextPass; add corresponding keys and
sane defaults to render-settings.json and the RenderSettings type/interface,
then replace uses of ATTACK_LABEL_SCREEN_SCALE, ATTACK_LABEL_OUTLINE_WIDTH and
the other pass constants inside the WorldTextPass class (and any methods
referencing them) with lookups like renderSettings.attackLabelScreenScale /
attackLabelOutlineWidth so the pass uses configuration-driven values.
If this PR fixes an issue, link it below. If not, delete these two lines.
Resolves #(issue number)
Description:
Describe the PR.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
DISCORD_USERNAME