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