fix: dark wheel backdrop to remove feathered-edge light fringe (issue #31)
linux / build (push) Successful in 11m25s

This commit is contained in:
2026-12-02 10:19:00 +00:00
parent e804cd281d
commit 81f85de060
+48 -1
View File
@@ -72,6 +72,7 @@ enum
// See src/weapons/WeaponType.h for the eWeaponType ordering.
WHEEL_SEGMENTS = 12,
WHEEL_ARC_STEPS = 8, // quads per segment; smoother arcs, only for the procedural ring
WHEEL_BACKDROP_SEGMENTS = 48,
WHEEL_MAX_RADIO = 12
};
@@ -104,6 +105,8 @@ enum
#define WHEEL_CURSOR_THICK 0.0018f // marker thickness, fraction of screen height
#define WHEEL_RING_FEATHER 0.003f // alpha-feather band on the procedural ring edges
#define WHEEL_RING_ANGULAR_FEATHER 0.10f // angular edge fade, fraction of one sector's angle
#define WHEEL_BACKDROP_MARGIN 0.012f // dark disc extends this far past WHEEL_OUTER_RADIUS
#define WHEEL_BACKDROP_FEATHER 0.010f // soft outer edge of the dark disc
#define WHEEL_ART_WW_PATH "weapon_wheel/ww%d.png"
#define WHEEL_ART_ICON_PATH "weapon_wheel/icon%d.png"
@@ -1087,6 +1090,49 @@ Wheel_DrawRing(void)
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
}
// A near-black disc behind the ring. The sectors and their feathers are
// semi-transparent; without it, a fading sector reveals the bright game scene
// and reads as a light fringe. The disc extends past the ring's outer feather
// and covers the centre, so every feather edge fades into dark.
static void
Wheel_DrawBackdrop(void)
{
float cx = SCREEN_WIDTH * 0.5f;
float cy = SCREEN_HEIGHT * 0.5f;
float outer = SCREEN_HEIGHT * WHEEL_OUTER_RADIUS;
float discR = outer + SCREEN_HEIGHT * WHEEL_BACKDROP_MARGIN;
float fadeR = discR + SCREEN_HEIGHT * WHEEL_BACKDROP_FEATHER;
CRGBA color(8, 8, 8, 235);
// Solid disc as a triangle fan: centre plus each pair of rim points.
for (int32 i = 0; i < WHEEL_BACKDROP_SEGMENTS; i++) {
float a0 = TWOPI * i / WHEEL_BACKDROP_SEGMENTS;
float a1 = TWOPI * (i + 1) / WHEEL_BACKDROP_SEGMENTS;
float p0x = cx + discR * Cos(a0), p0y = cy - discR * Sin(a0);
float p1x = cx + discR * Cos(a1), p1y = cy - discR * Sin(a1);
// Fan A-B-C-D with A=centre, B=p0, C=p1, D=centre (degenerate).
CSprite2d::Draw2DPolygon(cx, cy, p1x, p1y, cx, cy, p0x, p0y, color);
}
// Soft rim so the dark hub does not end in a hard circle.
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil);
RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEGOURAUD);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
for (int32 i = 0; i < WHEEL_BACKDROP_SEGMENTS; i++) {
float a0 = TWOPI * i / WHEEL_BACKDROP_SEGMENTS;
float a1 = TWOPI * (i + 1) / WHEEL_BACKDROP_SEGMENTS;
Wheel_DrawRingQuadFade(a0, a1, discR, fadeR, color);
}
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
}
static void
Wheel_DrawCentredText(float x, float y, wchar *text, float scaleX, float scaleY, const CRGBA &color)
{
@@ -1230,8 +1276,9 @@ Wheel_Draw(void)
// top of the HUD instead of under the queued text.
CFont::DrawFonts();
// Dim the game/HUD underneath, then the shared ring.
// Dim the game/HUD underneath, then the dark hub and the shared ring.
CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(0, 0, 0, 140));
Wheel_DrawBackdrop();
Wheel_DrawRing();
// Draw2DPolygon restores depth states to ON; the 2D pass wants them off.