diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-09-02 21:28:46 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-09-02 21:34:37 +0300 |
commit | aa781f98bb14eb1448f1a880195449502226f604 (patch) | |
tree | faaafe5ada0dbba3a7d07a04bab728839aa2f93a /source/blender/editors/interface | |
parent | 9ba04c4598fced674d784e1b6dcb30965deac211 (diff) |
Cleanup: Fix clang-tidy warnings: [bugprone-incorrect-roundings]
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface.cc | 14 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_utils.cc | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 933724c9294..ca4918b2e8d 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -153,8 +153,8 @@ void ui_block_to_window(const ARegion *region, uiBlock *block, int *r_x, int *r_ ui_block_to_window_fl(region, block, &fx, &fy); - *r_x = (int)(fx + 0.5f); - *r_y = (int)(fy + 0.5f); + *r_x = (int)lround(fx); + *r_y = (int)lround(fy); } void ui_block_to_region_rctf(const ARegion *region, @@ -232,8 +232,8 @@ void ui_window_to_block(const ARegion *region, uiBlock *block, int *r_x, int *r_ ui_window_to_block_fl(region, block, &fx, &fy); - *r_x = (int)(fx + 0.5f); - *r_y = (int)(fy + 0.5f); + *r_x = (int)lround(fx); + *r_y = (int)lround(fy); } void ui_window_to_region(const ARegion *region, int *r_x, int *r_y) @@ -2363,9 +2363,9 @@ void ui_but_v3_set(uiBut *but, const float vec[3]) } else if (but->pointype == UI_BUT_POIN_CHAR) { char *cp = (char *)but->poin; - cp[0] = (char)(0.5f + vec[0] * 255.0f); - cp[1] = (char)(0.5f + vec[1] * 255.0f); - cp[2] = (char)(0.5f + vec[2] * 255.0f); + cp[0] = (char)lround(vec[0] * 255.0f); + cp[1] = (char)lround(vec[1] * 255.0f); + cp[2] = (char)lround(vec[2] * 255.0f); } else if (but->pointype == UI_BUT_POIN_FLOAT) { float *fp = (float *)but->poin; diff --git a/source/blender/editors/interface/interface_utils.cc b/source/blender/editors/interface/interface_utils.cc index b7ca2d9aa11..4b94834ce97 100644 --- a/source/blender/editors/interface/interface_utils.cc +++ b/source/blender/editors/interface/interface_utils.cc @@ -787,7 +787,7 @@ int UI_calc_float_precision(int prec, double value) */ value = fabs(value); if ((value < pow10_neg[prec]) && (value > (1.0 / max_pow))) { - int value_i = (int)((value * max_pow) + 0.5); + int value_i = (int)lround(value * max_pow); if (value_i != 0) { const int prec_span = 3; /* show: 0.01001, 5 would allow 0.0100001 for eg. */ int test_prec; |