MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / SDL_HasIntersectionF

Function SDL_HasIntersectionF

deps/SDL2/src/render/SDL_render.c:2881–2926  ·  view source on GitHub ↗

!!! FIXME: move this to a public API if we want to do float versions of all of these later */

Source from the content-addressed store, hash-verified

2879
2880/* !!! FIXME: move this to a public API if we want to do float versions of all of these later */
2881static SDL_bool
2882SDL_HasIntersectionF(const SDL_FRect * A, const SDL_FRect * B)
2883{
2884 float Amin, Amax, Bmin, Bmax;
2885
2886 if (!A) {
2887 SDL_InvalidParamError("A");
2888 return SDL_FALSE;
2889 }
2890
2891 if (!B) {
2892 SDL_InvalidParamError("B");
2893 return SDL_FALSE;
2894 }
2895
2896 /* Special cases for empty rects */
2897 if (SDL_FRectEmpty(A) || SDL_FRectEmpty(B)) {
2898 return SDL_FALSE;
2899 }
2900
2901 /* Horizontal intersection */
2902 Amin = A->x;
2903 Amax = Amin + A->w;
2904 Bmin = B->x;
2905 Bmax = Bmin + B->w;
2906 if (Bmin > Amin)
2907 Amin = Bmin;
2908 if (Bmax < Amax)
2909 Amax = Bmax;
2910 if (Amax <= Amin)
2911 return SDL_FALSE;
2912
2913 /* Vertical intersection */
2914 Amin = A->y;
2915 Amax = Amin + A->h;
2916 Bmin = B->y;
2917 Bmax = Bmin + B->h;
2918 if (Bmin > Amin)
2919 Amin = Bmin;
2920 if (Bmax < Amax)
2921 Amax = Bmax;
2922 if (Amax <= Amin)
2923 return SDL_FALSE;
2924
2925 return SDL_TRUE;
2926}
2927
2928int
2929SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,

Callers 1

SDL_RenderCopyFFunction · 0.85

Calls 1

SDL_FRectEmptyFunction · 0.85

Tested by

no test coverage detected