Fixed floating point rectangles to be mathematically correct.

* A floating point rectangle contains all points >= x and <= x + w
* A floating point rectangle is only empty if it has negative width. The zero rectangle contains the zero point.
* Adjacent floating point rectangles intersect along their shared side

Fixes https://github.com/libsdl-org/SDL/issues/6791
This commit is contained in:
Sam Lantinga
2024-07-21 00:36:42 -07:00
parent 9e978740c3
commit e0fd59de64
4 changed files with 295 additions and 17 deletions

View File

@@ -90,6 +90,7 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height,
#define SCALARTYPE int
#define BIGSCALARTYPE Sint64
#define COMPUTEOUTCODE ComputeOutCode
#define ENCLOSEPOINTS_EPSILON 1
#define SDL_HASINTERSECTION SDL_HasRectIntersection
#define SDL_INTERSECTRECT SDL_GetRectIntersection
#define SDL_RECTEMPTY SDL_RectEmpty
@@ -103,6 +104,7 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height,
#define SCALARTYPE float
#define BIGSCALARTYPE double
#define COMPUTEOUTCODE ComputeOutCodeFloat
#define ENCLOSEPOINTS_EPSILON 0.0f
#define SDL_HASINTERSECTION SDL_HasRectIntersectionFloat
#define SDL_INTERSECTRECT SDL_GetRectIntersectionFloat
#define SDL_RECTEMPTY SDL_RectEmptyFloat