diff options
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_rect.h | 3 | ||||
-rw-r--r-- | source/blender/blenlib/intern/rct.c | 16 |
2 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index 49d10eb0be6..8a9794b77c9 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -46,6 +46,9 @@ void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax); void BLI_rcti_init_minmax(struct rcti *rect); void BLI_rctf_init_minmax(struct rctf *rect); +void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2]); +void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]); + void BLI_translate_rctf(struct rctf *rect, float x, float y); void BLI_translate_rcti(struct rcti *rect, int x, int y); void BLI_resize_rcti(struct rcti *rect, int x, int y); diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 4ac30da2369..c1ef3e27291 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -211,6 +211,22 @@ void BLI_rctf_init_minmax(struct rctf *rect) rect->xmax = rect->ymax = FLT_MIN; } +void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2]) +{ + if (xy[0] < rect->xmin) rect->xmin = xy[0]; + if (xy[0] > rect->xmax) rect->xmax = xy[0]; + if (xy[1] < rect->ymin) rect->ymin = xy[1]; + if (xy[1] > rect->ymax) rect->ymax = xy[1]; +} + +void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]) +{ + if (xy[0] < rect->xmin) rect->xmin = xy[0]; + if (xy[0] > rect->xmax) rect->xmax = xy[0]; + if (xy[1] < rect->ymin) rect->ymin = xy[1]; + if (xy[1] > rect->ymax) rect->ymax = xy[1]; +} + void BLI_translate_rcti(rcti *rect, int x, int y) { rect->xmin += x; |