Browse Source

refactoring

Kajetan Johannes Hammerle 3 years ago
parent
commit
6019d2e265
1 changed files with 12 additions and 12 deletions
  1. 12 12
      math/Frustum.cpp

+ 12 - 12
math/Frustum.cpp

@@ -46,19 +46,19 @@ void Frustum::updatePlanes(const Vector3& pos, const Vector3& right, const Vecto
 }
 
 bool Frustum::isInside(const Vector3& pos) const {
-    return planes[0].getSignedDistance(pos) >= 0.0f &&
-            planes[1].getSignedDistance(pos) >= 0.0f &&
-            planes[2].getSignedDistance(pos) >= 0.0f &&
-            planes[3].getSignedDistance(pos) >= 0.0f &&
-            planes[4].getSignedDistance(pos) >= 0.0f &&
-            planes[5].getSignedDistance(pos) >= 0.0f;
+    for(const Plane& p : planes) {
+        if(p.getSignedDistance(pos) < 0.0f) {
+            return false;
+        }
+    }
+    return true;
 }
 
 bool Frustum::isInside(const Vector3& pos, float radius) const {
-    return planes[0].getSignedDistance(pos) >= -radius &&
-            planes[1].getSignedDistance(pos) >= -radius &&
-            planes[2].getSignedDistance(pos) >= -radius &&
-            planes[3].getSignedDistance(pos) >= -radius &&
-            planes[4].getSignedDistance(pos) >= -radius &&
-            planes[5].getSignedDistance(pos) >= -radius;
+    for(const Plane& p : planes) {
+        if(p.getSignedDistance(pos) < -radius) {
+            return false;
+        }
+    }
+    return true;
 }