From 9cb5d1140504dfc7d0aef8e5d79e7becc9c198e3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 28 Feb 2020 02:27:12 -0500 Subject: [PATCH] CollisionUtil: Replace FINDMINMAX macro with std::minmax() Same thing, but already provided by the language. --- Runtime/Collision/CollisionUtil.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Runtime/Collision/CollisionUtil.cpp b/Runtime/Collision/CollisionUtil.cpp index ed63b8653..ee576456f 100644 --- a/Runtime/Collision/CollisionUtil.cpp +++ b/Runtime/Collision/CollisionUtil.cpp @@ -1,5 +1,8 @@ #include "Runtime/Collision/CollisionUtil.hpp" +#include +#include + #include "Runtime/Collision/CCollisionInfo.hpp" #include "Runtime/Collision/CCollisionInfoList.hpp" @@ -390,17 +393,6 @@ bool AABoxAABoxIntersection(const zeus::CAABox& aabb0, const zeus::CAABox& aabb1 /* Thanks to David Hunt for finding a ">="-bug! */ /********************************************************/ -#define FINDMINMAX(x0, x1, x2, min, max) \ - min = max = x0; \ - if (x1 < min) \ - min = x1; \ - if (x1 > max) \ - max = x1; \ - if (x2 < min) \ - min = x2; \ - if (x2 > max) \ - max = x2; - static bool planeBoxOverlap(const zeus::CVector3f& normal, float d, const zeus::CVector3f& maxbox) { zeus::CVector3f vmin, vmax; for (int q = 0; q <= 2; q++) { @@ -563,17 +555,17 @@ bool TriBoxOverlap(const zeus::CVector3f& boxcenter, const zeus::CVector3f& boxh /* the triangle against the AABB */ /* test in X-direction */ - FINDMINMAX(v0.x(), v1.x(), v2.x(), min, max); + std::tie(min, max) = std::minmax({v0.x(), v1.x(), v2.x()}); if (min > boxhalfsize.x() || max < -boxhalfsize.x()) return false; /* test in Y-direction */ - FINDMINMAX(v0.y(), v1.y(), v2.y(), min, max); + std::tie(min, max) = std::minmax({v0.y(), v1.y(), v2.y()}); if (min > boxhalfsize.y() || max < -boxhalfsize.y()) return false; /* test in Z-direction */ - FINDMINMAX(v0.z(), v1.z(), v2.z(), min, max); + std::tie(min, max) = std::minmax({v0.z(), v1.z(), v2.z()}); if (min > boxhalfsize.z() || max < -boxhalfsize.z()) return false;