Skip to content

Conversation

@Warchamp7
Copy link
Member

@Warchamp7 Warchamp7 commented Jun 19, 2025

Description

This PR makes a number of changes to source snapping in the preview:

  • Sources no longer snap to hidden sources
  • Edges can snap to any same axis edge of other sources
    • (The top edge of a source can snap to the top edge of a source)
  • Sources snap along the entire axis
    • (Sources don't have to be touching to snap)
  • Visual indicators for snapping
  • Replaces calculation macro with a static method

Additionally

  • Hidden sources can no longer be hovered or clicked in the preview to select them
obs64_wuvM7eemGG.mp4

Motivation and Context

I want to improve source snapping behaviour and visual feedback

How Has This Been Tested?

Moved a bunch of sources around. Toggles relevant snapping settings on and off to ensure behaviour matched settings.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Tweak (non-breaking change to improve existing functionality)
  • Code cleanup (non-breaking change which makes code smaller or more readable)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@Warchamp7 Warchamp7 added the UI/UX Anything to do with changes or additions to UI/UX elements. label Jun 19, 2025
@Warchamp7 Warchamp7 added this to the OBS Studio 32.0 milestone Jun 19, 2025
@WizardCM WizardCM added the Enhancement Improvement to existing functionality label Jun 21, 2025
@Warchamp7 Warchamp7 requested a review from PatTheMav September 23, 2025 21:47
Copy link
Member

@PatTheMav PatTheMav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally this PR is fine, but it seems very brute force and not particularly efficient to me and falls victim to "featuritis", just piling on little features one by one, each doing its own thing in isolation with no regard to other (similar) features and the architecture behind it.

Preview control drawing should be a single process, by a single responsible entity in code that knows about all of its "features" and thus set up a single render pass to draw all the pieces it knows should be visible for any given frame.

if (centerSnap && fabsf(screenSize.y - (br.y - tl.y)) > clampDist &&
fabsf(screenSize.y / 2.0f - centerY) < clampDist)
clampOffset.y = screenSize.y / 2.0f - centerY;
if (screenSnap) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it wouldn't be easier to just calculate the vector between the source's centre point and the screen edges and check which vector has the shortest distance (that eliminates 2 edges at once) and then check the x and y parts of the vector (that give you the actual edge).

Using dot product there's probably also a way to do this with common vector math even.

Given that the current code does this the "brute force" way and the PR just extends that, it's probably fine, but I wish this were more elegant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made this at least a little bit more elegant.

@Warchamp7 Warchamp7 moved this to Ready For Review in OBS Studio 32.1 PR Considerations Oct 29, 2025
@RytoEX RytoEX moved this from Ready For Review to Requires Changes in OBS Studio 32.1 PR Considerations Dec 18, 2025
@Warchamp7 Warchamp7 moved this from Requires Changes to Ready For Review in OBS Studio 32.1 PR Considerations Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Improvement to existing functionality UI/UX Anything to do with changes or additions to UI/UX elements.

Projects

Status: Ready For Review

Development

Successfully merging this pull request may close these issues.

3 participants