From 9c7ace059ab4d920e6fd3ffe84b52493686cb099 Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Fri, 26 Sep 2025 16:40:16 +0200 Subject: [PATCH] Refactor: Add name for curve map slope preset enum Names the formerly anonymous enum as `CurveMapSlopeType`, converts it to `enum class` and adds a specific backing type for the variable. Pull Request: https://projects.blender.org/blender/blender/pulls/146840 --- source/blender/blenkernel/BKE_colortools.hh | 11 ++++++----- source/blender/blenkernel/intern/brush.cc | 2 +- source/blender/blenkernel/intern/colortools.cc | 8 ++++---- source/blender/blenkernel/intern/paint.cc | 2 +- source/blender/blenkernel/intern/scene.cc | 14 ++++++++------ source/blender/blenloader/intern/versioning_270.cc | 6 ++++-- source/blender/blenloader/intern/versioning_280.cc | 4 ++-- .../blenloader/intern/versioning_defaults.cc | 4 ++-- .../templates/interface_template_curve_mapping.cc | 13 +++++++------ source/blender/editors/render/render_internal.cc | 6 ++++-- source/blender/editors/sculpt_paint/paint_utils.cc | 2 +- .../composite/nodes/node_composite_huecorrect.cc | 2 +- .../sequencer/intern/modifiers/MOD_hue_correct.cc | 2 +- source/blender/sequencer/intern/sound.cc | 5 ++++- 14 files changed, 46 insertions(+), 35 deletions(-) diff --git a/source/blender/blenkernel/BKE_colortools.hh b/source/blender/blenkernel/BKE_colortools.hh index 70302e781a9..96bdc2fccd7 100644 --- a/source/blender/blenkernel/BKE_colortools.hh +++ b/source/blender/blenkernel/BKE_colortools.hh @@ -6,6 +6,7 @@ /** \file * \ingroup bke */ +#include struct BlendDataReader; struct BlendWriter; @@ -39,17 +40,17 @@ void BKE_curvemapping_set_black_white(CurveMapping *cumap, const float black[3], const float white[3]); -enum { - CURVEMAP_SLOPE_NEGATIVE = 0, - CURVEMAP_SLOPE_POSITIVE = 1, - CURVEMAP_SLOPE_POS_NEG = 2, +enum class CurveMapSlopeType : int8_t { + Negative = 0, + Positive = 1, + PositiveNegative = 2, }; /** * Reset the view for current curve. */ void BKE_curvemapping_reset_view(CurveMapping *cumap); -void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope); +void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, CurveMapSlopeType slope); /** * Removes with flag set. */ diff --git a/source/blender/blenkernel/intern/brush.cc b/source/blender/blenkernel/intern/brush.cc index e3d4e3ba864..c31ca681698 100644 --- a/source/blender/blenkernel/intern/brush.cc +++ b/source/blender/blenkernel/intern/brush.cc @@ -886,7 +886,7 @@ void BKE_brush_curve_preset(Brush *b, eCurveMappingPreset preset) cumap->preset = preset; cuma = b->curve_distance_falloff->cm; - BKE_curvemap_reset(cuma, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_NEGATIVE); + BKE_curvemap_reset(cuma, &cumap->clipr, cumap->preset, CurveMapSlopeType::Negative); BKE_curvemapping_changed(cumap, false); BKE_brush_tag_unsaved_changes(b); } diff --git a/source/blender/blenkernel/intern/colortools.cc b/source/blender/blenkernel/intern/colortools.cc index 3da73171e45..b56e396bad4 100644 --- a/source/blender/blenkernel/intern/colortools.cc +++ b/source/blender/blenkernel/intern/colortools.cc @@ -273,7 +273,7 @@ CurveMapPoint *BKE_curvemap_insert(CurveMap *cuma, float x, float y) return newcmp; } -void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope) +void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, CurveMapSlopeType slope) { if (cuma->curve) { MEM_freeN(cuma->curve); @@ -322,7 +322,7 @@ void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope cuma->curve[0].y = clipr->ymax; cuma->curve[1].x = clipr->xmax; cuma->curve[1].y = clipr->ymin; - if (slope == CURVEMAP_SLOPE_POS_NEG) { + if (slope == CurveMapSlopeType::PositiveNegative) { cuma->curve[0].flag &= ~CUMA_HANDLE_AUTO_ANIM; cuma->curve[1].flag &= ~CUMA_HANDLE_AUTO_ANIM; cuma->curve[0].flag |= CUMA_HANDLE_VECTOR; @@ -420,7 +420,7 @@ void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope /* mirror curve in x direction to have positive slope * rather than default negative slope */ - if (slope == CURVEMAP_SLOPE_POSITIVE) { + if (slope == CurveMapSlopeType::Positive) { int i, last = cuma->totpoint - 1; CurveMapPoint *newpoints = static_cast(MEM_dupallocN(cuma->curve)); @@ -431,7 +431,7 @@ void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope MEM_freeN(cuma->curve); cuma->curve = newpoints; } - else if (slope == CURVEMAP_SLOPE_POS_NEG) { + else if (slope == CurveMapSlopeType::PositiveNegative) { const int num_points = cuma->totpoint * 2 - 1; CurveMapPoint *new_points = MEM_malloc_arrayN(size_t(num_points), "curve symmetric points"); diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 777aea3a4cc..0928ffa6e26 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -1685,7 +1685,7 @@ void BKE_paint_cavity_curve_preset(Paint *paint, int preset) cumap->preset = preset; cuma = cumap->cm; - BKE_curvemap_reset(cuma, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); + BKE_curvemap_reset(cuma, &cumap->clipr, cumap->preset, CurveMapSlopeType::Positive); BKE_curvemapping_changed(cumap, false); } diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index 27c98113d0c..298e2a97fa1 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -130,7 +130,7 @@ CurveMapping *BKE_sculpt_default_cavity_curve() cumap->flag &= ~CUMA_EXTEND_EXTRAPOLATE; cumap->preset = CURVE_PRESET_LINE; - BKE_curvemap_reset(cumap->cm, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); + BKE_curvemap_reset(cumap->cm, &cumap->clipr, cumap->preset, CurveMapSlopeType::Positive); BKE_curvemapping_changed(cumap, false); BKE_curvemapping_init(cumap); @@ -140,7 +140,7 @@ CurveMapping *BKE_sculpt_default_cavity_curve() CurveMapping *BKE_paint_default_curve() { CurveMapping *cumap = BKE_curvemapping_add(1, 0, 0, 1, 1); - BKE_curvemap_reset(cumap->cm, &cumap->clipr, CURVE_PRESET_LINE, CURVEMAP_SLOPE_POSITIVE); + BKE_curvemap_reset(cumap->cm, &cumap->clipr, CURVE_PRESET_LINE, CurveMapSlopeType::Positive); BKE_curvemapping_init(cumap); return cumap; @@ -165,7 +165,7 @@ static void scene_init_data(ID *id) BKE_curvemap_reset(mblur_shutter_curve->cm, &mblur_shutter_curve->clipr, CURVE_PRESET_MAX, - CURVEMAP_SLOPE_POS_NEG); + CurveMapSlopeType::PositiveNegative); scene->toolsettings = DNA_struct_default_alloc(ToolSettings); @@ -179,8 +179,10 @@ static void scene_init_data(ID *id) scene->toolsettings->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_falloff_curve = scene->toolsettings->gp_sculpt.cur_falloff; BKE_curvemapping_init(gp_falloff_curve); - BKE_curvemap_reset( - gp_falloff_curve->cm, &gp_falloff_curve->clipr, CURVE_PRESET_GAUSS, CURVEMAP_SLOPE_POSITIVE); + BKE_curvemap_reset(gp_falloff_curve->cm, + &gp_falloff_curve->clipr, + CURVE_PRESET_GAUSS, + CurveMapSlopeType::Positive); scene->toolsettings->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_primitive_curve = scene->toolsettings->gp_sculpt.cur_primitive; @@ -188,7 +190,7 @@ static void scene_init_data(ID *id) BKE_curvemap_reset(gp_primitive_curve->cm, &gp_primitive_curve->clipr, CURVE_PRESET_BELL, - CURVEMAP_SLOPE_POSITIVE); + CurveMapSlopeType::Positive); scene->unit.system = USER_UNIT_METRIC; scene->unit.scale_length = 1.0f; diff --git a/source/blender/blenloader/intern/versioning_270.cc b/source/blender/blenloader/intern/versioning_270.cc index 3a17ec3b2c7..d184dff307d 100644 --- a/source/blender/blenloader/intern/versioning_270.cc +++ b/source/blender/blenloader/intern/versioning_270.cc @@ -1007,8 +1007,10 @@ void blo_do_versions_270(FileData *fd, Library * /*lib*/, Main *bmain) CurveMapping *curve_mapping = &scene->r.mblur_shutter_curve; BKE_curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f, HD_AUTO); BKE_curvemapping_init(curve_mapping); - BKE_curvemap_reset( - curve_mapping->cm, &curve_mapping->clipr, CURVE_PRESET_MAX, CURVEMAP_SLOPE_POS_NEG); + BKE_curvemap_reset(curve_mapping->cm, + &curve_mapping->clipr, + CURVE_PRESET_MAX, + CurveMapSlopeType::PositiveNegative); } } } diff --git a/source/blender/blenloader/intern/versioning_280.cc b/source/blender/blenloader/intern/versioning_280.cc index 9db5400f40d..3b943619d87 100644 --- a/source/blender/blenloader/intern/versioning_280.cc +++ b/source/blender/blenloader/intern/versioning_280.cc @@ -3180,7 +3180,7 @@ void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain) BKE_curvemap_reset(gset.cur_falloff->cm, &gset.cur_falloff->clipr, CURVE_PRESET_GAUSS, - CURVEMAP_SLOPE_POSITIVE); + CurveMapSlopeType::Positive); } } } @@ -4554,7 +4554,7 @@ void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain) BKE_curvemap_reset(gset.cur_primitive->cm, &gset.cur_primitive->clipr, CURVE_PRESET_BELL, - CURVEMAP_SLOPE_POSITIVE); + CurveMapSlopeType::Positive); } } } diff --git a/source/blender/blenloader/intern/versioning_defaults.cc b/source/blender/blenloader/intern/versioning_defaults.cc index 3b20664581e..e28db2f9736 100644 --- a/source/blender/blenloader/intern/versioning_defaults.cc +++ b/source/blender/blenloader/intern/versioning_defaults.cc @@ -440,7 +440,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene) BKE_curvemap_reset(gp_falloff_curve->cm, &gp_falloff_curve->clipr, CURVE_PRESET_GAUSS, - CURVEMAP_SLOPE_POSITIVE); + CurveMapSlopeType::Positive); } if (ts->gp_sculpt.cur_primitive == nullptr) { ts->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); @@ -449,7 +449,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene) BKE_curvemap_reset(gp_primitive_curve->cm, &gp_primitive_curve->clipr, CURVE_PRESET_BELL, - CURVEMAP_SLOPE_POSITIVE); + CurveMapSlopeType::Positive); } if (ts->sculpt) { diff --git a/source/blender/editors/interface/templates/interface_template_curve_mapping.cc b/source/blender/editors/interface/templates/interface_template_curve_mapping.cc index 19c1984f973..5b40bdd68e1 100644 --- a/source/blender/editors/interface/templates/interface_template_curve_mapping.cc +++ b/source/blender/editors/interface/templates/interface_template_curve_mapping.cc @@ -190,7 +190,7 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *region, void *cumap } static uiBlock *curvemap_tools_func( - bContext *C, ARegion *region, RNAUpdateCb &cb, bool show_extend, int reset_mode) + bContext *C, ARegion *region, RNAUpdateCb &cb, bool show_extend, CurveMapSlopeType reset_mode) { PointerRNA cumap_ptr = RNA_property_pointer_get(&cb.ptr, cb.prop); CurveMapping *cumap = static_cast(cumap_ptr.data); @@ -292,25 +292,25 @@ static uiBlock *curvemap_tools_func( static uiBlock *curvemap_tools_posslope_func(bContext *C, ARegion *region, void *cb_v) { return curvemap_tools_func( - C, region, *static_cast(cb_v), true, CURVEMAP_SLOPE_POSITIVE); + C, region, *static_cast(cb_v), true, CurveMapSlopeType::Positive); } static uiBlock *curvemap_tools_negslope_func(bContext *C, ARegion *region, void *cb_v) { return curvemap_tools_func( - C, region, *static_cast(cb_v), true, CURVEMAP_SLOPE_NEGATIVE); + C, region, *static_cast(cb_v), true, CurveMapSlopeType::Negative); } static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *region, void *cb_v) { return curvemap_tools_func( - C, region, *static_cast(cb_v), false, CURVEMAP_SLOPE_POSITIVE); + C, region, *static_cast(cb_v), false, CurveMapSlopeType::Positive); } static uiBlock *curvemap_brush_tools_negslope_func(bContext *C, ARegion *region, void *cb_v) { return curvemap_tools_func( - C, region, *static_cast(cb_v), false, CURVEMAP_SLOPE_NEGATIVE); + C, region, *static_cast(cb_v), false, CurveMapSlopeType::Negative); } static void curvemap_buttons_redraw(bContext &C) @@ -755,7 +755,8 @@ static void curvemap_buttons_layout(uiLayout *layout, UI_but_func_set(bt, [cumap, cb](bContext &C) { cumap->preset = CURVE_PRESET_LINE; for (int a = 0; a < CM_TOT; a++) { - BKE_curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); + BKE_curvemap_reset( + cumap->cm + a, &cumap->clipr, cumap->preset, CurveMapSlopeType::Positive); } cumap->black[0] = cumap->black[1] = cumap->black[2] = 0.0f; diff --git a/source/blender/editors/render/render_internal.cc b/source/blender/editors/render/render_internal.cc index fd92e335879..8e4f8765712 100644 --- a/source/blender/editors/render/render_internal.cc +++ b/source/blender/editors/render/render_internal.cc @@ -1308,8 +1308,10 @@ static wmOperatorStatus render_shutter_curve_preset_exec(bContext *C, wmOperator mblur_shutter_curve->flag &= ~CUMA_EXTEND_EXTRAPOLATE; mblur_shutter_curve->preset = preset; - BKE_curvemap_reset( - cm, &mblur_shutter_curve->clipr, mblur_shutter_curve->preset, CURVEMAP_SLOPE_POS_NEG); + BKE_curvemap_reset(cm, + &mblur_shutter_curve->clipr, + mblur_shutter_curve->preset, + CurveMapSlopeType::PositiveNegative); BKE_curvemapping_changed(mblur_shutter_curve, false); return OPERATOR_FINISHED; diff --git a/source/blender/editors/sculpt_paint/paint_utils.cc b/source/blender/editors/sculpt_paint/paint_utils.cc index 439ba3de65d..dd7b5d38264 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.cc +++ b/source/blender/editors/sculpt_paint/paint_utils.cc @@ -239,7 +239,7 @@ static wmOperatorStatus brush_sculpt_curves_falloff_preset_exec(bContext *C, wmO CurveMapping *mapping = brush->curves_sculpt_settings->curve_parameter_falloff; mapping->preset = RNA_enum_get(op->ptr, "shape"); CurveMap *map = mapping->cm; - BKE_curvemap_reset(map, &mapping->clipr, mapping->preset, CURVEMAP_SLOPE_POSITIVE); + BKE_curvemap_reset(map, &mapping->clipr, mapping->preset, CurveMapSlopeType::Positive); BKE_brush_tag_unsaved_changes(brush); return OPERATOR_FINISHED; } diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc b/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc index 7a6f5623e44..ca4d418e53c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc +++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc @@ -42,7 +42,7 @@ static void node_composit_init_huecorrect(bNodeTree * /*ntree*/, bNode *node) for (int c = 0; c < 3; c++) { CurveMap *cuma = &cumapping->cm[c]; - BKE_curvemap_reset(cuma, &cumapping->clipr, cumapping->preset, CURVEMAP_SLOPE_POSITIVE); + BKE_curvemap_reset(cuma, &cumapping->clipr, cumapping->preset, CurveMapSlopeType::Positive); } /* use wrapping for all hue correct nodes */ cumapping->flag |= CUMA_USE_WRAPPING; diff --git a/source/blender/sequencer/intern/modifiers/MOD_hue_correct.cc b/source/blender/sequencer/intern/modifiers/MOD_hue_correct.cc index 177dd0feb08..7091fdf42a1 100644 --- a/source/blender/sequencer/intern/modifiers/MOD_hue_correct.cc +++ b/source/blender/sequencer/intern/modifiers/MOD_hue_correct.cc @@ -35,7 +35,7 @@ static void hue_correct_init_data(StripModifierData *smd) for (c = 0; c < 3; c++) { CurveMap *cuma = &hcmd->curve_mapping.cm[c]; BKE_curvemap_reset( - cuma, &hcmd->curve_mapping.clipr, hcmd->curve_mapping.preset, CURVEMAP_SLOPE_POSITIVE); + cuma, &hcmd->curve_mapping.clipr, hcmd->curve_mapping.preset, CurveMapSlopeType::Positive); } /* use wrapping for all hue correct modifiers */ hcmd->curve_mapping.flag |= CUMA_USE_WRAPPING; diff --git a/source/blender/sequencer/intern/sound.cc b/source/blender/sequencer/intern/sound.cc index 14433eeed98..1cb83fae4ef 100644 --- a/source/blender/sequencer/intern/sound.cc +++ b/source/blender/sequencer/intern/sound.cc @@ -184,7 +184,10 @@ EQCurveMappingData *sound_equalizer_add(SoundEqualizerModifierData *semd, float clipr.ymin = 0.0; clipr.ymax = 0.0; - BKE_curvemap_reset(&eqcmd->curve_mapping.cm[0], &clipr, CURVE_PRESET_CONSTANT_MEDIAN, 0); + BKE_curvemap_reset(&eqcmd->curve_mapping.cm[0], + &clipr, + CURVE_PRESET_CONSTANT_MEDIAN, + CurveMapSlopeType::Negative); BLI_addtail(&semd->graphics, eqcmd);