From 72dd0dbf982f6fbc575233b3ee6fcd8d2622b71a Mon Sep 17 00:00:00 2001 From: Ian Curtis Date: Thu, 22 Dec 2016 22:09:13 +0000 Subject: [PATCH] only need to cull against 4 clipping planes --- Src/Graphics/New3D/New3D.cpp | 26 +++++++------------------- Src/Graphics/New3D/New3D.h | 2 +- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/Src/Graphics/New3D/New3D.cpp b/Src/Graphics/New3D/New3D.cpp index 48b92cd..439cebb 100644 --- a/Src/Graphics/New3D/New3D.cpp +++ b/Src/Graphics/New3D/New3D.cpp @@ -1322,20 +1322,6 @@ void CNew3D::CalcFrustumPlanes(Plane p[6], const float* matrix) p[3].c = matrix[11] - matrix[9]; p[3].d = matrix[15] - matrix[13]; p[3].Normalise(); - - // Near Plane - p[4].a = matrix[3] + matrix[2]; - p[4].b = matrix[7] + matrix[6]; - p[4].c = matrix[11] + matrix[10]; - p[4].d = matrix[15] + matrix[14]; - p[4].Normalise(); - - // Far Plane - p[5].a = matrix[3] - matrix[2]; - p[5].b = matrix[7] - matrix[6]; - p[5].c = matrix[11] - matrix[10]; - p[5].d = matrix[15] - matrix[14]; - p[5].Normalise(); } void CNew3D::CalcBox(float distance, BBox& box) @@ -1411,7 +1397,7 @@ void CNew3D::TransformBox(const float *m, BBox& box) } } -Clip CNew3D::ClipBox(BBox& box, Plane planes[6]) +Clip CNew3D::ClipBox(BBox& box, Plane planes[4]) { int count = 0; @@ -1419,13 +1405,13 @@ Clip CNew3D::ClipBox(BBox& box, Plane planes[6]) int temp = 0; - for (int j = 0; j < 6; j++) { + for (int j = 0; j < 4; j++) { if (planes[j].DistanceToPoint(box.points[i]) >= 0) { temp++; } } - if (temp == 6) count++; // point is inside all 6 frustum planes + if (temp == 4) count++; // point is inside all 4 frustum planes } if (count == 8) return Clip::INSIDE; @@ -1434,7 +1420,7 @@ Clip CNew3D::ClipBox(BBox& box, Plane planes[6]) //if we got here all points are outside of the view frustum //check for all points being side same of any plane, means box outside of view - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 4; i++) { int temp = 0; @@ -1445,7 +1431,9 @@ Clip CNew3D::ClipBox(BBox& box, Plane planes[6]) } } - if (temp == 0) return Clip::OUTSIDE; + if (temp == 0) { + return Clip::OUTSIDE; + } } //if we got here, box is traversing view frustum diff --git a/Src/Graphics/New3D/New3D.h b/Src/Graphics/New3D/New3D.h index e5b87b4..da77213 100644 --- a/Src/Graphics/New3D/New3D.h +++ b/Src/Graphics/New3D/New3D.h @@ -222,7 +222,7 @@ private: R3DShader m_r3dShader; R3DScrollFog m_r3dScrollFog; - Plane m_planes[6]; + Plane m_planes[4]; struct BBox {