diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-21 12:47:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-21 12:47:36 +0400 |
commit | 320473120958cf4c978eb12ca37e07dec8ed0e71 (patch) | |
tree | 41daf0a050336f073741793b932c04313c9372de /source/blender/blenkernel | |
parent | 988df245519352ab80d8ad488660a0a2f7a963d3 (diff) |
code cleanup: don't use magic numbers for curve flag & use bool args for curvemapping_changed()
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_colortools.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/colortools.c | 34 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 2 |
4 files changed, 13 insertions, 27 deletions
diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index 90358ba9609..249cb32a082 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -59,7 +59,7 @@ void curvemapping_set_black_white(struct CurveMapping *cumap, con #define CURVEMAP_SLOPE_NEGATIVE 0 #define CURVEMAP_SLOPE_POSITIVE 1 void curvemap_reset(struct CurveMap *cuma, struct rctf *clipr, int preset, int slope); -void curvemap_remove(struct CurveMap *cuma, int flag); +void curvemap_remove(struct CurveMap *cuma, const short flag); void curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp); struct CurveMapPoint *curvemap_insert(struct CurveMap *cuma, float x, float y); void curvemap_sethandle(struct CurveMap *cuma, int type); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 468861242d0..fc4df9594f3 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -421,7 +421,7 @@ void BKE_brush_curve_preset(Brush *b, /*CurveMappingPreset*/ int preset) b->curve->preset = preset; curvemap_reset(cm, &b->curve->clipr, b->curve->preset, CURVEMAP_SLOPE_NEGATIVE); - curvemapping_changed(b->curve, 0); + curvemapping_changed(b->curve, FALSE); } int BKE_brush_texture_set_nr(Brush *brush, int nr) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 606fd83b1a5..4bc22d77ec9 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -202,7 +202,7 @@ void curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point) } /* removes with flag set */ -void curvemap_remove(CurveMap *cuma, int flag) +void curvemap_remove(CurveMap *cuma, const short flag) { CurveMapPoint *cmp = MEM_mallocN((cuma->totpoint) * sizeof(CurveMapPoint), "curve points"); int a, b, removed = 0; @@ -711,12 +711,12 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) dy = cmp[a].y - cmp[a + 1].y; if (sqrtf(dx * dx + dy * dy) < thresh) { if (a == 0) { - cmp[a + 1].flag |= 2; + cmp[a + 1].flag |= CUMA_VECTOR; if (cmp[a + 1].flag & CUMA_SELECT) cmp[a].flag |= CUMA_SELECT; } else { - cmp[a].flag |= 2; + cmp[a].flag |= CUMA_VECTOR; if (cmp[a].flag & CUMA_SELECT) cmp[a + 1].flag |= CUMA_SELECT; } @@ -736,7 +736,7 @@ void curvemapping_changed_all(CurveMapping *cumap) for (a = 0; a < CM_TOT; a++) { if (cumap->cm[a].curve) { cumap->cur = a; - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); } } @@ -807,31 +807,17 @@ void curvemapping_evaluateRGBF(CurveMapping *cumap, float vecout[3], const float void curvemapping_evaluate_premulRGBF_ex(CurveMapping *cumap, float vecout[3], const float vecin[3], const float black[3], const float bwmul[3]) { - float fac; - - fac = (vecin[0] - black[0]) * bwmul[0]; - vecout[0] = curvemap_evaluateF(cumap->cm, fac); - - fac = (vecin[1] - black[1]) * bwmul[1]; - vecout[1] = curvemap_evaluateF(cumap->cm + 1, fac); - - fac = (vecin[2] - black[2]) * bwmul[2]; - vecout[2] = curvemap_evaluateF(cumap->cm + 2, fac); + vecout[0] = curvemap_evaluateF(&cumap->cm[0], (vecin[0] - black[0]) * bwmul[0]); + vecout[1] = curvemap_evaluateF(&cumap->cm[1], (vecin[1] - black[1]) * bwmul[1]); + vecout[2] = curvemap_evaluateF(&cumap->cm[2], (vecin[2] - black[2]) * bwmul[2]); } /* RGB with black/white points and premult. tables are checked */ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3]) { - float fac; - - fac = (vecin[0] - cumap->black[0]) * cumap->bwmul[0]; - vecout[0] = curvemap_evaluateF(cumap->cm, fac); - - fac = (vecin[1] - cumap->black[1]) * cumap->bwmul[1]; - vecout[1] = curvemap_evaluateF(cumap->cm + 1, fac); - - fac = (vecin[2] - cumap->black[2]) * cumap->bwmul[2]; - vecout[2] = curvemap_evaluateF(cumap->cm + 2, fac); + vecout[0] = curvemap_evaluateF(&cumap->cm[0], (vecin[0] - cumap->black[0]) * cumap->bwmul[0]); + vecout[1] = curvemap_evaluateF(&cumap->cm[1], (vecin[1] - cumap->black[1]) * cumap->bwmul[1]); + vecout[2] = curvemap_evaluateF(&cumap->cm[2], (vecin[2] - cumap->black[2]) * cumap->bwmul[2]); } /* same as above, byte version */ diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 5bad69c2e8d..2f54fe6cebd 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -1292,7 +1292,7 @@ PointDensity *BKE_add_pointdensity(void) pd->falloff_curve->preset = CURVE_PRESET_LINE; pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; curvemap_reset(pd->falloff_curve->cm, &pd->falloff_curve->clipr, pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE); - curvemapping_changed(pd->falloff_curve, 0); + curvemapping_changed(pd->falloff_curve, FALSE); return pd; } |