From 5e6c3e720d8ce61e405401c85622e28c3ffa8df4 Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Tue, 7 Oct 2025 19:47:42 +0200 Subject: [PATCH] BKE: CurveMap: Update more curve presets Similar to 9b5f23c7a3d5ebeed042bcd2824099820fef46fc This commit updates the remaining three non-trivial preset curve types: * CURVE_PRESET_ROUND - approximating `sqrtf(2x - x^2)` * CURVE_PRESET_ROOT - approximating `sqrtf(x)` * CURVE_PRESET_SHARP - approximating x^2 Like in the above commit, this change only affects the defined presets, but does not change any existing curves in any files. Related to #145208 Pull Request: https://projects.blender.org/blender/blender/pulls/147012 --- .../blender/blenkernel/intern/colortools.cc | 58 +++++++++++++------ 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/source/blender/blenkernel/intern/colortools.cc b/source/blender/blenkernel/intern/colortools.cc index 6228379f74e..b6785b5f791 100644 --- a/source/blender/blenkernel/intern/colortools.cc +++ b/source/blender/blenkernel/intern/colortools.cc @@ -285,7 +285,7 @@ void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, CurveMapS cuma->totpoint = 2; break; case CURVE_PRESET_SHARP: - cuma->totpoint = 4; + cuma->totpoint = 5; break; case CURVE_PRESET_SMOOTH: cuma->totpoint = 8; @@ -297,10 +297,10 @@ void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, CurveMapS cuma->totpoint = 8; break; case CURVE_PRESET_ROUND: - cuma->totpoint = 4; + cuma->totpoint = 6; break; case CURVE_PRESET_ROOT: - cuma->totpoint = 4; + cuma->totpoint = 6; break; case CURVE_PRESET_GAUSS: cuma->totpoint = 7; @@ -339,11 +339,19 @@ void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, CurveMapS cuma->curve[0].x = 0; cuma->curve[0].y = 1; cuma->curve[1].x = 0.25; - cuma->curve[1].y = 0.50; - cuma->curve[2].x = 0.75; - cuma->curve[2].y = 0.04; - cuma->curve[3].x = 1; - cuma->curve[3].y = 0; + cuma->curve[1].y = 0.5625; + cuma->curve[2].x = 0.50; + cuma->curve[2].y = 0.25; + cuma->curve[3].x = 0.75; + cuma->curve[3].y = 0.0625; + cuma->curve[4].x = 1; + cuma->curve[4].y = 0; + if (slope == CurveMapSlopeType::PositiveNegative) { + cuma->curve[0].flag &= ~CUMA_HANDLE_AUTO_ANIM; + cuma->curve[0].flag |= CUMA_HANDLE_VECTOR; + cuma->curve[4].flag &= ~CUMA_HANDLE_AUTO_ANIM; + cuma->curve[4].flag |= CUMA_HANDLE_VECTOR; + } break; case CURVE_PRESET_SMOOTH: cuma->curve[0].x = 0; @@ -380,21 +388,35 @@ void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, CurveMapS cuma->curve[0].x = 0; cuma->curve[0].y = 1; cuma->curve[1].x = 0.5; - cuma->curve[1].y = 0.90; - cuma->curve[2].x = 0.86; - cuma->curve[2].y = 0.5; - cuma->curve[3].x = 1; - cuma->curve[3].y = 0; + cuma->curve[1].y = 0.866; + cuma->curve[2].x = 0.6765; + cuma->curve[2].y = 0.7364; + cuma->curve[3].x = 0.8582; + cuma->curve[3].y = 0.5133; + cuma->curve[4].x = 0.967; + cuma->curve[4].y = 0.2547; + cuma->curve[5].x = 1; + cuma->curve[5].y = 0; break; case CURVE_PRESET_ROOT: cuma->curve[0].x = 0; cuma->curve[0].y = 1; cuma->curve[1].x = 0.25; - cuma->curve[1].y = 0.95; - cuma->curve[2].x = 0.75; - cuma->curve[2].y = 0.44; - cuma->curve[3].x = 1; - cuma->curve[3].y = 0; + cuma->curve[1].y = 0.866; + cuma->curve[2].x = 0.5; + cuma->curve[2].y = 0.707; + cuma->curve[3].x = 0.75; + cuma->curve[3].y = 0.5; + cuma->curve[4].x = 0.9375; + cuma->curve[4].y = 0.25; + cuma->curve[5].x = 1; + cuma->curve[5].y = 0; + if (slope == CurveMapSlopeType::PositiveNegative) { + cuma->curve[0].flag &= ~CUMA_HANDLE_AUTO_ANIM; + cuma->curve[0].flag |= CUMA_HANDLE_VECTOR; + cuma->curve[5].flag &= ~CUMA_HANDLE_AUTO_ANIM; + cuma->curve[5].flag |= CUMA_HANDLE_VECTOR; + } break; case CURVE_PRESET_GAUSS: cuma->curve[0].x = 0;