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/GameEngine/Source/GameClient/Input/Mouse.cpp | Core fix: isClick() extended with camera-position parameters and circle-based 2D tolerance. The square-to-circle change subtly tightens diagonal click acceptance. |
| Core/Libraries/Include/Lib/BaseType.h | Adds operator overloads and set() methods to Coord2D, ICoord2D, Coord3D, ICoord3D. ICoord types use correctly-typed (Int/Int/Int) parameters. ICoord2D::lengthSqr() returns Real from an integer computation — harmless for screen coordinates but mildly surprising. |
| Core/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp | Renames deselect-anchor fields to use consistent naming convention and threads camera positions into isClick(). Correctly captures camera at both mouse-down and mouse-up events. |
| Core/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp | Records TheTacticalView->getPosition() at right-mouse-down and right-mouse-up events and threads both camera positions into both isClick() call sites. |
| Core/GameEngine/Include/GameClient/CommandXlat.h | Adds Coord3D members for camera position tracking at right-mouse-down and right-mouse-up; renames existing anchor and time fields. |
Sequence Diagram
%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant User
participant SelectionXlat/CommandXlat
participant TheTacticalView
participant Mouse
User->>SelectionXlat/CommandXlat: MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN
SelectionXlat/CommandXlat->>TheTacticalView: getPosition()
TheTacticalView-->>SelectionXlat/CommandXlat: cameraPos0
Note over SelectionXlat/CommandXlat: Store mouseAnchor0, timeMs0, cameraPos0
User->>SelectionXlat/CommandXlat: MSG_RAW_MOUSE_RIGHT_BUTTON_UP
SelectionXlat/CommandXlat->>TheTacticalView: getPosition()
TheTacticalView-->>SelectionXlat/CommandXlat: cameraPos1
SelectionXlat/CommandXlat->>Mouse: isClick(mouseAnchor0, mouseAnchor1, cameraPos0, cameraPos1, timeMs0, timeMs1)
Note over Mouse: timeDelta > dragToleranceMS?
Note over Mouse: mouseAnchorDelta.lengthSqr() > sqr(dragTolerance)?
Note over Mouse: cameraPosDelta.lengthSqr() > sqr(dragTolerance3D)?
Mouse-->>SelectionXlat/CommandXlat: TRUE (click) / FALSE (drag)
alt is click
SelectionXlat/CommandXlat->>User: Deselect / Cancel build placement
else is drag
SelectionXlat/CommandXlat->>User: Ignore (treat as drag)
end
%%{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"}}}%%
sequenceDiagram
participant User
participant SelectionXlat/CommandXlat
participant TheTacticalView
participant Mouse
User->>SelectionXlat/CommandXlat: MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN
SelectionXlat/CommandXlat->>TheTacticalView: getPosition()
TheTacticalView-->>SelectionXlat/CommandXlat: cameraPos0
Note over SelectionXlat/CommandXlat: Store mouseAnchor0, timeMs0, cameraPos0
User->>SelectionXlat/CommandXlat: MSG_RAW_MOUSE_RIGHT_BUTTON_UP
SelectionXlat/CommandXlat->>TheTacticalView: getPosition()
TheTacticalView-->>SelectionXlat/CommandXlat: cameraPos1
SelectionXlat/CommandXlat->>Mouse: isClick(mouseAnchor0, mouseAnchor1, cameraPos0, cameraPos1, timeMs0, timeMs1)
Note over Mouse: timeDelta > dragToleranceMS?
Note over Mouse: mouseAnchorDelta.lengthSqr() > sqr(dragTolerance)?
Note over Mouse: cameraPosDelta.lengthSqr() > sqr(dragTolerance3D)?
Mouse-->>SelectionXlat/CommandXlat: TRUE (click) / FALSE (drag)
alt is click
SelectionXlat/CommandXlat->>User: Deselect / Cancel build placement
else is drag
SelectionXlat/CommandXlat->>User: Ignore (treat as drag)
end
Reviews (3): 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. |
a412fc5 to
8399669
Compare
…oord3D, ICoord2D, ICoord3D (#2826)
8399669 to
cc8df7b
Compare
|
LoGicA
|
|
SR_MaD^
|
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