Cleanup: function style C++ casts, use printing & ELEM macros
This commit is contained in:
@@ -963,7 +963,7 @@ bool BLI_path_frame(char *path, size_t path_maxncpy, int frame, int digits)
|
||||
if (path_frame_chars_find_range(path, &ch_sta, &ch_end)) {
|
||||
char frame_str[FILENAME_FRAME_CHARS_MAX + 1]; /* One for null. */
|
||||
const int ch_span = MIN2(ch_end - ch_sta, FILENAME_FRAME_CHARS_MAX);
|
||||
BLI_snprintf(frame_str, sizeof(frame_str), "%.*d", ch_span, frame);
|
||||
SNPRINTF(frame_str, "%.*d", ch_span, frame);
|
||||
BLI_str_replace_range(path, path_maxncpy, ch_sta, ch_end, frame_str);
|
||||
return true;
|
||||
}
|
||||
@@ -983,7 +983,7 @@ bool BLI_path_frame_range(char *path, size_t path_maxncpy, int sta, int end, int
|
||||
if (path_frame_chars_find_range(path, &ch_sta, &ch_end)) {
|
||||
char frame_str[(FILENAME_FRAME_CHARS_MAX * 2) + 1 + 1]; /* One for null, one for the '-' */
|
||||
const int ch_span = MIN2(ch_end - ch_sta, FILENAME_FRAME_CHARS_MAX);
|
||||
BLI_snprintf(frame_str, sizeof(frame_str), "%.*d-%.*d", ch_span, sta, ch_span, end);
|
||||
SNPRINTF(frame_str, "%.*d-%.*d", ch_span, sta, ch_span, end);
|
||||
BLI_str_replace_range(path, path_maxncpy, ch_sta, ch_end, frame_str);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ TEST(string, StrCopyUTF8_ASCII)
|
||||
const char src[] = {__VA_ARGS__, 0}; \
|
||||
char dst[sizeof(src)]; \
|
||||
memset(dst, 0xff, sizeof(dst)); \
|
||||
BLI_strncpy_utf8(dst, src, sizeof(dst)); \
|
||||
STRNCPY_UTF8(dst, src); \
|
||||
EXPECT_EQ(strlen(dst), sizeof(dst) - 1); \
|
||||
EXPECT_STREQ(dst, src); \
|
||||
}
|
||||
@@ -70,7 +70,7 @@ TEST(string, StrCopyUTF8_TruncateEncoding)
|
||||
EXPECT_EQ(BLI_str_utf8_size(src), byte_size); \
|
||||
char dst[sizeof(src)]; \
|
||||
memset(dst, 0xff, sizeof(dst)); \
|
||||
BLI_strncpy_utf8(dst, src, sizeof(dst)); \
|
||||
STRNCPY_UTF8(dst, src); \
|
||||
EXPECT_EQ(strlen(dst), sizeof(dst) - 1); \
|
||||
EXPECT_STREQ(dst, src); \
|
||||
BLI_strncpy_utf8(dst, src, sizeof(dst) - 1); \
|
||||
@@ -97,13 +97,13 @@ TEST(string, StrCopyUTF8_TerminateEncodingEarly)
|
||||
EXPECT_EQ(BLI_str_utf8_size(src), byte_size); \
|
||||
char dst[sizeof(src)]; \
|
||||
memset(dst, 0xff, sizeof(dst)); \
|
||||
BLI_strncpy_utf8(dst, src, sizeof(dst)); \
|
||||
STRNCPY_UTF8(dst, src); \
|
||||
EXPECT_EQ(strlen(dst), sizeof(dst) - 1); \
|
||||
EXPECT_STREQ(dst, src); \
|
||||
for (int i = sizeof(dst) - 1; i > 1; i--) { \
|
||||
src[i] = '\0'; \
|
||||
memset(dst, 0xff, sizeof(dst)); \
|
||||
const int dst_copied = BLI_strncpy_utf8_rlen(dst, src, sizeof(dst)); \
|
||||
const int dst_copied = STRNCPY_UTF8_RLEN(dst, src); \
|
||||
EXPECT_STREQ(dst, src); \
|
||||
EXPECT_EQ(strlen(dst), i); \
|
||||
EXPECT_EQ(dst_copied, i); \
|
||||
|
||||
@@ -808,8 +808,8 @@ static bool gpencil_weightpaint_brush_init(bContext *C, wmOperator *op)
|
||||
gso->fn_kdtree = NULL;
|
||||
gso->fn_used = 0;
|
||||
gso->fn_size = 0;
|
||||
gso->use_find_nearest = ((gso->brush->gpencil_weight_tool == GPWEIGHT_TOOL_BLUR) ||
|
||||
(gso->brush->gpencil_weight_tool == GPWEIGHT_TOOL_SMEAR));
|
||||
gso->use_find_nearest = ELEM(
|
||||
gso->brush->gpencil_weight_tool, GPWEIGHT_TOOL_BLUR, GPWEIGHT_TOOL_SMEAR);
|
||||
|
||||
gso->gpd = ED_gpencil_data_get_active(C);
|
||||
gso->scene = scene;
|
||||
|
||||
@@ -3732,9 +3732,9 @@ static void ui_do_but_textedit(
|
||||
if (event->val == KM_DBL_CLICK && had_selection == false) {
|
||||
int selsta, selend;
|
||||
BLI_str_cursor_step_bounds_utf8(data->str, strlen(data->str), but->pos, &selsta, &selend);
|
||||
but->pos = (short)selend;
|
||||
but->selsta = (short)selsta;
|
||||
but->selend = (short)selend;
|
||||
but->pos = short(selend);
|
||||
but->selsta = short(selsta);
|
||||
but->selend = short(selend);
|
||||
retval = WM_UI_HANDLER_BREAK;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ static void bias_tangent_normal_pixels(
|
||||
BLI_assert(channels >= 3);
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
float *pixels = rect + ((size_t)stride) * y * channels;
|
||||
float *pixels = rect + size_t(stride) * y * channels;
|
||||
for (int x = 0; x < width; x++, pixels += channels) {
|
||||
if (fabsf(pixels[0] - 0.5f) < 1.0f / 255.0f) {
|
||||
pixels[0] = 0.5f + 1e-5f;
|
||||
|
||||
@@ -262,7 +262,7 @@ static void brush_painter_mask_imbuf_update(BrushPainter *painter,
|
||||
|
||||
if (!use_texture_old) {
|
||||
brush_imbuf_tex_co(&tex_mapping, x, y, texco);
|
||||
res = (ushort)(65535.0f * BKE_brush_sample_masktex(scene, brush, texco, thread, pool));
|
||||
res = ushort(65535.0f * BKE_brush_sample_masktex(scene, brush, texco, thread, pool));
|
||||
}
|
||||
|
||||
/* read from old texture buffer */
|
||||
@@ -1715,7 +1715,7 @@ static void paint_2d_fill_add_pixel_byte(const int x_px,
|
||||
return;
|
||||
}
|
||||
|
||||
coordinate = ((size_t)y_px) * ibuf->x + x_px;
|
||||
coordinate = size_t(y_px) * ibuf->x + x_px;
|
||||
|
||||
if (!BLI_BITMAP_TEST(touched, coordinate)) {
|
||||
float color_f[4];
|
||||
@@ -1744,7 +1744,7 @@ static void paint_2d_fill_add_pixel_float(const int x_px,
|
||||
return;
|
||||
}
|
||||
|
||||
coordinate = ((size_t)y_px) * ibuf->x + x_px;
|
||||
coordinate = size_t(y_px) * ibuf->x + x_px;
|
||||
|
||||
if (!BLI_BITMAP_TEST(touched, coordinate)) {
|
||||
if (len_squared_v4v4(ibuf->float_buffer.data + 4 * coordinate, color) <= threshold_sq) {
|
||||
@@ -1839,8 +1839,8 @@ void paint_2d_bucket_fill(const bContext *C,
|
||||
if (do_float) {
|
||||
for (x_px = 0; x_px < ibuf->x; x_px++) {
|
||||
for (y_px = 0; y_px < ibuf->y; y_px++) {
|
||||
blend_color_mix_float(ibuf->float_buffer.data + 4 * (((size_t)y_px) * ibuf->x + x_px),
|
||||
ibuf->float_buffer.data + 4 * (((size_t)y_px) * ibuf->x + x_px),
|
||||
blend_color_mix_float(ibuf->float_buffer.data + 4 * (size_t(y_px) * ibuf->x + x_px),
|
||||
ibuf->float_buffer.data + 4 * (size_t(y_px) * ibuf->x + x_px),
|
||||
color_f);
|
||||
}
|
||||
}
|
||||
@@ -1848,8 +1848,8 @@ void paint_2d_bucket_fill(const bContext *C,
|
||||
else {
|
||||
for (x_px = 0; x_px < ibuf->x; x_px++) {
|
||||
for (y_px = 0; y_px < ibuf->y; y_px++) {
|
||||
blend_color_mix_byte(ibuf->byte_buffer.data + 4 * (((size_t)y_px) * ibuf->x + x_px),
|
||||
ibuf->byte_buffer.data + 4 * (((size_t)y_px) * ibuf->x + x_px),
|
||||
blend_color_mix_byte(ibuf->byte_buffer.data + 4 * (size_t(y_px) * ibuf->x + x_px),
|
||||
ibuf->byte_buffer.data + 4 * (size_t(y_px) * ibuf->x + x_px),
|
||||
(uchar *)&color_b);
|
||||
}
|
||||
}
|
||||
@@ -1880,9 +1880,9 @@ void paint_2d_bucket_fill(const bContext *C,
|
||||
ED_imapaint_dirty_region(ima, ibuf, iuser, 0, 0, ibuf->x, ibuf->y, false);
|
||||
|
||||
stack = BLI_stack_new(sizeof(size_t), __func__);
|
||||
touched = BLI_BITMAP_NEW(((size_t)ibuf->x) * ibuf->y, "bucket_fill_bitmap");
|
||||
touched = BLI_BITMAP_NEW(size_t(ibuf->x) * ibuf->y, "bucket_fill_bitmap");
|
||||
|
||||
coordinate = (((size_t)y_px) * ibuf->x + x_px);
|
||||
coordinate = (size_t(y_px) * ibuf->x + x_px);
|
||||
|
||||
if (do_float) {
|
||||
copy_v4_v4(pixel_color, ibuf->float_buffer.data + 4 * coordinate);
|
||||
@@ -2074,8 +2074,8 @@ void paint_2d_gradient_fill(
|
||||
/* convert to premultiplied */
|
||||
mul_v3_fl(color_f, color_f[3]);
|
||||
color_f[3] *= brush_alpha;
|
||||
IMB_blend_color_float(ibuf->float_buffer.data + 4 * (((size_t)y_px) * ibuf->x + x_px),
|
||||
ibuf->float_buffer.data + 4 * (((size_t)y_px) * ibuf->x + x_px),
|
||||
IMB_blend_color_float(ibuf->float_buffer.data + 4 * (size_t(y_px) * ibuf->x + x_px),
|
||||
ibuf->float_buffer.data + 4 * (size_t(y_px) * ibuf->x + x_px),
|
||||
color_f,
|
||||
IMB_BlendMode(br->blend));
|
||||
}
|
||||
@@ -2103,8 +2103,8 @@ void paint_2d_gradient_fill(
|
||||
linearrgb_to_srgb_v3_v3(color_f, color_f);
|
||||
rgba_float_to_uchar((uchar *)&color_b, color_f);
|
||||
((uchar *)&color_b)[3] *= brush_alpha;
|
||||
IMB_blend_color_byte(ibuf->byte_buffer.data + 4 * (((size_t)y_px) * ibuf->x + x_px),
|
||||
ibuf->byte_buffer.data + 4 * (((size_t)y_px) * ibuf->x + x_px),
|
||||
IMB_blend_color_byte(ibuf->byte_buffer.data + 4 * (size_t(y_px) * ibuf->x + x_px),
|
||||
ibuf->byte_buffer.data + 4 * (size_t(y_px) * ibuf->x + x_px),
|
||||
(uchar *)&color_b,
|
||||
IMB_BlendMode(br->blend));
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ static int imapaint_pick_face(ViewContext *vc, const int mval[2], uint *r_index,
|
||||
ED_view3d_select_id_validate(vc);
|
||||
*r_index = DRW_select_buffer_sample_point(vc->depsgraph, vc->region, vc->v3d, mval);
|
||||
|
||||
if ((*r_index) == 0 || (*r_index) > (uint)totpoly) {
|
||||
if ((*r_index) == 0 || (*r_index) > uint(totpoly)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1441,7 +1441,7 @@ static void pack_islands_endjob(void *pidv)
|
||||
DEG_id_tag_update(static_cast<ID *>(obedit->data), ID_RECALC_GEOMETRY);
|
||||
WM_main_add_notifier(NC_GEOM | ND_DATA, obedit->data);
|
||||
}
|
||||
WM_main_add_notifier(NC_SPACE | ND_SPACE_IMAGE, NULL);
|
||||
WM_main_add_notifier(NC_SPACE | ND_SPACE_IMAGE, nullptr);
|
||||
|
||||
if (pid->undo_str) {
|
||||
ED_undo_push(pid->undo_context, pid->undo_str);
|
||||
|
||||
@@ -604,7 +604,7 @@ class RetimingRange {
|
||||
{
|
||||
for (int frame = start; frame <= end; frame++) {
|
||||
/* We need number actual number of frames here. */
|
||||
const double normal_step = 1 / (double)seq->len;
|
||||
const double normal_step = 1 / double(seq->len);
|
||||
|
||||
/* Who needs calculus, when you can have slow code? */
|
||||
const double val_prev = seq_retiming_evaluate(seq, frame - 1);
|
||||
|
||||
Reference in New Issue
Block a user