Cleanup: utility function to multiple rctf/rcti

This commit is contained in:
Campbell Barton
2023-07-07 15:42:07 +10:00
parent 23acedd432
commit 40ef6c400b
4 changed files with 20 additions and 8 deletions
+1 -4
View File
@@ -415,10 +415,7 @@ void BKE_camera_params_compute_viewplane(
/* the window matrix is used for clipping, and not changed during OSA steps */
/* using an offset of +0.5 here would give clip errors on edges */
viewplane.xmin *= pixsize;
viewplane.xmax *= pixsize;
viewplane.ymin *= pixsize;
viewplane.ymax *= pixsize;
BLI_rctf_mul(&viewplane, pixsize);
/* Used for rendering (offset by near-clip with perspective views), passed to RE_SetPixelSize.
* For viewport drawing 'RegionView3D.pixsize'. */
+2 -4
View File
@@ -21,6 +21,7 @@
#include "BLI_math.h"
#include "BLI_math_base_safe.h"
#include "BLI_path_util.h"
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_threads.h"
@@ -1398,10 +1399,7 @@ static bool vfont_to_curve(Object *ob,
char_idx_offset += line->char_nr + 1;
}
/* Move the bounds into a space compatible with `cursor_location`. */
bounds->xmin *= font_size;
bounds->xmax *= font_size;
bounds->ymin *= font_size;
bounds->ymax *= font_size;
BLI_rctf_mul(bounds, font_size);
char_beg_next = tb_bounds->char_index_last + 1;
}
+2
View File
@@ -70,6 +70,8 @@ void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, floa
void BLI_rctf_translate(struct rctf *rect, float x, float y);
void BLI_rcti_translate(struct rcti *rect, int x, int y);
void BLI_rctf_mul(struct rctf *rect, float factor);
void BLI_rcti_mul(struct rcti *rect, int factor);
void BLI_rcti_recenter(struct rcti *rect, int x, int y);
void BLI_rctf_recenter(struct rctf *rect, float x, float y);
void BLI_rcti_resize(struct rcti *rect, int x, int y);
+15
View File
@@ -572,6 +572,21 @@ void BLI_rctf_translate(rctf *rect, float x, float y)
rect->ymax += y;
}
void BLI_rcti_mul(rcti *rect, const int factor)
{
rect->xmin *= factor;
rect->ymin *= factor;
rect->xmax *= factor;
rect->ymax *= factor;
}
void BLI_rctf_mul(rctf *rect, const float factor)
{
rect->xmin *= factor;
rect->ymin *= factor;
rect->xmax *= factor;
rect->ymax *= factor;
}
void BLI_rcti_recenter(rcti *rect, int x, int y)
{
const int dx = x - BLI_rcti_cent_x(rect);