Blender V5.0
BLI_rect.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
10
11#include "BLI_compiler_compat.h"
12#include "BLI_sys_types.h" /* bool */
13#include "DNA_vec_types.h"
14
15struct rctf;
16struct rcti;
17
24bool BLI_rcti_is_empty(const struct rcti *rect);
25bool BLI_rctf_is_empty(const struct rctf *rect);
26void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax);
27void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax);
35bool BLI_rctf_is_valid(const struct rctf *rect);
36bool BLI_rcti_is_valid(const struct rcti *rect);
40void BLI_rctf_sanitize(struct rctf *rect);
41void BLI_rcti_sanitize(struct rcti *rect);
42void BLI_rctf_init_pt_radius(struct rctf *rect, const float xy[2], float size);
43void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size);
44void BLI_rcti_init_minmax(struct rcti *rect);
45void BLI_rctf_init_minmax(struct rctf *rect);
46void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2]);
47void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]);
48void BLI_rcti_do_minmax_rcti(struct rcti *rect, const struct rcti *other);
49
53void BLI_rctf_transform_pt_v(const rctf *dst,
54 const rctf *src,
55 float xy_dst[2],
56 const float xy_src[2]);
64 const rctf *dst, const rctf *src, float matrix[4][4], uint x, uint y);
65void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4]);
66void BLI_rctf_transform_calc_m3_pivot_min(const rctf *dst, const rctf *src, float matrix[3][3]);
67
68void BLI_rctf_translate(struct rctf *rect, float x, float y);
69void BLI_rcti_translate(struct rcti *rect, int x, int y);
70void BLI_rctf_mul(struct rctf *rect, float factor);
71void BLI_rcti_mul(struct rcti *rect, int factor);
72void BLI_rcti_recenter(struct rcti *rect, int x, int y);
73void BLI_rctf_recenter(struct rctf *rect, float x, float y);
74void BLI_rcti_resize(struct rcti *rect, int x, int y);
78void BLI_rcti_resize_x(struct rcti *rect, int x);
82void BLI_rcti_resize_y(struct rcti *rect, int y);
83void BLI_rcti_pad(struct rcti *rect, int pad_x, int pad_y);
84void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y);
85void BLI_rctf_resize(struct rctf *rect, float x, float y);
86void BLI_rctf_resize_x(struct rctf *rect, float x);
87void BLI_rctf_resize_y(struct rctf *rect, float y);
88void BLI_rcti_scale(rcti *rect, float scale);
89void BLI_rctf_scale(rctf *rect, float scale);
90void BLI_rctf_pad_y(struct rctf *rect, float boundary_size, float pad_min, float pad_max);
91void BLI_rctf_interp(struct rctf *rect,
92 const struct rctf *rect_a,
93 const struct rctf *rect_b,
94 float fac);
95// void BLI_rcti_interp(struct rctf *rect, struct rctf *rect_a, struct rctf *rect_b, float fac);
96bool BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2]);
97bool BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2]);
106bool BLI_rctf_clamp(struct rctf *rect, const struct rctf *rect_bounds, float r_xy[2]);
107bool BLI_rcti_clamp(struct rcti *rect, const struct rcti *rect_bounds, int r_xy[2]);
108bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit);
109bool BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b);
110bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest);
111bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest);
112bool BLI_rctf_isect_rect_x(const struct rctf *src1, const struct rctf *src2, float range_x[2]);
113bool BLI_rctf_isect_rect_y(const struct rctf *src1, const struct rctf *src2, float range_y[2]);
114bool BLI_rcti_isect_rect_x(const struct rcti *src1, const struct rcti *src2, int range_x[2]);
115bool BLI_rcti_isect_rect_y(const struct rcti *src1, const struct rcti *src2, int range_y[2]);
116bool BLI_rcti_isect_x(const rcti *rect, int x);
117bool BLI_rcti_isect_y(const rcti *rect, int y);
118bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y);
119bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2]);
120bool BLI_rctf_isect_x(const rctf *rect, float x);
121bool BLI_rctf_isect_y(const rctf *rect, float y);
122bool BLI_rctf_isect_pt(const struct rctf *rect, float x, float y);
123bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2]);
127int BLI_rcti_length_x(const rcti *rect, int x);
131int BLI_rcti_length_y(const rcti *rect, int y);
132float BLI_rctf_length_x(const rctf *rect, float x);
133float BLI_rctf_length_y(const rctf *rect, float y);
134bool BLI_rcti_isect_segment(const struct rcti *rect, const int s1[2], const int s2[2]);
135bool BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2]);
136bool BLI_rcti_isect_circle(const struct rcti *rect, const float xy[2], float radius);
137bool BLI_rctf_isect_circle(const struct rctf *rect, const float xy[2], float radius);
138bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b);
142bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b);
143void BLI_rcti_union(struct rcti *rct_a, const struct rcti *rct_b);
144void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b);
145void BLI_rcti_rctf_copy(struct rcti *dst, const struct rctf *src);
146void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src);
147void BLI_rcti_rctf_copy_floor(struct rcti *dst, const struct rctf *src);
148void BLI_rcti_rctf_copy_round(struct rcti *dst, const struct rctf *src);
149
156bool BLI_rctf_clamp_segment(const struct rctf *rect, float s1[2], float s2[2]);
157
161void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, float angle);
162
163void print_rctf(const char *str, const struct rctf *rect);
164void print_rcti(const char *str, const struct rcti *rect);
165
166#define print_rctf_id(rect) print_rctf(STRINGIFY(rect), rect)
167#define print_rcti_id(rect) print_rcti(STRINGIFY(rect), rect)
168
169BLI_INLINE float BLI_rcti_cent_x_fl(const struct rcti *rct)
170{
171 return (float)(rct->xmin + rct->xmax) / 2.0f;
172}
173BLI_INLINE float BLI_rcti_cent_y_fl(const struct rcti *rct)
174{
175 return (float)(rct->ymin + rct->ymax) / 2.0f;
176}
177BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
178{
179 return (rct->xmin + rct->xmax) / 2;
180}
181BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
182{
183 return (rct->ymin + rct->ymax) / 2;
184}
185BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
186{
187 return (rct->xmin + rct->xmax) / 2.0f;
188}
189BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
190{
191 return (rct->ymin + rct->ymax) / 2.0f;
192}
193
194BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
195{
196 return (rct->xmax - rct->xmin);
197}
198BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
199{
200 return (rct->ymax - rct->ymin);
201}
202BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
203{
204 return (rct->xmax - rct->xmin);
205}
206BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
207{
208 return (rct->ymax - rct->ymin);
209}
#define BLI_INLINE
bool BLI_rctf_is_empty(const struct rctf *rect)
void BLI_rcti_union(struct rcti *rct_a, const struct rcti *rct_b)
bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2])
void print_rctf(const char *str, const struct rctf *rect)
void BLI_rctf_translate(struct rctf *rect, float x, float y)
Definition rct.cc:573
bool BLI_rcti_isect_rect_y(const struct rcti *src1, const struct rcti *src2, int range_y[2])
bool BLI_rctf_isect_x(const rctf *rect, float x)
Definition rct.cc:93
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.h:198
void BLI_rcti_init_minmax(struct rcti *rect)
Definition rct.cc:474
bool BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b)
bool BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2])
void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b)
bool BLI_rctf_is_valid(const struct rctf *rect)
BLI_INLINE float BLI_rcti_cent_x_fl(const struct rcti *rct)
Definition BLI_rect.h:169
void BLI_rctf_transform_calc_m3_pivot_min(const rctf *dst, const rctf *src, float matrix[3][3])
Definition rct.cc:556
void BLI_rctf_resize_y(struct rctf *rect, float y)
Definition rct.cc:651
int BLI_rcti_length_x(const rcti *rect, int x)
Definition rct.cc:149
bool BLI_rcti_isect_y(const rcti *rect, int y)
Definition rct.cc:48
bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2])
void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size)
Definition rct.cc:466
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
Definition BLI_rect.h:189
void BLI_rcti_mul(struct rcti *rect, int factor)
Definition rct.cc:581
bool BLI_rcti_isect_segment(const struct rcti *rect, const int s1[2], const int s2[2])
void BLI_rctf_transform_pt_v(const rctf *dst, const rctf *src, float xy_dst[2], const float xy_src[2])
Definition rct.cc:526
bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest)
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
Definition BLI_rect.h:185
bool BLI_rctf_isect_y(const rctf *rect, float y)
Definition rct.cc:104
bool BLI_rctf_clamp(struct rctf *rect, const struct rctf *rect_bounds, float r_xy[2])
void BLI_rcti_rctf_copy_round(struct rcti *dst, const struct rctf *src)
void BLI_rcti_pad(struct rcti *rect, int pad_x, int pad_y)
Definition rct.cc:629
bool BLI_rcti_is_valid(const struct rcti *rect)
void BLI_rcti_rctf_copy_floor(struct rcti *dst, const struct rctf *src)
void BLI_rcti_translate(struct rcti *rect, int x, int y)
Definition rct.cc:566
void BLI_rctf_pad_y(struct rctf *rect, float boundary_size, float pad_min, float pad_max)
Definition rct.cc:689
int BLI_rcti_length_y(const rcti *rect, int y)
Definition rct.cc:160
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
Definition rct.cc:414
void BLI_rcti_resize_y(struct rcti *rect, int y)
Definition rct.cc:615
void BLI_rcti_recenter(struct rcti *rect, int x, int y)
Definition rct.cc:596
void BLI_rctf_resize_x(struct rctf *rect, float x)
Definition rct.cc:645
void BLI_rctf_sanitize(struct rctf *rect)
Definition rct.cc:434
bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y)
void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4])
Definition rct.cc:551
bool BLI_rctf_clamp_segment(const struct rctf *rect, float s1[2], float s2[2])
void BLI_rctf_scale(rctf *rect, float scale)
Definition rct.cc:677
void BLI_rcti_resize(struct rcti *rect, int x, int y)
Definition rct.cc:621
void BLI_rctf_transform_calc_m4_pivot_min_ex(const rctf *dst, const rctf *src, float matrix[4][4], uint x, uint y)
Definition rct.cc:538
float BLI_rctf_length_x(const rctf *rect, float x)
Definition rct.cc:171
bool BLI_rctf_isect_rect_y(const struct rctf *src1, const struct rctf *src2, float range_y[2])
bool BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2])
bool BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2])
bool BLI_rctf_isect_rect_x(const struct rctf *src1, const struct rctf *src2, float range_x[2])
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition rct.cc:404
bool BLI_rctf_isect_circle(const struct rctf *rect, const float xy[2], float radius)
void BLI_rcti_sanitize(struct rcti *rect)
Definition rct.cc:446
void BLI_rctf_recenter(struct rctf *rect, float x, float y)
Definition rct.cc:602
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
bool BLI_rcti_isect_x(const rcti *rect, int x)
Definition rct.cc:37
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.h:194
bool BLI_rcti_isect_rect_x(const struct rcti *src1, const struct rcti *src2, int range_x[2])
void BLI_rcti_scale(rcti *rect, float scale)
Definition rct.cc:665
void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y)
Definition rct.cc:637
bool BLI_rctf_isect_pt(const struct rctf *rect, float x, float y)
BLI_INLINE float BLI_rcti_cent_y_fl(const struct rcti *rct)
Definition BLI_rect.h:173
BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
Definition BLI_rect.h:181
void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src)
void BLI_rcti_resize_x(struct rcti *rect, int x)
Definition rct.cc:609
bool BLI_rcti_isect_circle(const struct rcti *rect, const float xy[2], float radius)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.h:202
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
Definition rct.cc:193
void BLI_rctf_mul(struct rctf *rect, float factor)
Definition rct.cc:588
void BLI_rcti_rctf_copy(struct rcti *dst, const struct rctf *src)
void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2])
Definition rct.cc:510
bool BLI_rcti_is_empty(const struct rcti *rect)
bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b)
Definition rct.cc:198
void BLI_rctf_interp(struct rctf *rect, const struct rctf *rect_a, const struct rctf *rect_b, float fac)
void BLI_rctf_resize(struct rctf *rect, float x, float y)
Definition rct.cc:657
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.h:206
void print_rcti(const char *str, const struct rcti *rect)
bool BLI_rcti_clamp(struct rcti *rect, const struct rcti *rect_bounds, int r_xy[2])
void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, float angle)
Definition rct.cc:1105
void BLI_rctf_init_pt_radius(struct rctf *rect, const float xy[2], float size)
Definition rct.cc:458
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
Definition rct.cc:486
void BLI_rcti_do_minmax_rcti(struct rcti *rect, const struct rcti *other)
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit)
float BLI_rctf_length_y(const rctf *rect, float y)
Definition rct.cc:182
BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
Definition BLI_rect.h:177
void BLI_rctf_init_minmax(struct rctf *rect)
Definition rct.cc:480
unsigned int uint
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Definition IK_Math.h:117
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
#define str(s)
float xmax
float xmin
float ymax
float ymin
int ymin
int ymax
int xmin
int xmax
int xy[2]
Definition wm_draw.cc:178