Commit: 868717e312930f6c1eb75cf6a099de0dab035bdb
Author: Sergey Sharybin
Date:   Sun Oct 25 16:14:19 2015 +0500
Branches: master
https://developer.blender.org/rB868717e312930f6c1eb75cf6a099de0dab035bdb

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.

===================================================================

M       source/blender/blenkernel/BKE_colortools.h
M       source/blender/blenkernel/intern/colortools.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_colortools.h 
b/source/blender/blenkernel/BKE_colortools.h
index 74a327c..b88972b 100644
--- a/source/blender/blenkernel/BKE_colortools.h
+++ b/source/blender/blenkernel/BKE_colortools.h
@@ -51,8 +51,12 @@ struct CurveMapping *curvemapping_copy(struct CurveMapping 
*cumap);
 void                curvemapping_set_black_white_ex(const float black[3], 
const float white[3], float r_bwmul[3]);
 void                curvemapping_set_black_white(struct CurveMapping *cumap, 
const float black[3], const float white[3]);
 
-#define CURVEMAP_SLOPE_NEGATIVE 0
-#define CURVEMAP_SLOPE_POSITIVE 1
+enum {
+       CURVEMAP_SLOPE_NEGATIVE   = 0,
+       CURVEMAP_SLOPE_POSITIVE   = 1,
+       CURVEMAP_SLOPE_RAISE_FALL = 2,
+};
+
 void                    curvemap_reset(struct CurveMap *cuma, const struct 
rctf *clipr, int preset, int slope);
 void                    curvemap_remove(struct CurveMap *cuma, const short 
flag);
 bool                    curvemap_remove_point(struct CurveMap *cuma, struct 
CurveMapPoint *cmp);
diff --git a/source/blender/blenkernel/intern/colortools.c 
b/source/blender/blenkernel/intern/colortools.c
index 9225923..c6e3d19 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;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to