Blender V5.3
BLI_rect.hh
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
12#include "BLI_sys_types.hh" /* bool */
13#include "DNA_vec_types.h"
14
15namespace blender {
16
17struct rctf;
18struct rcti;
19
26bool BLI_rcti_is_empty(const struct rcti *rect);
27bool BLI_rctf_is_empty(const struct rctf *rect);
28void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax);
29void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax);
37bool BLI_rctf_is_valid(const struct rctf *rect);
38bool BLI_rcti_is_valid(const struct rcti *rect);
42void BLI_rctf_sanitize(struct rctf *rect);
43void BLI_rcti_sanitize(struct rcti *rect);
44void BLI_rctf_init_pt_radius(struct rctf *rect, const float xy[2], float size);
45void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size);
46void BLI_rcti_init_minmax(struct rcti *rect);
47void BLI_rctf_init_minmax(struct rctf *rect);
48void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2]);
49void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]);
50void BLI_rcti_do_minmax_rcti(struct rcti *rect, const struct rcti *other);
51
55void BLI_rctf_transform_pt_v(const rctf *dst,
56 const rctf *src,
57 float xy_dst[2],
58 const float xy_src[2]);
66 const rctf *dst, const rctf *src, float matrix[4][4], uint x, uint y);
67void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4]);
68void BLI_rctf_transform_calc_m3_pivot_min(const rctf *dst, const rctf *src, float matrix[3][3]);
69
70void BLI_rctf_translate(struct rctf *rect, float x, float y);
71void BLI_rcti_translate(struct rcti *rect, int x, int y);
72void BLI_rctf_mul(struct rctf *rect, float factor);
73void BLI_rcti_mul(struct rcti *rect, int factor);
74void BLI_rcti_recenter(struct rcti *rect, int x, int y);
75void BLI_rctf_recenter(struct rctf *rect, float x, float y);
76void BLI_rcti_resize(struct rcti *rect, int x, int y);
80void BLI_rcti_resize_x(struct rcti *rect, int x);
84void BLI_rcti_resize_y(struct rcti *rect, int y);
85void BLI_rcti_pad(struct rcti *rect, int pad_x, int pad_y);
86void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y);
87void BLI_rctf_resize(struct rctf *rect, float x, float y);
88void BLI_rctf_resize_x(struct rctf *rect, float x);
89void BLI_rctf_resize_y(struct rctf *rect, float y);
90void BLI_rcti_scale(rcti *rect, float scale);
91void BLI_rctf_scale(rctf *rect, float scale);
92void BLI_rctf_pad_y(struct rctf *rect, float boundary_size, float pad_min, float pad_max);
93void BLI_rctf_interp(struct rctf *rect,
94 const struct rctf *rect_a,
95 const struct rctf *rect_b,
96 float fac);
97// void BLI_rcti_interp(struct rctf *rect, struct rctf *rect_a, struct rctf *rect_b, float fac);
98bool BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2]);
99bool BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2]);
108bool BLI_rctf_clamp(struct rctf *rect, const struct rctf *rect_bounds, float r_xy[2]);
109bool BLI_rcti_clamp(struct rcti *rect, const struct rcti *rect_bounds, int r_xy[2]);
110bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit);
111bool BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b);
112bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest);
113bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest);
114bool BLI_rctf_isect_rect_x(const struct rctf *src1, const struct rctf *src2, float range_x[2]);
115bool BLI_rctf_isect_rect_y(const struct rctf *src1, const struct rctf *src2, float range_y[2]);
116bool BLI_rcti_isect_rect_x(const struct rcti *src1, const struct rcti *src2, int range_x[2]);
117bool BLI_rcti_isect_rect_y(const struct rcti *src1, const struct rcti *src2, int range_y[2]);
118bool BLI_rcti_isect_x(const rcti *rect, int x);
119bool BLI_rcti_isect_y(const rcti *rect, int y);
120bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y);
121bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2]);
122bool BLI_rctf_isect_x(const rctf *rect, float x);
123bool BLI_rctf_isect_y(const rctf *rect, float y);
124bool BLI_rctf_isect_pt(const struct rctf *rect, float x, float y);
125bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2]);
129int BLI_rcti_length_x(const rcti *rect, int x);
133int BLI_rcti_length_y(const rcti *rect, int y);
134float BLI_rctf_length_x(const rctf *rect, float x);
135float BLI_rctf_length_y(const rctf *rect, float y);
136bool BLI_rcti_isect_segment(const struct rcti *rect, const int s1[2], const int s2[2]);
137bool BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2]);
138bool BLI_rcti_isect_circle(const struct rcti *rect, const float xy[2], float radius);
139bool BLI_rctf_isect_circle(const struct rctf *rect, const float xy[2], float radius);
140bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b);
144bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b);
145void BLI_rcti_union(struct rcti *rct_a, const struct rcti *rct_b);
146void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b);
147void BLI_rctf_union_x(struct rctf *rct, float x);
148void BLI_rctf_union_y(struct rctf *rct, float y);
149void BLI_rcti_rctf_copy(struct rcti *dst, const struct rctf *src);
150void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src);
151void BLI_rcti_rctf_copy_floor(struct rcti *dst, const struct rctf *src);
152void BLI_rcti_rctf_copy_round(struct rcti *dst, const struct rctf *src);
153
160bool BLI_rctf_clamp_segment(const struct rctf *rect, float s1[2], float s2[2]);
161
165void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, float angle);
166
170void BLI_rctf_rotate_expand_around(rctf *dst, const rctf *src, const float pivot[2], float angle);
171
172void print_rctf(const char *str, const struct rctf *rect);
173void print_rcti(const char *str, const struct rcti *rect);
174
175#define print_rctf_id(rect) print_rctf(STRINGIFY(rect), rect)
176#define print_rcti_id(rect) print_rcti(STRINGIFY(rect), rect)
177
178BLI_INLINE float BLI_rcti_cent_x_fl(const struct rcti *rct)
179{
180 return float(rct->xmin + rct->xmax) / 2.0f;
181}
182BLI_INLINE float BLI_rcti_cent_y_fl(const struct rcti *rct)
183{
184 return float(rct->ymin + rct->ymax) / 2.0f;
185}
186BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
187{
188 return (rct->xmin + rct->xmax) / 2;
189}
190BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
191{
192 return (rct->ymin + rct->ymax) / 2;
193}
194BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
195{
196 return (rct->xmin + rct->xmax) / 2.0f;
197}
198BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
199{
200 return (rct->ymin + rct->ymax) / 2.0f;
201}
202
203BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
204{
205 return (rct->xmax - rct->xmin);
206}
207BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
208{
209 return (rct->ymax - rct->ymin);
210}
211BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
212{
213 return (rct->xmax - rct->xmin);
214}
215BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
216{
217 return (rct->ymax - rct->ymin);
218}
219
220} // namespace blender
#define BLI_INLINE
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
#define str(s)
float3x3 scale(float3x3 mat, float2 scale)
BMesh Iterators.
bool BLI_rcti_is_valid(const struct rcti *rect)
float BLI_rctf_length_y(const rctf *rect, float y)
Definition rct.cc:184
bool BLI_rctf_clamp_segment(const struct rctf *rect, float s1[2], float s2[2])
void BLI_rcti_resize_y(struct rcti *rect, int y)
Definition rct.cc:629
bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2])
bool BLI_rcti_isect_x(const rcti *rect, int x)
Definition rct.cc:39
unsigned int uint
Definition BKE_text.h:55
void BLI_rctf_recenter(struct rctf *rect, float x, float y)
Definition rct.cc:616
void BLI_rctf_rotate_expand_around(rctf *dst, const rctf *src, const float pivot[2], float angle)
Definition rct.cc:1145
int BLI_rcti_length_x(const rcti *rect, int x)
Definition rct.cc:151
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
bool BLI_rcti_isect_rect_y(const struct rcti *src1, const struct rcti *src2, int range_y[2])
bool BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b)
void BLI_rcti_rctf_copy(struct rcti *dst, const struct rctf *src)
bool BLI_rcti_isect_circle(const struct rcti *rect, const float xy[2], float radius)
void BLI_rctf_resize(struct rctf *rect, float x, float y)
Definition rct.cc:671
void BLI_rcti_init_minmax(struct rcti *rect)
Definition rct.cc:488
void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2])
Definition rct.cc:524
void BLI_rcti_resize_x(struct rcti *rect, int x)
Definition rct.cc:623
bool BLI_rctf_isect_circle(const struct rctf *rect, const float xy[2], float radius)
void BLI_rctf_sanitize(struct rctf *rect)
Definition rct.cc:448
void BLI_rcti_rctf_copy_round(struct rcti *dst, const struct rctf *src)
void BLI_rctf_scale(rctf *rect, float scale)
Definition rct.cc:691
bool BLI_rcti_clamp(struct rcti *rect, const struct rcti *rect_bounds, int r_xy[2])
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
Definition rct.cc:500
void BLI_rcti_sanitize(struct rcti *rect)
Definition rct.cc:460
void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src)
void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, float angle)
Definition rct.cc:1119
bool BLI_rctf_isect_x(const rctf *rect, float x)
Definition rct.cc:95
bool BLI_rctf_isect_rect_x(const struct rctf *src1, const struct rctf *src2, float range_x[2])
void BLI_rctf_resize_x(struct rctf *rect, float x)
Definition rct.cc:659
bool BLI_rctf_is_valid(const struct rctf *rect)
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:552
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
void BLI_rctf_init_pt_radius(struct rctf *rect, const float xy[2], float size)
Definition rct.cc:472
bool BLI_rctf_is_empty(const struct rctf *rect)
void BLI_rctf_mul(struct rctf *rect, float factor)
Definition rct.cc:602
int BLI_rcti_length_y(const rcti *rect, int y)
Definition rct.cc:162
BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
Definition BLI_rect.hh:190
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit)
void BLI_rctf_resize_y(struct rctf *rect, float y)
Definition rct.cc:665
void BLI_rcti_scale(rcti *rect, float scale)
Definition rct.cc:679
void BLI_rctf_pad_y(struct rctf *rect, float boundary_size, float pad_min, float pad_max)
Definition rct.cc:703
void BLI_rctf_union_y(struct rctf *rct, float y)
Definition rct.cc:396
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.hh:215
bool BLI_rctf_isect_pt(const struct rctf *rect, float x, float y)
void BLI_rcti_union(struct rcti *rct_a, const struct rcti *rct_b)
void BLI_rcti_translate(struct rcti *rect, int x, int y)
Definition rct.cc:580
bool BLI_rcti_isect_y(const rcti *rect, int y)
Definition rct.cc:50
bool BLI_rctf_clamp(struct rctf *rect, const struct rctf *rect_bounds, float r_xy[2])
void BLI_rctf_transform_calc_m3_pivot_min(const rctf *dst, const rctf *src, float matrix[3][3])
Definition rct.cc:570
void BLI_rctf_init_minmax(struct rctf *rect)
Definition rct.cc:494
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
Definition rct.cc:195
void print_rcti(const char *str, const struct rcti *rect)
void BLI_rctf_union_x(struct rctf *rct, float x)
Definition rct.cc:390
bool BLI_rcti_is_empty(const struct rcti *rect)
void print_rctf(const char *str, const struct rctf *rect)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b)
bool BLI_rcti_isect_rect_x(const struct rcti *src1, const struct rcti *src2, int range_x[2])
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
Definition rct.cc:428
BLI_INLINE float BLI_rcti_cent_x_fl(const struct rcti *rct)
Definition BLI_rect.hh:178
float BLI_rctf_length_x(const rctf *rect, float x)
Definition rct.cc:173
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:540
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.hh:211
bool BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2])
void BLI_rctf_interp(struct rctf *rect, const struct rctf *rect_a, const struct rctf *rect_b, float fac)
void BLI_rcti_mul(struct rcti *rect, int factor)
Definition rct.cc:595
bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
Definition BLI_rect.hh:198
void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4])
Definition rct.cc:565
void BLI_rctf_translate(struct rctf *rect, float x, float y)
Definition rct.cc:587
bool BLI_rctf_isect_rect_y(const struct rctf *src1, const struct rctf *src2, float range_y[2])
bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2])
bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y)
void BLI_rcti_pad(struct rcti *rect, int pad_x, int pad_y)
Definition rct.cc:643
void BLI_rcti_resize(struct rcti *rect, int x, int y)
Definition rct.cc:635
BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
Definition BLI_rect.hh:186
bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b)
Definition rct.cc:200
bool BLI_rctf_isect_y(const rctf *rect, float y)
Definition rct.cc:106
void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size)
Definition rct.cc:480
BLI_INLINE float BLI_rcti_cent_y_fl(const struct rcti *rct)
Definition BLI_rect.hh:182
bool BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2])
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
Definition BLI_rect.hh:194
bool BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2])
void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y)
Definition rct.cc:651
void BLI_rcti_do_minmax_rcti(struct rcti *rect, const struct rcti *other)
void BLI_rcti_recenter(struct rcti *rect, int x, int y)
Definition rct.cc:610
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition rct.cc:418
void BLI_rcti_rctf_copy_floor(struct rcti *dst, const struct rctf *src)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float