BLI_rect: add init from point functions
Initialize a rectangle from point+size.
This commit is contained in:
parent
2089a17f7e
commit
4a4d71414e
|
@ -47,6 +47,8 @@ bool BLI_rcti_is_empty(const struct rcti *rect);
|
|||
bool BLI_rctf_is_empty(const struct rctf *rect);
|
||||
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax);
|
||||
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax);
|
||||
void BLI_rctf_init_pt_size(struct rctf *rect, const float xy[2], float size);
|
||||
void BLI_rcti_init_pt_size(struct rcti *rect, const int xy[2], int size);
|
||||
void BLI_rcti_init_minmax(struct rcti *rect);
|
||||
void BLI_rctf_init_minmax(struct rctf *rect);
|
||||
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2]);
|
||||
|
|
|
@ -351,6 +351,22 @@ void BLI_rcti_init(rcti *rect, int xmin, int xmax, int ymin, int ymax)
|
|||
}
|
||||
}
|
||||
|
||||
void BLI_rctf_init_pt_size(rctf *rect, const float xy[2], float size)
|
||||
{
|
||||
rect->xmin = xy[0] - size;
|
||||
rect->xmax = xy[0] + size;
|
||||
rect->ymin = xy[1] - size;
|
||||
rect->ymax = xy[1] + size;
|
||||
}
|
||||
|
||||
void BLI_rcti_init_pt_size(rcti *rect, const int xy[2], int size)
|
||||
{
|
||||
rect->xmin = xy[0] - size;
|
||||
rect->xmax = xy[0] + size;
|
||||
rect->ymin = xy[1] - size;
|
||||
rect->ymax = xy[1] + size;
|
||||
}
|
||||
|
||||
void BLI_rcti_init_minmax(rcti *rect)
|
||||
{
|
||||
rect->xmin = rect->ymin = INT_MAX;
|
||||
|
|
|
@ -303,17 +303,11 @@ static EditBone *get_nearest_editbonepoint(
|
|||
ebone_next_act = NULL;
|
||||
}
|
||||
|
||||
rect.xmin = mval[0] - 5;
|
||||
rect.xmax = mval[0] + 5;
|
||||
rect.ymin = mval[1] - 5;
|
||||
rect.ymax = mval[1] + 5;
|
||||
BLI_rcti_init_pt_size(&rect, mval, 5);
|
||||
|
||||
hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, true);
|
||||
if (hits == 0) {
|
||||
rect.xmin = mval[0] - 12;
|
||||
rect.xmax = mval[0] + 12;
|
||||
rect.ymin = mval[1] - 12;
|
||||
rect.ymax = mval[1] + 12;
|
||||
BLI_rcti_init_pt_size(&rect, mval, 12);
|
||||
hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, true);
|
||||
}
|
||||
/* See if there are any selected bones in this group */
|
||||
|
|
|
@ -1907,10 +1907,7 @@ static bool sk_selectStroke(bContext *C, SK_Sketch *sketch, const int mval[2], c
|
|||
|
||||
view3d_set_viewcontext(C, &vc);
|
||||
|
||||
rect.xmin = mval[0] - 5;
|
||||
rect.xmax = mval[0] + 5;
|
||||
rect.ymin = mval[1] - 5;
|
||||
rect.ymax = mval[1] + 5;
|
||||
BLI_rcti_init_pt_size(&rect, mval, 5);
|
||||
|
||||
hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect, true);
|
||||
|
||||
|
|
|
@ -592,10 +592,7 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
|
|||
|
||||
view3d_set_viewcontext(C, &vc);
|
||||
|
||||
rect.xmin = mval[0] - 12;
|
||||
rect.xmax = mval[0] + 12;
|
||||
rect.ymin = mval[1] - 12;
|
||||
rect.ymax = mval[1] + 12;
|
||||
BLI_rcti_init_pt_size(&rect, mval, 12);
|
||||
|
||||
hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect, true);
|
||||
|
||||
|
|
|
@ -1069,12 +1069,9 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so
|
|||
|
||||
/* check if we click in a socket */
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
|
||||
rect.xmin = cursor[0] - (NODE_SOCKSIZE + 4);
|
||||
rect.ymin = cursor[1] - (NODE_SOCKSIZE + 4);
|
||||
rect.xmax = cursor[0] + (NODE_SOCKSIZE + 4);
|
||||
rect.ymax = cursor[1] + (NODE_SOCKSIZE + 4);
|
||||
|
||||
|
||||
BLI_rctf_init_pt_size(&rect, cursor, NODE_SOCKSIZE + 4);
|
||||
|
||||
if (!(node->flag & NODE_HIDDEN)) {
|
||||
/* extra padding inside and out - allow dragging on the text areas too */
|
||||
if (in_out == SOCK_IN) {
|
||||
|
|
|
@ -4887,11 +4887,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg
|
|||
rect.ymax = mval[1] + 1;
|
||||
}
|
||||
else {
|
||||
rect.xmax = mval[0] + margin;
|
||||
rect.ymax = mval[1] + margin;
|
||||
|
||||
rect.xmin = mval[0] - margin;
|
||||
rect.ymin = mval[1] - margin;
|
||||
BLI_rcti_init_pt_size(&rect, mval, margin);
|
||||
}
|
||||
|
||||
view3d_update_depths_rect(ar, &depth_temp, &rect);
|
||||
|
|
|
@ -1184,10 +1184,8 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
|
|||
|
||||
/* case not a border select */
|
||||
if (input->xmin == input->xmax) {
|
||||
rect.xmin = input->xmin - 12; /* seems to be default value for bones only now */
|
||||
rect.xmax = input->xmin + 12;
|
||||
rect.ymin = input->ymin - 12;
|
||||
rect.ymax = input->ymin + 12;
|
||||
/* seems to be default value for bones only now */
|
||||
BLI_rctf_init_pt_size(&rect, (const float[2]){input->xmin, input->ymin}, 12);
|
||||
}
|
||||
else {
|
||||
BLI_rctf_rcti_copy(&rect, input);
|
||||
|
|
Loading…
Reference in New Issue