Browse Source

Remove some fat from Frustum

Panagiotis Christopoulos Charitos 10 months ago
parent
commit
5a03a00859
2 changed files with 0 additions and 101 deletions
  1. 0 57
      AnKi/Scene/Frustum.cpp
  2. 0 44
      AnKi/Scene/Frustum.h

+ 0 - 57
AnKi/Scene/Frustum.cpp

@@ -59,48 +59,11 @@ Bool Frustum::update()
 		{
 			m_projMat =
 				Mat4::calculatePerspectiveProjectionMatrix(m_perspective.m_fovX, m_perspective.m_fovY, m_perspective.m_near, m_perspective.m_far);
-
-			computeEdgesOfFrustum(m_perspective.m_far, m_perspective.m_fovX, m_perspective.m_fovY, &m_perspective.m_edgesL[0]);
-
-			// Planes
-			F32 c, s; // cos & sine
-
-			sinCos(kPi + m_perspective.m_fovX / 2.0f, s, c);
-			// right
-			m_viewPlanesL[FrustumPlaneType::kRight] = Plane(Vec4(c, 0.0f, s, 0.0f), 0.0f);
-			// left
-			m_viewPlanesL[FrustumPlaneType::kLeft] = Plane(Vec4(-c, 0.0f, s, 0.0f), 0.0f);
-
-			sinCos((kPi + m_perspective.m_fovY) * 0.5f, s, c);
-			// bottom
-			m_viewPlanesL[FrustumPlaneType::kBottom] = Plane(Vec4(0.0f, s, c, 0.0f), 0.0f);
-			// top
-			m_viewPlanesL[FrustumPlaneType::kTop] = Plane(Vec4(0.0f, -s, c, 0.0f), 0.0f);
-
-			// near
-			m_viewPlanesL[FrustumPlaneType::kNear] = Plane(Vec4(0.0f, 0.0f, -1.0, 0.0f), m_perspective.m_near);
-			// far
-			m_viewPlanesL[FrustumPlaneType::kFar] = Plane(Vec4(0.0f, 0.0f, 1.0, 0.0f), -m_perspective.m_far);
 		}
 		else
 		{
 			m_projMat = Mat4::calculateOrthographicProjectionMatrix(m_ortho.m_right, m_ortho.m_left, m_ortho.m_top, m_ortho.m_bottom, m_ortho.m_near,
 																	m_ortho.m_far);
-
-			// OBB
-			const Vec4 c((m_ortho.m_right + m_ortho.m_left) * 0.5f, (m_ortho.m_top + m_ortho.m_bottom) * 0.5f,
-						 -(m_ortho.m_far + m_ortho.m_near) * 0.5f, 0.0f);
-			const Vec4 e = Vec4(m_ortho.m_right, m_ortho.m_top, -m_ortho.m_far, 0.0f) - c;
-
-			m_ortho.m_obbL = Obb(c, Mat3x4::getIdentity(), e);
-
-			// Planes
-			m_viewPlanesL[FrustumPlaneType::kLeft] = Plane(Vec4(1.0f, 0.0f, 0.0f, 0.0f), m_ortho.m_left);
-			m_viewPlanesL[FrustumPlaneType::kRight] = Plane(Vec4(-1.0f, 0.0f, 0.0f, 0.0f), -m_ortho.m_right);
-			m_viewPlanesL[FrustumPlaneType::kNear] = Plane(Vec4(0.0f, 0.0f, -1.0f, 0.0f), m_ortho.m_near);
-			m_viewPlanesL[FrustumPlaneType::kFar] = Plane(Vec4(0.0f, 0.0f, 1.0f, 0.0f), -m_ortho.m_far);
-			m_viewPlanesL[FrustumPlaneType::kTop] = Plane(Vec4(0.0f, -1.0f, 0.0f, 0.0f), -m_ortho.m_top);
-			m_viewPlanesL[FrustumPlaneType::kBottom] = Plane(Vec4(0.0f, 1.0f, 0.0f, 0.0f), m_ortho.m_bottom);
 		}
 	}
 
@@ -118,26 +81,6 @@ Bool Frustum::update()
 		m_worldTransformDirty = false;
 
 		m_viewProjMat = m_projMat * Mat4(m_viewMat, Vec4(0.0f, 0.0f, 0.0f, 1.0f));
-
-		if(m_frustumType == FrustumType::kPerspective)
-		{
-			m_perspective.m_edgesW[0] = m_worldTransform.getOrigin();
-			m_perspective.m_edgesW[1] = m_worldTransform.transform(m_perspective.m_edgesL[0].xyz0());
-			m_perspective.m_edgesW[2] = m_worldTransform.transform(m_perspective.m_edgesL[1].xyz0());
-			m_perspective.m_edgesW[3] = m_worldTransform.transform(m_perspective.m_edgesL[2].xyz0());
-			m_perspective.m_edgesW[4] = m_worldTransform.transform(m_perspective.m_edgesL[3].xyz0());
-
-			m_perspective.m_hull = ConvexHullShape(&m_perspective.m_edgesW[0], m_perspective.m_edgesW.getSize());
-		}
-		else
-		{
-			m_ortho.m_obbW = m_ortho.m_obbL.getTransformed(m_worldTransform);
-		}
-
-		for(FrustumPlaneType planeId : EnumIterable<FrustumPlaneType>())
-		{
-			m_viewPlanesW[planeId] = m_viewPlanesL[planeId].getTransformed(m_worldTransform);
-		}
 	}
 
 	return updated;

+ 0 - 44
AnKi/Scene/Frustum.h

@@ -171,41 +171,6 @@ public:
 		return m_viewProjMat;
 	}
 
-	/// Check if a shape is inside the frustum.
-	template<typename T>
-	Bool insideFrustum(const T& t) const
-	{
-		for(const Plane& plane : m_viewPlanesW)
-		{
-			if(testPlane(plane, t) < 0.0f)
-			{
-				return false;
-			}
-		}
-
-		return true;
-	}
-
-	const ConvexHullShape& getPerspectiveBoundingShapeWorldSpace() const
-	{
-		ANKI_ASSERT(m_frustumType == FrustumType::kPerspective);
-		ANKI_ASSERT(!isDirty());
-		return m_perspective.m_hull;
-	}
-
-	const Obb& getOrthographicBoundingShapeWorldSpace() const
-	{
-		ANKI_ASSERT(m_frustumType == FrustumType::kOrthographic);
-		ANKI_ASSERT(!isDirty());
-		return m_ortho.m_obbW;
-	}
-
-	const Array<Plane, U32(FrustumPlaneType::kCount)>& getViewPlanes() const
-	{
-		ANKI_ASSERT(!isDirty());
-		return m_viewPlanesW;
-	}
-
 	void setWorldTransform(const Transform& worldTransform)
 	{
 		m_worldTransform = worldTransform;
@@ -238,9 +203,6 @@ private:
 	public:
 		F32 m_fovX;
 		F32 m_fovY;
-		Array<Vec4, 5> m_edgesW;
-		Array<Vec3, 4> m_edgesL; ///< Don't need the eye point.
-		ConvexHullShape m_hull;
 	};
 
 	class Ortho : public Common
@@ -250,8 +212,6 @@ private:
 		F32 m_right;
 		F32 m_top;
 		F32 m_bottom;
-		Obb m_obbL;
-		Obb m_obbW; ///< Including shape
 	};
 
 	static constexpr F32 kDefaultNear = 0.1f;
@@ -265,10 +225,6 @@ private:
 		Common m_common;
 	};
 
-	// View planes
-	Array<Plane, U32(FrustumPlaneType::kCount)> m_viewPlanesL;
-	Array<Plane, U32(FrustumPlaneType::kCount)> m_viewPlanesW;
-
 	Transform m_worldTransform = Transform::getIdentity();
 
 	Mat4 m_projMat = Mat4::getIdentity(); ///< Projection matrix