rename intersect_(f)rect to overlap_(f)rect and add simplified functions with the old names
This commit is contained in:
@ -171,30 +171,50 @@ bool strends(const char *str, const char *suffix) {
|
||||
}
|
||||
|
||||
|
||||
bool intersect_rect(const t_rect *a, const t_rect *b, t_rect *result) {
|
||||
bool overlap_rect(const t_rect *a, const t_rect *b, t_rect *result) {
|
||||
SDL_Rect a_sdl = { a->x, a->y, a->w, a->h };
|
||||
SDL_Rect b_sdl = { b->x, b->y, b->w, b->h };
|
||||
SDL_Rect result_sdl = { 0 };
|
||||
|
||||
bool intersection = SDL_IntersectRect(&a_sdl, &b_sdl, &result_sdl);
|
||||
|
||||
*result = (t_rect){ result_sdl.x, result_sdl.y, result_sdl.w, result_sdl.h };
|
||||
if (result != NULL)
|
||||
*result = (t_rect){ result_sdl.x, result_sdl.y, result_sdl.w, result_sdl.h };
|
||||
|
||||
return intersection;
|
||||
}
|
||||
|
||||
|
||||
bool intersect_frect(const t_frect *a, const t_frect *b, t_frect *result) {
|
||||
bool overlap_frect(const t_frect *a, const t_frect *b, t_frect *result) {
|
||||
SDL_FRect a_sdl = { a->x, a->y, a->w, a->h };
|
||||
SDL_FRect b_sdl = { b->x, b->y, b->w, b->h };
|
||||
SDL_FRect result_sdl = { 0 };
|
||||
|
||||
bool intersection = SDL_IntersectFRect(&a_sdl, &b_sdl, &result_sdl);
|
||||
|
||||
*result = (t_frect){ result_sdl.x, result_sdl.y, result_sdl.w, result_sdl.h };
|
||||
if (result != NULL)
|
||||
*result = (t_frect){ result_sdl.x, result_sdl.y, result_sdl.w, result_sdl.h };
|
||||
|
||||
return intersection;
|
||||
}
|
||||
|
||||
|
||||
bool intersect_rect(const t_rect *a, const t_rect *b) {
|
||||
SDL_Rect a_sdl = { a->x, a->y, a->w, a->h };
|
||||
SDL_Rect b_sdl = { b->x, b->y, b->w, b->h };
|
||||
SDL_Rect result_sdl = { 0 };
|
||||
return SDL_IntersectRect(&a_sdl, &b_sdl, &result_sdl);
|
||||
}
|
||||
|
||||
|
||||
bool intersect_frect(const t_frect *a, const t_frect *b) {
|
||||
SDL_FRect a_sdl = { a->x, a->y, a->w, a->h };
|
||||
SDL_FRect b_sdl = { b->x, b->y, b->w, b->h };
|
||||
SDL_FRect result_sdl = { 0 };
|
||||
return SDL_IntersectFRect(&a_sdl, &b_sdl, &result_sdl);
|
||||
}
|
||||
|
||||
|
||||
t_frect to_frect(t_rect rect) {
|
||||
return (t_frect) {
|
||||
.h = (float)rect.h,
|
||||
|
Reference in New Issue
Block a user