bugfix(mouse): Fix bad drag tolerances with high scroll speed factors, alternative#2826
bugfix(mouse): Fix bad drag tolerances with high scroll speed factors, alternative#2826xezon wants to merge 2 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Core/Libraries/Include/Lib/BaseType.h | Adds arithmetic operators (+, -, +=, -=), set(), add(), sub() methods and lengthSqr() to Coord2D, ICoord2D, Coord3D, ICoord3D — foundations needed by the click-detection refactor. |
| Core/GameEngine/Source/GameClient/Input/Mouse.cpp | isClick() signature extended with two Coord3D camera positions; drag check now uses circular lengthSqr comparison and adds a 3D camera-movement tolerance. Inline comment not updated to reflect the new 3rd condition. |
| Core/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp | Dead camera-position subtraction code replaced with proper camera-position tracking; right-click handler now passes both down/up camera positions to isClick(). Clean refactor. |
| Core/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp | Captures camera position on right-mouse-down and right-mouse-up, passes both to isClick(). Member variables renamed for clarity. Clean refactor. |
| Core/GameEngine/Include/GameClient/Mouse.h | isClick() signature updated to take const references instead of pointers, adding two Coord3D camera parameters. Clean API improvement. |
| Core/GameEngine/Include/GameClient/CommandXlat.h | Four right-mouse member fields renamed for clarity; two new Coord3D camera position fields added. |
| Core/GameEngine/Include/GameClient/SelectionXlat.h | Member fields renamed and m_deselectDownCameraPosition replaced by m_rightMouseDownCameraPos; m_lastClick renamed to m_rightMouseDownTimeMs for naming consistency. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Right Mouse Down] --> B[Store mouseDownAnchor\nStore mouseDownTimeMs\nStore cameraDownPos]
C[Right Mouse Up] --> D[Store mouseUpAnchor\nStore mouseUpTimeMs\nStore cameraUpPos]
D --> E[Call isClick]
E --> F{timeDelta > dragToleranceMS?}
F -- YES --> G[Return FALSE\nnot a click]
F -- NO --> H{mouseAnchorDelta.lengthSqr\n> sqr dragTolerance?}
H -- YES --> G
H -- NO --> I{cameraPosDelta.lengthSqr\n> sqr dragTolerance3D?}
I -- YES --> G
I -- NO --> J[Return TRUE\nit is a click]
J --> K[Execute right-click action]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[Right Mouse Down] --> B[Store mouseDownAnchor\nStore mouseDownTimeMs\nStore cameraDownPos]
C[Right Mouse Up] --> D[Store mouseUpAnchor\nStore mouseUpTimeMs\nStore cameraUpPos]
D --> E[Call isClick]
E --> F{timeDelta > dragToleranceMS?}
F -- YES --> G[Return FALSE\nnot a click]
F -- NO --> H{mouseAnchorDelta.lengthSqr\n> sqr dragTolerance?}
H -- YES --> G
H -- NO --> I{cameraPosDelta.lengthSqr\n> sqr dragTolerance3D?}
I -- YES --> G
I -- NO --> J[Return TRUE\nit is a click]
J --> K[Execute right-click action]
Reviews (2): Last reviewed commit: "bugfix(mouse): Fix bad drag tolerances w..." | Re-trigger Greptile
920fa79 to
a412fc5
Compare
|
Would be nice if GO could do some A/B testing. |
Merge with Rebase
This change fixes the bad drag tolerances with high scroll speed factors, which was introduced by #1501 and is especially pronounced in this Project because players are encouraged to set way higher scroll factors after #1026 when higher frame rates no longer increase the camera movement.
This is an alternative implementation to #2823 using the 3D camera tolerance.
TODO