diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-09-04 17:23:00 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-09-04 17:23:08 +0300 |
commit | fb5e2f56109e825ce3c446f80e075ee3dde81c3d (patch) | |
tree | 20b5808415568f503b4ed4b56d3d4f50b5fe8cee /source/blender/blenkernel/intern | |
parent | ee49ce482a797a5937829de497abd69bcd1edb48 (diff) |
Cleanup: Clang-Tidy bugprone-incorrect-roundings fixes
Should cause no noticeable difference.
Diffstat (limited to 'source/blender/blenkernel/intern')
4 files changed, 15 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 6fb2df04b3c..09731c15c0a 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -1320,10 +1320,10 @@ void BKE_histogram_update_sample_line(Histogram *hist, const float *fp; unsigned char *cp; - int x1 = 0.5f + hist->co[0][0] * ibuf->x; - int x2 = 0.5f + hist->co[1][0] * ibuf->x; - int y1 = 0.5f + hist->co[0][1] * ibuf->y; - int y2 = 0.5f + hist->co[1][1] * ibuf->y; + int x1 = roundf(hist->co[0][0] * ibuf->x); + int x2 = roundf(hist->co[1][0] * ibuf->x); + int y1 = roundf(hist->co[0][1] * ibuf->y); + int y2 = roundf(hist->co[1][1] * ibuf->y); struct ColormanageProcessor *cm_processor = NULL; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 630c5f9fb1f..7897d2bb66e 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -24,6 +24,7 @@ * \ingroup bke */ +#include <math.h> #include <stddef.h> #include <stdlib.h> #include <string.h> @@ -2204,8 +2205,8 @@ void BKE_sequencer_proxy_rebuild(SeqIndexBuildContext *context, BKE_sequencer_new_render_data(bmain, context->depsgraph, context->scene, - (scene->r.size * (float)scene->r.xsch) / 100.0f + 0.5f, - (scene->r.size * (float)scene->r.ysch) / 100.0f + 0.5f, + roundf((scene->r.size * (float)scene->r.xsch) / 100.0f), + roundf((scene->r.size * (float)scene->r.ysch) / 100.0f), 100, false, &render_context); diff --git a/source/blender/blenkernel/intern/subdiv_ccg_mask.c b/source/blender/blenkernel/intern/subdiv_ccg_mask.c index 0c02303dc2f..10cd7039948 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg_mask.c +++ b/source/blender/blenkernel/intern/subdiv_ccg_mask.c @@ -21,6 +21,8 @@ * \ingroup bke */ +#include <math.h> + #include "BKE_subdiv_ccg.h" #include "DNA_mesh_types.h" @@ -87,8 +89,8 @@ BLI_INLINE float read_mask_grid(const GridPaintMask *mask_grid, return 0; } const int grid_size = BKE_subdiv_grid_size_from_level(mask_grid->level); - const int x = (grid_u * (grid_size - 1) + 0.5f); - const int y = (grid_v * (grid_size - 1) + 0.5f); + const int x = roundf(grid_u * (grid_size - 1)); + const int y = roundf(grid_v * (grid_size - 1)); return mask_grid->data[y * grid_size + x]; } diff --git a/source/blender/blenkernel/intern/subdiv_displacement_multires.c b/source/blender/blenkernel/intern/subdiv_displacement_multires.c index a63c2994687..69cac840276 100644 --- a/source/blender/blenkernel/intern/subdiv_displacement_multires.c +++ b/source/blender/blenkernel/intern/subdiv_displacement_multires.c @@ -21,6 +21,8 @@ * \ingroup bke */ +#include <math.h> + #include "BKE_subdiv.h" #include "DNA_mesh_types.h" @@ -122,8 +124,8 @@ BLI_INLINE eAverageWith read_displacement_grid(const MDisps *displacement_grid, zero_v3(r_tangent_D); return AVERAGE_WITH_NONE; } - const int x = (grid_u * (grid_size - 1) + 0.5f); - const int y = (grid_v * (grid_size - 1) + 0.5f); + const int x = roundf(grid_u * (grid_size - 1)); + const int y = roundf(grid_v * (grid_size - 1)); copy_v3_v3(r_tangent_D, displacement_grid->disps[y * grid_size + x]); if (x == 0 && y == 0) { return AVERAGE_WITH_ALL; |