From df530d4fd4a342b118172589ff7ca9cfa2fd478a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 27 Jul 2023 21:49:56 +1000 Subject: [PATCH] Cleanup: various C++ cleanups - Use C++ headers. - Use function style cast. - Use boolean literals. - Remove redundant struct, void. - Correct struct comment ID's. --- .../blenloader/intern/versioning_250.cc | 40 +++--- .../blenloader/intern/versioning_legacy.cc | 10 +- .../blenloader/intern/versioning_userdef.cc | 2 +- source/blender/datatoc/datatoc.cc | 10 +- source/blender/datatoc/datatoc_icon.cc | 50 +++---- source/blender/render/intern/texture_image.cc | 122 +++++++++--------- .../render/intern/texture_pointdensity.cc | 22 ++-- .../render/intern/texture_procedural.cc | 56 ++++---- source/blender/render/intern/zbuf.cc | 18 +-- 9 files changed, 165 insertions(+), 165 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_250.cc b/source/blender/blenloader/intern/versioning_250.cc index 6b86e62cf67..001dc5a7ff0 100644 --- a/source/blender/blenloader/intern/versioning_250.cc +++ b/source/blender/blenloader/intern/versioning_250.cc @@ -75,7 +75,7 @@ #include "versioning_common.h" -#include +#include /* Make preferences read-only, use versioning_userdef.c. */ #define U (*((const UserDef *)&U)) @@ -305,7 +305,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) SpaceNla *snla = (SpaceNla *)sl; memcpy(®ion->v2d, &snla->v2d, sizeof(View2D)); - region->v2d.tot.ymin = (float)(-area->winy) / 3.0f; + region->v2d.tot.ymin = float(-area->winy) / 3.0f; region->v2d.tot.ymax = 0.0f; region->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_HORIZONTAL_HANDLES); @@ -320,8 +320,8 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) /* We totally reinit the view for the Action Editor, * as some old instances had some weird cruft set. */ region->v2d.tot.xmin = -20.0f; - region->v2d.tot.ymin = (float)(-area->winy) / 3.0f; - region->v2d.tot.xmax = (float)((area->winx > 120) ? (area->winx) : 120); + region->v2d.tot.ymin = float(-area->winy) / 3.0f; + region->v2d.tot.xmax = float((area->winx > 120) ? (area->winx) : 120); region->v2d.tot.ymax = 0.0f; region->v2d.cur = region->v2d.tot; @@ -521,17 +521,17 @@ static void do_version_constraints_radians_degrees_250(ListBase *lb) LISTBASE_FOREACH (bConstraint *, con, lb) { if (con->type == CONSTRAINT_TYPE_KINEMATIC) { bKinematicConstraint *data = static_cast(con->data); - data->poleangle *= (float)(M_PI / 180.0); + data->poleangle *= float(M_PI / 180.0); } else if (con->type == CONSTRAINT_TYPE_ROTLIMIT) { bRotLimitConstraint *data = static_cast(con->data); - data->xmin *= (float)(M_PI / 180.0); - data->xmax *= (float)(M_PI / 180.0); - data->ymin *= (float)(M_PI / 180.0); - data->ymax *= (float)(M_PI / 180.0); - data->zmin *= (float)(M_PI / 180.0); - data->zmax *= (float)(M_PI / 180.0); + data->xmin *= float(M_PI / 180.0); + data->xmax *= float(M_PI / 180.0); + data->ymin *= float(M_PI / 180.0); + data->ymax *= float(M_PI / 180.0); + data->zmin *= float(M_PI / 180.0); + data->zmax *= float(M_PI / 180.0); } } } @@ -1303,12 +1303,12 @@ void blo_do_versions_250(FileData *fd, Library * /*lib*/, Main *bmain) if (ob->pose) { LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { - pchan->limitmin[0] *= (float)(M_PI / 180.0); - pchan->limitmin[1] *= (float)(M_PI / 180.0); - pchan->limitmin[2] *= (float)(M_PI / 180.0); - pchan->limitmax[0] *= (float)(M_PI / 180.0); - pchan->limitmax[1] *= (float)(M_PI / 180.0); - pchan->limitmax[2] *= (float)(M_PI / 180.0); + pchan->limitmin[0] *= float(M_PI / 180.0); + pchan->limitmin[1] *= float(M_PI / 180.0); + pchan->limitmin[2] *= float(M_PI / 180.0); + pchan->limitmax[0] *= float(M_PI / 180.0); + pchan->limitmax[1] *= float(M_PI / 180.0); + pchan->limitmax[2] *= float(M_PI / 180.0); do_version_constraints_radians_degrees_250(&pchan->constraints); } @@ -1334,7 +1334,7 @@ void blo_do_versions_250(FileData *fd, Library * /*lib*/, Main *bmain) LISTBASE_FOREACH (ARegion *, region, regionbase) { if (region->regiontype == RGN_TYPE_WINDOW) { region->v2d.cur.ymax = region->v2d.tot.ymax = 0.0f; - region->v2d.cur.ymin = region->v2d.tot.ymin = (float)(-area->winy) / 3.0f; + region->v2d.cur.ymin = region->v2d.tot.ymin = float(-area->winy) / 3.0f; } } } @@ -1660,7 +1660,7 @@ void blo_do_versions_250(FileData *fd, Library * /*lib*/, Main *bmain) /* spacing was originally in pixels, convert it to percentage for new version * size should not be zero due to sanity check above */ - brush->spacing = (int)(100 * ((float)brush->spacing) / ((float)brush->size)); + brush->spacing = int(100 * float(brush->spacing) / float(brush->size)); if (brush->add_col[0] == 0 && brush->add_col[1] == 0 && brush->add_col[2] == 0) { brush->add_col[0] = 1.00f; @@ -1958,7 +1958,7 @@ void blo_do_versions_250(FileData *fd, Library * /*lib*/, Main *bmain) } } - if (0) { + if (false) { if (!MAIN_VERSION_FILE_ATLEAST(bmain, 256, 6)) { LISTBASE_FOREACH (Mesh *, me, &bmain->meshes) { /* Vertex normal calculation from legacy 'MFace' has been removed. diff --git a/source/blender/blenloader/intern/versioning_legacy.cc b/source/blender/blenloader/intern/versioning_legacy.cc index 71e769298e8..92ceab1c4f0 100644 --- a/source/blender/blenloader/intern/versioning_legacy.cc +++ b/source/blender/blenloader/intern/versioning_legacy.cc @@ -6,7 +6,7 @@ * \ingroup blenloader */ -#include +#include #ifndef WIN32 # include /* for read close */ @@ -75,7 +75,7 @@ #include "PIL_time.h" -#include +#include /* Make preferences read-only, use versioning_userdef.c. */ #define U (*((const UserDef *)&U)) @@ -2592,8 +2592,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) * use it for the number of divisions per segment */ if (nu->pntsv > 1) { - nu->resolu = MAX2(1, (int)(((float)nu->resolu / (float)nu->pntsu) + 0.5f)); - nu->resolv = MAX2(1, (int)(((float)nu->resolv / (float)nu->pntsv) + 0.5f)); + nu->resolu = MAX2(1, int((float(nu->resolu) / float(nu->pntsu)) + 0.5f)); + nu->resolv = MAX2(1, int((float(nu->resolv) / float(nu->pntsv)) + 0.5f)); } } } @@ -2654,7 +2654,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) for (ob = static_cast(bmain->objects.first); ob; ob = static_cast(ob->id.next)) { if (ob->pd) { - ob->pd->seed = ((uint)ceil(PIL_check_seconds_timer()) + 1) % 128; + ob->pd->seed = (uint(ceil(PIL_check_seconds_timer())) + 1) % 128; } } } diff --git a/source/blender/blenloader/intern/versioning_userdef.cc b/source/blender/blenloader/intern/versioning_userdef.cc index 9bada9efe8c..133e4409879 100644 --- a/source/blender/blenloader/intern/versioning_userdef.cc +++ b/source/blender/blenloader/intern/versioning_userdef.cc @@ -8,7 +8,7 @@ * Version patch user preferences. */ #define DNA_DEPRECATED_ALLOW -#include +#include #include "BLI_listbase.h" #include "BLI_math.h" diff --git a/source/blender/datatoc/datatoc.cc b/source/blender/datatoc/datatoc.cc index bc9ce795066..f8ca59cf508 100644 --- a/source/blender/datatoc/datatoc.cc +++ b/source/blender/datatoc/datatoc.cc @@ -6,9 +6,9 @@ * \ingroup datatoc */ -#include -#include -#include +#include +#include +#include /* #define VERBOSE */ @@ -63,7 +63,7 @@ int main(int argc, char **argv) printf("Making C file <%s>\n", argv[2]); #endif - argv_len = (int)strlen(argv[1]); + argv_len = int(strlen(argv[1])); for (i = 0; i < argv_len; i++) { if (argv[1][i] == '.') { argv[1][i] = '_'; @@ -82,7 +82,7 @@ int main(int argc, char **argv) fprintf(fpout, "extern const int datatoc_%s_size;\n", argv[1]); fprintf(fpout, "extern const char datatoc_%s[];\n\n", argv[1]); - fprintf(fpout, "const int datatoc_%s_size = %d;\n", argv[1], (int)size); + fprintf(fpout, "const int datatoc_%s_size = %d;\n", argv[1], int(size)); fprintf(fpout, "const char datatoc_%s[] = {\n", argv[1]); while (size--) { /* Even though this file is generated and doesn't need new-lines, diff --git a/source/blender/datatoc/datatoc_icon.cc b/source/blender/datatoc/datatoc_icon.cc index 93feb108386..251eb19dbe3 100644 --- a/source/blender/datatoc/datatoc_icon.cc +++ b/source/blender/datatoc/datatoc_icon.cc @@ -6,11 +6,11 @@ * \ingroup datatoc */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* for bool */ #include "../blenlib/BLI_sys_types.h" @@ -198,7 +198,7 @@ struct IconHead { }; struct IconInfo { - struct IconHead head; + IconHead head; char *file_name; }; @@ -207,10 +207,10 @@ struct IconMergeContext { * Is used for sanity checks like prevention of two files defining icon for * the same position on canvas. */ int num_read_icons; - struct IconInfo *read_icons; + IconInfo *read_icons; }; -static void icon_merge_context_init(struct IconMergeContext *context) +static void icon_merge_context_init(IconMergeContext *context) { context->num_read_icons = 0; context->read_icons = nullptr; @@ -219,16 +219,16 @@ static void icon_merge_context_init(struct IconMergeContext *context) /* Get icon information from the context which matches given icon head. * Is used to check whether icon is re-defined, and to provide useful information about which * files are conflicting. */ -static struct IconInfo *icon_merge_context_info_for_icon_head(struct IconMergeContext *context, - struct IconHead *icon_head) +static IconInfo *icon_merge_context_info_for_icon_head(IconMergeContext *context, + IconHead *icon_head) { if (context->read_icons == nullptr) { return nullptr; } for (int i = 0; i < context->num_read_icons; i++) { - struct IconInfo *read_icon_info = &context->read_icons[i]; - const struct IconHead *read_icon_head = &read_icon_info->head; + IconInfo *read_icon_info = &context->read_icons[i]; + const IconHead *read_icon_head = &read_icon_info->head; if (read_icon_head->orig_x == icon_head->orig_x && read_icon_head->orig_y == icon_head->orig_y) { return read_icon_info; @@ -238,21 +238,21 @@ static struct IconInfo *icon_merge_context_info_for_icon_head(struct IconMergeCo return nullptr; } -static void icon_merge_context_register_icon(struct IconMergeContext *context, +static void icon_merge_context_register_icon(IconMergeContext *context, const char *file_name, - const struct IconHead *icon_head) + const IconHead *icon_head) { context->read_icons = static_cast( - realloc(context->read_icons, sizeof(struct IconInfo) * (context->num_read_icons + 1))); + realloc(context->read_icons, sizeof(IconInfo) * (context->num_read_icons + 1))); - struct IconInfo *icon_info = &context->read_icons[context->num_read_icons]; + IconInfo *icon_info = &context->read_icons[context->num_read_icons]; icon_info->head = *icon_head; icon_info->file_name = strdup(path_basename(file_name)); context->num_read_icons++; } -static void icon_merge_context_free(struct IconMergeContext *context) +static void icon_merge_context_free(IconMergeContext *context) { if (context->read_icons != nullptr) { for (int i = 0; i < context->num_read_icons; i++) { @@ -262,7 +262,7 @@ static void icon_merge_context_free(struct IconMergeContext *context) } } -static bool icon_decode_head(FILE *f_src, struct IconHead *r_head) +static bool icon_decode_head(FILE *f_src, IconHead *r_head) { if (fread(r_head, 1, sizeof(*r_head), f_src) == sizeof(*r_head)) { #ifndef __LITTLE_ENDIAN__ @@ -282,7 +282,7 @@ static bool icon_decode_head(FILE *f_src, struct IconHead *r_head) return false; } -static bool icon_decode(FILE *f_src, struct IconHead *r_head, uint **r_pixels) +static bool icon_decode(FILE *f_src, IconHead *r_head, uint **r_pixels) { uint *pixels; uint pixels_size; @@ -309,7 +309,7 @@ static bool icon_decode(FILE *f_src, struct IconHead *r_head, uint **r_pixels) return true; } -static bool icon_read(const char *file_src, struct IconHead *r_head, uint **r_pixels) +static bool icon_read(const char *file_src, IconHead *r_head, uint **r_pixels) { FILE *f_src; bool success; @@ -326,13 +326,13 @@ static bool icon_read(const char *file_src, struct IconHead *r_head, uint **r_pi return success; } -static bool icon_merge(struct IconMergeContext *context, +static bool icon_merge(IconMergeContext *context, const char *file_src, uint32_t **r_pixels_canvas, uint *r_canvas_w, uint *r_canvas_h) { - struct IconHead head; + IconHead head; uint *pixels; uint x, y; @@ -345,7 +345,7 @@ static bool icon_merge(struct IconMergeContext *context, return false; } - const struct IconInfo *read_icon_info = icon_merge_context_info_for_icon_head(context, &head); + const IconInfo *read_icon_info = icon_merge_context_info_for_icon_head(context, &head); if (read_icon_info != nullptr) { printf( "Conflicting icon files %s and %s\n", path_basename(file_src), read_icon_info->file_name); @@ -399,11 +399,11 @@ static bool icondir_to_png(const char *path_src, const char *file_dst) { /* Takes a path full of 'dat' files and writes out */ DIR *dir; - const struct dirent *fname; + const dirent *fname; char filepath[1024]; int found = 0, fail = 0; - struct IconMergeContext context; + IconMergeContext context; uint32_t *pixels_canvas = nullptr; uint canvas_w = 0, canvas_h = 0; diff --git a/source/blender/render/intern/texture_image.cc b/source/blender/render/intern/texture_image.cc index 1253d532851..4b616c39904 100644 --- a/source/blender/render/intern/texture_image.cc +++ b/source/blender/render/intern/texture_image.cc @@ -7,10 +7,10 @@ */ #include -#include -#include -#include -#include +#include +#include +#include +#include #ifndef WIN32 # include #else @@ -69,10 +69,10 @@ static void ibuf_get_color(float col[4], ImBuf *ibuf, int x, int y) else { const uchar *rect = ibuf->byte_buffer.data + 4 * ofs; - col[0] = ((float)rect[0]) * (1.0f / 255.0f); - col[1] = ((float)rect[1]) * (1.0f / 255.0f); - col[2] = ((float)rect[2]) * (1.0f / 255.0f); - col[3] = ((float)rect[3]) * (1.0f / 255.0f); + col[0] = float(rect[0]) * (1.0f / 255.0f); + col[1] = float(rect[1]) * (1.0f / 255.0f); + col[2] = float(rect[2]) * (1.0f / 255.0f); + col[3] = float(rect[3]) * (1.0f / 255.0f); /* bytes are internally straight, however render pipeline seems to expect premul */ col[0] *= col[3]; @@ -85,7 +85,7 @@ int imagewrap(Tex *tex, Image *ima, const float texvec[3], TexResult *texres, - struct ImagePool *pool, + ImagePool *pool, const bool skip_load_image) { float fx, fy; @@ -141,8 +141,8 @@ int imagewrap(Tex *tex, if (tex->extend == TEX_CHECKER) { int xs, ys; - xs = (int)floor(fx); - ys = (int)floor(fy); + xs = int(floor(fx)); + ys = int(floor(fy)); fx -= xs; fy -= ys; @@ -172,8 +172,8 @@ int imagewrap(Tex *tex, } } - x = xi = (int)floorf(fx * ibuf->x); - y = yi = (int)floorf(fy * ibuf->y); + x = xi = int(floorf(fx * ibuf->x)); + y = yi = int(floorf(fy * ibuf->y)); if (tex->extend == TEX_CLIPCUBE) { if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y || texvec[2] < -1.0f || texvec[2] > 1.0f) { @@ -240,8 +240,8 @@ int imagewrap(Tex *tex, /* Important that this value is wrapped #27782. * this applies the modifications made by the checks above, * back to the floating point values */ - fx -= (float)(xi - x) / (float)ibuf->x; - fy -= (float)(yi - y) / (float)ibuf->y; + fx -= float(xi - x) / float(ibuf->x); + fy -= float(yi - y) / float(ibuf->y); boxsample(ibuf, fx - filterx, @@ -470,10 +470,10 @@ static void boxsampleclip(ImBuf *ibuf, const rctf *rf, TexResult *texres) float muly, mulx, div, col[4]; int x, y, startx, endx, starty, endy; - startx = (int)floor(rf->xmin); - endx = (int)floor(rf->xmax); - starty = (int)floor(rf->ymin); - endy = (int)floor(rf->ymax); + startx = int(floor(rf->xmin)); + endx = int(floor(rf->xmax)); + starty = int(floor(rf->ymin)); + endy = int(floor(rf->ymax)); if (startx < 0) { startx = 0; @@ -588,10 +588,10 @@ static void boxsample(ImBuf *ibuf, CLAMP(rf->xmax, 0.0f, ibuf->x - 1); } else if (imaprepeat) { - clipx_rctf_swap(stack, &count, 0.0, (float)(ibuf->x)); + clipx_rctf_swap(stack, &count, 0.0, float(ibuf->x)); } else { - alphaclip = clipx_rctf(rf, 0.0, (float)(ibuf->x)); + alphaclip = clipx_rctf(rf, 0.0, float(ibuf->x)); if (alphaclip <= 0.0f) { texres->trgba[0] = texres->trgba[2] = texres->trgba[1] = texres->trgba[3] = 0.0; @@ -604,10 +604,10 @@ static void boxsample(ImBuf *ibuf, CLAMP(rf->ymax, 0.0f, ibuf->y - 1); } else if (imaprepeat) { - clipy_rctf_swap(stack, &count, 0.0, (float)(ibuf->y)); + clipy_rctf_swap(stack, &count, 0.0, float(ibuf->y)); } else { - alphaclip *= clipy_rctf(rf, 0.0, (float)(ibuf->y)); + alphaclip *= clipy_rctf(rf, 0.0, float(ibuf->y)); if (alphaclip <= 0.0f) { texres->trgba[0] = texres->trgba[2] = texres->trgba[1] = texres->trgba[3] = 0.0; @@ -754,7 +754,7 @@ static int ibuf_get_color_clip_bilerp( const float uf = u - ufl, vf = v - vfl; const float w00 = (1.0f - uf) * (1.0f - vf), w10 = uf * (1.0f - vf), w01 = (1.0f - uf) * vf, w11 = uf * vf; - const int x1 = (int)ufl, y1 = (int)vfl, x2 = x1 + 1, y2 = y1 + 1; + const int x1 = int(ufl), y1 = int(vfl), x2 = x1 + 1, y2 = y1 + 1; int clip = ibuf_get_color_clip(c00, ibuf, x1, y1, extflag); clip |= ibuf_get_color_clip(c10, ibuf, x2, y1, extflag); clip |= ibuf_get_color_clip(c01, ibuf, x1, y2, extflag); @@ -765,7 +765,7 @@ static int ibuf_get_color_clip_bilerp( col[3] = clip ? 0.0f : w00 * c00[3] + w10 * c10[3] + w01 * c01[3] + w11 * c11[3]; return clip; } - return ibuf_get_color_clip(col, ibuf, (int)u, (int)v, extflag); + return ibuf_get_color_clip(col, ibuf, int(u), int(v), extflag); } static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD) @@ -774,8 +774,8 @@ static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata float tc[4], xsd, ysd, cw = 0.0f; const float ux = ibuf->x * AFD->dxt[0], uy = ibuf->y * AFD->dxt[1]; const float vx = ibuf->x * AFD->dyt[0], vy = ibuf->y * AFD->dyt[1]; - int xsam = (int)(0.5f * sqrtf(ux * ux + uy * uy) + 0.5f); - int ysam = (int)(0.5f * sqrtf(vx * vx + vy * vy) + 0.5f); + int xsam = int(0.5f * sqrtf(ux * ux + uy * uy) + 0.5f); + int ysam = int(0.5f * sqrtf(vx * vx + vy * vy) + 0.5f); const int minsam = AFD->intpol ? 2 : 4; xsam = CLAMPIS(xsam, minsam, ibuf->x * 2); ysam = CLAMPIS(ysam, minsam, ibuf->y * 2); @@ -840,7 +840,7 @@ static void feline_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata const int maxn = AFD->iProbes - 1; const float ll = ((AFD->majrad == AFD->minrad) ? 2.0f * AFD->majrad : 2.0f * (AFD->majrad - AFD->minrad)) / - (maxn ? (float)maxn : 1.0f); + (maxn ? float(maxn) : 1.0f); float du = maxn ? cosf(AFD->theta) * ll : 0.0f; float dv = maxn ? sinf(AFD->theta) * ll : 0.0f; // const float D = -0.5f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); @@ -859,7 +859,7 @@ static void feline_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata #if 0 const float wt = expf(n * n * D); #else - const float wt = EWA_WTS[(int)(n * n * D)]; + const float wt = EWA_WTS[int(n * n * D)]; #endif /* `const int out =` */ ibuf_get_color_clip_bilerp( tc, ibuf, ibuf->x * u, ibuf->y * v, AFD->intpol, AFD->extflag); @@ -902,8 +902,8 @@ static void alpha_clip_aniso(const ImBuf *ibuf, rf.ymin = miny * (ibuf->y); rf.ymax = maxy * (ibuf->y); - alphaclip = clipx_rctf(&rf, 0.0, (float)(ibuf->x)); - alphaclip *= clipy_rctf(&rf, 0.0, (float)(ibuf->y)); + alphaclip = clipx_rctf(&rf, 0.0, float(ibuf->x)); + alphaclip *= clipy_rctf(&rf, 0.0, float(ibuf->y)); alphaclip = max_ff(alphaclip, 0.0f); if (alphaclip != 1.0f) { @@ -948,7 +948,7 @@ static int imagewraposa_aniso(Tex *tex, float dxt[2], float dyt[2], TexResult *texres, - struct ImagePool *pool, + ImagePool *pool, const bool skip_load_image) { TexResult texr; @@ -1033,7 +1033,7 @@ static int imagewraposa_aniso(Tex *tex, if (tex->imaflag & TEX_FILTER_MIN) { /* Make sure the filtersize is minimal in pixels * (normal, ref map can have miniature pixel dx/dy). */ - const float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y); + const float addval = (0.5f * tex->filtersize) / float(MIN2(ibuf->x, ibuf->y)); if (addval > minx) { minx = addval; } @@ -1090,7 +1090,7 @@ static int imagewraposa_aniso(Tex *tex, } if (tex->extend == TEX_CHECKER) { - int xs = (int)floorf(fx), ys = (int)floorf(fy); + int xs = int(floorf(fx)), ys = int(floorf(fy)); /* both checkers available, no boundary exceptions, checkerdist will eat aliasing */ if ((tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN)) { fx -= xs; @@ -1103,10 +1103,10 @@ static int imagewraposa_aniso(Tex *tex, return retval; } else { - int xs1 = (int)floorf(fx - minx); - int ys1 = (int)floorf(fy - miny); - int xs2 = (int)floorf(fx + minx); - int ys2 = (int)floorf(fy + miny); + int xs1 = int(floorf(fx - minx)); + int ys1 = int(floorf(fy - miny)); + int xs2 = int(floorf(fx + minx)); + int ys2 = int(floorf(fy + miny)); if ((xs1 != xs2) || (ys1 != ys2)) { if (tex->flag & TEX_CHECKER_ODD) { fx -= ((xs1 + ys) & 1) ? xs2 : xs1; @@ -1219,22 +1219,22 @@ static int imagewraposa_aniso(Tex *tex, AFD.iProbes = round_fl_to_int(fProbes); AFD.iProbes = MIN2(AFD.iProbes, tex->afmax); if (AFD.iProbes < fProbes) { - b = 2.0f * a / (float)(AFD.iProbes + 1); + b = 2.0f * a / float(AFD.iProbes + 1); } AFD.majrad = a / ff; AFD.minrad = b / ff; AFD.theta = th; AFD.dusc = 1.0f / ff; - AFD.dvsc = ff / (float)ibuf->y; + AFD.dvsc = ff / float(ibuf->y); } else { /* EWA & area */ - if (ecc > (float)tex->afmax) { - b = a / (float)tex->afmax; + if (ecc > float(tex->afmax)) { + b = a / float(tex->afmax); } b *= ff; } maxd = max_ff(b, 1e-8f); - levf = ((float)M_LOG2E) * logf(maxd); + levf = (float(M_LOG2E)) * logf(maxd); curmap = 0; maxlev = 1; @@ -1260,7 +1260,7 @@ static int imagewraposa_aniso(Tex *tex, } } else { - const int lev = isnan(levf) ? 0 : (int)levf; + const int lev = isnan(levf) ? 0 : int(levf); curibuf = mipmaps[lev]; previbuf = mipmaps[lev + 1]; levf -= floorf(levf); @@ -1299,13 +1299,13 @@ static int imagewraposa_aniso(Tex *tex, /* no limit to number of Probes here */ AFD.iProbes = round_fl_to_int(fProbes); if (AFD.iProbes < fProbes) { - b = 2.0f * a / (float)(AFD.iProbes + 1); + b = 2.0f * a / float(AFD.iProbes + 1); } AFD.majrad = a / ff; AFD.minrad = b / ff; AFD.theta = th; AFD.dusc = 1.0f / ff; - AFD.dvsc = ff / (float)ibuf->y; + AFD.dvsc = ff / float(ibuf->y); } filterfunc(texres, ibuf, fx, fy, &AFD); if (tex->texfilter != TXF_EWA) { @@ -1355,7 +1355,7 @@ int imagewraposa(Tex *tex, const float DXT[2], const float DYT[2], TexResult *texres, - struct ImagePool *pool, + ImagePool *pool, const bool skip_load_image) { TexResult texr; @@ -1436,7 +1436,7 @@ int imagewraposa(Tex *tex, if (tex->imaflag & TEX_FILTER_MIN) { /* Make sure the filtersize is minimal in pixels * (normal, ref map can have miniature pixel dx/dy). */ - float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y); + float addval = (0.5f * tex->filtersize) / float(MIN2(ibuf->x, ibuf->y)); if (addval > minx) { minx = addval; @@ -1486,8 +1486,8 @@ int imagewraposa(Tex *tex, if (tex->extend == TEX_CHECKER) { int xs, ys, xs1, ys1, xs2, ys2, boundary; - xs = (int)floor(fx); - ys = (int)floor(fy); + xs = int(floor(fx)); + ys = int(floor(fy)); /* both checkers available, no boundary exceptions, checkerdist will eat aliasing */ if ((tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN)) { @@ -1502,10 +1502,10 @@ int imagewraposa(Tex *tex, } else { - xs1 = (int)floor(fx - minx); - ys1 = (int)floor(fy - miny); - xs2 = (int)floor(fx + minx); - ys2 = (int)floor(fy + miny); + xs1 = int(floor(fx - minx)); + ys1 = int(floor(fy - miny)); + xs2 = int(floor(fx + minx)); + ys2 = int(floor(fy + miny)); boundary = (xs1 != xs2) || (ys1 != ys2); if (boundary == 0) { @@ -1603,10 +1603,10 @@ int imagewraposa(Tex *tex, } else { if (fx > 1.0f) { - fx -= (int)(fx); + fx -= int(fx); } else if (fx < 0.0f) { - fx += 1 - (int)(fx); + fx += 1 - int(fx); } } @@ -1620,10 +1620,10 @@ int imagewraposa(Tex *tex, } else { if (fy > 1.0f) { - fy -= (int)(fy); + fy -= int(fy); } else if (fy < 0.0f) { - fy += 1 - (int)(fy); + fy += 1 - int(fy); } } } @@ -1639,7 +1639,7 @@ int imagewraposa(Tex *tex, maxd = 0.5f; } - pixsize = 1.0f / (float)MIN2(ibuf->x, ibuf->y); + pixsize = 1.0f / float(MIN2(ibuf->x, ibuf->y)); curmap = 0; previbuf = curibuf = ibuf; @@ -1649,7 +1649,7 @@ int imagewraposa(Tex *tex, } previbuf = curibuf; curibuf = ibuf->mipmap[curmap]; - pixsize = 1.0f / (float)MIN2(curibuf->x, curibuf->y); + pixsize = 1.0f / float(MIN2(curibuf->x, curibuf->y)); curmap++; } @@ -1733,7 +1733,7 @@ int imagewraposa(Tex *tex, } void image_sample( - Image *ima, float fx, float fy, float dx, float dy, float result[4], struct ImagePool *pool) + Image *ima, float fx, float fy, float dx, float dy, float result[4], ImagePool *pool) { TexResult texres; ImBuf *ibuf = BKE_image_pool_acquire_ibuf(ima, nullptr, pool); diff --git a/source/blender/render/intern/texture_pointdensity.cc b/source/blender/render/intern/texture_pointdensity.cc index 3413018ff19..d6415b75515 100644 --- a/source/blender/render/intern/texture_pointdensity.cc +++ b/source/blender/render/intern/texture_pointdensity.cc @@ -6,9 +6,9 @@ * \ingroup render */ -#include -#include -#include +#include +#include +#include #include "MEM_guardedalloc.h" @@ -225,7 +225,7 @@ static void pointdensity_cache_psys( /* emitter particles */ state.time = cfra; - if (!psys_get_particle_state(&sim, i, &state, 0)) { + if (!psys_get_particle_state(&sim, i, &state, false)) { continue; } @@ -645,7 +645,7 @@ static int pointdensity(PointDensity *pd, texvec[1] + vec[1], texvec[2] + vec[2], pd->noise_depth, - 0, + false, pd->noise_basis); turb -= 0.5f; /* re-center 0.0-1.0 range around 0 to prevent offsetting result */ @@ -797,7 +797,7 @@ static void particle_system_minmax(Depsgraph *depsgraph, float co_object[3], co_min[3], co_max[3]; ParticleKey state; state.time = cfra; - if (!psys_get_particle_state(&sim, i, &state, 0)) { + if (!psys_get_particle_state(&sim, i, &state, false)) { continue; } mul_v3_m4v3(co_object, imat, state.co); @@ -891,7 +891,7 @@ static void point_density_sample_func(void *__restrict data_v, return; } - size_t z = (size_t)iter; + size_t z = size_t(iter); for (size_t y = 0; y < resolution; y++) { for (size_t x = 0; x < resolution; x++) { size_t index = z * resolution2 + y * resolution + x; @@ -900,9 +900,9 @@ static void point_density_sample_func(void *__restrict data_v, TexResult texres; copy_v3_v3(texvec, min); - texvec[0] += dim[0] * (float)x / (float)resolution; - texvec[1] += dim[1] * (float)y / (float)resolution; - texvec[2] += dim[2] * (float)z / (float)resolution; + texvec[0] += dim[0] * float(x) / float(resolution); + texvec[1] += dim[1] * float(y) / float(resolution); + texvec[2] += dim[2] * float(z) / float(resolution); pointdensity(pd, texvec, &texres, vec, &age, col); pointdensity_color(pd, &texres, age, vec, col); @@ -958,4 +958,4 @@ void RE_point_density_free(PointDensity *pd) free_pointdensity(pd); } -void RE_point_density_fix_linking(void) {} +void RE_point_density_fix_linking() {} diff --git a/source/blender/render/intern/texture_procedural.cc b/source/blender/render/intern/texture_procedural.cc index e0b904ab4d8..e676ab2cda3 100644 --- a/source/blender/render/intern/texture_procedural.cc +++ b/source/blender/render/intern/texture_procedural.cc @@ -6,10 +6,10 @@ * \ingroup render */ -#include -#include -#include -#include +#include +#include +#include +#include #include "BLI_math.h" #include "BLI_noise.h" @@ -45,12 +45,12 @@ static RNG_THREAD_ARRAY *random_tex_array; -void RE_texture_rng_init(void) +void RE_texture_rng_init() { random_tex_array = BLI_rng_threaded_new(); } -void RE_texture_rng_exit(void) +void RE_texture_rng_exit() { if (random_tex_array == nullptr) { return; @@ -103,7 +103,7 @@ static int blend(const Tex *tex, const float texvec[3], TexResult *texres) texres->tin = (2.0f + x + y) / 4.0f; } else if (tex->stype == TEX_RAD) { /* Radial. */ - texres->tin = (atan2f(y, x) / (float)(2 * M_PI) + 0.5f); + texres->tin = (atan2f(y, x) / float(2 * M_PI) + 0.5f); } else { /* sphere TEX_SPHERE */ texres->tin = 1.0f - sqrtf(x * x + y * y + texvec[2] * texvec[2]); @@ -176,7 +176,7 @@ static float tex_saw(float a) { const float b = 2 * M_PI; - int n = (int)(a / b); + int n = int(a / b); a -= n * b; if (a < 0) { a += b; @@ -589,7 +589,7 @@ static int texnoise(const Tex *tex, TexResult *texres, int thread) div *= 3.0f; } - texres->tin = ((float)val) / div; + texres->tin = (float(val)) / div; BRICONT; return TEX_INT; @@ -668,14 +668,14 @@ static void do_2d_mapping( float origf = fx *= tex->xrepeat; if (fx > 1.0f) { - fx -= (int)(fx); + fx -= int(fx); } else if (fx < 0.0f) { - fx += 1 - (int)(fx); + fx += 1 - int(fx); } if (tex->flag & TEX_REPEAT_XMIR) { - int orig = (int)floor(origf); + int orig = int(floor(origf)); if (orig & 1) { fx = 1.0f - fx; } @@ -685,14 +685,14 @@ static void do_2d_mapping( float origf = fy *= tex->yrepeat; if (fy > 1.0f) { - fy -= (int)(fy); + fy -= int(fy); } else if (fy < 0.0f) { - fy += 1 - (int)(fy); + fy += 1 - int(fy); } if (tex->flag & TEX_REPEAT_YMIR) { - int orig = (int)floor(origf); + int orig = int(floor(origf)); if (orig & 1) { fy = 1.0f - fy; } @@ -817,14 +817,14 @@ static void do_2d_mapping( /* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */ if (tex->texfilter == TXF_BOX) { if (fx > 1.0f) { - fx -= (int)(fx); + fx -= int(fx); } else if (fx < 0.0f) { - fx += 1 - (int)(fx); + fx += 1 - int(fx); } if (tex->flag & TEX_REPEAT_XMIR) { - int orig = (int)floor(origf); + int orig = int(floor(origf)); if (orig & 1) { fx = 1.0f - fx; } @@ -842,14 +842,14 @@ static void do_2d_mapping( /* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */ if (tex->texfilter == TXF_BOX) { if (fy > 1.0f) { - fy -= (int)(fy); + fy -= int(fy); } else if (fy < 0.0f) { - fy += 1 - (int)(fy); + fy += 1 - int(fy); } if (tex->flag & TEX_REPEAT_YMIR) { - int orig = (int)floor(origf); + int orig = int(floor(origf)); if (orig & 1) { fy = 1.0f - fy; } @@ -897,7 +897,7 @@ static int multitex(Tex *tex, TexResult *texres, const short thread, const short which_output, - struct ImagePool *pool, + ImagePool *pool, const bool skip_load_image, const bool texnode_preview, const bool use_nodes) @@ -1022,7 +1022,7 @@ static int multitex_nodes_intern(Tex *tex, const short thread, short which_output, MTex *mtex, - struct ImagePool *pool, + ImagePool *pool, const bool scene_color_manage, const bool skip_load_image, const bool texnode_preview, @@ -1147,7 +1147,7 @@ int multitex_nodes(Tex *tex, const short thread, short which_output, MTex *mtex, - struct ImagePool *pool) + ImagePool *pool) { return multitex_nodes_intern(tex, texvec, @@ -1172,7 +1172,7 @@ int multitex_ext(Tex *tex, int osatex, TexResult *texres, const short thread, - struct ImagePool *pool, + ImagePool *pool, bool scene_color_manage, const bool skip_load_image) { @@ -1195,7 +1195,7 @@ int multitex_ext(Tex *tex, int multitex_ext_safe(Tex *tex, const float texvec[3], TexResult *texres, - struct ImagePool *pool, + ImagePool *pool, bool scene_color_manage, const bool skip_load_image) { @@ -1309,7 +1309,7 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen bool RE_texture_evaluate(const MTex *mtex, const float vec[3], const int thread, - struct ImagePool *pool, + ImagePool *pool, const bool skip_load_image, const bool texnode_preview, /* Return arguments. */ @@ -1323,7 +1323,7 @@ bool RE_texture_evaluate(const MTex *mtex, tex = mtex->tex; if (tex == nullptr) { - return 0; + return false; } /* placement */ diff --git a/source/blender/render/intern/zbuf.cc b/source/blender/render/intern/zbuf.cc index f31936a22b0..d9a471ad853 100644 --- a/source/blender/render/intern/zbuf.cc +++ b/source/blender/render/intern/zbuf.cc @@ -13,7 +13,7 @@ /* Common includes */ /*---------------------------------------------------------------------------*/ -#include +#include #include "MEM_guardedalloc.h" @@ -208,9 +208,9 @@ void zspan_scanconvert(ZSpan *zspan, } xx1 = (x0 * v1[0] + y0 * v1[1]) / z0 + 1.0f; - uxd = -(double)x0 / (double)z0; - uyd = -(double)y0 / (double)z0; - uy0 = ((double)my2) * uyd + (double)xx1; + uxd = -double(x0) / double(z0); + uyd = -double(y0) / double(z0); + uy0 = double(my2) * uyd + double(xx1); z1 = -1.0f; /* (v1 - v2) */ z2 = 1.0f; /* (v2 - v3) */ @@ -219,9 +219,9 @@ void zspan_scanconvert(ZSpan *zspan, y0 = z1 * x2 - x1 * z2; xx1 = (x0 * v1[0] + y0 * v1[1]) / z0; - vxd = -(double)x0 / (double)z0; - vyd = -(double)y0 / (double)z0; - vy0 = ((double)my2) * vyd + (double)xx1; + vxd = -double(x0) / double(z0); + vyd = -double(y0) / double(z0); + vy0 = double(my2) * vyd + double(xx1); /* correct span */ span1 = zspan->span1 + my2; @@ -240,8 +240,8 @@ void zspan_scanconvert(ZSpan *zspan, sn1 = 0; } - u = (((double)sn1 * uxd) + uy0) - (i * uyd); - v = (((double)sn1 * vxd) + vy0) - (i * vyd); + u = ((double(sn1) * uxd) + uy0) - (i * uyd); + v = ((double(sn1) * vxd) + vy0) - (i * vyd); for (j = 0, x = sn1; x <= sn2; j++, x++) { func(handle, x, y, u + (j * uxd), v + (j * vxd));