Repository navigation
Conversation
Replace the sample table + Newton-Raphson + bisection search (in float) with the closed-form solver of bezier-easing 3.2, computed in double: exact, and no backward jump on steep curves such as cubic-bezier(1, 0, 0, 1). Values outside [0, 1] now saturate to start / end instead of going through the old search, which returned arbitrary values there.
6 of 27 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, this is @gre, I'm the author of bezier-easing, which is also embedded in this project (
TimingFunctions.CubicBezierinunity/core/Runtime/Styling/Animations/TimingFunctions.cs). The library was recently improved with better performance and more reliability, and I wanted to backport the benefits here.This brings its 3.2 solver (closed-form, no sample table) to CSS
cubic-bezier(...)transitions and animations:cubic-bezier(1, 0, 0, 1)at 0.4996 returned 0.348 instead of 0.431, so the transition went backwards for a frame.Math.Cbrt, which is available from Unity 2021.3 (.NET Standard 2.1).I checked it in a standalone .NET harness (with
Mathf.Lerpstubbed) against the reference values and the old code. I couldn't run the Unity test suite locally.Note
Medium Risk
Changes core animation easing math used by all transitions and preset eases; behavior improves for edge cases but any numerical differences could affect motion timing across the UI.
Overview
Replaces the iterative cubic-bezier solver in
TimingFunctions.CubicBezierwith the closed-form bezier-easing 3.2 approach, so CSScubic-bezier(...)and built-in eases no longer use a per-curve sample table or Newton/bisection iteration.Evaluation now solves for parameter
tin double viasolveTForX(Cardano / trigonometric cases withMath.Cbrt), then mapsy(t)into the animation range. Inputs outside (0, 1) are handled by saturating throughLinearinstead of returning values from the old search. The linear shortcut when control points match the diagonal is unchanged.This targets correctness on steep curves (e.g.
cubic-bezier(1, 0, 0, 1)no longer briefly runs backward) and lower per-timing-function cost (no 11-sample allocation perCreatecall).Reviewed by Cursor Bugbot for commit 74dec38. Bugbot is set up for automated code reviews on this repo. Configure here.