diff options
author | Campbell Barton <campbell@blender.org> | 2022-09-25 11:30:50 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-09-25 11:31:10 +0300 |
commit | c7b247a118e302a3afc6473797e53b6af28b69e2 (patch) | |
tree | d11149a165bfd8f3b3b791f24547499f041b133b /source/blender/editors | |
parent | 891949cbb47143420f4324cb60efc05ef5d70b39 (diff) |
Cleanup: replace static_casts with functional casts for numeric types
Diffstat (limited to 'source/blender/editors')
6 files changed, 19 insertions, 22 deletions
diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index f52e11276e9..eb3e40f9f76 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -714,13 +714,13 @@ static void CURVES_OT_snap_curves_to_surface(wmOperatorType *ot) ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER; static const EnumPropertyItem attach_mode_items[] = { - {static_cast<int>(AttachMode::Nearest), + {int(AttachMode::Nearest), "NEAREST", 0, "Nearest", "Find the closest point on the surface for the root point of every curve and move the root " "there"}, - {static_cast<int>(AttachMode::Deform), + {int(AttachMode::Deform), "DEFORM", 0, "Deform", @@ -732,7 +732,7 @@ static void CURVES_OT_snap_curves_to_surface(wmOperatorType *ot) RNA_def_enum(ot->srna, "attach_mode", attach_mode_items, - static_cast<int>(AttachMode::Nearest), + int(AttachMode::Nearest), "Attach Mode", "How to find the point on the surface to attach to"); } diff --git a/source/blender/editors/geometry/geometry_attributes.cc b/source/blender/editors/geometry/geometry_attributes.cc index 14f2f8c6af5..673fb947c57 100644 --- a/source/blender/editors/geometry/geometry_attributes.cc +++ b/source/blender/editors/geometry/geometry_attributes.cc @@ -612,8 +612,7 @@ void GEOMETRY_OT_attribute_convert(wmOperatorType *ot) PropertyRNA *prop; - RNA_def_enum( - ot->srna, "mode", mode_items, static_cast<int>(ConvertAttributeMode::Generic), "Mode", ""); + RNA_def_enum(ot->srna, "mode", mode_items, int(ConvertAttributeMode::Generic), "Mode", ""); prop = RNA_def_enum(ot->srna, "domain", diff --git a/source/blender/editors/interface/interface_context_path.cc b/source/blender/editors/interface/interface_context_path.cc index 3b91ca79c00..e8f552e26a3 100644 --- a/source/blender/editors/interface/interface_context_path.cc +++ b/source/blender/editors/interface/interface_context_path.cc @@ -41,7 +41,7 @@ void context_path_add_generic(Vector<ContextPathItem> &path, static_cast<BIFIconID>(RNA_struct_ui_icon(rna_ptr.type)) : icon_override; - path.append({name, static_cast<int>(icon)}); + path.append({name, int(icon)}); } /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/interface/interface_region_tooltip.cc b/source/blender/editors/interface/interface_region_tooltip.cc index 2c4d13e0717..b1621f1a040 100644 --- a/source/blender/editors/interface/interface_region_tooltip.cc +++ b/source/blender/editors/interface/interface_region_tooltip.cc @@ -109,8 +109,7 @@ struct uiTooltipData { #define UI_TIP_LC_MAX 6 -BLI_STATIC_ASSERT(UI_TIP_LC_MAX == static_cast<int>(uiTooltipFormat::ColorID::Alert) + 1, - "invalid lc-max"); +BLI_STATIC_ASSERT(UI_TIP_LC_MAX == int(uiTooltipFormat::ColorID::Alert) + 1, "invalid lc-max"); BLI_STATIC_ASSERT(sizeof(uiTooltipFormat) <= sizeof(int), "oversize"); static uiTooltipField *text_field_add_only(uiTooltipData *data) @@ -168,12 +167,12 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region uchar drawcol[4] = {0, 0, 0, 255}; /* to store color in while drawing (alpha is always 255) */ /* The color from the theme. */ - float *main_color = tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Main)]; - float *value_color = tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Value)]; - float *active_color = tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Active)]; - float *normal_color = tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Normal)]; - float *python_color = tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Python)]; - float *alert_color = tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Alert)]; + float *main_color = tip_colors[int(uiTooltipFormat::ColorID::Main)]; + float *value_color = tip_colors[int(uiTooltipFormat::ColorID::Value)]; + float *active_color = tip_colors[int(uiTooltipFormat::ColorID::Active)]; + float *normal_color = tip_colors[int(uiTooltipFormat::ColorID::Normal)]; + float *python_color = tip_colors[int(uiTooltipFormat::ColorID::Python)]; + float *alert_color = tip_colors[int(uiTooltipFormat::ColorID::Alert)]; float background_color[3]; @@ -224,7 +223,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region fs_params.word_wrap = true; /* Draw header and active data (is done here to be able to change color). */ - rgb_float_to_uchar(drawcol, tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Main)]); + rgb_float_to_uchar(drawcol, tip_colors[int(uiTooltipFormat::ColorID::Main)]); UI_fontstyle_set(&data->fstyle); UI_fontstyle_draw(&data->fstyle, &bbox, field->text, UI_TIP_STR_MAX, drawcol, &fs_params); @@ -235,8 +234,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region bbox.xmin += xofs; bbox.ymax -= yofs; - rgb_float_to_uchar(drawcol, - tip_colors[static_cast<int>(uiTooltipFormat::ColorID::Active)]); + rgb_float_to_uchar(drawcol, tip_colors[int(uiTooltipFormat::ColorID::Active)]); UI_fontstyle_draw( &data->fstyle, &bbox, field->text_suffix, UI_TIP_STR_MAX, drawcol, &fs_params); @@ -255,7 +253,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region UI_fontstyle_set(&fstyle_mono); /* XXX: needed because we don't have mono in 'U.uifonts'. */ BLF_size(fstyle_mono.uifont_id, fstyle_mono.points * U.dpi_fac); - rgb_float_to_uchar(drawcol, tip_colors[static_cast<int>(field->format.color_id)]); + rgb_float_to_uchar(drawcol, tip_colors[int(field->format.color_id)]); UI_fontstyle_draw(&fstyle_mono, &bbox, field->text, UI_TIP_STR_MAX, drawcol, &fs_params); } else { @@ -265,7 +263,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region fs_params.word_wrap = true; /* Draw remaining data. */ - rgb_float_to_uchar(drawcol, tip_colors[static_cast<int>(field->format.color_id)]); + rgb_float_to_uchar(drawcol, tip_colors[int(field->format.color_id)]); UI_fontstyle_set(&data->fstyle); UI_fontstyle_draw(&data->fstyle, &bbox, field->text, UI_TIP_STR_MAX, drawcol, &fs_params); } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index 423fd70e1e2..ee12afeb506 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -344,7 +344,7 @@ static int select_random_exec(bContext *C, wmOperator *op) VectorSet<Curves *> unique_curves = curves::get_unique_editable_curves(*C); const int seed = RNA_int_get(op->ptr, "seed"); - RandomNumberGenerator rng{static_cast<uint32_t>(seed)}; + RandomNumberGenerator rng{uint32_t(seed)}; const bool partial = RNA_boolean_get(op->ptr, "partial"); const bool constant_per_curve = RNA_boolean_get(op->ptr, "constant_per_curve"); diff --git a/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc b/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc index dc45a7ec51c..d3c61508726 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc +++ b/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc @@ -70,11 +70,11 @@ static void update_curve_mask(CurveMaskCache *curve_mask_cache, for (int y = 0; y < diameter; y++) { for (int x = 0; x < diameter; x++, m++) { float pixel_xy[2]; - pixel_xy[0] = static_cast<float>(x) + aa_offset; + pixel_xy[0] = float(x) + aa_offset; float total_weight = 0; for (int i = 0; i < aa_samples; i++) { - pixel_xy[1] = static_cast<float>(y) + aa_offset; + pixel_xy[1] = float(y) + aa_offset; for (int j = 0; j < aa_samples; j++) { const float len = len_v2v2(pixel_xy, bpos); const int sample_index = min_ii((len / clamped_radius) * CurveSamplesBaseLen, |