From f53b547a40ae196c6663c0d1ec12d803e0934311 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 24 Aug 2017 17:27:31 +1000 Subject: [PATCH] geom/aabb: prefer to use vector operations over loops --- geom/aabb.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/geom/aabb.cpp b/geom/aabb.cpp index 03d1608a..a5258ba7 100644 --- a/geom/aabb.cpp +++ b/geom/aabb.cpp @@ -57,14 +57,7 @@ template util::point aabb::closest (point q) const { - point res; - - for (size_t i = 0; i < S; ++i) - res[i] = q[i] < p0[i] ? p0[i] : - q[i] > p1[i] ? p1[i] : - q[i]; - - return res; + return limit (q, p0, p1); } @@ -148,11 +141,7 @@ namespace util::debug { struct validator> { static bool is_valid (const aabb &b) { - for (size_t i = 0; i < S; ++i) - if (b.p1[i] < b.p0[i]) - return false; - - return true; + return all (b.p0 <= b.p1); } }; }