78 if (xy[0] < rect->
xmin) {
81 if (xy[0] > rect->
xmax) {
84 if (xy[1] < rect->
ymin) {
87 if (xy[1] > rect->
ymax) {
109 if (
y > rect->
ymax) {
120 if (
x > rect->
xmax) {
126 if (
y > rect->
ymax) {
134 if (xy[0] < rect->
xmin) {
137 if (xy[0] > rect->
xmax) {
140 if (xy[1] < rect->
ymin) {
143 if (xy[1] > rect->
ymax) {
152 return rect->
xmin -
x;
154 if (
x > rect->
xmax) {
155 return x - rect->
xmax;
163 return rect->
ymin -
y;
165 if (
y > rect->
ymax) {
166 return y - rect->
ymax;
174 return rect->
xmin -
x;
176 if (
x > rect->
xmax) {
177 return x - rect->
xmax;
185 return rect->
ymin -
y;
187 if (
y > rect->
ymax) {
188 return y - rect->
ymax;
208 const double div = double((
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]));
213 const double lambda = double((v1[1] - v3[1]) * (v4[0] - v3[0]) -
214 (v1[0] - v3[0]) * (v4[1] - v3[1])) /
216 const double mu = double((v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) /
218 return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
225 const double div = double((
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]));
230 const double lambda = double((v1[1] - v3[1]) * (v4[0] - v3[0]) -
231 (v1[0] - v3[0]) * (v4[1] - v3[1])) /
233 const double mu = double((v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) /
235 return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
241 if (s1[0] < rect->
xmin && s2[0] < rect->
xmin) {
244 if (s1[0] > rect->
xmax && s2[0] > rect->
xmax) {
247 if (s1[1] < rect->
ymin && s2[1] < rect->
ymin) {
250 if (s1[1] > rect->
ymax && s2[1] > rect->
ymax) {
263 tvec1[0] = rect->
xmin;
264 tvec1[1] = rect->
ymin;
265 tvec2[0] = rect->
xmax;
266 tvec2[1] = rect->
ymax;
272 tvec1[0] = rect->
xmin;
273 tvec1[1] = rect->
ymax;
274 tvec2[0] = rect->
xmax;
275 tvec2[1] = rect->
ymin;
287 if (s1[0] < rect->
xmin && s2[0] < rect->
xmin) {
290 if (s1[0] > rect->
xmax && s2[0] > rect->
xmax) {
293 if (s1[1] < rect->
ymin && s2[1] < rect->
ymin) {
296 if (s1[1] > rect->
ymax && s2[1] > rect->
ymax) {
309 tvec1[0] = rect->
xmin;
310 tvec1[1] = rect->
ymin;
311 tvec2[0] = rect->
xmax;
312 tvec2[1] = rect->
ymax;
318 tvec1[0] = rect->
xmin;
319 tvec1[1] = rect->
ymax;
320 tvec2[0] = rect->
xmax;
321 tvec2[1] = rect->
ymin;
334 if (xy[0] >= rect->
xmin && xy[0] <= rect->
xmax) {
338 dx = (xy[0] < rect->
xmin) ? (rect->
xmin - xy[0]) : (xy[0] - rect->
xmax);
341 if (xy[1] >= rect->
ymin && xy[1] <= rect->
ymax) {
345 dy = (xy[1] < rect->
ymin) ? (rect->
ymin - xy[1]) : (xy[1] - rect->
ymax);
348 return dx * dx + dy * dy <= radius * radius;
355 if (xy[0] >= rect->
xmin && xy[0] <= rect->
xmax) {
359 dx = (xy[0] < rect->
xmin) ? (rect->
xmin - xy[0]) : (xy[0] - rect->
xmax);
362 if (xy[1] >= rect->
ymin && xy[1] <= rect->
ymax) {
366 dy = (xy[1] < rect->
ymin) ? (rect->
ymin - xy[1]) : (xy[1] - rect->
ymax);
369 return dx * dx + dy * dy <= radius * radius;
488 if (xy[0] < rect->
xmin) {
491 if (xy[0] > rect->
xmax) {
494 if (xy[1] < rect->
ymin) {
497 if (xy[1] > rect->
ymax) {
512 if (xy[0] < rect->
xmin) {
515 if (xy[0] > rect->
xmax) {
518 if (xy[1] < rect->
ymin) {
521 if (xy[1] > rect->
ymax) {
529 const float xy_src[2])
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]);
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]);
547 matrix[3][
x] = (src->
xmin - dst->
xmin) * matrix[
x][
x];
548 matrix[3][
y] = (src->
ymin - dst->
ymin) * matrix[
y][
y];
562 matrix[2][0] = (src->
xmin - dst->
xmin) * matrix[0][0];
563 matrix[2][1] = (src->
ymin - dst->
ymin) * matrix[1][1];
583 rect->
xmin *= factor;
584 rect->
ymin *= factor;
585 rect->
xmax *= factor;
586 rect->
ymax *= factor;
590 rect->
xmin *= factor;
591 rect->
ymin *= factor;
592 rect->
xmax *= factor;
593 rect->
ymax *= factor;
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;
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;
690 const float boundary_size,
698 float total_pad = pad_max + pad_min;
699 if (total_pad == 0.0f) {
723 float local_pad = local_view_size / (boundary_size - total_pad);
725 rect->
ymax += local_pad * pad_max;
726 rect->
ymin -= local_pad * pad_min;
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);
742 bool changed =
false;
743 if (xy[0] < rect->
xmin) {
747 if (xy[0] > rect->
xmax) {
751 if (xy[1] < rect->
ymin) {
755 if (xy[1] > rect->
ymax) {
764 bool changed =
false;
765 if (xy[0] < rect->
xmin) {
769 if (xy[0] > rect->
xmax) {
773 if (xy[1] < rect->
ymin) {
777 if (xy[1] > rect->
ymax) {
786 bool changed =
false;
791 if (rect->
xmax > rect_bounds->
xmax) {
792 float ofs = rect_bounds->
xmax - rect->
xmax;
799 if (rect->
xmin < rect_bounds->
xmin) {
800 float ofs = rect_bounds->
xmin - rect->
xmin;
807 if (rect->
ymin < rect_bounds->
ymin) {
808 float ofs = rect_bounds->
ymin - rect->
ymin;
815 if (rect->
ymax > rect_bounds->
ymax) {
816 float ofs = rect_bounds->
ymax - rect->
ymax;
828 bool changed =
false;
833 if (rect->
xmax > rect_bounds->
xmax) {
834 int ofs = rect_bounds->
xmax - rect->
xmax;
841 if (rect->
xmin < rect_bounds->
xmin) {
842 int ofs = rect_bounds->
xmin - rect->
xmin;
849 if (rect->
ymin < rect_bounds->
ymin) {
850 int ofs = rect_bounds->
ymin - rect->
ymin;
857 if (rect->
ymax > rect_bounds->
ymax) {
858 int ofs = rect_bounds->
ymax - rect->
ymax;
908 if (xmax >= xmin && ymax >= ymin) {
937 if (xmax >= xmin && ymax >= ymin) {
958 const float xmin = (src1->
xmin) > (src2->
xmin) ? (src1->
xmin) : (src2->
xmin);
959 const float xmax = (src1->
xmax) < (src2->
xmax) ? (src1->
xmax) : (src2->
xmax);
978 const float ymin = (src1->
ymin) > (src2->
ymin) ? (src1->
ymin) : (src2->
ymin);
979 const float ymax = (src1->
ymax) < (src2->
ymax) ? (src1->
ymax) : (src2->
ymax);
1018 const int ymin = (src1->
ymin) > (src2->
ymin) ? (src1->
ymin) : (src2->
ymin);
1019 const int ymax = (src1->
ymax) < (src2->
ymax) ? (src1->
ymax) : (src2->
ymax);
1070 printf(
"%s: xmin %.8f, xmax %.8f, ymin %.8f, ymax %.8f (%.12fx%.12f)\n",
1082 printf(
"%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n",
1098#define ROTATE_SINCOS(r_vec, mat2, vec) \
1100 (r_vec)[0] = (mat2)[1] * (vec)[0] + (+(mat2)[0]) * (vec)[1]; \
1101 (r_vec)[1] = (mat2)[0] * (vec)[0] + (-(mat2)[1]) * (vec)[1]; \
1109 float corner[2], corner_rot[2], corder_max[2];
1112 corner[0] = src->
xmax - cent[0];
1113 corner[1] = src->
ymax - cent[1];
1115 corder_max[0] =
fabsf(corner_rot[0]);
1116 corder_max[1] =
fabsf(corner_rot[1]);
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]));
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];
1137 if (p1_inside && p2_inside) {
1141 const std::array<float2, 2> top_line = {
float2{rect->
xmin, rect->
ymax},
1143 const std::array<float2, 2> bottom_line = {
float2{rect->
xmin, rect->
ymin},
1145 const std::array<float2, 2> left_line = {
float2{rect->
xmin, rect->
ymin},
1147 const std::array<float2, 2> right_line = {
float2{rect->
xmax, rect->
ymin},
1149 const std::array<std::array<float2, 2>, 4> lines = {
1150 top_line, bottom_line, left_line, right_line};
1152 if (p1_inside && !p2_inside) {
1153 for (
const std::array<float2, 2> &line : lines) {
1161 if (!p1_inside && p2_inside) {
1162 for (
const std::array<float2, 2> &line : lines) {
1171 for (
const std::array<float2, 2> &line : lines) {
1180 for (
const std::array<float2, 2> &line : lines) {
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])
bool BLI_rctf_is_empty(const struct rctf *rect)
void BLI_rcti_union(struct rcti *rct_a, const struct rcti *rct_b)
bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2])
void print_rctf(const char *str, const struct rctf *rect)
void BLI_rctf_translate(struct rctf *rect, float x, float y)
bool BLI_rcti_isect_rect_y(const struct rcti *src1, const struct rcti *src2, int range_y[2])
bool BLI_rctf_isect_x(const rctf *rect, float x)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void BLI_rcti_init_minmax(struct rcti *rect)
bool BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b)
bool BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2])
void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b)
bool BLI_rctf_is_valid(const struct rctf *rect)
void BLI_rctf_transform_calc_m3_pivot_min(const rctf *dst, const rctf *src, float matrix[3][3])
void BLI_rctf_resize_y(struct rctf *rect, float y)
int BLI_rcti_length_x(const rcti *rect, int x)
bool BLI_rcti_isect_y(const rcti *rect, int y)
bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2])
void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
void BLI_rcti_mul(struct rcti *rect, int factor)
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])
bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest)
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
bool BLI_rctf_isect_y(const rctf *rect, float y)
bool BLI_rctf_clamp(struct rctf *rect, const struct rctf *rect_bounds, float r_xy[2])
void BLI_rcti_rctf_copy_round(struct rcti *dst, const struct rctf *src)
void BLI_rcti_pad(struct rcti *rect, int pad_x, int pad_y)
bool BLI_rcti_is_valid(const struct rcti *rect)
void BLI_rcti_rctf_copy_floor(struct rcti *dst, const struct rctf *src)
void BLI_rcti_translate(struct rcti *rect, int x, int y)
void BLI_rctf_pad_y(struct rctf *rect, float boundary_size, float pad_min, float pad_max)
int BLI_rcti_length_y(const rcti *rect, int y)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
void BLI_rcti_resize_y(struct rcti *rect, int y)
void BLI_rcti_recenter(struct rcti *rect, int x, int y)
void BLI_rctf_resize_x(struct rctf *rect, float x)
void BLI_rctf_sanitize(struct rctf *rect)
bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y)
void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4])
bool BLI_rctf_clamp_segment(const struct rctf *rect, float s1[2], float s2[2])
void BLI_rctf_scale(rctf *rect, float scale)
void BLI_rcti_resize(struct rcti *rect, int x, int y)
void BLI_rctf_transform_calc_m4_pivot_min_ex(const rctf *dst, const rctf *src, float matrix[4][4], uint x, uint y)
float BLI_rctf_length_x(const rctf *rect, float x)
bool BLI_rctf_isect_rect_y(const struct rctf *src1, const struct rctf *src2, float range_y[2])
bool BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2])
bool BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2])
bool BLI_rctf_isect_rect_x(const struct rctf *src1, const struct rctf *src2, float range_x[2])
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
bool BLI_rctf_isect_circle(const struct rctf *rect, const float xy[2], float radius)
void BLI_rcti_sanitize(struct rcti *rect)
void BLI_rctf_recenter(struct rctf *rect, float x, float y)
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
bool BLI_rcti_isect_x(const rcti *rect, int x)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
bool BLI_rcti_isect_rect_x(const struct rcti *src1, const struct rcti *src2, int range_x[2])
void BLI_rcti_scale(rcti *rect, float scale)
void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y)
bool BLI_rctf_isect_pt(const struct rctf *rect, float x, float y)
BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src)
void BLI_rcti_resize_x(struct rcti *rect, int x)
bool BLI_rcti_isect_circle(const struct rcti *rect, const float xy[2], float radius)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
void BLI_rctf_mul(struct rctf *rect, float factor)
void BLI_rcti_rctf_copy(struct rcti *dst, const struct rctf *src)
void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2])
bool BLI_rcti_is_empty(const struct rcti *rect)
bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b)
void BLI_rctf_interp(struct rctf *rect, const struct rctf *rect_a, const struct rctf *rect_b, float fac)
void BLI_rctf_resize(struct rctf *rect, float x, float y)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
void print_rcti(const char *str, const struct rcti *rect)
bool BLI_rcti_clamp(struct rcti *rect, const struct rcti *rect_bounds, int r_xy[2])
void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, float angle)
void BLI_rctf_init_pt_radius(struct rctf *rect, const float xy[2], float size)
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
void BLI_rcti_do_minmax_rcti(struct rcti *rect, const struct rcti *other)
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit)
float BLI_rctf_length_y(const rctf *rect, float y)
BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
void BLI_rctf_init_minmax(struct rctf *rect)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
#define ROTATE_SINCOS(r_vec, mat2, vec)
static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
static int isect_segments_fl(const float v1[2], const float v2[2], const float v3[2], const float v4[2])