Blender  V3.3
BLI_rect.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
4 #pragma once
5 
10 #include "BLI_compiler_compat.h"
11 #include "BLI_sys_types.h" /* bool */
12 #include "DNA_vec_types.h"
13 
14 struct rctf;
15 struct rcti;
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
27 bool BLI_rcti_is_empty(const struct rcti *rect);
28 bool BLI_rctf_is_empty(const struct rctf *rect);
29 void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax);
30 void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax);
38 bool BLI_rctf_is_valid(const struct rctf *rect);
39 bool BLI_rcti_is_valid(const struct rcti *rect);
43 void BLI_rctf_sanitize(struct rctf *rect);
44 void BLI_rcti_sanitize(struct rcti *rect);
45 void BLI_rctf_init_pt_radius(struct rctf *rect, const float xy[2], float size);
46 void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size);
47 void BLI_rcti_init_minmax(struct rcti *rect);
48 void BLI_rctf_init_minmax(struct rctf *rect);
49 void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2]);
50 void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]);
51 void BLI_rcti_do_minmax_rcti(struct rcti *rect, const struct rcti *other);
52 
56 void BLI_rctf_transform_pt_v(const rctf *dst,
57  const rctf *src,
58  float xy_dst[2],
59  const float xy_src[2]);
67  const rctf *dst, const rctf *src, float matrix[4][4], uint x, uint y);
68 void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4]);
69 
70 void BLI_rctf_translate(struct rctf *rect, float x, float y);
71 void BLI_rcti_translate(struct rcti *rect, int x, int y);
72 void BLI_rcti_recenter(struct rcti *rect, int x, int y);
73 void BLI_rctf_recenter(struct rctf *rect, float x, float y);
74 void BLI_rcti_resize(struct rcti *rect, int x, int y);
78 void BLI_rcti_resize_x(struct rcti *rect, int x);
82 void BLI_rcti_resize_y(struct rcti *rect, int y);
83 void BLI_rcti_pad(struct rcti *rect, int pad_x, int pad_y);
84 void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y);
85 void BLI_rctf_resize(struct rctf *rect, float x, float y);
86 void BLI_rctf_resize_x(struct rctf *rect, float x);
87 void BLI_rctf_resize_y(struct rctf *rect, float y);
88 void BLI_rcti_scale(rcti *rect, float scale);
89 void BLI_rctf_scale(rctf *rect, float scale);
90 void BLI_rctf_pad_y(struct rctf *rect, float boundary_size, float pad_min, float pad_max);
91 void 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);
96 bool BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2]);
97 bool BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2]);
106 bool BLI_rctf_clamp(struct rctf *rect, const struct rctf *rect_bounds, float r_xy[2]);
107 bool BLI_rcti_clamp(struct rcti *rect, const struct rcti *rect_bounds, int r_xy[2]);
108 bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit);
109 bool BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b);
110 bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest);
111 bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest);
112 bool BLI_rctf_isect_rect_x(const struct rctf *src1, const struct rctf *src2, float range_x[2]);
113 bool BLI_rctf_isect_rect_y(const struct rctf *src1, const struct rctf *src2, float range_y[2]);
114 bool BLI_rcti_isect_rect_x(const struct rcti *src1, const struct rcti *src2, int range_x[2]);
115 bool BLI_rcti_isect_rect_y(const struct rcti *src1, const struct rcti *src2, int range_y[2]);
116 bool BLI_rcti_isect_x(const rcti *rect, int x);
117 bool BLI_rcti_isect_y(const rcti *rect, int y);
118 bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y);
119 bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2]);
120 bool BLI_rctf_isect_x(const rctf *rect, float x);
121 bool BLI_rctf_isect_y(const rctf *rect, float y);
122 bool BLI_rctf_isect_pt(const struct rctf *rect, float x, float y);
123 bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2]);
127 int BLI_rcti_length_x(const rcti *rect, int x);
131 int BLI_rcti_length_y(const rcti *rect, int y);
132 float BLI_rctf_length_x(const rctf *rect, float x);
133 float BLI_rctf_length_y(const rctf *rect, float y);
134 bool BLI_rcti_isect_segment(const struct rcti *rect, const int s1[2], const int s2[2]);
135 bool BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2]);
136 bool BLI_rcti_isect_circle(const struct rcti *rect, const float xy[2], float radius);
137 bool BLI_rctf_isect_circle(const struct rctf *rect, const float xy[2], float radius);
138 bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b);
142 bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b);
143 void BLI_rcti_union(struct rcti *rct_a, const struct rcti *rct_b);
144 void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b);
145 void BLI_rcti_rctf_copy(struct rcti *dst, const struct rctf *src);
146 void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src);
147 void BLI_rcti_rctf_copy_floor(struct rcti *dst, const struct rctf *src);
148 void BLI_rcti_rctf_copy_round(struct rcti *dst, const struct rctf *src);
149 
153 void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, float angle);
154 
155 void print_rctf(const char *str, const struct rctf *rect);
156 void print_rcti(const char *str, const struct rcti *rect);
157 
158 #define print_rctf_id(rect) print_rctf(STRINGIFY(rect), rect)
159 #define print_rcti_id(rect) print_rcti(STRINGIFY(rect), rect)
160 
161 BLI_INLINE float BLI_rcti_cent_x_fl(const struct rcti *rct)
162 {
163  return (float)(rct->xmin + rct->xmax) / 2.0f;
164 }
165 BLI_INLINE float BLI_rcti_cent_y_fl(const struct rcti *rct)
166 {
167  return (float)(rct->ymin + rct->ymax) / 2.0f;
168 }
169 BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
170 {
171  return (rct->xmin + rct->xmax) / 2;
172 }
173 BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
174 {
175  return (rct->ymin + rct->ymax) / 2;
176 }
177 BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
178 {
179  return (rct->xmin + rct->xmax) / 2.0f;
180 }
181 BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
182 {
183  return (rct->ymin + rct->ymax) / 2.0f;
184 }
185 
186 BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
187 {
188  return (rct->xmax - rct->xmin);
189 }
190 BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
191 {
192  return (rct->ymax - rct->ymin);
193 }
194 BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
195 {
196  return (rct->xmax - rct->xmin);
197 }
198 BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
199 {
200  return (rct->ymax - rct->ymin);
201 }
202 
203 #ifdef __cplusplus
204 }
205 #endif
#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.c:566
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.c:92
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition: BLI_rect.h:190
void BLI_rcti_init_minmax(struct rcti *rect)
Definition: rct.c:477
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:161
void BLI_rctf_resize_y(struct rctf *rect, float y)
Definition: rct.c:629
int BLI_rcti_length_x(const rcti *rect, int x)
Definition: rct.c:148
bool BLI_rcti_isect_y(const rcti *rect, int y)
Definition: rct.c:47
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.c:469
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
Definition: BLI_rect.h:181
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.c:529
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:177
bool BLI_rctf_isect_y(const rctf *rect, float y)
Definition: rct.c:103
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.c:607
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.c:559
void BLI_rctf_pad_y(struct rctf *rect, float boundary_size, float pad_min, float pad_max)
Definition: rct.c:667
int BLI_rcti_length_y(const rcti *rect, int y)
Definition: rct.c:159
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
Definition: rct.c:417
void BLI_rcti_resize_y(struct rcti *rect, int y)
Definition: rct.c:593
void BLI_rcti_recenter(struct rcti *rect, int x, int y)
Definition: rct.c:574
void BLI_rctf_resize_x(struct rctf *rect, float x)
Definition: rct.c:623
void BLI_rctf_sanitize(struct rctf *rect)
Definition: rct.c:437
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.c:554
void BLI_rctf_scale(rctf *rect, float scale)
Definition: rct.c:655
void BLI_rcti_resize(struct rcti *rect, int x, int y)
Definition: rct.c:599
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.c:541
float BLI_rctf_length_x(const rctf *rect, float x)
Definition: rct.c:170
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.c:407
bool BLI_rctf_isect_circle(const struct rctf *rect, const float xy[2], float radius)
void BLI_rcti_sanitize(struct rcti *rect)
Definition: rct.c:449
void BLI_rctf_recenter(struct rctf *rect, float x, float y)
Definition: rct.c:580
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.c:36
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition: BLI_rect.h:186
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.c:643
void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y)
Definition: rct.c:615
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:165
BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
Definition: BLI_rect.h:173
void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src)
void BLI_rcti_resize_x(struct rcti *rect, int x)
Definition: rct.c:587
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:194
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
Definition: rct.c:192
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.c:513
bool BLI_rcti_is_empty(const struct rcti *rect)
bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b)
Definition: rct.c:197
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.c:635
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition: BLI_rect.h:198
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.c:1062
void BLI_rctf_init_pt_radius(struct rctf *rect, const float xy[2], float size)
Definition: rct.c:461
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
Definition: rct.c:489
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.c:181
BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
Definition: BLI_rect.h:169
void BLI_rctf_init_minmax(struct rctf *rect)
Definition: rct.c:483
unsigned int uint
Definition: BLI_sys_types.h:67
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
SyclQueue void void * src
SyclQueue void * dest
#define str(s)
float xmax
Definition: DNA_vec_types.h:69
float xmin
Definition: DNA_vec_types.h:69
float ymax
Definition: DNA_vec_types.h:70
float ymin
Definition: DNA_vec_types.h:70
int ymin
Definition: DNA_vec_types.h:64
int ymax
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
int xmax
Definition: DNA_vec_types.h:63
int xy[2]
Definition: wm_draw.c:135