Browse Source

Some refactoring

Panagiotis Christopoulos Charitos 8 years ago
parent
commit
0f19a9a80e

+ 2 - 2
src/anki/renderer/Ir.cpp

@@ -423,7 +423,7 @@ void Ir::runIs(RenderingContext& rctx, FrustumComponent& frc, U layer, U faceIdx
 
 		Vec4 pos = vMat * movec.getWorldTransform().getOrigin().xyz1();
 
-		light->m_projectionParams = frc.getProjectionParameters();
+		light->m_projectionParams = frc.getProjectionMatrix().extractPerspectiveUnprojectionParams();
 		light->m_posRadius = Vec4(pos.xyz(), 1.0 / (lightc.getRadius() * lightc.getRadius()));
 		light->m_diffuseColorPad1 = lightc.getDiffuseColor();
 		light->m_specularColorPad1 = lightc.getSpecularColor();
@@ -466,7 +466,7 @@ void Ir::runIs(RenderingContext& rctx, FrustumComponent& frc, U layer, U faceIdx
 		// Update fragment uniforms
 		IrSpotLight* light = allocateAndBindUniforms<IrSpotLight*>(sizeof(IrSpotLight), cmdb, 0, 1);
 
-		light->m_projectionParams = frc.getProjectionParameters();
+		light->m_projectionParams = frc.getProjectionMatrix().extractPerspectiveUnprojectionParams();
 
 		Vec4 pos = vMat * movec.getWorldTransform().getOrigin().xyz1();
 		light->m_posRadius = Vec4(pos.xyz(), 1.0 / (lightc.getDistance() * lightc.getDistance()));

+ 1 - 1
src/anki/renderer/MainRenderer.cpp

@@ -122,7 +122,7 @@ Error MainRenderer::render(SceneGraph& scene)
 	ctx.m_camTrfMat = Mat4(frc.getFrustum().getTransform());
 	ctx.m_near = frc.getFrustum().getNear();
 	ctx.m_far = frc.getFrustum().getFar();
-	ctx.m_unprojParams = frc.getProjectionParameters();
+	ctx.m_unprojParams = ctx.m_projMat.extractPerspectiveUnprojectionParams();
 	ANKI_CHECK(m_r->render(ctx));
 
 	// Blit renderer's result to default FB if needed

+ 0 - 13
src/anki/scene/FrustumComponent.cpp

@@ -41,7 +41,6 @@ Error FrustumComponent::update(SceneNode& node, F32, F32, Bool& updated)
 	{
 		updated = true;
 		m_pm = m_frustum->calculateProjectionMatrix();
-		computeProjectionParams();
 	}
 
 	if(m_flags.get(TRANSFORM_MARKED_FOR_UPDATE))
@@ -59,16 +58,4 @@ Error FrustumComponent::update(SceneNode& node, F32, F32, Bool& updated)
 	return ErrorCode::NONE;
 }
 
-void FrustumComponent::computeProjectionParams()
-{
-	if(m_frustum->getType() == FrustumType::PERSPECTIVE)
-	{
-		m_projParams = m_pm.extractPerspectiveUnprojectionParams();
-	}
-	else
-	{
-		ANKI_ASSERT(0 && "TODO");
-	}
-}
-
 } // end namespace anki

+ 0 - 15
src/anki/scene/FrustumComponent.h

@@ -80,17 +80,6 @@ public:
 		return m_vpm;
 	}
 
-	/// Parameters used to get the view space position using the depth value and the NDC xy coordinates.
-	/// @code
-	/// vec3 fragPos;
-	/// fragPos.z = projectionParams.z / (projectionParams.w + depth);
-	/// fragPos.xy = projectionParams * NDC * fragPos.z;
-	/// @endcode
-	const Vec4& getProjectionParameters() const
-	{
-		return m_projParams;
-	}
-
 	/// Get the origin for sorting and visibility tests
 	const Vec4& getFrustumOrigin() const
 	{
@@ -192,16 +181,12 @@ private:
 	Mat4 m_vm = Mat4::getIdentity(); ///< View matrix
 	Mat4 m_vpm = Mat4::getIdentity(); ///< View projection matrix
 
-	Vec4 m_projParams = Vec4(0.0);
-
 	/// Visibility stuff. It's per frame so the pointer is invalid on the next frame and before any visibility tests
 	/// are run.
 	VisibilityTestResults* m_visible = nullptr;
 	VisibilityStats m_stats;
 
 	BitMask<U16> m_flags;
-
-	void computeProjectionParams();
 };
 /// @}