minor refactor for rect functions. more consistent naming.
This commit is contained in:
@@ -403,9 +403,9 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
|
||||
* as optimal as it could be, but checking pixels against faces they will never intersect
|
||||
* with is likely the greater slowdown here - so check if the cell intersects the face */
|
||||
if (layer_bucket_isect_test(layer, face_index,
|
||||
xi, yi,
|
||||
bucket_size_x, bucket_size_y,
|
||||
bucket_max_rad_squared))
|
||||
xi, yi,
|
||||
bucket_size_x, bucket_size_y,
|
||||
bucket_max_rad_squared))
|
||||
{
|
||||
BLI_linklist_prepend_arena(&bucketstore[bucket_index], face_index_void, arena);
|
||||
bucketstore_tot[bucket_index]++;
|
||||
@@ -805,7 +805,7 @@ void BLI_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
|
||||
{
|
||||
MaskRasterLayer *layer = &mr_handle->layers[masklay_index];
|
||||
|
||||
if (BLI_isect_rctf(&default_bounds, &bounds, &bounds)) {
|
||||
if (BLI_rctf_isect(&default_bounds, &bounds, &bounds)) {
|
||||
layer->face_tot = sf_tri_tot + tot_feather_quads;
|
||||
layer->face_coords = face_coords;
|
||||
layer->face_array = face_array;
|
||||
@@ -813,7 +813,7 @@ void BLI_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
|
||||
|
||||
layer_bucket_init(layer, pixel_size);
|
||||
|
||||
BLI_union_rctf(&mr_handle->bounds, &bounds);
|
||||
BLI_rctf_union(&mr_handle->bounds, &bounds);
|
||||
}
|
||||
else {
|
||||
MEM_freeN(face_coords);
|
||||
|
||||
@@ -49,23 +49,23 @@ void BLI_rctf_init_minmax(struct rctf *rect);
|
||||
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2]);
|
||||
void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]);
|
||||
|
||||
void BLI_translate_rctf(struct rctf *rect, float x, float y);
|
||||
void BLI_translate_rcti(struct rcti *rect, int x, int y);
|
||||
void BLI_resize_rcti(struct rcti *rect, int x, int y);
|
||||
void BLI_resize_rctf(struct rctf *rect, float x, float y);
|
||||
void BLI_rctf_translate(struct rctf *rect, float x, float y);
|
||||
void BLI_rcti_translate(struct rcti *rect, int x, int y);
|
||||
void BLI_rcti_resize(struct rcti *rect, int x, int y);
|
||||
void BLI_rctf_resize(struct rctf *rect, float x, float y);
|
||||
int BLI_in_rcti(const struct rcti *rect, const int x, const int y);
|
||||
int BLI_in_rcti_v(const struct rcti *rect, const int xy[2]);
|
||||
int BLI_in_rctf(const struct rctf *rect, const float x, const float y);
|
||||
int BLI_in_rctf_v(const struct rctf *rect, const float xy[2]);
|
||||
int BLI_segment_in_rcti(const struct rcti *rect, const int s1[2], const int s2[2]);
|
||||
int BLI_rcti_isect_segment(const struct rcti *rect, const int s1[2], const int s2[2]);
|
||||
#if 0 /* NOT NEEDED YET */
|
||||
int BLI_segment_in_rctf(struct rcti *rect, int s1[2], int s2[2]);
|
||||
int BLI_rctf_isect_segment(struct rcti *rect, int s1[2], int s2[2]);
|
||||
#endif
|
||||
int BLI_isect_rctf(const struct rctf *src1, const struct rctf *src2, struct rctf *dest);
|
||||
int BLI_isect_rcti(const struct rcti *src1, const struct rcti *src2, struct rcti *dest);
|
||||
void BLI_union_rctf(struct rctf *rctf1, const struct rctf *rctf2);
|
||||
void BLI_union_rcti(struct rcti *rcti1, const struct rcti *rcti2);
|
||||
void BLI_copy_rcti_rctf(struct rcti *tar, const struct rctf *src);
|
||||
int BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest);
|
||||
int BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest);
|
||||
void BLI_rctf_union(struct rctf *rctf1, const struct rctf *rctf2);
|
||||
void BLI_rcti_union(struct rcti *rcti1, const struct rcti *rcti2);
|
||||
void BLI_rcti_rctf_copy(struct rcti *tar, const struct rctf *src);
|
||||
|
||||
void print_rctf(const char *str, const struct rctf *rect);
|
||||
void print_rcti(const char *str, const struct rcti *rect);
|
||||
|
||||
@@ -115,7 +115,7 @@ static int isect_segments(const int v1[2], const int v2[2], const int v3[2], con
|
||||
}
|
||||
}
|
||||
|
||||
int BLI_segment_in_rcti(const rcti *rect, const int s1[2], const int s2[2])
|
||||
int BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
|
||||
{
|
||||
/* first do outside-bounds check for both points of the segment */
|
||||
if (s1[0] < rect->xmin && s2[0] < rect->xmin) return 0;
|
||||
@@ -150,7 +150,7 @@ int BLI_segment_in_rcti(const rcti *rect, const int s1[2], const int s2[2])
|
||||
}
|
||||
}
|
||||
|
||||
void BLI_union_rctf(rctf *rct1, const rctf *rct2)
|
||||
void BLI_rctf_union(rctf *rct1, const rctf *rct2)
|
||||
{
|
||||
if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin;
|
||||
if (rct1->xmax < rct2->xmax) rct1->xmax = rct2->xmax;
|
||||
@@ -158,7 +158,7 @@ void BLI_union_rctf(rctf *rct1, const rctf *rct2)
|
||||
if (rct1->ymax < rct2->ymax) rct1->ymax = rct2->ymax;
|
||||
}
|
||||
|
||||
void BLI_union_rcti(rcti *rct1, const rcti *rct2)
|
||||
void BLI_rcti_union(rcti *rct1, const rcti *rct2)
|
||||
{
|
||||
if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin;
|
||||
if (rct1->xmax < rct2->xmax) rct1->xmax = rct2->xmax;
|
||||
@@ -234,14 +234,14 @@ void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2])
|
||||
if (xy[1] > rect->ymax) rect->ymax = xy[1];
|
||||
}
|
||||
|
||||
void BLI_translate_rcti(rcti *rect, int x, int y)
|
||||
void BLI_rcti_translate(rcti *rect, int x, int y)
|
||||
{
|
||||
rect->xmin += x;
|
||||
rect->ymin += y;
|
||||
rect->xmax += x;
|
||||
rect->ymax += y;
|
||||
}
|
||||
void BLI_translate_rctf(rctf *rect, float x, float y)
|
||||
void BLI_rctf_translate(rctf *rect, float x, float y)
|
||||
{
|
||||
rect->xmin += x;
|
||||
rect->ymin += y;
|
||||
@@ -250,7 +250,7 @@ void BLI_translate_rctf(rctf *rect, float x, float y)
|
||||
}
|
||||
|
||||
/* change width & height around the central location */
|
||||
void BLI_resize_rcti(rcti *rect, int x, int y)
|
||||
void BLI_rcti_resize(rcti *rect, int x, int y)
|
||||
{
|
||||
rect->xmin = rect->xmax = (rect->xmax + rect->xmin) / 2;
|
||||
rect->ymin = rect->ymax = (rect->ymax + rect->ymin) / 2;
|
||||
@@ -260,7 +260,7 @@ void BLI_resize_rcti(rcti *rect, int x, int y)
|
||||
rect->ymax = rect->ymin + y;
|
||||
}
|
||||
|
||||
void BLI_resize_rctf(rctf *rect, float x, float y)
|
||||
void BLI_rctf_resize(rctf *rect, float x, float y)
|
||||
{
|
||||
rect->xmin = rect->xmax = (rect->xmax + rect->xmin) * 0.5f;
|
||||
rect->ymin = rect->ymax = (rect->ymax + rect->ymin) * 0.5f;
|
||||
@@ -270,7 +270,7 @@ void BLI_resize_rctf(rctf *rect, float x, float y)
|
||||
rect->ymax = rect->ymin + y;
|
||||
}
|
||||
|
||||
int BLI_isect_rctf(const rctf *src1, const rctf *src2, rctf *dest)
|
||||
int BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest)
|
||||
{
|
||||
float xmin, xmax;
|
||||
float ymin, ymax;
|
||||
@@ -300,7 +300,7 @@ int BLI_isect_rctf(const rctf *src1, const rctf *src2, rctf *dest)
|
||||
}
|
||||
}
|
||||
|
||||
int BLI_isect_rcti(const rcti *src1, const rcti *src2, rcti *dest)
|
||||
int BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
|
||||
{
|
||||
int xmin, xmax;
|
||||
int ymin, ymax;
|
||||
@@ -330,7 +330,7 @@ int BLI_isect_rcti(const rcti *src1, const rcti *src2, rcti *dest)
|
||||
}
|
||||
}
|
||||
|
||||
void BLI_copy_rcti_rctf(rcti *tar, const rctf *src)
|
||||
void BLI_rcti_rctf_copy(rcti *tar, const rctf *src)
|
||||
{
|
||||
tar->xmin = floorf(src->xmin + 0.5f);
|
||||
tar->xmax = floorf((src->xmax - src->xmin) + 0.5f);
|
||||
|
||||
@@ -247,7 +247,7 @@ void *KeyingScreenOperation::initializeTileData(rcti *rect)
|
||||
tile_data = (TileData *) MEM_callocN(sizeof(TileData), "keying screen tile data");
|
||||
|
||||
for (i = 0; i < triangulation->triangles_total; i++) {
|
||||
bool ok = BLI_isect_rctf(&rect_float, &triangulation->triangles_AABB[i], NULL);
|
||||
bool ok = BLI_rctf_isect(&rect_float, &triangulation->triangles_AABB[i], NULL);
|
||||
|
||||
if (ok) {
|
||||
tile_data->triangles_total++;
|
||||
|
||||
@@ -769,7 +769,7 @@ void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, short only3d)
|
||||
if ((rv3d->persp == RV3D_CAMOB) && !(G.f & G_RENDER_OGL)) {
|
||||
rctf rectf;
|
||||
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &rectf, TRUE); /* no shift */
|
||||
BLI_copy_rcti_rctf(&rect, &rectf);
|
||||
BLI_rcti_rctf_copy(&rect, &rectf);
|
||||
}
|
||||
else {
|
||||
rect.xmin = 0;
|
||||
|
||||
@@ -1353,7 +1353,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
|
||||
scissor_new.ymin = ar->winrct.ymin + rect->ymin;
|
||||
scissor_new.xmax = ar->winrct.xmin + rect->xmax;
|
||||
scissor_new.ymax = ar->winrct.ymin + rect->ymax;
|
||||
BLI_isect_rcti(&scissor_new, &ar->winrct, &scissor_new);
|
||||
BLI_rcti_isect(&scissor_new, &ar->winrct, &scissor_new);
|
||||
glScissor(scissor_new.xmin, scissor_new.ymin, scissor_new.xmax - scissor_new.xmin, scissor_new.ymax - scissor_new.ymin);
|
||||
|
||||
/* calculate offset and zoom */
|
||||
|
||||
@@ -403,7 +403,7 @@ void region_scissor_winrct(ARegion *ar, rcti *winrct)
|
||||
while (ar->prev) {
|
||||
ar = ar->prev;
|
||||
|
||||
if (BLI_isect_rcti(winrct, &ar->winrct, NULL)) {
|
||||
if (BLI_rcti_isect(winrct, &ar->winrct, NULL)) {
|
||||
if (ar->flag & RGN_FLAG_HIDDEN) ;
|
||||
else if (ar->alignment & RGN_SPLIT_PREV) ;
|
||||
else if (ar->alignment == RGN_OVERLAP_LEFT) {
|
||||
|
||||
@@ -827,7 +827,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
/* adds window to WM */
|
||||
rect = sa->totrct;
|
||||
BLI_translate_rcti(&rect, win->posx, win->posy);
|
||||
BLI_rcti_translate(&rect, win->posx, win->posy);
|
||||
newwin = WM_window_open(C, &rect);
|
||||
|
||||
/* allocs new screen and adds to newly created window, using window size */
|
||||
|
||||
@@ -369,7 +369,7 @@ static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
|
||||
ss = ob->sculpt;
|
||||
if (ss->cache) {
|
||||
if (!BLI_rcti_is_empty(&ss->cache->previous_r))
|
||||
BLI_union_rcti(rect, &ss->cache->previous_r);
|
||||
BLI_rcti_union(rect, &ss->cache->previous_r);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -248,7 +248,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
rect.xmax = RNA_int_get(op->ptr, "xmax");
|
||||
rect.ymax = RNA_int_get(op->ptr, "ymax");
|
||||
|
||||
BLI_isect_rcti(&(ar->v2d.mask), &rect, &rect);
|
||||
BLI_rcti_isect(&(ar->v2d.mask), &rect, &rect);
|
||||
|
||||
sel = file_selection_get(C, &rect, 0);
|
||||
if ( (sel.first != params->sel_first) || (sel.last != params->sel_last) ) {
|
||||
@@ -288,7 +288,7 @@ static int file_border_select_exec(bContext *C, wmOperator *op)
|
||||
file_deselect_all(sfile, SELECTED_FILE);
|
||||
}
|
||||
|
||||
BLI_isect_rcti(&(ar->v2d.mask), &rect, &rect);
|
||||
BLI_rcti_isect(&(ar->v2d.mask), &rect, &rect);
|
||||
|
||||
ret = file_select(C, &rect, select ? FILE_SEL_ADD : FILE_SEL_REMOVE, 0);
|
||||
if (FILE_SELECT_DIR == ret) {
|
||||
|
||||
@@ -280,7 +280,7 @@ static void preview_cb(struct ScrArea *sa, struct uiBlock *block)
|
||||
ui_graphics_to_window_rct(sa->win, &dispf, disprect);
|
||||
|
||||
/* correction for gla draw */
|
||||
BLI_translate_rcti(disprect, -curarea->winrct.xmin, -curarea->winrct.ymin);
|
||||
BLI_rcti_translate(disprect, -curarea->winrct.xmin, -curarea->winrct.ymin);
|
||||
|
||||
calc_image_view(sima, 'p');
|
||||
// printf("winrct %d %d %d %d\n", disprect->xmin, disprect->ymin,disprect->xmax, disprect->ymax);
|
||||
|
||||
@@ -523,7 +523,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
|
||||
counter = 0;
|
||||
}
|
||||
else
|
||||
BLI_union_rctf(rect, &node->totr);
|
||||
BLI_rctf_union(rect, &node->totr);
|
||||
}
|
||||
|
||||
/* add some room for links to group sockets */
|
||||
@@ -954,7 +954,7 @@ static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode
|
||||
data->flag &= ~NODE_FRAME_RESIZEABLE;
|
||||
}
|
||||
else
|
||||
BLI_union_rctf(&rect, &noderect);
|
||||
BLI_rctf_union(&rect, &noderect);
|
||||
}
|
||||
|
||||
/* now adjust the frame size from view-space bounding box */
|
||||
|
||||
@@ -1521,7 +1521,7 @@ static bNode *visible_node(SpaceNode *snode, rctf *rct)
|
||||
bNode *node;
|
||||
|
||||
for (node = snode->edittree->nodes.last; node; node = node->prev) {
|
||||
if (BLI_isect_rctf(&node->totr, rct, NULL))
|
||||
if (BLI_rctf_isect(&node->totr, rct, NULL))
|
||||
break;
|
||||
}
|
||||
return node;
|
||||
|
||||
@@ -474,7 +474,7 @@ static int node_borderselect_exec(bContext *C, wmOperator *op)
|
||||
UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
|
||||
|
||||
for (node= snode->edittree->nodes.first; node; node= node->next) {
|
||||
if (BLI_isect_rctf(&rectf, &node->totr, NULL)) {
|
||||
if (BLI_rctf_isect(&rectf, &node->totr, NULL)) {
|
||||
if (gesture_mode==GESTURE_MODAL_SELECT)
|
||||
node_select(node);
|
||||
else
|
||||
|
||||
@@ -78,7 +78,7 @@ static void snode_home(ScrArea *UNUSED(sa), ARegion *ar, SpaceNode* snode)
|
||||
ar->v2d.cur= node->totr;
|
||||
}
|
||||
else {
|
||||
BLI_union_rctf(cur, &node->totr);
|
||||
BLI_rctf_union(cur, &node->totr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2124,7 +2124,7 @@ static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op)
|
||||
float facx = (v2d->mask.xmax - v2d->mask.xmin) / winx;
|
||||
float facy = (v2d->mask.ymax - v2d->mask.ymin) / winy;
|
||||
|
||||
BLI_resize_rctf(&v2d->cur, (int)(winx * facx * ratio) + 1, (int)(winy * facy * ratio) + 1);
|
||||
BLI_rctf_resize(&v2d->cur, (int)(winx * facx * ratio) + 1, (int)(winy * facy * ratio) + 1);
|
||||
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
|
||||
|
||||
@@ -875,7 +875,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op)
|
||||
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
|
||||
seq_rectf(seq, &rq);
|
||||
|
||||
if (BLI_isect_rctf(&rq, &rectf, NULL)) {
|
||||
if (BLI_rctf_isect(&rq, &rectf, NULL)) {
|
||||
if (selecting) seq->flag |= SELECT;
|
||||
else seq->flag &= ~SEQ_ALLSEL;
|
||||
recurs_sel_seq(seq);
|
||||
|
||||
@@ -2162,7 +2162,7 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, const flo
|
||||
/* make an int copy */
|
||||
int s_int[2][2] = {{s[0][0], s[0][1]},
|
||||
{s[1][0], s[1][1]}};
|
||||
if (!BLI_segment_in_rcti(&data->win_rect, s_int[0], s_int[1])) {
|
||||
if (!BLI_rcti_isect_segment(&data->win_rect, s_int[0], s_int[1])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2028,7 +2028,7 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect)
|
||||
r.ymax = ar->winy - 1;
|
||||
|
||||
/* Constrain rect to depth bounds */
|
||||
BLI_isect_rcti(&r, rect, rect);
|
||||
BLI_rcti_isect(&r, rect, rect);
|
||||
|
||||
/* assign values to compare with the ViewDepths */
|
||||
x = rect->xmin;
|
||||
|
||||
@@ -1786,7 +1786,7 @@ static int game_engine_exec(bContext *C, wmOperator *op)
|
||||
cam_frame.xmax = cam_framef.xmax + ar->winrct.xmin;
|
||||
cam_frame.ymin = cam_framef.ymin + ar->winrct.ymin;
|
||||
cam_frame.ymax = cam_framef.ymax + ar->winrct.ymin;
|
||||
BLI_isect_rcti(&ar->winrct, &cam_frame, &cam_frame);
|
||||
BLI_rcti_isect(&ar->winrct, &cam_frame, &cam_frame);
|
||||
}
|
||||
else {
|
||||
cam_frame.xmin = ar->winrct.xmin;
|
||||
|
||||
@@ -1815,7 +1815,7 @@ static void isb_bsp_face_inside(ISBBranch *bspn, BSPFace *face)
|
||||
return;
|
||||
|
||||
/* if face boundbox is outside of branch rect, give up */
|
||||
if (0==BLI_isect_rctf((rctf *)&face->box, (rctf *)&bspn->box, NULL))
|
||||
if (0==BLI_rctf_isect((rctf *)&face->box, (rctf *)&bspn->box, NULL))
|
||||
return;
|
||||
|
||||
/* test all points inside branch */
|
||||
|
||||
@@ -193,7 +193,7 @@ static void wm_flush_regions_down(bScreen *screen, rcti *dirty)
|
||||
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (BLI_isect_rcti(dirty, &ar->winrct, NULL)) {
|
||||
if (BLI_rcti_isect(dirty, &ar->winrct, NULL)) {
|
||||
ar->do_draw = RGN_DRAW;
|
||||
memset(&ar->drawrct, 0, sizeof(ar->drawrct));
|
||||
ar->swap = WIN_NONE_OK;
|
||||
@@ -208,7 +208,7 @@ static void wm_flush_regions_up(bScreen *screen, rcti *dirty)
|
||||
ARegion *ar;
|
||||
|
||||
for (ar = screen->regionbase.first; ar; ar = ar->next) {
|
||||
if (BLI_isect_rcti(dirty, &ar->winrct, NULL)) {
|
||||
if (BLI_rcti_isect(dirty, &ar->winrct, NULL)) {
|
||||
ar->do_draw = RGN_DRAW;
|
||||
memset(&ar->drawrct, 0, sizeof(ar->drawrct));
|
||||
ar->swap = WIN_NONE_OK;
|
||||
|
||||
@@ -1636,7 +1636,7 @@ static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event)
|
||||
if (handler->bbwin) {
|
||||
if (handler->bblocal) {
|
||||
rcti rect = *handler->bblocal;
|
||||
BLI_translate_rcti(&rect, handler->bbwin->xmin, handler->bbwin->ymin);
|
||||
BLI_rcti_translate(&rect, handler->bbwin->xmin, handler->bbwin->ymin);
|
||||
|
||||
if (BLI_in_rcti_v(&rect, &event->x))
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user