From 45d4195527d6f2a79d3230a08bf1269cf254f9b9 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Sat, 5 Nov 2022 00:49:38 +0100 Subject: [PATCH] Math/Box|Rect: Fix Intersect method with zero-sized boxes --- include/Nazara/Math/Box.inl | 2 +- include/Nazara/Math/Rect.inl | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index 7d3c0b9d1..806bba7e8 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -464,7 +464,7 @@ namespace Nz T up = std::max(z, box.z); T down = std::min(z + depth, box.z + box.depth); - if (left >= right || top >= bottom || up >= down) + if (left > right || top > bottom || up > down) return false; if (intersection) diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index d81ffaf55..77c70f322 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -366,12 +366,10 @@ namespace Nz { T left = std::max(x, rect.x); T right = std::min(x + width, rect.x + rect.width); - if (left >= right) - return false; - T top = std::max(y, rect.y); T bottom = std::min(y + height, rect.y + rect.height); - if (top >= bottom) + + if (left > right || top > bottom) return false; if (intersection)