diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-12 12:31:23 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-12 12:31:23 +0400 |
commit | 993dfd7d2a2eb18949a6c7680e05a950e7a1e9c8 (patch) | |
tree | 7987ef9027f960a2885a9129071602325bcbef1c /source/blender/blenlib | |
parent | 92119982cb2073829560c54991179359f1c1fca1 (diff) |
add bli rect funcs BLI_rctf_init_minmax, BLI_rcti_init_minmax
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_rect.h | 14 | ||||
-rw-r--r-- | source/blender/blenlib/intern/rct.c | 26 |
2 files changed, 28 insertions, 12 deletions
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index 4d0e54e344c..49d10eb0be6 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -40,18 +40,12 @@ struct rcti; extern "C" { #endif -/* BLI_rct.c */ -/** - * Determine if a rect is empty. An empty - * rect is one with a zero (or negative) - * width or height. - * - * \return True if \a rect is empty. - */ int BLI_rcti_is_empty(const struct rcti *rect); int BLI_rctf_is_empty(const struct rctf *rect); -void BLI_init_rctf(struct rctf *rect, float xmin, float xmax, float ymin, float ymax); -void BLI_init_rcti(struct rcti *rect, int xmin, int xmax, int ymin, int ymax); +void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax); +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_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 b4397ea4546..4ac30da2369 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -35,6 +35,9 @@ #include <stdio.h> #include <math.h> +#include <limits.h> +#include <float.h> + #include "DNA_vec_types.h" #include "BLI_rect.h" @@ -57,6 +60,13 @@ int BLI_in_rcti(const rcti *rect, const int x, const int y) return 1; } +/** + * Determine if a rect is empty. An empty + * rect is one with a zero (or negative) + * width or height. + * + * \return True if \a rect is empty. + */ int BLI_in_rcti_v(const rcti *rect, const int xy[2]) { if (xy[0] < rect->xmin) return 0; @@ -149,7 +159,7 @@ void BLI_union_rcti(rcti *rct1, const rcti *rct2) if (rct1->ymax < rct2->ymax) rct1->ymax = rct2->ymax; } -void BLI_init_rctf(rctf *rect, float xmin, float xmax, float ymin, float ymax) +void BLI_rctf_init(rctf *rect, float xmin, float xmax, float ymin, float ymax) { if (xmin <= xmax) { rect->xmin = xmin; @@ -169,7 +179,7 @@ void BLI_init_rctf(rctf *rect, float xmin, float xmax, float ymin, float ymax) } } -void BLI_init_rcti(rcti *rect, int xmin, int xmax, int ymin, int ymax) +void BLI_rcti_init(rcti *rect, int xmin, int xmax, int ymin, int ymax) { if (xmin <= xmax) { rect->xmin = xmin; @@ -189,6 +199,18 @@ void BLI_init_rcti(rcti *rect, int xmin, int xmax, int ymin, int ymax) } } +void BLI_rcti_init_minmax(struct rcti *rect) +{ + rect->xmin = rect->ymin = INT_MAX; + rect->xmax = rect->ymax = INT_MIN; +} + +void BLI_rctf_init_minmax(struct rctf *rect) +{ + rect->xmin = rect->ymin = FLT_MAX; + rect->xmax = rect->ymax = FLT_MIN; +} + void BLI_translate_rcti(rcti *rect, int x, int y) { rect->xmin += x; |