feat(client): Add SelectionCircle option drawing a ring under selected objects - #3220
feat(client): Add SelectionCircle option drawing a ring under selected objects#3220triatomic wants to merge 2 commits into
Conversation
…d objects Options.ini: SelectionCircle = Yes draws a green ring on the ground under every selected object, so the current selection reads at a glance. The ring is a projected decal through the shadow system rather than screen space lines, so it wraps the terrain and the model genuinely occludes it. It lives in its own decal slot, so selecting a horde unit does not evict its horde ring, and it is released alongside the shadow and terrain decal when the render object is torn down - left behind it would dangle in the projected shadow manager and crash the next renderShadows. Sized from the bounding circle, scaled per kind - a building fills its circle, a soldier barely occupies the middle of one. Expects a PlainRingSelection.tga in the mod's assets; the art is tinted green at runtime, so a plain white ring works. The drawing lives in the shared W3D model draw code with a default no-op in both titles' draw module interface; the option currently drives it from Zero Hour's Drawable only. A Generals replica can follow after review.
PR Summary by QodoAdd opt-in projected selection circles for Zero Hour
AI Description
Diagram
High-Level Assessment
Files changed (10)
|
|
| Filename | Overview |
|---|---|
| Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp | Adds selection-decal creation and lifecycle handling, but model replacement can re-enable the decal for an effectively hidden drawable. |
| Core/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h | Adds independent selection-decal ownership and remembered requested state used during render-object replacement. |
| GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp | Connects selection and geometry changes to decal updates and derives decal size from drawable geometry. |
| Core/GameEngine/Source/Common/OptionPreferences.cpp | Adds opt-in parsing for SelectionCircle with disabled behavior when the option is absent. |
| GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp | Initializes the feature off and imports the client preference during global-data parsing. |
Prompt To Fix All With AI
### Issue 1
Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp:3147-3150
**Hidden ring becomes visible**
When a selected, effectively hidden drawable replaces its model, this block recreates the selection decal with rendering enabled, while the subsequent hidden-state restoration disables only the render object and normal shadow. The green ring therefore renders beneath the hidden drawable and reveals its location.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (2): Last reviewed commit: "fix(client): Keep the selection ring thr..." | Re-trigger Greptile
Code Review by Qodo
1.
|
…geometry changes Addresses the review findings: - setTerrainDecal no longer drops the ring: a horde or chem suit decal update while the unit is selected left it ringless. - The wanted state and radius are remembered in the draw module, and the ring is recreated after a render object rebuild - a damage state or upgrade swaps the model while the object stays selected, and the ring used to vanish until reselection. - Hidden and fully shrouded transitions now disable the ring's render like the shadow and terrain decal, so it cannot expose a unit the client should not display. - reactToGeometryChange resizes the ring along with the geometry its radius is derived from.
| // TheSuperHackers @fix The selection ring was bound to the render object that was just | ||
| // torn down; the object is still selected, so put the ring back on the new one. | ||
| if (m_selectionDecalWanted) | ||
| setSelectionDecal(TRUE, m_selectionDecalRadius); |
There was a problem hiding this comment.
When a selected, effectively hidden drawable replaces its model, this block recreates the selection decal with rendering enabled, while the subsequent hidden-state restoration disables only the render object and normal shadow. The green ring therefore renders beneath the hidden drawable and reveals its location.
Knowledge Base Used: Game client runtime
Prompt To Fix With AI
This is a comment left during a code review.
Path: Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp
Line: 3147-3150
Comment:
**Hidden ring becomes visible**
When a selected, effectively hidden drawable replaces its model, this block recreates the selection decal with rendering enabled, while the subsequent hidden-state restoration disables only the render object and normal shadow. The green ring therefore renders beneath the hidden drawable and reveals its location.
**Knowledge Base Used:** [Game client runtime](https://app.greptile.com/thesuperhackers/-/custom-context/knowledge-base/thesuperhackers/generalsgamecode/-/docs/game-client-runtime.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Adds an opt-in client option drawing a green ring on the ground under every selected object, so the current selection reads at a glance. Defaults off; retail behavior unless set in Options.ini.
SelectionCircle (
= Yes) — the ring is a projected decal through the shadow system rather than screen-space lines, so it wraps the terrain and the model genuinely occludes it. It lives in its own decal slot (selecting a horde unit does not evict its horde ring) and is released alongside the shadow and terrain decal when the render object is torn down — left behind it would dangle in the projected shadow manager and crash the nextrenderShadows. Sized from the bounding circle, scaled per kind: a building fills its circle, a soldier barely occupies the middle of one.Asset dependency, up front: the decal expects a
PlainRingSelection.tgain the game's assets — the engine appends the extension and tints the art green at runtime, so a plain white or greyscale ring works. This repo ships no such texture; the Contra mod provides its own. With the option on but no texture present, no ring renders. Happy to contribute the texture through whatever channel fits your asset pipeline, or the name can be pointed at an existing decal.The drawing lives in the shared W3D model draw code with a default no-op in both titles' draw-module interface; the option currently drives it from Zero Hour's Drawable only. A Generals replica can follow after review.
This option ships in the Contra mod's engine fork and has been played there; this PR is the port onto current main, collapsing the fork's five ring commits into their final state with the teardown fix folded in. Code was written with LLM assistance and human-reviewed, adapted and playtested by the author.
Prepared for Squash and Merge.