Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-10-25 14:14:19 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-10-28 00:43:06 +0300
commit868717e312930f6c1eb75cf6a099de0dab035bdb (patch)
treec477f73afc94109075b4ea02cfa35dbc587c6eec /source/blender/blenkernel/intern/colortools.c
parent4f6b01ce1fa5d618b37c49170fc23fe78ff4b471 (diff)
Support symmetrical curve mapping presets
Previously curve mapping was always setting to only a single slope which then was symmetrizied by a tools (such as brush or compositing). With this change it's possible to set curve to symmetrical slopes as a part of preset.
Diffstat (limited to 'source/blender/blenkernel/intern/colortools.c')
-rw-r--r--source/blender/blenkernel/intern/colortools.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 92259235588..c6e3d1919e1 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -368,7 +368,24 @@ void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope)
MEM_freeN(cuma->curve);
cuma->curve = newpoints;
}
-
+ else if (slope == CURVEMAP_SLOPE_RAISE_FALL) {
+ const int num_points = cuma->totpoint * 2 - 1;
+ CurveMapPoint *new_points = MEM_mallocN(num_points * sizeof(CurveMapPoint),
+ "curve symmetric points");
+ int i;
+ for (i = 0; i < cuma->totpoint; i++) {
+ const int src_last_point = cuma->totpoint - i - 1;
+ const int dst_last_point = num_points - i - 1;
+ new_points[i] = cuma->curve[src_last_point];
+ new_points[i].x = (1.0f - cuma->curve[src_last_point].x) * 0.5f;
+ new_points[dst_last_point] = new_points[i];
+ new_points[dst_last_point].x = 0.5f + cuma->curve[src_last_point].x * 0.5f;
+ }
+ cuma->totpoint = num_points;
+ MEM_freeN(cuma->curve);
+ cuma->curve = new_points;
+ }
+
if (cuma->table) {
MEM_freeN(cuma->table);
cuma->table = NULL;