mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 16:08:04 +02:00
util/box: add intersection test functions for 1d/3d
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21397>
This commit is contained in:
parent
8f3d0141de
commit
935184ca44
1 changed files with 40 additions and 0 deletions
|
|
@ -194,6 +194,21 @@ u_box_union_3d(struct pipe_box *dst,
|
|||
dst->z = z;
|
||||
}
|
||||
|
||||
static inline boolean
|
||||
u_box_test_intersection_1d(const struct pipe_box *a,
|
||||
const struct pipe_box *b)
|
||||
{
|
||||
int ax[2], bx[2];
|
||||
|
||||
ax[0] = MIN2(a->x, a->x + a->width);
|
||||
ax[1] = MAX2(a->x, a->x + a->width);
|
||||
|
||||
bx[0] = MIN2(b->x, b->x + b->width);
|
||||
bx[1] = MAX2(b->x, b->x + b->width);
|
||||
|
||||
return ax[1] >= bx[0] && bx[1] >= ax[0];
|
||||
}
|
||||
|
||||
static inline boolean
|
||||
u_box_test_intersection_2d(const struct pipe_box *a,
|
||||
const struct pipe_box *b)
|
||||
|
|
@ -218,6 +233,31 @@ u_box_test_intersection_2d(const struct pipe_box *a,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static inline boolean
|
||||
u_box_test_intersection_3d(const struct pipe_box *a,
|
||||
const struct pipe_box *b)
|
||||
{
|
||||
int ax[2], ay[2], ad[2], bx[2], by[2], bd[2];
|
||||
|
||||
ax[0] = MIN2(a->x, a->x + a->width);
|
||||
ax[1] = MAX2(a->x, a->x + a->width);
|
||||
ay[0] = MIN2(a->y, a->y + a->height);
|
||||
ay[1] = MAX2(a->y, a->y + a->height);
|
||||
ad[0] = MIN2(a->z, a->z + a->depth);
|
||||
ad[1] = MAX2(a->z, a->z + a->depth);
|
||||
|
||||
bx[0] = MIN2(b->x, b->x + b->width);
|
||||
bx[1] = MAX2(b->x, b->x + b->width);
|
||||
by[0] = MIN2(b->y, b->y + b->height);
|
||||
by[1] = MAX2(b->y, b->y + b->height);
|
||||
bd[0] = MIN2(b->z, b->z + b->depth);
|
||||
bd[1] = MAX2(b->z, b->z + b->depth);
|
||||
|
||||
return ax[1] >= bx[0] && bx[1] >= ax[0] &&
|
||||
ay[1] >= by[0] && by[1] >= ay[0] &&
|
||||
ad[1] >= bd[0] && bd[1] >= ad[0];
|
||||
}
|
||||
|
||||
static inline void
|
||||
u_box_minify_2d(struct pipe_box *dst,
|
||||
const struct pipe_box *src, unsigned l)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue