BlankSourceCode / obs-zoom-to-mouse

An OBS lua script to zoom a display-capture source to focus on the mouse
286 stars 27 forks source link

Search into nested scenes #5

Closed BlankSourceCode closed 10 months ago

BlankSourceCode commented 10 months ago

This PR updates the refresh_sceneitem() function so that it will search for the matching source_name inside nested scenes.

Issue: Previously if you had a scene nested inside another scene then the script would be unable to find the matching sceneitem. This would prevent any zooming because without the sceneitem we cannot update the crop/pad filter.

Cause: The problem was due to assuming that the source_name would be available in the current scene via the obs_scene_sceneitem_from_source() call. Apparently this isn't the case if you have nested a scene inside the current scene.

Fix: The fix is to use obs_scene_find_source() to find the matching source in the specified scene. We start with the current scene, and if the source isn't found, we enumerate the scene items to look for nested scenes. If we find any, we then search into those scenes too. We use BFS as the source is most likely to be at the top level of the scene.

Also fixes an issue with sub-pixel coordinates by using math.floor()

 Fixes #4