From 83d011019ff26550d1882a9a77d693352e571aeb Mon Sep 17 00:00:00 2001 From: cutealien Date: Thu, 11 Feb 2021 13:57:53 +0000 Subject: [PATCH] Fix bug in rect::clipAgainst that had caused rects completely outside the rect to be clipped against ending up with one corner outside. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6188 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 1 + include/rect.h | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/changes.txt b/changes.txt index 7df3713..7f5d89a 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,6 @@ -------------------------- Changes in 1.9 (not yet released) +- Fix bug in rect::clipAgainst that had caused rects completely outside the rect to be clipped against ending up with one corner outside. - Add getAlign functions to IGUIElement - Add optional multitouch support to X11 (but disabled in IrrCompileConfig by default). Thanks @TheBrokenRail for a patch proposal based on example code from esjeon (patch #322). - Slightly changed close window handling on X11 (optimized and avoids problems on some shells). Thanks @TheBrokenRail for a patch (was part of patch #322). diff --git a/include/rect.h b/include/rect.h index aeb9cc5..85becf0 100644 --- a/include/rect.h +++ b/include/rect.h @@ -135,16 +135,20 @@ namespace core if (other.LowerRightCorner.Y < LowerRightCorner.Y) LowerRightCorner.Y = other.LowerRightCorner.Y; + if (other.UpperLeftCorner.X > LowerRightCorner.X) + LowerRightCorner.X = other.UpperLeftCorner.X; + if (other.UpperLeftCorner.Y > LowerRightCorner.Y) + LowerRightCorner.Y = other.UpperLeftCorner.Y; + + if (other.LowerRightCorner.X < UpperLeftCorner.X) + UpperLeftCorner.X = other.LowerRightCorner.X; + if (other.LowerRightCorner.Y < UpperLeftCorner.Y) + UpperLeftCorner.Y = other.LowerRightCorner.Y; + if (other.UpperLeftCorner.X > UpperLeftCorner.X) UpperLeftCorner.X = other.UpperLeftCorner.X; if (other.UpperLeftCorner.Y > UpperLeftCorner.Y) UpperLeftCorner.Y = other.UpperLeftCorner.Y; - - // correct possible invalid rect resulting from clipping - if (UpperLeftCorner.Y > LowerRightCorner.Y) - UpperLeftCorner.Y = LowerRightCorner.Y; - if (UpperLeftCorner.X > LowerRightCorner.X) - UpperLeftCorner.X = LowerRightCorner.X; } //! Moves this rectangle to fit inside another one.