25static void unit_m4(
float m[4][4]);
109 if (y > rect->
ymax) {
120 if (x > rect->
xmax) {
126 if (y > 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]) -
209 (
v2[1] - v1[1]) * (v4[0] - v3[0]));
214 const double lambda = (
double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
215 (v1[0] - v3[0]) * (v4[1] - v3[1])) /
217 const double mu = (
double)((v1[1] - v3[1]) * (
v2[0] - v1[0]) -
218 (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]) -
228 (
v2[1] - v1[1]) * (v4[0] - v3[0]));
233 const double lambda = (
double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
234 (v1[0] - v3[0]) * (v4[1] - v3[1])) /
236 const double mu = (
double)((v1[1] - v3[1]) * (
v2[0] - v1[0]) -
237 (v1[0] - v3[0]) * (
v2[1] - v1[1])) /
239 return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
245 if (s1[0] < rect->
xmin && s2[0] < rect->
xmin) {
248 if (s1[0] > rect->
xmax && s2[0] > rect->
xmax) {
251 if (s1[1] < rect->
ymin && s2[1] < rect->
ymin) {
254 if (s1[1] > rect->
ymax && s2[1] > rect->
ymax) {
267 tvec1[0] = rect->
xmin;
268 tvec1[1] = rect->
ymin;
269 tvec2[0] = rect->
xmax;
270 tvec2[1] = rect->
ymax;
276 tvec1[0] = rect->
xmin;
277 tvec1[1] = rect->
ymax;
278 tvec2[0] = rect->
xmax;
279 tvec2[1] = rect->
ymin;
291 if (s1[0] < rect->
xmin && s2[0] < rect->
xmin) {
294 if (s1[0] > rect->
xmax && s2[0] > rect->
xmax) {
297 if (s1[1] < rect->
ymin && s2[1] < rect->
ymin) {
300 if (s1[1] > rect->
ymax && s2[1] > rect->
ymax) {
313 tvec1[0] = rect->
xmin;
314 tvec1[1] = rect->
ymin;
315 tvec2[0] = rect->
xmax;
316 tvec2[1] = rect->
ymax;
322 tvec1[0] = rect->
xmin;
323 tvec1[1] = rect->
ymax;
324 tvec2[0] = rect->
xmax;
325 tvec2[1] = rect->
ymin;
352 return dx * dx + dy * dy <= radius * radius;
373 return dx * dx + dy * dy <= radius * radius;
533 const float xy_src[2])
535 xy_dst[0] = ((xy_src[0] - src->
xmin) / (src->
xmax - src->
xmin));
536 xy_dst[0] = dst->
xmin + ((dst->
xmax - dst->
xmin) * xy_dst[0]);
538 xy_dst[1] = ((xy_src[1] - src->
ymin) / (src->
ymax - src->
ymin));
539 xy_dst[1] = dst->
ymin + ((dst->
ymax - dst->
ymin) * xy_dst[1]);
551 matrix[3][
x] = (src->
xmin - dst->
xmin) * matrix[x][x];
552 matrix[3][
y] = (src->
ymin - dst->
ymin) * matrix[y][y];
577 rect->
xmin *= factor;
578 rect->
ymin *= factor;
579 rect->
xmax *= factor;
580 rect->
ymax *= factor;
584 rect->
xmin *= factor;
585 rect->
ymin *= factor;
586 rect->
xmax *= factor;
587 rect->
ymax *= factor;
665 rect->
xmin = cent_x - size_x_half;
666 rect->
ymin = cent_y - size_y_half;
667 rect->
xmax = cent_x + size_x_half;
668 rect->
ymax = cent_y + size_y_half;
677 rect->
xmin = cent_x - size_x_half;
678 rect->
ymin = cent_y - size_y_half;
679 rect->
xmax = cent_x + size_x_half;
680 rect->
ymax = cent_y + size_y_half;
684 const float boundary_size,
692 float total_pad = pad_max + pad_min;
693 if (total_pad == 0.0f) {
717 float local_pad = local_view_size / (boundary_size - total_pad);
719 rect->
ymax += local_pad * pad_max;
720 rect->
ymin -= local_pad * pad_min;
725 const float ifac = 1.0f - fac;
726 rect->
xmin = (rect_a->
xmin * ifac) + (rect_b->
xmin * fac);
727 rect->
xmax = (rect_a->
xmax * ifac) + (rect_b->
xmax * fac);
728 rect->
ymin = (rect_a->
ymin * ifac) + (rect_b->
ymin * fac);
729 rect->
ymax = (rect_a->
ymax * ifac) + (rect_b->
ymax * fac);
736 bool changed =
false;
758 bool changed =
false;
780 bool changed =
false;
785 if (rect->
xmax > rect_bounds->
xmax) {
786 float ofs = rect_bounds->
xmax - rect->
xmax;
793 if (rect->
xmin < rect_bounds->
xmin) {
794 float ofs = rect_bounds->
xmin - rect->
xmin;
801 if (rect->
ymin < rect_bounds->
ymin) {
802 float ofs = rect_bounds->
ymin - rect->
ymin;
809 if (rect->
ymax > rect_bounds->
ymax) {
810 float ofs = rect_bounds->
ymax - rect->
ymax;
822 bool changed =
false;
827 if (rect->
xmax > rect_bounds->
xmax) {
828 int ofs = rect_bounds->
xmax - rect->
xmax;
835 if (rect->
xmin < rect_bounds->
xmin) {
836 int ofs = rect_bounds->
xmin - rect->
xmin;
843 if (rect->
ymin < rect_bounds->
ymin) {
844 int ofs = rect_bounds->
ymin - rect->
ymin;
851 if (rect->
ymax > rect_bounds->
ymax) {
852 int ofs = rect_bounds->
ymax - rect->
ymax;
902 if (xmax >= xmin && ymax >= ymin) {
931 if (xmax >= xmin && ymax >= ymin) {
952 const float xmin = (src1->
xmin) > (src2->
xmin) ? (src1->
xmin) : (src2->
xmin);
953 const float xmax = (src1->
xmax) < (src2->
xmax) ? (src1->
xmax) : (src2->
xmax);
972 const float ymin = (src1->
ymin) > (src2->
ymin) ? (src1->
ymin) : (src2->
ymin);
973 const float ymax = (src1->
ymax) < (src2->
ymax) ? (src1->
ymax) : (src2->
ymax);
1012 const int ymin = (src1->
ymin) > (src2->
ymin) ? (src1->
ymin) : (src2->
ymin);
1013 const int ymax = (src1->
ymax) < (src2->
ymax) ? (src1->
ymax) : (src2->
ymax);
1064 printf(
"%s: xmin %.8f, xmax %.8f, ymin %.8f, ymax %.8f (%.12fx%.12f)\n",
1076 printf(
"%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n",
1092#define ROTATE_SINCOS(r_vec, mat2, vec) \
1094 (r_vec)[0] = (mat2)[1] * (vec)[0] + (+(mat2)[0]) * (vec)[1]; \
1095 (r_vec)[1] = (mat2)[0] * (vec)[0] + (-(mat2)[1]) * (vec)[1]; \
1101 const float mat2[2] = {
sinf(angle),
cosf(angle)};
1103 float corner[2], corner_rot[2], corder_max[2];
1106 corner[0] = src->
xmax - cent[0];
1107 corner[1] = src->
ymax - cent[1];
1109 corder_max[0] =
fabsf(corner_rot[0]);
1110 corder_max[1] =
fabsf(corner_rot[1]);
1114 corder_max[0] =
MAX2(corder_max[0],
fabsf(corner_rot[0]));
1115 corder_max[1] =
MAX2(corder_max[1],
fabsf(corner_rot[1]));
1117 dst->
xmin = cent[0] - corder_max[0];
1118 dst->
xmax = cent[0] + corder_max[0];
1119 dst->
ymin = cent[1] - corder_max[1];
1120 dst->
ymax = cent[1] + corder_max[1];
1129 m[0][0] = m[1][1] = m[2][2] = m[3][3] = 1.0f;
1130 m[0][1] = m[0][2] = m[0][3] = 0.0f;
1131 m[1][0] = m[1][2] = m[1][3] = 0.0f;
1132 m[2][0] = m[2][1] = m[2][3] = 0.0f;
1133 m[3][0] = m[3][1] = m[3][2] = 0.0f;
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)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
typedef double(DMatrix)[4][4]
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
#define ROTATE_SINCOS(r_vec, mat2, vec)
bool BLI_rcti_compare(const rcti *rect_a, const rcti *rect_b)
void BLI_rctf_init(rctf *rect, float xmin, float xmax, float ymin, float ymax)
bool BLI_rcti_isect_circle(const rcti *rect, const float xy[2], const float radius)
void BLI_rctf_rcti_copy(rctf *dst, const rcti *src)
void BLI_rcti_init(rcti *rect, int xmin, int xmax, int ymin, int ymax)
void BLI_rctf_init_pt_radius(rctf *rect, const float xy[2], float size)
void BLI_rcti_rctf_copy(rcti *dst, const rctf *src)
bool BLI_rctf_isect_x(const rctf *rect, const float x)
bool BLI_rcti_isect_y(const rcti *rect, const int y)
bool BLI_rctf_isect_y(const rctf *rect, const float y)
bool BLI_rcti_is_empty(const rcti *rect)
bool BLI_rctf_is_valid(const rctf *rect)
bool BLI_rcti_is_valid(const rcti *rect)
void BLI_rctf_resize(rctf *rect, float x, float y)
void BLI_rcti_do_minmax_v(rcti *rect, const int xy[2])
bool BLI_rcti_isect_rect_y(const rcti *src1, const rcti *src2, int range_y[2])
void BLI_rctf_mul(rctf *rect, const float factor)
bool BLI_rctf_is_empty(const rctf *rect)
void print_rctf(const char *str, const rctf *rect)
void BLI_rctf_interp(rctf *rect, const rctf *rect_a, const rctf *rect_b, const float fac)
void BLI_rctf_transform_pt_v(const rctf *dst, const rctf *src, float xy_dst[2], const float xy_src[2])
void BLI_rcti_recenter(rcti *rect, int x, int y)
float BLI_rctf_length_y(const rctf *rect, const float y)
void BLI_rcti_init_minmax(rcti *rect)
void BLI_rcti_init_pt_radius(rcti *rect, const int xy[2], int size)
void BLI_rcti_do_minmax_rcti(rcti *rect, const rcti *other)
bool BLI_rctf_compare(const rctf *rect_a, const rctf *rect_b, const float limit)
void BLI_rcti_mul(rcti *rect, const int factor)
void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, const float angle)
bool BLI_rctf_clamp_pt_v(const rctf *rect, float xy[2])
bool BLI_rctf_isect_rect_x(const rctf *src1, const rctf *src2, float range_x[2])
bool BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
static void unit_m4(float m[4][4])
void BLI_rcti_rctf_copy_floor(rcti *dst, const rctf *src)
int BLI_rcti_length_x(const rcti *rect, const int x)
bool BLI_rctf_isect_rect_y(const rctf *src1, const rctf *src2, float range_y[2])
void BLI_rcti_union(rcti *rct_a, const rcti *rct_b)
bool BLI_rcti_clamp(rcti *rect, const rcti *rect_bounds, int r_xy[2])
void BLI_rcti_resize_x(rcti *rect, int x)
void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4])
void BLI_rctf_init_minmax(rctf *rect)
int BLI_rcti_length_y(const rcti *rect, const int y)
bool BLI_rcti_isect_x(const rcti *rect, const int x)
void BLI_rctf_transform_calc_m4_pivot_min_ex(const rctf *dst, const rctf *src, float matrix[4][4], uint x, uint y)
void BLI_rctf_union(rctf *rct_a, const rctf *rct_b)
void BLI_rcti_scale(rcti *rect, const float scale)
static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
void BLI_rctf_pad(rctf *rect, float pad_x, float pad_y)
void BLI_rctf_do_minmax_v(rctf *rect, const float xy[2])
bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[2])
bool BLI_rcti_isect_rect_x(const rcti *src1, const rcti *src2, int range_x[2])
void BLI_rctf_pad_y(rctf *rect, const float boundary_size, const float pad_min, const float pad_max)
void BLI_rctf_recenter(rctf *rect, float x, float y)
void BLI_rcti_resize_y(rcti *rect, int y)
void BLI_rctf_translate(rctf *rect, float x, float y)
float BLI_rctf_length_x(const rctf *rect, const float x)
bool BLI_rcti_clamp_pt_v(const rcti *rect, int xy[2])
void BLI_rctf_resize_x(rctf *rect, float x)
bool BLI_rctf_clamp(rctf *rect, const rctf *rect_bounds, float r_xy[2])
bool BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
void BLI_rctf_scale(rctf *rect, const float scale)
void BLI_rctf_sanitize(rctf *rect)
bool BLI_rcti_isect_pt_v(const rcti *rect, const int xy[2])
void BLI_rcti_pad(rcti *rect, int pad_x, int pad_y)
void BLI_rcti_rctf_copy_round(rcti *dst, const rctf *src)
bool BLI_rcti_isect_pt(const rcti *rect, const int x, const int y)
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
void print_rcti(const char *str, const rcti *rect)
void BLI_rctf_resize_y(rctf *rect, float y)
static int isect_segments_fl(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b)
bool BLI_rctf_isect_circle(const rctf *rect, const float xy[2], const float radius)
void BLI_rcti_resize(rcti *rect, int x, int y)
bool BLI_rctf_isect_pt(const rctf *rect, const float x, const float y)
void BLI_rcti_translate(rcti *rect, int x, int y)
bool BLI_rctf_isect_pt_v(const rctf *rect, const float xy[2])
bool BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest)
void BLI_rcti_sanitize(rcti *rect)