Blender V5.0
rct.cc
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
10
11#include <algorithm>
12#include <cfloat>
13#include <climits>
14#include <cmath>
15#include <cstdio>
16#include <cstdlib>
17
18#include "BLI_math_base.h"
19#include "BLI_math_geom.h"
20#include "BLI_math_matrix.h"
21#include "BLI_math_vector.hh"
22#include "BLI_rect.h"
23#include "BLI_utildefines.h"
24
25#include "DNA_vec_types.h"
26
27bool BLI_rcti_is_empty(const rcti *rect)
28{
29 return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin));
30}
31
32bool BLI_rctf_is_empty(const rctf *rect)
33{
34 return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin));
35}
36
37bool BLI_rcti_isect_x(const rcti *rect, const int x)
38{
39 if (x < rect->xmin) {
40 return false;
41 }
42 if (x > rect->xmax) {
43 return false;
44 }
45 return true;
46}
47
48bool BLI_rcti_isect_y(const rcti *rect, const int y)
49{
50 if (y < rect->ymin) {
51 return false;
52 }
53 if (y > rect->ymax) {
54 return false;
55 }
56 return true;
57}
58
59bool BLI_rcti_isect_pt(const rcti *rect, const int x, const int y)
60{
61 if (x < rect->xmin) {
62 return false;
63 }
64 if (x > rect->xmax) {
65 return false;
66 }
67 if (y < rect->ymin) {
68 return false;
69 }
70 if (y > rect->ymax) {
71 return false;
72 }
73 return true;
74}
75
76bool BLI_rcti_isect_pt_v(const rcti *rect, const int xy[2])
77{
78 if (xy[0] < rect->xmin) {
79 return false;
80 }
81 if (xy[0] > rect->xmax) {
82 return false;
83 }
84 if (xy[1] < rect->ymin) {
85 return false;
86 }
87 if (xy[1] > rect->ymax) {
88 return false;
89 }
90 return true;
91}
92
93bool BLI_rctf_isect_x(const rctf *rect, const float x)
94{
95 if (x < rect->xmin) {
96 return false;
97 }
98 if (x > rect->xmax) {
99 return false;
100 }
101 return true;
102}
103
104bool BLI_rctf_isect_y(const rctf *rect, const float y)
105{
106 if (y < rect->ymin) {
107 return false;
108 }
109 if (y > rect->ymax) {
110 return false;
111 }
112 return true;
113}
114
115bool BLI_rctf_isect_pt(const rctf *rect, const float x, const float y)
116{
117 if (x < rect->xmin) {
118 return false;
119 }
120 if (x > rect->xmax) {
121 return false;
122 }
123 if (y < rect->ymin) {
124 return false;
125 }
126 if (y > rect->ymax) {
127 return false;
128 }
129 return true;
130}
131
132bool BLI_rctf_isect_pt_v(const rctf *rect, const float xy[2])
133{
134 if (xy[0] < rect->xmin) {
135 return false;
136 }
137 if (xy[0] > rect->xmax) {
138 return false;
139 }
140 if (xy[1] < rect->ymin) {
141 return false;
142 }
143 if (xy[1] > rect->ymax) {
144 return false;
145 }
146 return true;
147}
148
149int BLI_rcti_length_x(const rcti *rect, const int x)
150{
151 if (x < rect->xmin) {
152 return rect->xmin - x;
153 }
154 if (x > rect->xmax) {
155 return x - rect->xmax;
156 }
157 return 0;
158}
159
160int BLI_rcti_length_y(const rcti *rect, const int y)
161{
162 if (y < rect->ymin) {
163 return rect->ymin - y;
164 }
165 if (y > rect->ymax) {
166 return y - rect->ymax;
167 }
168 return 0;
169}
170
171float BLI_rctf_length_x(const rctf *rect, const float x)
172{
173 if (x < rect->xmin) {
174 return rect->xmin - x;
175 }
176 if (x > rect->xmax) {
177 return x - rect->xmax;
178 }
179 return 0.0f;
180}
181
182float BLI_rctf_length_y(const rctf *rect, const float y)
183{
184 if (y < rect->ymin) {
185 return rect->ymin - y;
186 }
187 if (y > rect->ymax) {
188 return y - rect->ymax;
189 }
190 return 0.0f;
191}
192
193bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
194{
195 return ((rct_a->xmin <= rct_b->xmin) && (rct_a->xmax >= rct_b->xmax) &&
196 (rct_a->ymin <= rct_b->ymin) && (rct_a->ymax >= rct_b->ymax));
197}
198bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b)
199{
200 return ((rct_a->xmin <= rct_b->xmin) && (rct_a->xmax >= rct_b->xmax) &&
201 (rct_a->ymin <= rct_b->ymin) && (rct_a->ymax >= rct_b->ymax));
202}
203
204/* based closely on 'isect_seg_seg_v2_int',
205 * but in modified so corner cases are treated as intersections */
206static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
207{
208 const double div = double((v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]));
209 if (div == 0.0) {
210 return 1; /* co-linear */
211 }
212
213 const double lambda = double((v1[1] - v3[1]) * (v4[0] - v3[0]) -
214 (v1[0] - v3[0]) * (v4[1] - v3[1])) /
215 div;
216 const double mu = double((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) /
217 div;
218 return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
219}
220static int isect_segments_fl(const float v1[2],
221 const float v2[2],
222 const float v3[2],
223 const float v4[2])
224{
225 const double div = double((v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]));
226 if (div == 0.0) {
227 return 1; /* co-linear */
228 }
229
230 const double lambda = double((v1[1] - v3[1]) * (v4[0] - v3[0]) -
231 (v1[0] - v3[0]) * (v4[1] - v3[1])) /
232 div;
233 const double mu = double((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) /
234 div;
235 return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
236}
237
238bool BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
239{
240 /* first do outside-bounds check for both points of the segment */
241 if (s1[0] < rect->xmin && s2[0] < rect->xmin) {
242 return false;
243 }
244 if (s1[0] > rect->xmax && s2[0] > rect->xmax) {
245 return false;
246 }
247 if (s1[1] < rect->ymin && s2[1] < rect->ymin) {
248 return false;
249 }
250 if (s1[1] > rect->ymax && s2[1] > rect->ymax) {
251 return false;
252 }
253
254 /* if either points intersect then we definitely intersect */
255 if (BLI_rcti_isect_pt_v(rect, s1) || BLI_rcti_isect_pt_v(rect, s2)) {
256 return true;
257 }
258
259 /* both points are outside but may intersect the rect */
260 int tvec1[2];
261 int tvec2[2];
262 /* diagonal: [/] */
263 tvec1[0] = rect->xmin;
264 tvec1[1] = rect->ymin;
265 tvec2[0] = rect->xmax;
266 tvec2[1] = rect->ymax;
267 if (isect_segments_i(s1, s2, tvec1, tvec2)) {
268 return true;
269 }
270
271 /* diagonal: [\‍] */
272 tvec1[0] = rect->xmin;
273 tvec1[1] = rect->ymax;
274 tvec2[0] = rect->xmax;
275 tvec2[1] = rect->ymin;
276 if (isect_segments_i(s1, s2, tvec1, tvec2)) {
277 return true;
278 }
279
280 /* no intersection */
281 return false;
282}
283
284bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[2])
285{
286 /* first do outside-bounds check for both points of the segment */
287 if (s1[0] < rect->xmin && s2[0] < rect->xmin) {
288 return false;
289 }
290 if (s1[0] > rect->xmax && s2[0] > rect->xmax) {
291 return false;
292 }
293 if (s1[1] < rect->ymin && s2[1] < rect->ymin) {
294 return false;
295 }
296 if (s1[1] > rect->ymax && s2[1] > rect->ymax) {
297 return false;
298 }
299
300 /* if either points intersect then we definitely intersect */
301 if (BLI_rctf_isect_pt_v(rect, s1) || BLI_rctf_isect_pt_v(rect, s2)) {
302 return true;
303 }
304
305 /* both points are outside but may intersect the rect */
306 float tvec1[2];
307 float tvec2[2];
308 /* diagonal: [/] */
309 tvec1[0] = rect->xmin;
310 tvec1[1] = rect->ymin;
311 tvec2[0] = rect->xmax;
312 tvec2[1] = rect->ymax;
313 if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
314 return true;
315 }
316
317 /* diagonal: [\‍] */
318 tvec1[0] = rect->xmin;
319 tvec1[1] = rect->ymax;
320 tvec2[0] = rect->xmax;
321 tvec2[1] = rect->ymin;
322 if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
323 return true;
324 }
325
326 /* no intersection */
327 return false;
328}
329
330bool BLI_rcti_isect_circle(const rcti *rect, const float xy[2], const float radius)
331{
332 float dx, dy;
333
334 if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) {
335 dx = 0;
336 }
337 else {
338 dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax);
339 }
340
341 if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) {
342 dy = 0;
343 }
344 else {
345 dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax);
346 }
347
348 return dx * dx + dy * dy <= radius * radius;
349}
350
351bool BLI_rctf_isect_circle(const rctf *rect, const float xy[2], const float radius)
352{
353 float dx, dy;
354
355 if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) {
356 dx = 0;
357 }
358 else {
359 dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax);
360 }
361
362 if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) {
363 dy = 0;
364 }
365 else {
366 dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax);
367 }
368
369 return dx * dx + dy * dy <= radius * radius;
370}
371
372void BLI_rctf_union(rctf *rct_a, const rctf *rct_b)
373{
374 if (rct_a->xmin > rct_b->xmin) {
375 rct_a->xmin = rct_b->xmin;
376 }
377 if (rct_a->xmax < rct_b->xmax) {
378 rct_a->xmax = rct_b->xmax;
379 }
380 if (rct_a->ymin > rct_b->ymin) {
381 rct_a->ymin = rct_b->ymin;
382 }
383 if (rct_a->ymax < rct_b->ymax) {
384 rct_a->ymax = rct_b->ymax;
385 }
386}
387
388void BLI_rcti_union(rcti *rct_a, const rcti *rct_b)
389{
390 if (rct_a->xmin > rct_b->xmin) {
391 rct_a->xmin = rct_b->xmin;
392 }
393 if (rct_a->xmax < rct_b->xmax) {
394 rct_a->xmax = rct_b->xmax;
395 }
396 if (rct_a->ymin > rct_b->ymin) {
397 rct_a->ymin = rct_b->ymin;
398 }
399 if (rct_a->ymax < rct_b->ymax) {
400 rct_a->ymax = rct_b->ymax;
401 }
402}
403
404void BLI_rctf_init(rctf *rect, float xmin, float xmax, float ymin, float ymax)
405{
406 rect->xmin = xmin;
407 rect->xmax = xmax;
408 rect->ymin = ymin;
409 rect->ymax = ymax;
410
411 BLI_rctf_sanitize(rect);
412}
413
414void BLI_rcti_init(rcti *rect, int xmin, int xmax, int ymin, int ymax)
415{
416 rect->xmin = xmin;
417 rect->xmax = xmax;
418 rect->ymin = ymin;
419 rect->ymax = ymax;
420
421 BLI_rcti_sanitize(rect);
422}
423
424bool BLI_rctf_is_valid(const rctf *rect)
425{
426 return (rect->xmin <= rect->xmax) && (rect->ymin <= rect->ymax);
427}
428
429bool BLI_rcti_is_valid(const rcti *rect)
430{
431 return (rect->xmin <= rect->xmax) && (rect->ymin <= rect->ymax);
432}
433
435{
436 if (rect->xmin > rect->xmax) {
437 SWAP(float, rect->xmin, rect->xmax);
438 }
439 if (rect->ymin > rect->ymax) {
440 SWAP(float, rect->ymin, rect->ymax);
441 }
442
444}
445
447{
448 if (rect->xmin > rect->xmax) {
449 SWAP(int, rect->xmin, rect->xmax);
450 }
451 if (rect->ymin > rect->ymax) {
452 SWAP(int, rect->ymin, rect->ymax);
453 }
454
456}
457
458void BLI_rctf_init_pt_radius(rctf *rect, const float xy[2], float size)
459{
460 rect->xmin = xy[0] - size;
461 rect->xmax = xy[0] + size;
462 rect->ymin = xy[1] - size;
463 rect->ymax = xy[1] + size;
464}
465
466void BLI_rcti_init_pt_radius(rcti *rect, const int xy[2], int size)
467{
468 rect->xmin = xy[0] - size;
469 rect->xmax = xy[0] + size;
470 rect->ymin = xy[1] - size;
471 rect->ymax = xy[1] + size;
472}
473
475{
476 rect->xmin = rect->ymin = INT_MAX;
477 rect->xmax = rect->ymax = INT_MIN;
478}
479
481{
482 rect->xmin = rect->ymin = FLT_MAX;
483 rect->xmax = rect->ymax = -FLT_MAX;
484}
485
486void BLI_rcti_do_minmax_v(rcti *rect, const int xy[2])
487{
488 if (xy[0] < rect->xmin) {
489 rect->xmin = xy[0];
490 }
491 if (xy[0] > rect->xmax) {
492 rect->xmax = xy[0];
493 }
494 if (xy[1] < rect->ymin) {
495 rect->ymin = xy[1];
496 }
497 if (xy[1] > rect->ymax) {
498 rect->ymax = xy[1];
499 }
500}
501
502void BLI_rcti_do_minmax_rcti(rcti *rect, const rcti *other)
503{
504 rect->xmin = min_ii(rect->xmin, other->xmin);
505 rect->xmax = max_ii(rect->xmax, other->xmax);
506 rect->ymin = min_ii(rect->ymin, other->ymin);
507 rect->ymax = max_ii(rect->ymax, other->ymax);
508}
509
510void BLI_rctf_do_minmax_v(rctf *rect, const float xy[2])
511{
512 if (xy[0] < rect->xmin) {
513 rect->xmin = xy[0];
514 }
515 if (xy[0] > rect->xmax) {
516 rect->xmax = xy[0];
517 }
518 if (xy[1] < rect->ymin) {
519 rect->ymin = xy[1];
520 }
521 if (xy[1] > rect->ymax) {
522 rect->ymax = xy[1];
523 }
524}
525
527 const rctf *src,
528 float xy_dst[2],
529 const float xy_src[2])
530{
531 xy_dst[0] = ((xy_src[0] - src->xmin) / (src->xmax - src->xmin));
532 xy_dst[0] = dst->xmin + ((dst->xmax - dst->xmin) * xy_dst[0]);
533
534 xy_dst[1] = ((xy_src[1] - src->ymin) / (src->ymax - src->ymin));
535 xy_dst[1] = dst->ymin + ((dst->ymax - dst->ymin) * xy_dst[1]);
536}
537
539 const rctf *dst, const rctf *src, float matrix[4][4], uint x, uint y)
540{
541 BLI_assert(x < 3 && y < 3);
542
543 unit_m4(matrix);
544
545 matrix[x][x] = BLI_rctf_size_x(src) / BLI_rctf_size_x(dst);
546 matrix[y][y] = BLI_rctf_size_y(src) / BLI_rctf_size_y(dst);
547 matrix[3][x] = (src->xmin - dst->xmin) * matrix[x][x];
548 matrix[3][y] = (src->ymin - dst->ymin) * matrix[y][y];
549}
550
551void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4])
552{
553 BLI_rctf_transform_calc_m4_pivot_min_ex(dst, src, matrix, 0, 1);
554}
555
556void BLI_rctf_transform_calc_m3_pivot_min(const rctf *dst, const rctf *src, float matrix[3][3])
557{
558 unit_m3(matrix);
559
560 matrix[0][0] = BLI_rctf_size_x(src) / BLI_rctf_size_x(dst);
561 matrix[1][1] = BLI_rctf_size_y(src) / BLI_rctf_size_y(dst);
562 matrix[2][0] = (src->xmin - dst->xmin) * matrix[0][0];
563 matrix[2][1] = (src->ymin - dst->ymin) * matrix[1][1];
564}
565
566void BLI_rcti_translate(rcti *rect, int x, int y)
567{
568 rect->xmin += x;
569 rect->ymin += y;
570 rect->xmax += x;
571 rect->ymax += y;
572}
573void BLI_rctf_translate(rctf *rect, float x, float y)
574{
575 rect->xmin += x;
576 rect->ymin += y;
577 rect->xmax += x;
578 rect->ymax += y;
579}
580
581void BLI_rcti_mul(rcti *rect, const int factor)
582{
583 rect->xmin *= factor;
584 rect->ymin *= factor;
585 rect->xmax *= factor;
586 rect->ymax *= factor;
587}
588void BLI_rctf_mul(rctf *rect, const float factor)
589{
590 rect->xmin *= factor;
591 rect->ymin *= factor;
592 rect->xmax *= factor;
593 rect->ymax *= factor;
594}
595
596void BLI_rcti_recenter(rcti *rect, int x, int y)
597{
598 const int dx = x - BLI_rcti_cent_x(rect);
599 const int dy = y - BLI_rcti_cent_y(rect);
600 BLI_rcti_translate(rect, dx, dy);
601}
602void BLI_rctf_recenter(rctf *rect, float x, float y)
603{
604 const float dx = x - BLI_rctf_cent_x(rect);
605 const float dy = y - BLI_rctf_cent_y(rect);
606 BLI_rctf_translate(rect, dx, dy);
607}
608
609void BLI_rcti_resize_x(rcti *rect, int x)
610{
611 rect->xmin = BLI_rcti_cent_x(rect) - (x / 2);
612 rect->xmax = rect->xmin + x;
613}
614
615void BLI_rcti_resize_y(rcti *rect, int y)
616{
617 rect->ymin = BLI_rcti_cent_y(rect) - (y / 2);
618 rect->ymax = rect->ymin + y;
619}
620
621void BLI_rcti_resize(rcti *rect, int x, int y)
622{
623 rect->xmin = BLI_rcti_cent_x(rect) - (x / 2);
624 rect->ymin = BLI_rcti_cent_y(rect) - (y / 2);
625 rect->xmax = rect->xmin + x;
626 rect->ymax = rect->ymin + y;
627}
628
629void BLI_rcti_pad(rcti *rect, int pad_x, int pad_y)
630{
631 rect->xmin -= pad_x;
632 rect->ymin -= pad_y;
633 rect->xmax += pad_x;
634 rect->ymax += pad_y;
635}
636
637void BLI_rctf_pad(rctf *rect, float pad_x, float pad_y)
638{
639 rect->xmin -= pad_x;
640 rect->ymin -= pad_y;
641 rect->xmax += pad_x;
642 rect->ymax += pad_y;
643}
644
645void BLI_rctf_resize_x(rctf *rect, float x)
646{
647 rect->xmin = BLI_rctf_cent_x(rect) - (x * 0.5f);
648 rect->xmax = rect->xmin + x;
649}
650
651void BLI_rctf_resize_y(rctf *rect, float y)
652{
653 rect->ymin = BLI_rctf_cent_y(rect) - (y * 0.5f);
654 rect->ymax = rect->ymin + y;
655}
656
657void BLI_rctf_resize(rctf *rect, float x, float y)
658{
659 rect->xmin = BLI_rctf_cent_x(rect) - (x * 0.5f);
660 rect->ymin = BLI_rctf_cent_y(rect) - (y * 0.5f);
661 rect->xmax = rect->xmin + x;
662 rect->ymax = rect->ymin + y;
663}
664
665void BLI_rcti_scale(rcti *rect, const float scale)
666{
667 const int cent_x = BLI_rcti_cent_x(rect);
668 const int cent_y = BLI_rcti_cent_y(rect);
669 const int size_x_half = BLI_rcti_size_x(rect) * (scale * 0.5f);
670 const int size_y_half = BLI_rcti_size_y(rect) * (scale * 0.5f);
671 rect->xmin = cent_x - size_x_half;
672 rect->ymin = cent_y - size_y_half;
673 rect->xmax = cent_x + size_x_half;
674 rect->ymax = cent_y + size_y_half;
675}
676
677void BLI_rctf_scale(rctf *rect, const float scale)
678{
679 const float cent_x = BLI_rctf_cent_x(rect);
680 const float cent_y = BLI_rctf_cent_y(rect);
681 const float size_x_half = BLI_rctf_size_x(rect) * (scale * 0.5f);
682 const float size_y_half = BLI_rctf_size_y(rect) * (scale * 0.5f);
683 rect->xmin = cent_x - size_x_half;
684 rect->ymin = cent_y - size_y_half;
685 rect->xmax = cent_x + size_x_half;
686 rect->ymax = cent_y + size_y_half;
687}
688
690 const float boundary_size,
691 const float pad_min,
692 const float pad_max)
693{
694 BLI_assert(pad_max >= 0.0f);
695 BLI_assert(pad_min >= 0.0f);
696 BLI_assert(boundary_size > 0.0f);
697
698 float total_pad = pad_max + pad_min;
699 if (total_pad == 0.0f) {
700 return;
701 }
702
703 /* To get the padding to work as intended, we have to calculate the
704 * new 'rect' y size that has the same ratio between its padding and size
705 * as our screen space ratio (total_pad / boundary_size).
706 *
707 * Here is how the equation was derived:
708 *
709 * ratio = local_pad / new_local_view_size = total_pad / boundary_size
710 * Where, new_local_view_size = local_view_size + local_pad
711 *
712 * ratio = local_pad / (local_view_size + local_pad) ->
713 * ratio * local_view_size + ratio * local_pad = local_pad ->
714 * ratio * local_view_size = local_pad * (1 - ratio) ->
715 * ratio * local_view_size / (1 - ratio) = local_pad ->
716 * total_pad * local_view_size / (boundary_size - total_pad) = local_pad
717 *
718 * We can then remove the first "total_pad" in the equation as we need to
719 * divide pad_(max/min) by "total_pad" when we are calculating the final ymax/ymin.
720 */
721
722 float local_view_size = BLI_rctf_size_y(rect);
723 float local_pad = local_view_size / (boundary_size - total_pad);
724
725 rect->ymax += local_pad * pad_max;
726 rect->ymin -= local_pad * pad_min;
727}
728
729void BLI_rctf_interp(rctf *rect, const rctf *rect_a, const rctf *rect_b, const float fac)
730{
731 const float ifac = 1.0f - fac;
732 rect->xmin = (rect_a->xmin * ifac) + (rect_b->xmin * fac);
733 rect->xmax = (rect_a->xmax * ifac) + (rect_b->xmax * fac);
734 rect->ymin = (rect_a->ymin * ifac) + (rect_b->ymin * fac);
735 rect->ymax = (rect_a->ymax * ifac) + (rect_b->ymax * fac);
736}
737
738/* BLI_rcti_interp() not needed yet */
739
740bool BLI_rctf_clamp_pt_v(const rctf *rect, float xy[2])
741{
742 bool changed = false;
743 if (xy[0] < rect->xmin) {
744 xy[0] = rect->xmin;
745 changed = true;
746 }
747 if (xy[0] > rect->xmax) {
748 xy[0] = rect->xmax;
749 changed = true;
750 }
751 if (xy[1] < rect->ymin) {
752 xy[1] = rect->ymin;
753 changed = true;
754 }
755 if (xy[1] > rect->ymax) {
756 xy[1] = rect->ymax;
757 changed = true;
758 }
759 return changed;
760}
761
762bool BLI_rcti_clamp_pt_v(const rcti *rect, int xy[2])
763{
764 bool changed = false;
765 if (xy[0] < rect->xmin) {
766 xy[0] = rect->xmin;
767 changed = true;
768 }
769 if (xy[0] > rect->xmax) {
770 xy[0] = rect->xmax;
771 changed = true;
772 }
773 if (xy[1] < rect->ymin) {
774 xy[1] = rect->ymin;
775 changed = true;
776 }
777 if (xy[1] > rect->ymax) {
778 xy[1] = rect->ymax;
779 changed = true;
780 }
781 return changed;
782}
783
784bool BLI_rctf_clamp(rctf *rect, const rctf *rect_bounds, float r_xy[2])
785{
786 bool changed = false;
787
788 r_xy[0] = 0.0f;
789 r_xy[1] = 0.0f;
790
791 if (rect->xmax > rect_bounds->xmax) {
792 float ofs = rect_bounds->xmax - rect->xmax;
793 rect->xmin += ofs;
794 rect->xmax += ofs;
795 r_xy[0] += ofs;
796 changed = true;
797 }
798
799 if (rect->xmin < rect_bounds->xmin) {
800 float ofs = rect_bounds->xmin - rect->xmin;
801 rect->xmin += ofs;
802 rect->xmax += ofs;
803 r_xy[0] += ofs;
804 changed = true;
805 }
806
807 if (rect->ymin < rect_bounds->ymin) {
808 float ofs = rect_bounds->ymin - rect->ymin;
809 rect->ymin += ofs;
810 rect->ymax += ofs;
811 r_xy[1] += ofs;
812 changed = true;
813 }
814
815 if (rect->ymax > rect_bounds->ymax) {
816 float ofs = rect_bounds->ymax - rect->ymax;
817 rect->ymin += ofs;
818 rect->ymax += ofs;
819 r_xy[1] += ofs;
820 changed = true;
821 }
822
823 return changed;
824}
825
826bool BLI_rcti_clamp(rcti *rect, const rcti *rect_bounds, int r_xy[2])
827{
828 bool changed = false;
829
830 r_xy[0] = 0;
831 r_xy[1] = 0;
832
833 if (rect->xmax > rect_bounds->xmax) {
834 int ofs = rect_bounds->xmax - rect->xmax;
835 rect->xmin += ofs;
836 rect->xmax += ofs;
837 r_xy[0] += ofs;
838 changed = true;
839 }
840
841 if (rect->xmin < rect_bounds->xmin) {
842 int ofs = rect_bounds->xmin - rect->xmin;
843 rect->xmin += ofs;
844 rect->xmax += ofs;
845 r_xy[0] += ofs;
846 changed = true;
847 }
848
849 if (rect->ymin < rect_bounds->ymin) {
850 int ofs = rect_bounds->ymin - rect->ymin;
851 rect->ymin += ofs;
852 rect->ymax += ofs;
853 r_xy[1] += ofs;
854 changed = true;
855 }
856
857 if (rect->ymax > rect_bounds->ymax) {
858 int ofs = rect_bounds->ymax - rect->ymax;
859 rect->ymin += ofs;
860 rect->ymax += ofs;
861 r_xy[1] += ofs;
862 changed = true;
863 }
864
865 return changed;
866}
867
868bool BLI_rctf_compare(const rctf *rect_a, const rctf *rect_b, const float limit)
869{
870 if (fabsf(rect_a->xmin - rect_b->xmin) <= limit) {
871 if (fabsf(rect_a->xmax - rect_b->xmax) <= limit) {
872 if (fabsf(rect_a->ymin - rect_b->ymin) <= limit) {
873 if (fabsf(rect_a->ymax - rect_b->ymax) <= limit) {
874 return true;
875 }
876 }
877 }
878 }
879
880 return false;
881}
882
883bool BLI_rcti_compare(const rcti *rect_a, const rcti *rect_b)
884{
885 if (rect_a->xmin == rect_b->xmin) {
886 if (rect_a->xmax == rect_b->xmax) {
887 if (rect_a->ymin == rect_b->ymin) {
888 if (rect_a->ymax == rect_b->ymax) {
889 return true;
890 }
891 }
892 }
893 }
894
895 return false;
896}
897
898bool BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest)
899{
900 float xmin, xmax;
901 float ymin, ymax;
902
903 xmin = (src1->xmin) > (src2->xmin) ? (src1->xmin) : (src2->xmin);
904 xmax = (src1->xmax) < (src2->xmax) ? (src1->xmax) : (src2->xmax);
905 ymin = (src1->ymin) > (src2->ymin) ? (src1->ymin) : (src2->ymin);
906 ymax = (src1->ymax) < (src2->ymax) ? (src1->ymax) : (src2->ymax);
907
908 if (xmax >= xmin && ymax >= ymin) {
909 if (dest) {
910 dest->xmin = xmin;
911 dest->xmax = xmax;
912 dest->ymin = ymin;
913 dest->ymax = ymax;
914 }
915 return true;
916 }
917
918 if (dest) {
919 dest->xmin = 0;
920 dest->xmax = 0;
921 dest->ymin = 0;
922 dest->ymax = 0;
923 }
924 return false;
925}
926
927bool BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
928{
929 int xmin, xmax;
930 int ymin, ymax;
931
932 xmin = (src1->xmin) > (src2->xmin) ? (src1->xmin) : (src2->xmin);
933 xmax = (src1->xmax) < (src2->xmax) ? (src1->xmax) : (src2->xmax);
934 ymin = (src1->ymin) > (src2->ymin) ? (src1->ymin) : (src2->ymin);
935 ymax = (src1->ymax) < (src2->ymax) ? (src1->ymax) : (src2->ymax);
936
937 if (xmax >= xmin && ymax >= ymin) {
938 if (dest) {
939 dest->xmin = xmin;
940 dest->xmax = xmax;
941 dest->ymin = ymin;
942 dest->ymax = ymax;
943 }
944 return true;
945 }
946
947 if (dest) {
948 dest->xmin = 0;
949 dest->xmax = 0;
950 dest->ymin = 0;
951 dest->ymax = 0;
952 }
953 return false;
954}
955
956bool BLI_rctf_isect_rect_x(const rctf *src1, const rctf *src2, float range_x[2])
957{
958 const float xmin = (src1->xmin) > (src2->xmin) ? (src1->xmin) : (src2->xmin);
959 const float xmax = (src1->xmax) < (src2->xmax) ? (src1->xmax) : (src2->xmax);
960
961 if (xmax >= xmin) {
962 if (range_x) {
963 range_x[0] = xmin;
964 range_x[1] = xmax;
965 }
966 return true;
967 }
968
969 if (range_x) {
970 range_x[0] = 0;
971 range_x[1] = 0;
972 }
973 return false;
974}
975
976bool BLI_rctf_isect_rect_y(const rctf *src1, const rctf *src2, float range_y[2])
977{
978 const float ymin = (src1->ymin) > (src2->ymin) ? (src1->ymin) : (src2->ymin);
979 const float ymax = (src1->ymax) < (src2->ymax) ? (src1->ymax) : (src2->ymax);
980
981 if (ymax >= ymin) {
982 if (range_y) {
983 range_y[0] = ymin;
984 range_y[1] = ymax;
985 }
986 return true;
987 }
988
989 if (range_y) {
990 range_y[0] = 0;
991 range_y[1] = 0;
992 }
993 return false;
994}
995
996bool BLI_rcti_isect_rect_x(const rcti *src1, const rcti *src2, int range_x[2])
997{
998 const int xmin = (src1->xmin) > (src2->xmin) ? (src1->xmin) : (src2->xmin);
999 const int xmax = (src1->xmax) < (src2->xmax) ? (src1->xmax) : (src2->xmax);
1000
1001 if (xmax >= xmin) {
1002 if (range_x) {
1003 range_x[0] = xmin;
1004 range_x[1] = xmax;
1005 }
1006 return true;
1007 }
1008
1009 if (range_x) {
1010 range_x[0] = 0;
1011 range_x[1] = 0;
1012 }
1013 return false;
1014}
1015
1016bool BLI_rcti_isect_rect_y(const rcti *src1, const rcti *src2, int range_y[2])
1017{
1018 const int ymin = (src1->ymin) > (src2->ymin) ? (src1->ymin) : (src2->ymin);
1019 const int ymax = (src1->ymax) < (src2->ymax) ? (src1->ymax) : (src2->ymax);
1020
1021 if (ymax >= ymin) {
1022 if (range_y) {
1023 range_y[0] = ymin;
1024 range_y[1] = ymax;
1025 }
1026 return true;
1027 }
1028
1029 if (range_y) {
1030 range_y[0] = 0;
1031 range_y[1] = 0;
1032 }
1033 return false;
1034}
1035
1036void BLI_rcti_rctf_copy(rcti *dst, const rctf *src)
1037{
1038 dst->xmin = floorf(src->xmin + 0.5f);
1039 dst->xmax = dst->xmin + floorf(BLI_rctf_size_x(src) + 0.5f);
1040 dst->ymin = floorf(src->ymin + 0.5f);
1041 dst->ymax = dst->ymin + floorf(BLI_rctf_size_y(src) + 0.5f);
1042}
1043
1044void BLI_rcti_rctf_copy_floor(rcti *dst, const rctf *src)
1045{
1046 dst->xmin = floorf(src->xmin);
1047 dst->xmax = floorf(src->xmax);
1048 dst->ymin = floorf(src->ymin);
1049 dst->ymax = floorf(src->ymax);
1050}
1051
1052void BLI_rcti_rctf_copy_round(rcti *dst, const rctf *src)
1053{
1054 dst->xmin = floorf(src->xmin + 0.5f);
1055 dst->xmax = floorf(src->xmax + 0.5f);
1056 dst->ymin = floorf(src->ymin + 0.5f);
1057 dst->ymax = floorf(src->ymax + 0.5f);
1058}
1059
1060void BLI_rctf_rcti_copy(rctf *dst, const rcti *src)
1061{
1062 dst->xmin = src->xmin;
1063 dst->xmax = src->xmax;
1064 dst->ymin = src->ymin;
1065 dst->ymax = src->ymax;
1066}
1067
1068void print_rctf(const char *str, const rctf *rect)
1069{
1070 printf("%s: xmin %.8f, xmax %.8f, ymin %.8f, ymax %.8f (%.12fx%.12f)\n",
1071 str,
1072 rect->xmin,
1073 rect->xmax,
1074 rect->ymin,
1075 rect->ymax,
1076 BLI_rctf_size_x(rect),
1077 BLI_rctf_size_y(rect));
1078}
1079
1080void print_rcti(const char *str, const rcti *rect)
1081{
1082 printf("%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n",
1083 str,
1084 rect->xmin,
1085 rect->xmax,
1086 rect->ymin,
1087 rect->ymax,
1088 BLI_rcti_size_x(rect),
1089 BLI_rcti_size_y(rect));
1090}
1091
1092/* Comprehensive math (float only) */
1093
1094/* -------------------------------------------------------------------- */
1097
1098#define ROTATE_SINCOS(r_vec, mat2, vec) \
1099 { \
1100 (r_vec)[0] = (mat2)[1] * (vec)[0] + (+(mat2)[0]) * (vec)[1]; \
1101 (r_vec)[1] = (mat2)[0] * (vec)[0] + (-(mat2)[1]) * (vec)[1]; \
1102 } \
1103 ((void)0)
1104
1105void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, const float angle)
1106{
1107 const float mat2[2] = {sinf(angle), cosf(angle)};
1108 const float cent[2] = {BLI_rctf_cent_x(src), BLI_rctf_cent_y(src)};
1109 float corner[2], corner_rot[2], corder_max[2];
1110
1111 /* x is same for both corners */
1112 corner[0] = src->xmax - cent[0];
1113 corner[1] = src->ymax - cent[1];
1114 ROTATE_SINCOS(corner_rot, mat2, corner);
1115 corder_max[0] = fabsf(corner_rot[0]);
1116 corder_max[1] = fabsf(corner_rot[1]);
1117
1118 corner[1] *= -1;
1119 ROTATE_SINCOS(corner_rot, mat2, corner);
1120 corder_max[0] = std::max(corder_max[0], fabsf(corner_rot[0]));
1121 corder_max[1] = std::max(corder_max[1], fabsf(corner_rot[1]));
1122
1123 dst->xmin = cent[0] - corder_max[0];
1124 dst->xmax = cent[0] + corder_max[0];
1125 dst->ymin = cent[1] - corder_max[1];
1126 dst->ymax = cent[1] + corder_max[1];
1127}
1128
1129#undef ROTATE_SINCOS
1130
1131bool BLI_rctf_clamp_segment(const rctf *rect, float s1[2], float s2[2])
1132{
1133 using namespace blender;
1134
1135 const bool p1_inside = BLI_rctf_isect_pt_v(rect, s1);
1136 const bool p2_inside = BLI_rctf_isect_pt_v(rect, s2);
1137 if (p1_inside && p2_inside) {
1138 return true;
1139 }
1140
1141 const std::array<float2, 2> top_line = {float2{rect->xmin, rect->ymax},
1142 float2{rect->xmax, rect->ymax}};
1143 const std::array<float2, 2> bottom_line = {float2{rect->xmin, rect->ymin},
1144 float2{rect->xmax, rect->ymin}};
1145 const std::array<float2, 2> left_line = {float2{rect->xmin, rect->ymin},
1146 float2{rect->xmin, rect->ymax}};
1147 const std::array<float2, 2> right_line = {float2{rect->xmax, rect->ymin},
1148 float2{rect->xmax, rect->ymax}};
1149 const std::array<std::array<float2, 2>, 4> lines = {
1150 top_line, bottom_line, left_line, right_line};
1151
1152 if (p1_inside && !p2_inside) {
1153 for (const std::array<float2, 2> &line : lines) {
1154 float2 intersection;
1155 if (isect_seg_seg_v2_point(s1, s2, line[0], line[1], intersection) == 1) {
1156 copy_v2_v2(s2, intersection);
1157 }
1158 }
1159 return true;
1160 }
1161 if (!p1_inside && p2_inside) {
1162 for (const std::array<float2, 2> &line : lines) {
1163 float2 intersection;
1164 if (isect_seg_seg_v2_point(s1, s2, line[0], line[1], intersection) == 1) {
1165 copy_v2_v2(s1, intersection);
1166 }
1167 }
1168 return true;
1169 }
1170
1171 for (const std::array<float2, 2> &line : lines) {
1172 float2 intersection;
1173 if (isect_seg_seg_v2_point(s1, s2, line[0], line[1], intersection) == 1) {
1174 copy_v2_v2(s1, intersection);
1175 }
1176 else {
1177 return false;
1178 }
1179 }
1180 for (const std::array<float2, 2> &line : lines) {
1181 float2 intersection;
1182 if (isect_seg_seg_v2_point(s2, s1, line[0], line[1], intersection) == 1) {
1183 copy_v2_v2(s2, intersection);
1184 }
1185 else {
1186 return false;
1187 }
1188 }
1189
1190 return true;
1191}
1192
#define BLI_assert(a)
Definition BLI_assert.h:46
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
int isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2])
void unit_m3(float m[3][3])
void unit_m4(float m[4][4])
MINLINE void copy_v2_v2(float r[2], const float a[2])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.h:198
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
Definition BLI_rect.h:189
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
Definition BLI_rect.h:185
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.h:194
BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
Definition BLI_rect.h:181
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.h:202
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.h:206
BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
Definition BLI_rect.h:177
unsigned int uint
#define SWAP(type, a, b)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Definition IK_Math.h:117
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
#define str(s)
#define printf(...)
#define floorf
#define fabsf
#define sinf
#define cosf
#define ROTATE_SINCOS(r_vec, mat2, vec)
Definition rct.cc:1098
bool BLI_rcti_compare(const rcti *rect_a, const rcti *rect_b)
Definition rct.cc:883
void BLI_rctf_init(rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition rct.cc:404
bool BLI_rcti_isect_circle(const rcti *rect, const float xy[2], const float radius)
Definition rct.cc:330
void BLI_rctf_rcti_copy(rctf *dst, const rcti *src)
Definition rct.cc:1060
void BLI_rcti_init(rcti *rect, int xmin, int xmax, int ymin, int ymax)
Definition rct.cc:414
void BLI_rctf_init_pt_radius(rctf *rect, const float xy[2], float size)
Definition rct.cc:458
void BLI_rcti_rctf_copy(rcti *dst, const rctf *src)
Definition rct.cc:1036
bool BLI_rctf_isect_x(const rctf *rect, const float x)
Definition rct.cc:93
bool BLI_rcti_isect_y(const rcti *rect, const int y)
Definition rct.cc:48
void BLI_rctf_transform_calc_m3_pivot_min(const rctf *dst, const rctf *src, float matrix[3][3])
Definition rct.cc:556
bool BLI_rctf_isect_y(const rctf *rect, const float y)
Definition rct.cc:104
bool BLI_rcti_is_empty(const rcti *rect)
Definition rct.cc:27
bool BLI_rctf_is_valid(const rctf *rect)
Definition rct.cc:424
bool BLI_rcti_is_valid(const rcti *rect)
Definition rct.cc:429
void BLI_rctf_resize(rctf *rect, float x, float y)
Definition rct.cc:657
void BLI_rcti_do_minmax_v(rcti *rect, const int xy[2])
Definition rct.cc:486
bool BLI_rcti_isect_rect_y(const rcti *src1, const rcti *src2, int range_y[2])
Definition rct.cc:1016
void BLI_rctf_mul(rctf *rect, const float factor)
Definition rct.cc:588
bool BLI_rctf_is_empty(const rctf *rect)
Definition rct.cc:32
void print_rctf(const char *str, const rctf *rect)
Definition rct.cc:1068
void BLI_rctf_interp(rctf *rect, const rctf *rect_a, const rctf *rect_b, const float fac)
Definition rct.cc:729
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
void BLI_rcti_recenter(rcti *rect, int x, int y)
Definition rct.cc:596
float BLI_rctf_length_y(const rctf *rect, const float y)
Definition rct.cc:182
void BLI_rcti_init_minmax(rcti *rect)
Definition rct.cc:474
void BLI_rcti_init_pt_radius(rcti *rect, const int xy[2], int size)
Definition rct.cc:466
void BLI_rcti_do_minmax_rcti(rcti *rect, const rcti *other)
Definition rct.cc:502
bool BLI_rctf_compare(const rctf *rect_a, const rctf *rect_b, const float limit)
Definition rct.cc:868
void BLI_rcti_mul(rcti *rect, const int factor)
Definition rct.cc:581
void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, const float angle)
Definition rct.cc:1105
bool BLI_rctf_clamp_pt_v(const rctf *rect, float xy[2])
Definition rct.cc:740
bool BLI_rctf_isect_rect_x(const rctf *src1, const rctf *src2, float range_x[2])
Definition rct.cc:956
bool BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
Definition rct.cc:927
void BLI_rcti_rctf_copy_floor(rcti *dst, const rctf *src)
Definition rct.cc:1044
int BLI_rcti_length_x(const rcti *rect, const int x)
Definition rct.cc:149
bool BLI_rctf_isect_rect_y(const rctf *src1, const rctf *src2, float range_y[2])
Definition rct.cc:976
void BLI_rcti_union(rcti *rct_a, const rcti *rct_b)
Definition rct.cc:388
bool BLI_rcti_clamp(rcti *rect, const rcti *rect_bounds, int r_xy[2])
Definition rct.cc:826
void BLI_rcti_resize_x(rcti *rect, int x)
Definition rct.cc:609
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 rctf *rect, float s1[2], float s2[2])
Definition rct.cc:1131
void BLI_rctf_init_minmax(rctf *rect)
Definition rct.cc:480
int BLI_rcti_length_y(const rcti *rect, const int y)
Definition rct.cc:160
bool BLI_rcti_isect_x(const rcti *rect, const int x)
Definition rct.cc:37
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
void BLI_rctf_union(rctf *rct_a, const rctf *rct_b)
Definition rct.cc:372
void BLI_rcti_scale(rcti *rect, const float scale)
Definition rct.cc:665
static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
Definition rct.cc:206
void BLI_rctf_pad(rctf *rect, float pad_x, float pad_y)
Definition rct.cc:637
void BLI_rctf_do_minmax_v(rctf *rect, const float xy[2])
Definition rct.cc:510
bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[2])
Definition rct.cc:284
bool BLI_rcti_isect_rect_x(const rcti *src1, const rcti *src2, int range_x[2])
Definition rct.cc:996
void BLI_rctf_pad_y(rctf *rect, const float boundary_size, const float pad_min, const float pad_max)
Definition rct.cc:689
void BLI_rctf_recenter(rctf *rect, float x, float y)
Definition rct.cc:602
void BLI_rcti_resize_y(rcti *rect, int y)
Definition rct.cc:615
void BLI_rctf_translate(rctf *rect, float x, float y)
Definition rct.cc:573
float BLI_rctf_length_x(const rctf *rect, const float x)
Definition rct.cc:171
bool BLI_rcti_clamp_pt_v(const rcti *rect, int xy[2])
Definition rct.cc:762
void BLI_rctf_resize_x(rctf *rect, float x)
Definition rct.cc:645
bool BLI_rctf_clamp(rctf *rect, const rctf *rect_bounds, float r_xy[2])
Definition rct.cc:784
bool BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
Definition rct.cc:238
void BLI_rctf_scale(rctf *rect, const float scale)
Definition rct.cc:677
void BLI_rctf_sanitize(rctf *rect)
Definition rct.cc:434
bool BLI_rcti_isect_pt_v(const rcti *rect, const int xy[2])
Definition rct.cc:76
void BLI_rcti_pad(rcti *rect, int pad_x, int pad_y)
Definition rct.cc:629
void BLI_rcti_rctf_copy_round(rcti *dst, const rctf *src)
Definition rct.cc:1052
bool BLI_rcti_isect_pt(const rcti *rect, const int x, const int y)
Definition rct.cc:59
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
Definition rct.cc:193
void print_rcti(const char *str, const rcti *rect)
Definition rct.cc:1080
void BLI_rctf_resize_y(rctf *rect, float y)
Definition rct.cc:651
static int isect_segments_fl(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
Definition rct.cc:220
bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b)
Definition rct.cc:198
bool BLI_rctf_isect_circle(const rctf *rect, const float xy[2], const float radius)
Definition rct.cc:351
void BLI_rcti_resize(rcti *rect, int x, int y)
Definition rct.cc:621
bool BLI_rctf_isect_pt(const rctf *rect, const float x, const float y)
Definition rct.cc:115
void BLI_rcti_translate(rcti *rect, int x, int y)
Definition rct.cc:566
bool BLI_rctf_isect_pt_v(const rctf *rect, const float xy[2])
Definition rct.cc:132
bool BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest)
Definition rct.cc:898
void BLI_rcti_sanitize(rcti *rect)
Definition rct.cc:446
#define FLT_MAX
Definition stdcycles.h:14
float xmax
float xmin
float ymax
float ymin
int ymin
int ymax
int xmin
int xmax
int xy[2]
Definition wm_draw.cc:178