Skip to content

Claude/fix obs zoom script b f bh m#96

Open
Sphiment wants to merge 3 commits into
BlankSourceCode:mainfrom
Sphiment:claude/fix-obs-zoom-script-bFBhM
Open

Claude/fix obs zoom script b f bh m#96
Sphiment wants to merge 3 commits into
BlankSourceCode:mainfrom
Sphiment:claude/fix-obs-zoom-script-bFBhM

Conversation

@Sphiment

Copy link
Copy Markdown

No description provided.

Sphiment and others added 2 commits March 2, 2025 08:57
obs_sceneitem_get_info and obs_sceneitem_set_info were renamed to
obs_sceneitem_get_info2 / obs_sceneitem_set_info2 in OBS 29 and
removed in later releases, causing a nil-call crash on script_update.

Add a compatibility shim at startup: if the old names are missing,
alias them from the new _info2 variants. This keeps the script
working on both old and new OBS versions.

Also fix a pre-existing bug in the zoom reset path: it was calling
obs_sceneitem_get_info (read) instead of obs_sceneitem_set_info
(write) when restoring the original transform, so the scene item
was never actually reset after zooming out.

https://claude.ai/code/session_01Rq3ZDgoKcZu6LZzFLsk9F6
Copilot AI review requested due to automatic review settings April 14, 2026 13:12
@Sphiment

Copy link
Copy Markdown
Author

fix in new obs versions

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the OBS “zoom-to-mouse” Lua script to improve compatibility with newer OBS scripting APIs and to better restore state when zooming ends.

Changes:

  • Add an OBS API compatibility shim mapping obs_sceneitem_get/set_info to *_info2 when the older names aren’t available.
  • Fix transform reset logic to call obs_sceneitem_set_info(...) when restoring the original transform info.
  • Reset crop filter settings back to the original crop when a zoom-out animation completes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread obs-zoom-to-mouse.lua
-- When we finished zooming out we remove the timer
if zoom_state == ZoomState.ZoomingOut then
log("Zoomed out")
set_crop_settings(crop_filter_info_orig)

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

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

After calling set_crop_settings(crop_filter_info_orig) when zooming out finishes, the OBS filter state is reset to the original crop, but the in-memory crop_filter_info table is left at its last interpolated value. If zoom_speed overshoots 1 (e.g., 0.6), the last interpolation step may be far from the original crop, causing a visible jump on the next zoom/follow frame when set_crop_settings(crop_filter_info) is called again. Consider also copying crop_filter_info_orig into crop_filter_info (or otherwise re-syncing crop_filter_info with the applied settings) at this point.

Suggested change
set_crop_settings(crop_filter_info_orig)
set_crop_settings(crop_filter_info_orig)
-- Keep the in-memory crop state in sync with the crop we just applied.
for key in pairs(crop_filter_info) do
crop_filter_info[key] = nil
end
for key, value in pairs(crop_filter_info_orig) do
crop_filter_info[key] = value
end

Copilot uses AI. Check for mistakes.
The previous animation used lerp(current_pos, target, ease_in_out(t))
where current_pos changed every frame. Because the "from" point moved
each tick, the ease function never operated on a fixed range and the
motion collapsed to near-linear.

Fix by storing zoom_from_crop at the moment each zoom starts, then
always interpolating lerp(zoom_from_crop, target, eased_t). This gives
a clean, predictable curve over the full duration.

Apply direction-specific cubic easing:
- Zoom in:  ease_in  (t^3) — starts slow, accelerates into the zoom
- Zoom out: ease_out (1-(1-t)^3) — snaps away fast, settles smoothly

Also add standalone ease_in() and ease_out() helpers alongside the
existing ease_in_out() function.

https://claude.ai/code/session_01Rq3ZDgoKcZu6LZzFLsk9F6
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.

3 participants