Fix [#21188] HueCorrection Node, when reseting Curve, it goes to a incline instead of flat/straight
This commit is contained in:
@@ -45,13 +45,6 @@ struct rctf;
|
||||
# define DO_INLINE static inline
|
||||
#endif
|
||||
|
||||
typedef enum CurveMappingPreset {
|
||||
CURVE_PRESET_LINE,
|
||||
CURVE_PRESET_SHARP,
|
||||
CURVE_PRESET_SMOOTH,
|
||||
CURVE_PRESET_MAX
|
||||
} CurveMappingPreset;
|
||||
|
||||
void floatbuf_to_srgb_byte(float *rectf, unsigned char *rectc, int x1, int x2, int y1, int y2, int w);
|
||||
void floatbuf_to_byte(float *rectf, unsigned char *rectc, int x1, int x2, int y1, int y2, int w);
|
||||
|
||||
@@ -62,7 +55,7 @@ void curvemapping_set_black_white(struct CurveMapping *cumap, float *black, f
|
||||
|
||||
void curvemap_remove(struct CurveMap *cuma, int flag);
|
||||
void curvemap_insert(struct CurveMap *cuma, float x, float y);
|
||||
void curvemap_reset(struct CurveMap *cuma, struct rctf *clipr, CurveMappingPreset preset);
|
||||
void curvemap_reset(struct CurveMap *cuma, struct rctf *clipr, int preset);
|
||||
void curvemap_sethandle(struct CurveMap *cuma, int type);
|
||||
|
||||
void curvemapping_changed(struct CurveMapping *cumap, int rem_doubles);
|
||||
|
||||
@@ -237,7 +237,8 @@ void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset)
|
||||
cm = b->curve->cm;
|
||||
cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
|
||||
|
||||
curvemap_reset(cm, &b->curve->clipr, preset);
|
||||
b->curve->preset = preset;
|
||||
curvemap_reset(cm, &b->curve->clipr, b->curve->preset);
|
||||
curvemapping_changed(b->curve, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ void curvemap_insert(CurveMap *cuma, float x, float y)
|
||||
cuma->curve= cmp;
|
||||
}
|
||||
|
||||
void curvemap_reset(CurveMap *cuma, rctf *clipr, CurveMappingPreset preset)
|
||||
void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset)
|
||||
{
|
||||
if(cuma->curve)
|
||||
MEM_freeN(cuma->curve);
|
||||
@@ -249,6 +249,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, CurveMappingPreset preset)
|
||||
case CURVE_PRESET_SHARP: cuma->totpoint= 3; break;
|
||||
case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break;
|
||||
case CURVE_PRESET_MAX: cuma->totpoint= 2; break;
|
||||
case CURVE_PRESET_MID9: cuma->totpoint= 9;
|
||||
}
|
||||
|
||||
cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points");
|
||||
@@ -286,6 +287,15 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, CurveMappingPreset preset)
|
||||
cuma->curve[1].x= 1;
|
||||
cuma->curve[1].y= 1;
|
||||
break;
|
||||
case CURVE_PRESET_MID9:
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < cuma->totpoint; i++)
|
||||
{
|
||||
cuma->curve[i].x= i / ((float)cuma->totpoint-1);
|
||||
cuma->curve[i].y= 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(cuma->table) {
|
||||
|
||||
@@ -10647,6 +10647,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
|
||||
/* put 2.50 compatibility code here until next subversion bump */
|
||||
{
|
||||
Brush *brush;
|
||||
|
||||
for (brush= main->brush.first; brush; brush= brush->id.next) {
|
||||
if (brush->curve) brush->curve->preset = CURVE_PRESET_SMOOTH;
|
||||
}
|
||||
}
|
||||
|
||||
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
|
||||
|
||||
@@ -1707,7 +1707,7 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
|
||||
|
||||
switch(event) {
|
||||
case 0: /* reset */
|
||||
curvemap_reset(cuma, &cumap->clipr, CURVE_PRESET_LINE);
|
||||
curvemap_reset(cuma, &cumap->clipr, cumap->preset);
|
||||
curvemapping_changed(cumap, 0);
|
||||
break;
|
||||
case 1:
|
||||
@@ -1729,10 +1729,6 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
|
||||
cuma->flag |= CUMA_EXTEND_EXTRAPOLATE;
|
||||
curvemapping_changed(cumap, 0);
|
||||
break;
|
||||
case 6: /* reset smooth */
|
||||
curvemap_reset(cuma, &cumap->clipr, CURVE_PRESET_SMOOTH);
|
||||
curvemapping_changed(cumap, 0);
|
||||
break;
|
||||
}
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
}
|
||||
@@ -1770,7 +1766,7 @@ static uiBlock *curvemap_brush_tools_func(bContext *C, struct ARegion *ar, void
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
uiTextBoundsBlock(block, 50);
|
||||
@@ -1789,8 +1785,9 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
|
||||
CurveMapping *cumap = cumap_v;
|
||||
int a;
|
||||
|
||||
cumap->preset = CURVE_PRESET_LINE;
|
||||
for(a=0; a<CM_TOT; a++)
|
||||
curvemap_reset(cumap->cm+a, &cumap->clipr, CURVE_PRESET_LINE);
|
||||
curvemap_reset(cumap->cm+a, &cumap->clipr, cumap->preset);
|
||||
|
||||
cumap->black[0]=cumap->black[1]=cumap->black[2]= 0.0f;
|
||||
cumap->white[0]=cumap->white[1]=cumap->white[2]= 1.0f;
|
||||
|
||||
@@ -64,6 +64,7 @@ typedef struct CurveMap {
|
||||
|
||||
typedef struct CurveMapping {
|
||||
int flag, cur; /* cur; for buttons, to show active curve */
|
||||
int preset, pad;
|
||||
|
||||
rctf curr, clipr; /* current rect, clip rect (is default rect too) */
|
||||
|
||||
@@ -80,6 +81,15 @@ typedef struct CurveMapping {
|
||||
#define CUMA_DRAW_CFRA 4
|
||||
#define CUMA_DRAW_SAMPLE 8
|
||||
|
||||
/* cumapping->preset */
|
||||
typedef enum CurveMappingPreset {
|
||||
CURVE_PRESET_LINE,
|
||||
CURVE_PRESET_SHARP,
|
||||
CURVE_PRESET_SMOOTH,
|
||||
CURVE_PRESET_MAX,
|
||||
CURVE_PRESET_MID9
|
||||
} CurveMappingPreset;
|
||||
|
||||
typedef struct Histogram {
|
||||
int channels;
|
||||
int x_resolution;
|
||||
|
||||
@@ -137,28 +137,13 @@ static void node_composit_exec_huecorrect(void *data, bNode *node, bNodeStack **
|
||||
static void node_composit_init_huecorrect(bNode* node)
|
||||
{
|
||||
CurveMapping *cumapping = node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
||||
int c, i;
|
||||
int c;
|
||||
|
||||
cumapping->preset = CURVE_PRESET_MID9;
|
||||
|
||||
for (c=0; c<3; c++) {
|
||||
CurveMap *cuma = &cumapping->cm[c];
|
||||
|
||||
/* set default horizontal curve */
|
||||
if(cuma->curve)
|
||||
MEM_freeN(cuma->curve);
|
||||
|
||||
cuma->totpoint= 9;
|
||||
cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points");
|
||||
|
||||
for (i=0; i < cuma->totpoint; i++)
|
||||
{
|
||||
cuma->curve[i].x= i / ((float)cuma->totpoint-1);
|
||||
cuma->curve[i].y= 0.5;
|
||||
}
|
||||
|
||||
if(cuma->table) {
|
||||
MEM_freeN(cuma->table);
|
||||
cuma->table= NULL;
|
||||
}
|
||||
curvemap_reset(cuma, &cumapping->clipr, cumapping->preset);
|
||||
}
|
||||
|
||||
/* default to showing Saturation */
|
||||
|
||||
Reference in New Issue
Block a user