From 06904755d9b2b1e56f1e53070a66101a12dddff9 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 20 Jan 2020 23:27:07 +0200 Subject: Refactor CCullZone::CalcDistToCullZoneSquared --- src/core/ZoneCull.cpp | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/core/ZoneCull.cpp b/src/core/ZoneCull.cpp index ab7fc9ac..b6929e86 100644 --- a/src/core/ZoneCull.cpp +++ b/src/core/ZoneCull.cpp @@ -507,27 +507,14 @@ float CCullZone::CalcDistToCullZoneSquared(float x, float y) { float rx, ry; - float temp; - - temp = minx; - if (temp <= x) { - temp = maxx; - if (x <= temp) - rx = 0.0f; - else - rx = sq(x - temp); - } else - rx = sq(x - temp); - - temp = miny; - if (temp <= y) { - temp = maxy; - if (y <= temp) - ry = 0.0f; - else - ry = sq(y - temp); - } else - ry = sq(y - temp); + + if (x < minx) rx = sq(x - minx); + else if (x > maxx) rx = sq(x - maxx); + else rx = 0.0f; + + if (y < miny) ry = sq(y - miny); + else if (y > maxy) ry = sq(y - maxy); + else ry = 0.0f; return rx + ry; } -- cgit v1.2.3