80 if (xy[0] < rect->
xmin) {
83 if (xy[0] > rect->
xmax) {
86 if (xy[1] < rect->
ymin) {
89 if (xy[1] > rect->
ymax) {
100 if (
x > rect->
xmax) {
111 if (
y > rect->
ymax) {
122 if (
x > rect->
xmax) {
128 if (
y > rect->
ymax) {
136 if (xy[0] < rect->
xmin) {
139 if (xy[0] > rect->
xmax) {
142 if (xy[1] < rect->
ymin) {
145 if (xy[1] > rect->
ymax) {
154 return rect->
xmin -
x;
156 if (
x > rect->
xmax) {
157 return x - rect->
xmax;
165 return rect->
ymin -
y;
167 if (
y > rect->
ymax) {
168 return y - rect->
ymax;
176 return rect->
xmin -
x;
178 if (
x > rect->
xmax) {
179 return x - rect->
xmax;
187 return rect->
ymin -
y;
189 if (
y > rect->
ymax) {
190 return y - rect->
ymax;
210 const double div = double((
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]));
215 const double lambda = double((v1[1] - v3[1]) * (v4[0] - v3[0]) -
216 (v1[0] - v3[0]) * (v4[1] - v3[1])) /
218 const double mu = double((v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) /
220 return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
227 const double div = double((
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]));
232 const double lambda = double((v1[1] - v3[1]) * (v4[0] - v3[0]) -
233 (v1[0] - v3[0]) * (v4[1] - v3[1])) /
235 const double mu = double((v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) /
237 return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
243 if (s1[0] < rect->
xmin && s2[0] < rect->
xmin) {
246 if (s1[0] > rect->
xmax && s2[0] > rect->
xmax) {
249 if (s1[1] < rect->
ymin && s2[1] < rect->
ymin) {
252 if (s1[1] > rect->
ymax && s2[1] > rect->
ymax) {
265 tvec1[0] = rect->
xmin;
266 tvec1[1] = rect->
ymin;
267 tvec2[0] = rect->
xmax;
268 tvec2[1] = rect->
ymax;
274 tvec1[0] = rect->
xmin;
275 tvec1[1] = rect->
ymax;
276 tvec2[0] = rect->
xmax;
277 tvec2[1] = rect->
ymin;
289 if (s1[0] < rect->
xmin && s2[0] < rect->
xmin) {
292 if (s1[0] > rect->
xmax && s2[0] > rect->
xmax) {
295 if (s1[1] < rect->
ymin && s2[1] < rect->
ymin) {
298 if (s1[1] > rect->
ymax && s2[1] > rect->
ymax) {
311 tvec1[0] = rect->
xmin;
312 tvec1[1] = rect->
ymin;
313 tvec2[0] = rect->
xmax;
314 tvec2[1] = rect->
ymax;
320 tvec1[0] = rect->
xmin;
321 tvec1[1] = rect->
ymax;
322 tvec2[0] = rect->
xmax;
323 tvec2[1] = rect->
ymin;
336 if (xy[0] >= rect->
xmin && xy[0] <= rect->
xmax) {
340 dx = (xy[0] < rect->
xmin) ? (rect->
xmin - xy[0]) : (xy[0] - rect->
xmax);
343 if (xy[1] >= rect->
ymin && xy[1] <= rect->
ymax) {
347 dy = (xy[1] < rect->
ymin) ? (rect->
ymin - xy[1]) : (xy[1] - rect->
ymax);
350 return dx * dx + dy * dy <= radius * radius;
357 if (xy[0] >= rect->
xmin && xy[0] <= rect->
xmax) {
361 dx = (xy[0] < rect->
xmin) ? (rect->
xmin - xy[0]) : (xy[0] - rect->
xmax);
364 if (xy[1] >= rect->
ymin && xy[1] <= rect->
ymax) {
368 dy = (xy[1] < rect->
ymin) ? (rect->
ymin - xy[1]) : (xy[1] - rect->
ymax);
371 return dx * dx + dy * dy <= radius * radius;
474 rect->
xmin = xy[0] - size;
475 rect->
xmax = xy[0] + size;
476 rect->
ymin = xy[1] - size;
477 rect->
ymax = xy[1] + size;
482 rect->
xmin = xy[0] - size;
483 rect->
xmax = xy[0] + size;
484 rect->
ymin = xy[1] - size;
485 rect->
ymax = xy[1] + size;
502 if (xy[0] < rect->
xmin) {
505 if (xy[0] > rect->
xmax) {
508 if (xy[1] < rect->
ymin) {
511 if (xy[1] > rect->
ymax) {
526 if (xy[0] < rect->
xmin) {
529 if (xy[0] > rect->
xmax) {
532 if (xy[1] < rect->
ymin) {
535 if (xy[1] > rect->
ymax) {
543 const float xy_src[2])
545 xy_dst[0] = ((xy_src[0] - src->
xmin) / (src->
xmax - src->
xmin));
546 xy_dst[0] = dst->
xmin + ((dst->
xmax - dst->
xmin) * xy_dst[0]);
548 xy_dst[1] = ((xy_src[1] - src->
ymin) / (src->
ymax - src->
ymin));
549 xy_dst[1] = dst->
ymin + ((dst->
ymax - dst->
ymin) * xy_dst[1]);
561 matrix[3][
x] = (src->
xmin - dst->
xmin) * matrix[
x][
x];
562 matrix[3][
y] = (src->
ymin - dst->
ymin) * matrix[
y][
y];
576 matrix[2][0] = (src->
xmin - dst->
xmin) * matrix[0][0];
577 matrix[2][1] = (src->
ymin - dst->
ymin) * matrix[1][1];
597 rect->
xmin *= factor;
598 rect->
ymin *= factor;
599 rect->
xmax *= factor;
600 rect->
ymax *= factor;
604 rect->
xmin *= factor;
605 rect->
ymin *= factor;
606 rect->
xmax *= factor;
607 rect->
ymax *= factor;
685 rect->
xmin = cent_x - size_x_half;
686 rect->
ymin = cent_y - size_y_half;
687 rect->
xmax = cent_x + size_x_half;
688 rect->
ymax = cent_y + size_y_half;
697 rect->
xmin = cent_x - size_x_half;
698 rect->
ymin = cent_y - size_y_half;
699 rect->
xmax = cent_x + size_x_half;
700 rect->
ymax = cent_y + size_y_half;
704 const float boundary_size,
712 float total_pad = pad_max + pad_min;
713 if (total_pad == 0.0f) {
737 float local_pad = local_view_size / (boundary_size - total_pad);
739 rect->
ymax += local_pad * pad_max;
740 rect->
ymin -= local_pad * pad_min;
745 const float ifac = 1.0f - fac;
746 rect->
xmin = (rect_a->
xmin * ifac) + (rect_b->
xmin * fac);
747 rect->
xmax = (rect_a->
xmax * ifac) + (rect_b->
xmax * fac);
748 rect->
ymin = (rect_a->
ymin * ifac) + (rect_b->
ymin * fac);
749 rect->
ymax = (rect_a->
ymax * ifac) + (rect_b->
ymax * fac);
756 bool changed =
false;
757 if (xy[0] < rect->
xmin) {
761 if (xy[0] > rect->
xmax) {
765 if (xy[1] < rect->
ymin) {
769 if (xy[1] > rect->
ymax) {
778 bool changed =
false;
779 if (xy[0] < rect->
xmin) {
783 if (xy[0] > rect->
xmax) {
787 if (xy[1] < rect->
ymin) {
791 if (xy[1] > rect->
ymax) {
800 bool changed =
false;
805 if (rect->
xmax > rect_bounds->
xmax) {
806 float ofs = rect_bounds->
xmax - rect->
xmax;
813 if (rect->
xmin < rect_bounds->
xmin) {
814 float ofs = rect_bounds->
xmin - rect->
xmin;
821 if (rect->
ymin < rect_bounds->
ymin) {
822 float ofs = rect_bounds->
ymin - rect->
ymin;
829 if (rect->
ymax > rect_bounds->
ymax) {
830 float ofs = rect_bounds->
ymax - rect->
ymax;
842 bool changed =
false;
847 if (rect->
xmax > rect_bounds->
xmax) {
848 int ofs = rect_bounds->
xmax - rect->
xmax;
855 if (rect->
xmin < rect_bounds->
xmin) {
856 int ofs = rect_bounds->
xmin - rect->
xmin;
863 if (rect->
ymin < rect_bounds->
ymin) {
864 int ofs = rect_bounds->
ymin - rect->
ymin;
871 if (rect->
ymax > rect_bounds->
ymax) {
872 int ofs = rect_bounds->
ymax - rect->
ymax;
922 if (xmax >= xmin && ymax >= ymin) {
951 if (xmax >= xmin && ymax >= ymin) {
972 const float xmin = (src1->
xmin) > (src2->
xmin) ? (src1->
xmin) : (src2->
xmin);
973 const float xmax = (src1->
xmax) < (src2->
xmax) ? (src1->
xmax) : (src2->
xmax);
992 const float ymin = (src1->
ymin) > (src2->
ymin) ? (src1->
ymin) : (src2->
ymin);
993 const float ymax = (src1->
ymax) < (src2->
ymax) ? (src1->
ymax) : (src2->
ymax);
1012 const int xmin = (src1->
xmin) > (src2->
xmin) ? (src1->
xmin) : (src2->
xmin);
1013 const int xmax = (src1->
xmax) < (src2->
xmax) ? (src1->
xmax) : (src2->
xmax);
1032 const int ymin = (src1->
ymin) > (src2->
ymin) ? (src1->
ymin) : (src2->
ymin);
1033 const int ymax = (src1->
ymax) < (src2->
ymax) ? (src1->
ymax) : (src2->
ymax);
1084 printf(
"%s: xmin %.8f, xmax %.8f, ymin %.8f, ymax %.8f (%.12fx%.12f)\n",
1096 printf(
"%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n",
1112#define ROTATE_SINCOS(r_vec, mat2, vec) \
1114 (r_vec)[0] = (mat2)[1] * (vec)[0] + (+(mat2)[0]) * (vec)[1]; \
1115 (r_vec)[1] = (mat2)[0] * (vec)[0] + (-(mat2)[1]) * (vec)[1]; \
1123 float corner[2], corner_rot[2], corder_max[2];
1126 corner[0] = src->
xmax - cent[0];
1127 corner[1] = src->
ymax - cent[1];
1129 corder_max[0] =
fabsf(corner_rot[0]);
1130 corder_max[1] =
fabsf(corner_rot[1]);
1134 corder_max[0] = std::max(corder_max[0],
fabsf(corner_rot[0]));
1135 corder_max[1] = std::max(corder_max[1],
fabsf(corner_rot[1]));
1137 dst->
xmin = cent[0] - corder_max[0];
1138 dst->
xmax = cent[0] + corder_max[0];
1139 dst->
ymin = cent[1] - corder_max[1];
1140 dst->
ymax = cent[1] + corder_max[1];
1147 const float pivot[2],
1153 const float cent_rot[2] = {cent[0] * cos_a - cent[1] * sin_a, cent[0] * sin_a + cent[1] * cos_a};
1163 if (p1_inside && p2_inside) {
1167 const std::array<float2, 2> top_line = {
float2{rect->
xmin, rect->
ymax},
1169 const std::array<float2, 2> bottom_line = {
float2{rect->
xmin, rect->
ymin},
1171 const std::array<float2, 2> left_line = {
float2{rect->
xmin, rect->
ymin},
1173 const std::array<float2, 2> right_line = {
float2{rect->
xmax, rect->
ymin},
1175 const std::array<std::array<float2, 2>, 4> lines = {
1176 top_line, bottom_line, left_line, right_line};
1178 if (p1_inside && !p2_inside) {
1179 for (
const std::array<float2, 2> &line : lines) {
1187 if (!p1_inside && p2_inside) {
1188 for (
const std::array<float2, 2> &line : lines) {
1197 for (
const std::array<float2, 2> &line : lines) {
1206 for (
const std::array<float2, 2> &line : lines) {
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
float3x3 scale(float3x3 mat, float2 scale)
MINLINE float min_ff(float a, float b)
bool BLI_rcti_is_valid(const struct rcti *rect)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
float BLI_rctf_length_y(const rctf *rect, float y)
bool BLI_rctf_clamp_segment(const struct rctf *rect, float s1[2], float s2[2])
void BLI_rcti_resize_y(struct rcti *rect, int y)
bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2])
bool BLI_rcti_isect_x(const rcti *rect, int x)
void BLI_rctf_recenter(struct rctf *rect, float x, float y)
void BLI_rctf_rotate_expand_around(rctf *dst, const rctf *src, const float pivot[2], float angle)
int BLI_rcti_length_x(const rcti *rect, int x)
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
bool BLI_rcti_isect_rect_y(const struct rcti *src1, const struct rcti *src2, int range_y[2])
MINLINE void copy_v2_v2(float r[2], const float a[2])
bool BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b)
void BLI_rcti_rctf_copy(struct rcti *dst, const struct rctf *src)
bool BLI_rcti_isect_circle(const struct rcti *rect, const float xy[2], float radius)
void BLI_rctf_resize(struct rctf *rect, float x, float y)
void BLI_rcti_init_minmax(struct rcti *rect)
void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2])
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 BLI_rcti_resize_x(struct rcti *rect, int x)
bool BLI_rctf_isect_circle(const struct rctf *rect, const float xy[2], float radius)
static int isect_segments_fl(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
MINLINE int max_ii(int a, int b)
void BLI_rctf_sanitize(struct rctf *rect)
void BLI_rcti_rctf_copy_round(struct rcti *dst, const struct rctf *src)
void BLI_rctf_scale(rctf *rect, float scale)
bool BLI_rcti_clamp(struct rcti *rect, const struct rcti *rect_bounds, int r_xy[2])
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
void BLI_rcti_sanitize(struct rcti *rect)
void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src)
void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, float angle)
bool BLI_rctf_isect_x(const rctf *rect, float x)
bool BLI_rctf_isect_rect_x(const struct rctf *src1, const struct rctf *src2, float range_x[2])
void BLI_rctf_resize_x(struct rctf *rect, float x)
bool BLI_rctf_is_valid(const struct rctf *rect)
void BLI_rctf_transform_calc_m4_pivot_min_ex(const rctf *dst, const rctf *src, float matrix[4][4], uint x, uint y)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void BLI_rctf_init_pt_radius(struct rctf *rect, const float xy[2], float size)
bool BLI_rctf_is_empty(const struct rctf *rect)
void BLI_rctf_mul(struct rctf *rect, float factor)
int BLI_rcti_length_y(const rcti *rect, int y)
static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
VecBase< float, 2 > float2
BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit)
void BLI_rctf_resize_y(struct rctf *rect, float y)
void BLI_rcti_scale(rcti *rect, float scale)
void BLI_rctf_pad_y(struct rctf *rect, float boundary_size, float pad_min, float pad_max)
void BLI_rctf_union_y(struct rctf *rct, float y)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
bool BLI_rctf_isect_pt(const struct rctf *rect, float x, float y)
void BLI_rcti_union(struct rcti *rct_a, const struct rcti *rct_b)
void BLI_rcti_translate(struct rcti *rect, int x, int y)
bool BLI_rcti_isect_y(const rcti *rect, int y)
bool BLI_rctf_clamp(struct rctf *rect, const struct rctf *rect_bounds, float r_xy[2])
void BLI_rctf_transform_calc_m3_pivot_min(const rctf *dst, const rctf *src, float matrix[3][3])
void BLI_rctf_init_minmax(struct rctf *rect)
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
void print_rcti(const char *str, const struct rcti *rect)
void unit_m4(float m[4][4])
void BLI_rctf_union_x(struct rctf *rct, float x)
bool BLI_rcti_is_empty(const struct rcti *rect)
void print_rctf(const char *str, const struct rctf *rect)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b)
bool BLI_rcti_isect_rect_x(const struct rcti *src1, const struct rcti *src2, int range_x[2])
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
float BLI_rctf_length_x(const rctf *rect, float x)
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])
void unit_m3(float m[3][3])
ATTR_WARN_UNUSED_RESULT const BMVert * v2
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
bool BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2])
void BLI_rctf_interp(struct rctf *rect, const struct rctf *rect_a, const struct rctf *rect_b, float fac)
void BLI_rcti_mul(struct rcti *rect, int factor)
MINLINE float max_ff(float a, float b)
bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4])
void BLI_rctf_translate(struct rctf *rect, float x, float y)
bool BLI_rctf_isect_rect_y(const struct rctf *src1, const struct rctf *src2, float range_y[2])
bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2])
bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y)
void BLI_rcti_pad(struct rcti *rect, int pad_x, int pad_y)
void BLI_rcti_resize(struct rcti *rect, int x, int y)
BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b)
bool BLI_rctf_isect_y(const rctf *rect, float y)
void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size)
MINLINE int min_ii(int a, int b)
bool BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2])
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
bool BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2])
void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y)
void BLI_rcti_do_minmax_rcti(struct rcti *rect, const struct rcti *other)
void BLI_rcti_recenter(struct rcti *rect, int x, int y)
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
void BLI_rcti_rctf_copy_floor(struct rcti *dst, const struct rctf *src)
#define ROTATE_SINCOS(r_vec, mat2, vec)