Fix: Potential divide by 0 using GRAPH_OT_ease
In case there is only 1 key on the FCurve, the operator can run into a situation where it divides by 0. It now skips the curve in that case Reviewed by: Sybren A. Stüvel Differential Revision: https://developer.blender.org/D16982 Ref: D16982
This commit is contained in:
Submodule release/datafiles/locale updated: 7084c4ecd9...4f6dbb6989
Submodule release/scripts/addons updated: a9d4443c24...bf49eeaa14
Submodule release/scripts/addons_contrib updated: bdcfdd47ec...0f72f6c85c
@@ -388,6 +388,12 @@ void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor
|
||||
const float key_x_range = right_key.vec[1][0] - left_x;
|
||||
const float key_y_range = right_key.vec[1][1] - left_y;
|
||||
|
||||
/* Happens if there is only 1 key on the FCurve. Needs to be skipped because it
|
||||
* would be a divide by 0. */
|
||||
if (IS_EQF(key_x_range, 0.0f)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* In order to have a curve that favors the right key, the curve needs to be mirrored in x and y.
|
||||
* Having an exponent that is a fraction of 1 would produce a similar but inferior result. */
|
||||
const bool inverted = factor > 0.5;
|
||||
|
||||
Submodule source/tools updated: e1744b9bd8...3582f5326d
Reference in New Issue
Block a user