Jelajahi Sumber

Removing unused methods from render system #1

Marko Pintera 13 tahun lalu
induk
melakukan
9dc5f1dff7

+ 2 - 2
CamelotClient/CamelotClient.cpp

@@ -27,8 +27,8 @@ using namespace CamelotEngine;
 
 int _tmain(int argc, _TCHAR* argv[])
 {
-	//gApplication().startUp("CamelotGLRenderSystem", "CamelotForwardRenderer");
-	gApplication().startUp("CamelotD3D9RenderSystem", "CamelotForwardRenderer");
+	gApplication().startUp("CamelotGLRenderSystem", "CamelotForwardRenderer");
+	//gApplication().startUp("CamelotD3D9RenderSystem", "CamelotForwardRenderer");
 
 	RenderSystem* renderSystem = RenderSystemManager::getActive();
 	RenderWindow* renderWindow = gApplication().getPrimaryRenderWindow();

+ 1 - 11
CamelotD3D9Renderer/Include/CmD3D9RenderSystem.h

@@ -214,7 +214,6 @@ namespace CamelotEngine
             StencilOperation depthFailOp = SOP_KEEP,
             StencilOperation passOp = SOP_KEEP, 
             bool twoSidedOperation = false);
-        void setNormaliseNormals(bool normalise);
 
 		// Low-level overridden members, mainly for internal use
 		void _setWorldMatrix( const Matrix4 &m );
@@ -245,16 +244,7 @@ namespace CamelotEngine
 		void _setDepthBufferFunction( CompareFunction func = CMPF_LESS_EQUAL );
 		void _setDepthBias(float constantBias, float slopeScaleBias);
 		void _setFog( FogMode mode = FOG_NONE, const Color& colour = Color::White, float expDensity = 1.0, float linearStart = 0.0, float linearEnd = 1.0 );
-		void _convertProjectionMatrix(const Matrix4& matrix,
-            Matrix4& dest, bool forGpuProgram = false);
-		void _makeProjectionMatrix(const Radian& fovy, float aspect, float nearPlane, float farPlane, 
-            Matrix4& dest, bool forGpuProgram = false);
-		void _makeProjectionMatrix(float left, float right, float bottom, float top, float nearPlane, 
-            float farPlane, Matrix4& dest, bool forGpuProgram = false);
-		void _makeOrthoMatrix(const Radian& fovy, float aspect, float nearPlane, float farPlane, 
-            Matrix4& dest, bool forGpuProgram = false);
-        void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, 
-            bool forGpuProgram);
+		void _convertProjectionMatrix(const Matrix4& matrix, Matrix4& dest, bool forGpuProgram = false);
 		void _setPolygonMode(PolygonMode level);
         void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter);
 		void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy);

+ 0 - 172
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -1466,77 +1466,6 @@ namespace CamelotEngine
 		}
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_makeProjectionMatrix(const Radian& fovy, float aspect, float nearPlane, 
-		float farPlane, Matrix4& dest, bool forGpuProgram)
-	{
-		Radian theta ( fovy * 0.5 );
-		float h = 1 / Math::Tan(theta);
-		float w = h / aspect;
-		float q, qn;
-		if (farPlane == 0)
-		{
-			q = 1 - Camera::INFINITE_FAR_PLANE_ADJUST;
-			qn = nearPlane * (Camera::INFINITE_FAR_PLANE_ADJUST - 1);
-		}
-		else
-		{
-			q = farPlane / ( farPlane - nearPlane );
-			qn = -q * nearPlane;
-		}
-
-		dest = Matrix4::ZERO;
-		dest[0][0] = w;
-		dest[1][1] = h;
-
-		if (forGpuProgram)
-		{
-			dest[2][2] = -q;
-			dest[3][2] = -1.0f;
-		}
-		else
-		{
-			dest[2][2] = q;
-			dest[3][2] = 1.0f;
-		}
-
-		dest[2][3] = qn;
-	}
-	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_makeOrthoMatrix(const Radian& fovy, float aspect, float nearPlane, float farPlane, 
-		Matrix4& dest, bool forGpuProgram )
-	{
-		Radian thetaY (fovy / 2.0f);
-		float tanThetaY = Math::Tan(thetaY);
-
-		//float thetaX = thetaY * aspect;
-		float tanThetaX = tanThetaY * aspect; //Math::Tan(thetaX);
-		float half_w = tanThetaX * nearPlane;
-		float half_h = tanThetaY * nearPlane;
-		float iw = static_cast<float>(1.0 / half_w);
-		float ih = static_cast<float>(1.0 / half_h);
-		float q;
-		if (farPlane == 0)
-		{
-			q = 0;
-		}
-		else
-		{
-			q = static_cast<float>(1.0 / (farPlane - nearPlane));
-		}
-
-		dest = Matrix4::ZERO;
-		dest[0][0] = iw;
-		dest[1][1] = ih;
-		dest[2][2] = q;
-		dest[2][3] = -nearPlane / (farPlane - nearPlane);
-		dest[3][3] = 1;
-
-		if (forGpuProgram)
-		{
-			dest[2][2] = -dest[2][2];
-		}
-	}
-	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setViewMatrix( const Matrix4 &m )
 	{
 		// save latest view matrix
@@ -2553,12 +2482,6 @@ namespace CamelotEngine
 
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::setNormaliseNormals(bool normalise)
-	{
-		__SetRenderState(D3DRS_NORMALIZENORMALS, 
-			normalise ? TRUE : FALSE);
-	}
-	//---------------------------------------------------------------------
 	void D3D9RenderSystem::bindGpuProgram(GpuProgram* prg)
 	{
 		HRESULT hr;
@@ -2858,54 +2781,6 @@ namespace CamelotEngine
 			CM_EXCEPT(RenderingAPIException, "Error clearing frame buffer : " + msg);
 		}
 	}
-	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_makeProjectionMatrix(float left, float right, 
-		float bottom, float top, float nearPlane, float farPlane, Matrix4& dest,
-		bool forGpuProgram)
-	{
-		// Correct position for off-axis projection matrix
-		if (!forGpuProgram)
-		{
-			float offsetX = left + right;
-			float offsetY = top + bottom;
-
-			left -= offsetX;
-			right -= offsetX;
-			top -= offsetY;
-			bottom -= offsetY;
-		}
-
-		float width = right - left;
-		float height = top - bottom;
-		float q, qn;
-		if (farPlane == 0)
-		{
-			q = 1 - Camera::INFINITE_FAR_PLANE_ADJUST;
-			qn = nearPlane * (Camera::INFINITE_FAR_PLANE_ADJUST - 1);
-		}
-		else
-		{
-			q = farPlane / ( farPlane - nearPlane );
-			qn = -q * nearPlane;
-		}
-		dest = Matrix4::ZERO;
-		dest[0][0] = 2 * nearPlane / width;
-		dest[0][2] = (right+left) / width;
-		dest[1][1] = 2 * nearPlane / height;
-		dest[1][2] = (top+bottom) / height;
-		if (forGpuProgram)
-		{
-			dest[2][2] = -q;
-			dest[3][2] = -1.0f;
-		}
-		else
-		{
-			dest[2][2] = q;
-			dest[3][2] = 1.0f;
-		}
-		dest[2][3] = qn;
-	}
-
 	// ------------------------------------------------------------------
 	void D3D9RenderSystem::setClipPlane (UINT16 index, float A, float B, float C, float D)
 	{
@@ -2941,53 +2816,6 @@ namespace CamelotEngine
 		return -0.5f;
 	}
 	//---------------------------------------------------------------------
-	void D3D9RenderSystem::_applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, 
-		bool forGpuProgram)
-	{
-		// Thanks to Eric Lenyel for posting this calculation at www.terathon.com
-
-		// Calculate the clip-space corner point opposite the clipping plane
-		// as (sgn(clipPlane.x), sgn(clipPlane.y), 1, 1) and
-		// transform it into camera space by multiplying it
-		// by the inverse of the projection matrix
-
-		/* generalised version
-		Vector4 q = matrix.inverse() * 
-		Vector4(Math::Sign(plane.normal.x), Math::Sign(plane.normal.y), 1.0f, 1.0f);
-		*/
-		Vector4 q;
-		q.x = Math::Sign(plane.normal.x) / matrix[0][0];
-		q.y = Math::Sign(plane.normal.y) / matrix[1][1];
-		q.z = 1.0F; 
-		// flip the next bit from Lengyel since we're right-handed
-		if (forGpuProgram)
-		{
-			q.w = (1.0F - matrix[2][2]) / matrix[2][3];
-		}
-		else
-		{
-			q.w = (1.0F + matrix[2][2]) / matrix[2][3];
-		}
-
-		// Calculate the scaled plane vector
-		Vector4 clipPlane4d(plane.normal.x, plane.normal.y, plane.normal.z, plane.d);
-		Vector4 c = clipPlane4d * (1.0F / (clipPlane4d.dotProduct(q)));
-
-		// Replace the third row of the projection matrix
-		matrix[2][0] = c.x;
-		matrix[2][1] = c.y;
-		// flip the next bit from Lengyel since we're right-handed
-		if (forGpuProgram)
-		{
-			matrix[2][2] = c.z; 
-		}
-		else
-		{
-			matrix[2][2] = -c.z; 
-		}
-		matrix[2][3] = c.w;        
-	}
-	//---------------------------------------------------------------------
 	float D3D9RenderSystem::getMinimumDepthInputValue()
 	{
 		// Range [0.0f, 1.0f]

+ 0 - 24
CamelotGLRenderer/Include/CmGLRenderSystem.h

@@ -193,10 +193,6 @@ namespace CamelotEngine {
           RenderSystem
          */
         VertexElementType getColourVertexElementType(void) const;
-        /** See
-          RenderSystem
-         */
-        void setNormaliseNormals(bool normalise);
 
         // -----------------------------
         // Low-level overridden members
@@ -325,26 +321,6 @@ namespace CamelotEngine {
         /** See
           RenderSystem
          */
-        void _makeProjectionMatrix(const Radian& fovy, float aspect, float nearPlane, float farPlane, 
-            Matrix4& dest, bool forGpuProgram = false);
-        /** See
-          RenderSystem
-         */
-        void _makeProjectionMatrix(float left, float right, float bottom, float top, 
-            float nearPlane, float farPlane, Matrix4& dest, bool forGpuProgram = false);
-        /** See
-          RenderSystem
-         */
-		void _makeOrthoMatrix(const Radian& fovy, float aspect, float nearPlane, float farPlane, 
-            Matrix4& dest, bool forGpuProgram = false);
-        /** See
-        RenderSystem
-        */
-        void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, 
-            bool forGpuProgram);
-        /** See
-          RenderSystem
-         */
         void setClipPlane (UINT16 index, float A, float B, float C, float D);
         /** See
           RenderSystem

+ 1 - 134
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -1778,76 +1778,7 @@ namespace CamelotEngine {
 		// no any conversion request for OpenGL
 		dest = matrix;
 	}
-
-	void GLRenderSystem::_makeProjectionMatrix(const Radian& fovy, float aspect, float nearPlane, 
-		float farPlane, Matrix4& dest, bool forGpuProgram)
-	{
-		Radian thetaY ( fovy / 2.0f );
-		float tanThetaY = Math::Tan(thetaY);
-		//float thetaX = thetaY * aspect;
-		//float tanThetaX = Math::Tan(thetaX);
-
-		// Calc matrix elements
-		float w = (1.0f / tanThetaY) / aspect;
-		float h = 1.0f / tanThetaY;
-		float q, qn;
-		if (farPlane == 0)
-		{
-			// Infinite far plane
-			q = Camera::INFINITE_FAR_PLANE_ADJUST - 1;
-			qn = nearPlane * (Camera::INFINITE_FAR_PLANE_ADJUST - 2);
-		}
-		else
-		{
-			q = -(farPlane + nearPlane) / (farPlane - nearPlane);
-			qn = -2 * (farPlane * nearPlane) / (farPlane - nearPlane);
-		}
-
-		// NB This creates Z in range [-1,1]
-		//
-		// [ w   0   0   0  ]
-		// [ 0   h   0   0  ]
-		// [ 0   0   q   qn ]
-		// [ 0   0   -1  0  ]
-
-		dest = Matrix4::ZERO;
-		dest[0][0] = w;
-		dest[1][1] = h;
-		dest[2][2] = q;
-		dest[2][3] = qn;
-		dest[3][2] = -1;
-
-	}
-
-	void GLRenderSystem::_makeOrthoMatrix(const Radian& fovy, float aspect, float nearPlane, 
-		float farPlane, Matrix4& dest, bool forGpuProgram)
-	{
-		Radian thetaY (fovy / 2.0f);
-		float tanThetaY = Math::Tan(thetaY);
-
-		//float thetaX = thetaY * aspect;
-		float tanThetaX = tanThetaY * aspect; //Math::Tan(thetaX);
-		float half_w = tanThetaX * nearPlane;
-		float half_h = tanThetaY * nearPlane;
-		float iw = 1.0f / half_w;
-		float ih = 1.0f / half_h;
-		float q;
-		if (farPlane == 0)
-		{
-			q = 0;
-		}
-		else
-		{
-			q = 2.0f / (farPlane - nearPlane);
-		}
-		dest = Matrix4::ZERO;
-		dest[0][0] = iw;
-		dest[1][1] = ih;
-		dest[2][2] = -q;
-		dest[2][3] = - (farPlane + nearPlane)/(farPlane - nearPlane);
-		dest[3][3] = 1;
-	}
-
+	//---------------------------------------------------------------------
 	void GLRenderSystem::_setPolygonMode(PolygonMode level)
 	{
 		GLenum glmode;
@@ -2371,15 +2302,6 @@ namespace CamelotEngine {
 			glSecondaryColor3fEXT(0.0f, 0.0f, 0.0f);
 		}
 
-	}
-	//---------------------------------------------------------------------
-	void GLRenderSystem::setNormaliseNormals(bool normalise)
-	{
-		if (normalise)
-			glEnable(GL_NORMALIZE);
-		else
-			glDisable(GL_NORMALIZE);
-
 	}
 	//---------------------------------------------------------------------
 	void GLRenderSystem::bindGpuProgram(GpuProgram* prg)
@@ -2678,34 +2600,6 @@ namespace CamelotEngine {
 			glStencilMask(mStencilMask);
 		}
 	}
-	// ------------------------------------------------------------------
-	void GLRenderSystem::_makeProjectionMatrix(float left, float right, 
-		float bottom, float top, float nearPlane, float farPlane, Matrix4& dest, 
-		bool forGpuProgram)
-	{
-		float width = right - left;
-		float height = top - bottom;
-		float q, qn;
-		if (farPlane == 0)
-		{
-			// Infinite far plane
-			q = Camera::INFINITE_FAR_PLANE_ADJUST - 1;
-			qn = nearPlane * (Camera::INFINITE_FAR_PLANE_ADJUST - 2);
-		}
-		else
-		{
-			q = -(farPlane + nearPlane) / (farPlane - nearPlane);
-			qn = -2 * (farPlane * nearPlane) / (farPlane - nearPlane);
-		}
-		dest = Matrix4::ZERO;
-		dest[0][0] = 2 * nearPlane / width;
-		dest[0][2] = (right+left) / width;
-		dest[1][1] = 2 * nearPlane / height;
-		dest[1][2] = (top+bottom) / height;
-		dest[2][2] = q;
-		dest[2][3] = qn;
-		dest[3][2] = -1;
-	}
 	//---------------------------------------------------------------------
 	HardwareOcclusionQuery* GLRenderSystem::createHardwareOcclusionQuery(void)
 	{
@@ -2726,33 +2620,6 @@ namespace CamelotEngine {
 		return 0.0f;
 	}
 	//---------------------------------------------------------------------
-	void GLRenderSystem::_applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, 
-		bool forGpuProgram)
-	{
-		// Thanks to Eric Lenyel for posting this calculation at www.terathon.com
-
-		// Calculate the clip-space corner point opposite the clipping plane
-		// as (sgn(clipPlane.x), sgn(clipPlane.y), 1, 1) and
-		// transform it into camera space by multiplying it
-		// by the inverse of the projection matrix
-
-		Vector4 q;
-		q.x = (Math::Sign(plane.normal.x) + matrix[0][2]) / matrix[0][0];
-		q.y = (Math::Sign(plane.normal.y) + matrix[1][2]) / matrix[1][1];
-		q.z = -1.0F;
-		q.w = (1.0F + matrix[2][2]) / matrix[2][3];
-
-		// Calculate the scaled plane vector
-		Vector4 clipPlane4d(plane.normal.x, plane.normal.y, plane.normal.z, plane.d);
-		Vector4 c = clipPlane4d * (2.0F / (clipPlane4d.dotProduct(q)));
-
-		// Replace the third row of the projection matrix
-		matrix[2][0] = c.x;
-		matrix[2][1] = c.y;
-		matrix[2][2] = c.z + 1.0F;
-		matrix[2][3] = c.w; 
-	}
-	//---------------------------------------------------------------------
 	void GLRenderSystem::_oneTimeContextInitialization()
 	{
 		if (GLEW_VERSION_1_2)

+ 1 - 68
CamelotRenderer/Include/CmRenderSystem.h

@@ -824,56 +824,11 @@ namespace CamelotEngine
 		@remarks
 		Because different APIs have different requirements (some incompatible) for the
 		projection matrix, this method allows each to implement their own correctly and pass
-		back a generic OGRE matrix for storage in the engine.
+		back a generic Camelot matrix for storage in the engine.
 		*/
 		virtual void _convertProjectionMatrix(const Matrix4& matrix,
 			Matrix4& dest, bool forGpuProgram = false) = 0;
 
-		/** Builds a perspective projection matrix suitable for this render system.
-		@remarks
-		Because different APIs have different requirements (some incompatible) for the
-		projection matrix, this method allows each to implement their own correctly and pass
-		back a generic OGRE matrix for storage in the engine.
-		*/
-		virtual void _makeProjectionMatrix(const Radian& fovy, float aspect, float nearPlane, float farPlane, 
-			Matrix4& dest, bool forGpuProgram = false) = 0;
-
-		/** Builds a perspective projection matrix for the case when frustum is
-		not centered around camera.
-		@remarks
-		Viewport coordinates are in camera coordinate frame, i.e. camera is 
-		at the origin.
-		*/
-		virtual void _makeProjectionMatrix(float left, float right, float bottom, float top, 
-			float nearPlane, float farPlane, Matrix4& dest, bool forGpuProgram = false) = 0;
-		/** Builds an orthographic projection matrix suitable for this render system.
-		@remarks
-		Because different APIs have different requirements (some incompatible) for the
-		projection matrix, this method allows each to implement their own correctly and pass
-		back a generic OGRE matrix for storage in the engine.
-		*/
-		virtual void _makeOrthoMatrix(const Radian& fovy, float aspect, float nearPlane, float farPlane, 
-			Matrix4& dest, bool forGpuProgram = false) = 0;
-
-		/** Update a perspective projection matrix to use 'oblique depth projection'.
-		@remarks
-		This method can be used to change the nature of a perspective 
-		transform in order to make the near plane not perpendicular to the 
-		camera view direction, but to be at some different orientation. 
-		This can be useful for performing arbitrary clipping (e.g. to a 
-		reflection plane) which could otherwise only be done using user
-		clip planes, which are more expensive, and not necessarily supported
-		on all cards.
-		@param matrix The existing projection matrix. Note that this must be a
-		perspective transform (not orthographic), and must not have already
-		been altered by this method. The matrix will be altered in-place.
-		@param plane The plane which is to be used as the clipping plane. This
-		plane must be in CAMERA (view) space.
-		@param forGpuProgram Is this for use with a Gpu program or fixed-function
-		*/
-		virtual void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, 
-			bool forGpuProgram) = 0;
-
 		/** Sets how to rasterise triangles, as points, wireframe or solid polys. */
 		virtual void _setPolygonMode(PolygonMode level) = 0;
 
@@ -950,18 +905,6 @@ namespace CamelotEngine
 		/** Sets the current vertex buffer binding state. */
 		virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0;
 
-		/** Sets whether or not normals are to be automatically normalised.
-		@remarks
-		This is useful when, for example, you are scaling SceneNodes such that
-		normals may not be unit-length anymore. Note though that this has an
-		overhead so should not be turn on unless you really need it.
-		@par
-		You should not normally call this direct unless you are rendering
-		world geometry; set it on the Renderable because otherwise it will be
-		overridden by material settings. 
-		*/
-		virtual void setNormaliseNormals(bool normalise) = 0;
-
 		/**
 		Render something to the active viewport.
 
@@ -1020,16 +963,6 @@ namespace CamelotEngine
 		*/
 		virtual void resetClipPlanes();
 
-		/** Utility method for initialising all render targets attached to this rendering system. */
-		virtual void _initRenderTargets(void);
-
-		/** Utility method to notify all render targets that a camera has been removed, 
-		in case they were referring to it as their viewer. 
-		*/
-		virtual void _notifyCameraRemoved(const Camera* cam);
-
-		/** Internal method for updating all render targets attached to this rendering system. */
-		virtual void _updateAllRenderTargets(bool swapBuffers = true);
 		/** Internal method for swapping all the buffers on all render targets,
 		if _updateAllRenderTargets was called with a 'false' parameter. */
 		virtual void _swapAllRenderTargetBuffers(bool waitForVsync = true);

+ 0 - 23
CamelotRenderer/Source/CmRenderSystem.cpp

@@ -75,24 +75,6 @@ namespace CamelotEngine {
 		mCurrentCapabilities = 0;
     }
     //-----------------------------------------------------------------------
-    void RenderSystem::_initRenderTargets(void)
-    {
-
-    }
-    //-----------------------------------------------------------------------
-    void RenderSystem::_updateAllRenderTargets(bool swapBuffers)
-    {
-        // Update all in order of priority
-        // This ensures render-to-texture targets get updated before render windows
-		RenderTargetPriorityMap::iterator itarg, itargend;
-		itargend = mPrioritisedRenderTargets.end();
-		for( itarg = mPrioritisedRenderTargets.begin(); itarg != itargend; ++itarg )
-		{
-			if( itarg->second->isActive())
-				itarg->second->update(swapBuffers);
-		}
-    }
-    //-----------------------------------------------------------------------
     void RenderSystem::_swapAllRenderTargetBuffers(bool waitForVSync)
     {
         // Update all in order of priority
@@ -506,11 +488,6 @@ namespace CamelotEngine {
 			mClipPlanesDirty = true;
 		}
 	}
-    //-----------------------------------------------------------------------
-    void RenderSystem::_notifyCameraRemoved(const Camera* cam)
-    {
-		// TODO PORT - Not used in the port. Should probably be removed
-    }
 	//-----------------------------------------------------------------------
 	void RenderSystem::destroyHardwareOcclusionQuery( HardwareOcclusionQuery *hq)
 	{