diff options
| author | thejch <66577496+thejch@users.noreply.github.com> | 2024-03-30 18:14:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-31 02:14:26 +0100 |
| commit | 16a9c16d9f99bd8be9f1bb15442b001fdf2ea759 (patch) | |
| tree | f9cb60dc2d92519079699e9cb6e71e562b55a8a5 /src/helpers/Box.cpp | |
| parent | 1cc9a44318e53a34f41cc36483502de985b88cf8 (diff) | |
renderer/animations: Fix various inaccurate damage tracking issues and offsets (#5297)
Diffstat (limited to 'src/helpers/Box.cpp')
| -rw-r--r-- | src/helpers/Box.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/helpers/Box.cpp b/src/helpers/Box.cpp index e9e0eeeb..8470b509 100644 --- a/src/helpers/Box.cpp +++ b/src/helpers/Box.cpp @@ -106,6 +106,11 @@ CBox& CBox::expand(const double& value) { w += value * 2.0; h += value * 2.0; + if (w <= 0 || h <= 0) { + w = 0; + h = 0; + } + return *this; } @@ -116,22 +121,20 @@ CBox& CBox::noNegativeSize() { return *this; } -CBox& CBox::intersection(const CBox other) { - const float newTop = std::max(y, other.y); +CBox CBox::intersection(const CBox other) const { + const float newX = std::max(x, other.x); + const float newY = std::max(y, other.y); const float newBottom = std::min(y + h, other.y + other.h); - const float newLeft = std::max(x, other.x); const float newRight = std::min(x + w, other.x + other.w); - y = newTop; - x = newLeft; - w = newRight - newLeft; - h = newBottom - newTop; + float newW = newRight - newX; + float newH = newBottom - newY; - if (w <= 0 || h <= 0) { - w = 0; - h = 0; + if (newW <= 0 || newH <= 0) { + newW = 0; + newH = 0; } - return *this; + return {newX, newY, newW, newH}; } CBox CBox::roundInternal() { |
