From 6fcaf3238689d0bfdf03b5f1d99712ab143ee88d Mon Sep 17 00:00:00 2001 From: opencode Date: Wed, 2 Dec 2026 06:51:58 +0000 Subject: [PATCH] fix: decouple wheel mouse sensitivity, consume mouse while open, fix unavailable-segment highlight + art edge smoothing (issue #31) --- src/extras/weaponwheel.cpp | 86 ++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 36 deletions(-) diff --git a/src/extras/weaponwheel.cpp b/src/extras/weaponwheel.cpp index 5862501c..d7afdc13 100644 --- a/src/extras/weaponwheel.cpp +++ b/src/extras/weaponwheel.cpp @@ -71,7 +71,7 @@ enum // One segment per eWeaponType 0..11; detonator (12) shares segment 11. // See src/weapons/WeaponType.h for the eWeaponType ordering. WHEEL_SEGMENTS = 12, - WHEEL_ARC_STEPS = 4, // quads per segment, only for the procedural ring + WHEEL_ARC_STEPS = 8, // quads per segment; smoother arcs, only for the procedural ring WHEEL_MAX_RADIO = 12 }; @@ -751,11 +751,15 @@ Wheel_UpdateInput(void) bestMag = mag; } - // Mouse: only deltas are available. Accumulate a virtual cursor target at a - // low gain, then lerp the displayed cursor toward it so pointing is smooth - // rather than twitchy (playtest issue #31). - ms_fMouseTargetX += pad->GetMouseX() * WHEEL_MOUSE_SENSITIVITY; - ms_fMouseTargetY += pad->GetMouseY() * WHEEL_MOUSE_SENSITIVITY; + // Mouse: only deltas are available. Read the raw pad field directly: + // NewMouseControllerState.x/y is the un-scaled OS delta. The in-game mouse + // sensitivity (TheCamera::m_fMouseAccelHorzntl/Vertical) is applied later at + // the camera look sites, not here, so WHEEL_MOUSE_SENSITIVITY is the only + // gain in this path and the wheel feels the same at every sensitivity + // setting. Accumulate a virtual cursor target, then lerp the displayed + // cursor toward it so pointing is smooth rather than twitchy. + ms_fMouseTargetX += pad->NewMouseControllerState.x * WHEEL_MOUSE_SENSITIVITY; + ms_fMouseTargetY += pad->NewMouseControllerState.y * WHEEL_MOUSE_SENSITIVITY; if (ms_fMouseTargetX < -WHEEL_CURSOR_CLAMP) ms_fMouseTargetX = -WHEEL_CURSOR_CLAMP; if (ms_fMouseTargetX > WHEEL_CURSOR_CLAMP) ms_fMouseTargetX = WHEEL_CURSOR_CLAMP; if (ms_fMouseTargetY < -WHEEL_CURSOR_CLAMP) ms_fMouseTargetY = -WHEEL_CURSOR_CLAMP; @@ -806,6 +810,19 @@ Wheel_UpdateInput(void) // Process / draw // --------------------------------------------------------------------------- +// The look/freecam code reads CPad::NewMouseControllerState.x/y directly and is +// NOT gated by PLAYERCONTROL_CAMERA, so the weapon wheel must consume the delta +// after using it. Wheel_Process runs from CGame::Process before CWorld::Process +// and TheCamera.Process, and after CPad::UpdatePads committed the delta; the +// debug menu uses the same zeroing trick. Buttons are untouched. +static void +Wheel_ConsumeMouse(void) +{ + CPad *pad = CPad::GetPad(0); + pad->NewMouseControllerState.x = 0.0f; + pad->NewMouseControllerState.y = 0.0f; +} + void Wheel_Process(void) { @@ -821,6 +838,8 @@ Wheel_Process(void) if (Wheel_WeaponTriggerHeld()) { Wheel_Open(false); + // The opening frame's delta must not turn the camera/player too. + Wheel_ConsumeMouse(); } else if (Wheel_RadioTriggerHeld()) { Wheel_Open(true); } @@ -834,17 +853,30 @@ Wheel_Process(void) pad->SetDisablePlayerControls(PLAYERCONTROL_CAMERA); if (!Wheel_AllowedToOpen()) { + bool consumeMouse = !ms_bRadio; Wheel_Close(false); + if (consumeMouse) + Wheel_ConsumeMouse(); return; } bool stillWanted = ms_bRadio ? Wheel_RadioTriggerHeld() : Wheel_WeaponTriggerHeld(); if (!stillWanted) { + // Consume on the closing frame too, so the delta that was read while + // the wheel was up does not produce a one-frame camera jump on release. + bool consumeMouse = !ms_bRadio; Wheel_Close(true); + if (consumeMouse) + Wheel_ConsumeMouse(); return; } Wheel_UpdateInput(); + + // The radio wheel is non-freezing and does not own the mouse; only the + // on-foot weapon wheel consumes the delta. + if (!ms_bRadio) + Wheel_ConsumeMouse(); } static void @@ -861,34 +893,6 @@ Wheel_DrawRingQuad(float a0, float a1, float r0, float r1, const CRGBA &color) color); } -static void -Wheel_DrawRingOutline(int32 segment) -{ - if (ms_nSegments <= 0 || segment < 0 || segment >= ms_nSegments) - return; - - float outer = SCREEN_HEIGHT * WHEEL_OUTER_RADIUS; - float inner = SCREEN_HEIGHT * WHEEL_INNER_RADIUS; - float step = TWOPI / ms_nSegments; - float center = HALFPI - segment * step; - float half = step * 0.5f; - float band = SCREEN_HEIGHT * 0.004f; // ~4px at 1080p - float edge = step * 0.035f; // thin radial border, ~1 degree - CRGBA color(255, 245, 210, 245); - - // Inner/outer rim of the selected sector. - for (int32 k = 0; k < WHEEL_ARC_STEPS; k++) { - float aa = center + half + (-2.0f * half) * (k / (float)WHEEL_ARC_STEPS); - float ab = center + half + (-2.0f * half) * ((k + 1) / (float)WHEEL_ARC_STEPS); - Wheel_DrawRingQuad(aa, ab, outer - band, outer, color); - Wheel_DrawRingQuad(aa, ab, inner, inner + band, color); - } - - // Radial borders. - Wheel_DrawRingQuad(center + half - edge, center + half + edge, inner, outer, color); - Wheel_DrawRingQuad(center - half - edge, center - half + edge, inner, outer, color); -} - static void Wheel_DrawRing(void) { @@ -906,6 +910,12 @@ Wheel_DrawRing(void) if (!ms_bRadio) available = player != nil && Wheel_FirstWeaponInSegment(player, i) >= 0; + // In art mode the selected sector is filled by the smooth wwN overlay. + // Drawing the hard-edged procedural sector underneath it leaves a + // jagged rim peeking past the texture's anti-aliased edge, so skip it. + if (!ms_bRadio && i == highlight && available && ms_apWwArt[i] != nil) + continue; + CRGBA color; if (!available) color = CRGBA(10, 10, 10, 70); @@ -1040,7 +1050,6 @@ Wheel_Draw(void) // Dim the game/HUD underneath, then the shared ring. CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(0, 0, 0, 140)); Wheel_DrawRing(); - Wheel_DrawRingOutline(highlight); // Draw2DPolygon restores depth states to ON; the 2D pass wants them off. RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); @@ -1050,7 +1059,12 @@ Wheel_Draw(void) Wheel_DrawRadio(); } else { // Art highlight for the pointed-at (or currently equipped) segment. - if (highlight >= 0 && highlight < WHEEL_SEGMENTS && ms_apWwArt[highlight] != nil) + // An unavailable segment must not draw the bright wwN wedge at all: + // the wedge is full-white and would make the greyed-out entry look + // selected/white. The dim procedural sector is enough feedback. + bool highlightAvailable = highlight >= 0 && highlight < WHEEL_SEGMENTS + && player != nil && Wheel_FirstWeaponInSegment(player, highlight) >= 0; + if (highlightAvailable && ms_apWwArt[highlight] != nil) Wheel_DrawArt(ms_apWwArt[highlight], ms_aWwOffX[highlight], ms_aWwOffY[highlight], ms_aWwW[highlight], ms_aWwH[highlight], CRGBA(255, 255, 255, 255)); Wheel_DrawWeaponIcons();