Skip to content

Add Blender-style infinite mouse drag to Engine#10677

Open
themightypooh wants to merge 1 commit intoFacepunch:masterfrom
themightypooh:feature/infinite-mouse-drag
Open

Add Blender-style infinite mouse drag to Engine#10677
themightypooh wants to merge 1 commit intoFacepunch:masterfrom
themightypooh:feature/infinite-mouse-drag

Conversation

@themightypooh
Copy link
Copy Markdown

Pull Request

Thanks for contributing to s&box ❤️
Please fill out the sections below to help us review your change efficiently.


Summary

Adds a "Blender-style" infinite mouse drag feature to the engine and editor. When a user is holding the left mouse button (dragging a slider, rotating a gizmo, etc.) and their cursor hits the edge of the screen, it smoothly wraps to the opposite side of the monitor.

Motivation & Context

This is a massive Quality of Life (QoL) improvement for the Editor. Currently, when tweaking large numeric values (like object transforms, lighting intensities, or cloth physics), users frequently hit the physical edge of their monitor and have to drop the slider, reposition their mouse, and click again.

This brings s&box's input feel up to parity with industry-standard 3D software like Blender, making value-scrubbing feel completely frictionless.

Implementation Details

The logic is injected into the core Sandbox.Mouse class to ensure it works globally across UI elements.

Opt-out functionality: Added a public InfiniteDrag toggle (defaulted to true) so users or developers can disable it if it conflicts with specific project needs.

Drag Detection: The wrap only triggers if Input.Down("mouse1") is true, preventing the mouse from wildly teleporting during normal navigation.

The Delta Fix: Added an internal _isWarping flag. When the cursor is teleported via Game.InputContext.SetMousePosition, this flag intercepts the Delta property for that specific frame and returns Vector2.Zero. This prevents the engine from reading a massive -1920px jump and violently snapping the camera or UI values.

Screenshots / Videos (if applicable)

mousedrag.mp4

Checklist

  • Code follows existing style and conventions
  • No unnecessary formatting or unrelated changes
  • Public APIs are documented (if applicable)
  • Unit tests added where applicable and all passing (N/A for raw mouse input)
  • I’m okay with this PR being rejected or requested to change 🙂

@joshuascript
Copy link
Copy Markdown

Thank god this was really needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants